changeset c990582ffc6e in modules/production:default details: https://hg.tryton.org/modules/production?cmd=changeset;node=c990582ffc6e description: Add production picking and output locations
issue9331 review299671003 diffstat: CHANGELOG | 1 + doc/index.rst | 10 ++++++---- production.py | 39 ++++++++++++++++++++++++--------------- stock.py | 24 ++++++++++++++++++++++++ view/location_form.xml | 4 ++++ 5 files changed, 59 insertions(+), 19 deletions(-) diffs (170 lines): diff -r 732c7b588de3 -r c990582ffc6e CHANGELOG --- a/CHANGELOG Mon Oct 12 19:20:21 2020 +0200 +++ b/CHANGELOG Mon Oct 12 19:32:02 2020 +0200 @@ -1,3 +1,4 @@ +* Add production picking and output locations * Add cron task to reschedule past productions * Allow lost_found as output of production * Keep cost of unused input products diff -r 732c7b588de3 -r c990582ffc6e doc/index.rst --- a/doc/index.rst Mon Oct 12 19:20:21 2020 +0200 +++ b/doc/index.rst Mon Oct 12 19:32:02 2020 +0200 @@ -19,13 +19,15 @@ * Inputs - The moves between the storage location and the production location (as - defined on the warehouse) for products used for production. + The moves between the production picking location, or the storage location + if product picking location is empty, and the production location + (as defined on the warehouse) for products used for production. * Outputs - The moves between the production location and the storage location for - products produced. + The moves between the production location and the production output + location, or the storage location if production output is empty, for produced + products. The production can be in one of this states: diff -r 732c7b588de3 -r c990582ffc6e production.py --- a/production.py Mon Oct 12 19:20:21 2020 +0200 +++ b/production.py Mon Oct 12 19:32:02 2020 +0200 @@ -366,18 +366,14 @@ if not (self.bom and self.product and self.uom): return - if self.warehouse: - storage_location = self.warehouse.storage_location - else: - storage_location = None - factor = self.bom.compute_factor(self.product, self.quantity or 0, self.uom) inputs = [] for input_ in self.bom.inputs: quantity = input_.compute_quantity(factor) - move = self._explode_move_values(storage_location, self.location, - self.company, input_, quantity) + move = self._explode_move_values( + self.picking_location, self.location, self.company, + input_, quantity) if move: inputs.append(move) quantity = Uom.compute_qty(input_.uom, quantity, @@ -387,8 +383,9 @@ outputs = [] for output in self.bom.outputs: quantity = output.compute_quantity(factor) - move = self._explode_move_values(self.location, storage_location, - self.company, output, quantity) + move = self._explode_move_values( + self.location, self.output_location, self.company, output, + quantity) if move: move.unit_price = Decimal(0) outputs.append(move) @@ -475,14 +472,13 @@ Move = pool.get('stock.move') to_save = [] for production in productions: - storage_location = production.warehouse.storage_location location = production.location company = production.company if not production.bom: if production.product: move = production._move( - location, storage_location, company, + location, production.output_location, company, production.product, production.uom, production.quantity) if move: @@ -496,8 +492,9 @@ for input_ in production.bom.inputs: quantity = input_.compute_quantity(factor) product = input_.product - move = production._move(storage_location, location, company, - product, input_.uom, quantity) + move = production._move( + production.picking_location, location, company, product, + input_.uom, quantity) if move: move.production_input = production to_save.append(move) @@ -505,8 +502,8 @@ for output in production.bom.outputs: quantity = output.compute_quantity(factor) product = output.product - move = production._move(location, storage_location, company, - product, output.uom, quantity) + move = production._move(location, production.output_location, + company, product, output.uom, quantity) if move: move.production_output = production move.unit_price = Decimal(0) @@ -780,3 +777,15 @@ production.planned_start_date = date production.on_change_planned_start_date() cls.save(productions) + + @property + def picking_location(self): + if self.warehouse: + return (self.warehouse.production_picking_location + or self.warehouse.storage_location) + + @property + def output_location(self): + if self.warehouse: + return (self.warehouse.production_output_location + or self.warehouse.storage_location) diff -r 732c7b588de3 -r c990582ffc6e stock.py --- a/stock.py Mon Oct 12 19:20:21 2020 +0200 +++ b/stock.py Mon Oct 12 19:32:02 2020 +0200 @@ -16,6 +16,30 @@ ('type', '=', 'production'), ], depends=['type']) + production_picking_location = fields.Many2One( + 'stock.location', "Production Picking", + states={ + 'invisible': Eval('type') != 'warehouse', + }, + domain=[ + ('type', '=', 'storage'), + ('parent', 'child_of', [Eval('id')]), + ], + depends=['type', 'id'], + help="Where the production components are picked from.\n" + "Leave empty to use the warehouse storage location.") + production_output_location = fields.Many2One( + 'stock.location', "Proudction Output", + states={ + 'invisible': Eval('type') != 'warehouse', + }, + domain=[ + ('type', '=', 'storage'), + ('parent', 'child_of', [Eval('id')]), + ], + depends=['type', 'id'], + help="Where the produced goods are stored.\n" + "Leave empty to use the warehouse storage location.") class Move(metaclass=PoolMeta): diff -r 732c7b588de3 -r c990582ffc6e view/location_form.xml --- a/view/location_form.xml Mon Oct 12 19:20:21 2020 +0200 +++ b/view/location_form.xml Mon Oct 12 19:32:02 2020 +0200 @@ -7,5 +7,9 @@ <label name="production_location"/> <field name="production_location"/> <newline/> + <label name="production_picking_location"/> + <field name="production_picking_location"/> + <label name="production_output_location"/> + <field name="production_output_location"/> </xpath> </data>