From 44b2fa7713bb6a57f91a50ef2d59d53bcf53e629 Mon Sep 17 00:00:00 2001 From: alfredoavanzosc Date: Thu, 10 Sep 2015 12:11:35 +0200 Subject: [PATCH] [IMP] mrp_production_project_estimated_cost: Show "Estimated Average Cost" field in mrp.production tree view. [IMP] mrp_production_real_cost: Show "Total Real Cost" field in mrp.production tree view. --- mrp_production_real_cost/models/mrp_production.py | 9 +++++++++ .../views/mrp_production_view.xml | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/mrp_production_real_cost/models/mrp_production.py b/mrp_production_real_cost/models/mrp_production.py index bfe7c544c..4db8a082a 100644 --- a/mrp_production_real_cost/models/mrp_production.py +++ b/mrp_production_real_cost/models/mrp_production.py @@ -36,10 +36,19 @@ class MrpProduction(models.Model): self.real_cost = self.calc_mrp_real_cost() self.unit_real_cost = self.real_cost / self.product_qty + @api.one + @api.depends('avg_cost', 'real_cost') + def get_percentage_difference(self): + self.percentage_difference = 0 + if self.avg_cost and self.real_cost: + self.percentage_difference = (self.real_cost * 100 / self.avg_cost) + real_cost = fields.Float("Total Real Cost", compute="get_real_cost", store=True) unit_real_cost = fields.Float("Unit Real Cost", compute="get_real_cost", store=True) + percentage_difference = fields.Float( + "% difference", compute="get_percentage_difference", store=True) @api.multi def action_production_end(self): diff --git a/mrp_production_real_cost/views/mrp_production_view.xml b/mrp_production_real_cost/views/mrp_production_view.xml index 8cfbeff95..22d455b50 100644 --- a/mrp_production_real_cost/views/mrp_production_view.xml +++ b/mrp_production_real_cost/views/mrp_production_view.xml @@ -12,5 +12,16 @@ + + mrp.production.tree.view.inh.realcost + mrp.production + + + + + + + +