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

[IMP] mrp_packaging: make compute field store=True #1371

Open
wants to merge 1 commit into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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
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