Skip to content

Commit

Permalink
[IMP] mrp_packaging: make compute field store=True
Browse files Browse the repository at this point in the history
  • Loading branch information
oihane committed May 29, 2017
1 parent 3c13740 commit 6d35b33
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mrp_packaging/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Manufacturing order from packaging summary",
"version": "8.0.1.0.0",
"version": "8.0.2.0.0",
"category": "Manufacturing",
"license": "AGPL-3",
"author": "OdooMRP team, "
Expand Down
25 changes: 15 additions & 10 deletions mrp_packaging/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MrpProduction(models.Model):
string='Qty left for packaging', compute='_left_product_qty',
digits=dp.get_precision('Product Unit of Measure'),
help='This amount is indicative, it is calculated with packaging'
' orders that are not in canceled state.')
' orders that are not in canceled state.', store=True)

@api.multi
@api.depends('move_created_ids2')
Expand All @@ -38,7 +38,13 @@ def _final_product_qty(self):
record.final_product_qty = sum(moves.mapped('product_uom_qty'))

@api.multi
@api.depends('final_product_qty', 'expected_production')
@api.depends('move_created_ids2', 'move_created_ids2.state',
'move_created_ids2.product_id',
'move_created_ids2.product_uom_qty',
'expected_production', 'expected_production.state',
'expected_production.move_lines2',
'expected_production.move_lines',
'expected_production.product_lines')
def _left_product_qty(self):
for record in self:
moves = record.mapped('move_created_ids2').filtered(
Expand Down Expand Up @@ -73,14 +79,13 @@ def get_dump_packages(self):
('product_id', '=', self.product_id.id)])
exist_prod = [x.product.id for x in self.pack]
for line in lines:
if line not in exist_prod:
packs = filter(
lambda x: x not in exist_prod,
line.bom_id.product_tmpl_id.product_variant_ids.ids)
pack_line = map(
lambda x: (0, 0, {'product': x}), packs)
exist_prod += packs
pack_lines.extend(pack_line)
packs = filter(
lambda x: x not in exist_prod,
line.bom_id.product_tmpl_id.product_variant_ids.ids)
pack_line = map(
lambda x: (0, 0, {'product': x}), packs)
exist_prod += packs
pack_lines.extend(pack_line)
self.write({'pack': pack_lines})

@api.one
Expand Down

0 comments on commit 6d35b33

Please sign in to comment.