Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mrp_production): add automatically a lot even if there is not a … #1309

Open
wants to merge 1 commit into
base: 8.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions mrp_final_product_lot/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class MrpProduction(models.Model):
def action_produce(
self, production_id, production_qty, production_mode, wiz=False):
lot_obj = self.env['stock.production.lot']
if production_mode == 'consume_produce' and wiz and not wiz.lot_id:
lot = wiz.lot_id if wiz else False
if production_mode == 'consume_produce' and not lot:
production = self.browse(production_id)
if (production.product_id.track_all or
production.product_id.track_production or
production.product_id.track_incoming):
lot = False
for line in production.move_created_ids2:
if (line.product_id.id == production.product_id.id and
line.restrict_lot_id):
Expand All @@ -35,14 +35,15 @@ def action_produce(
if not lot:
code = (production.manual_production_lot or
production.name or '')
if production.concatenate_lots_components:
if production.concatenate_lots_components and wiz:
lots = wiz.mapped('consume_lines.lot_id')
lots += production.mapped(
'move_lines2.restrict_lot_id')
code = '-'.join(lots.mapped('name'))
vals = {'name': code,
'product_id': production.product_id.id}
lot = lot_obj.create(vals)
wiz.lot_id = lot
for produce_product in production.move_created_ids:
produce_product.write({'prodlot_id': lot.id})
return super(MrpProduction, self).action_produce(
production_id, production_qty, production_mode, wiz=wiz)