[FIX] mrp_production_real_cost: error when ending mo, fixes #124

This commit is contained in:
oihane
2016-05-26 14:35:01 +02:00
parent edfd0fff4e
commit 8d8c78a748

View File

@@ -31,8 +31,15 @@ class MrpProduction(models.Model):
@api.multi
def action_production_end(self):
res = super(MrpProduction, self).action_production_end()
self.mapped('move_created_ids2').filtered(
lambda l: l.state == 'done').product_price_update_production_done()
for production in self:
# This is needed because commit
# https://github.com/odoo/odoo/commit/
# 6f29bfc181d23d70d29776d96b4318e9ee2c93a9
# introduces a weird behavior on the next call, provoking an error.
production.sudo().refresh()
production.mapped('move_created_ids2').filtered(
lambda l: l.state == 'done'
).product_price_update_production_done()
return res
@api.model