summaryrefslogtreecommitdiff
path: root/addons/stock_picking_batch/wizard/stock_picking_to_batch.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/stock_picking_batch/wizard/stock_picking_to_batch.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/stock_picking_batch/wizard/stock_picking_to_batch.py')
-rw-r--r--addons/stock_picking_batch/wizard/stock_picking_to_batch.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/addons/stock_picking_batch/wizard/stock_picking_to_batch.py b/addons/stock_picking_batch/wizard/stock_picking_to_batch.py
new file mode 100644
index 00000000..f4f50f02
--- /dev/null
+++ b/addons/stock_picking_batch/wizard/stock_picking_to_batch.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models, _
+from odoo.exceptions import UserError
+
+
+class StockPickingToBatch(models.TransientModel):
+ _name = 'stock.picking.to.batch'
+ _description = 'Batch Transfer Lines'
+
+ batch_id = fields.Many2one('stock.picking.batch', string='Batch Transfer', domain="[('state', '=', 'draft')]")
+ mode = fields.Selection([('existing', 'an existing batch transfer'), ('new', 'a new batch transfer')], default='existing')
+ user_id = fields.Many2one('res.users', string='Responsible', help='Person responsible for this batch transfer')
+
+ def attach_pickings(self):
+ self.ensure_one()
+ pickings = self.env['stock.picking'].browse(self.env.context.get('active_ids'))
+ if self.mode == 'new':
+ company = pickings.company_id
+ if len(company) > 1:
+ raise UserError(_("The selected pickings should belong to an unique company."))
+ batch = self.env['stock.picking.batch'].create({
+ 'user_id': self.user_id.id,
+ 'company_id': company.id,
+ 'picking_type_id': pickings[0].picking_type_id.id,
+ })
+ else:
+ batch = self.batch_id
+
+ pickings.write({'batch_id': batch.id})