From 8d8c78a7489b18dcbac163f6b091ed48a6088f43 Mon Sep 17 00:00:00 2001 From: oihane Date: Thu, 26 May 2016 14:35:01 +0200 Subject: [PATCH] [FIX] mrp_production_real_cost: error when ending mo, fixes #124 --- mrp_production_real_cost/models/mrp_production.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mrp_production_real_cost/models/mrp_production.py b/mrp_production_real_cost/models/mrp_production.py index 23dcbf9c5..94f5bc5e3 100644 --- a/mrp_production_real_cost/models/mrp_production.py +++ b/mrp_production_real_cost/models/mrp_production.py @@ -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