From 9debcaf377f4ce371150950dd4e501dde1d40551 Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Wed, 4 Dec 2019 12:53:43 +0000 Subject: [PATCH] [FIX] mrp_account: show valuation button The valuation stat button was shown only at validation of the manufacturing order. If an intermediary inventory is posted. A part of the stock moves are validated so some stock valuation layer are generated. This commit shows the valuation button as soon as some valuation layers are linked to those validated stock moves. Task : 54665 X-original-commit: 7f67af93299c449ba80489a84ed0b13930edff90 --- addons/mrp_account/models/mrp_production.py | 6 +++++- addons/mrp_account/views/mrp_production_views.xml | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/mrp_account/models/mrp_production.py b/addons/mrp_account/models/mrp_production.py index 6eaf19949a8..e3d53149757 100644 --- a/addons/mrp_account/models/mrp_production.py +++ b/addons/mrp_account/models/mrp_production.py @@ -17,6 +17,11 @@ class MrpProduction(models.Model): _inherit = 'mrp.production' extra_cost = fields.Float(copy=False, help='Extra cost per produced unit') + show_valuation = fields.Boolean(compute='_compute_show_valuation') + + def _compute_show_valuation(self): + for order in self: + order.show_valuation = any(m.state == 'done' for m in order.move_finished_ids) def _cal_price(self, consumed_moves): """Set a price unit on the finished move according to `consumed_moves`. @@ -79,4 +84,3 @@ class MrpProduction(models.Model): context.update(self.env.context) context['no_at_date'] = True return dict(action, domain=domain, context=context) - diff --git a/addons/mrp_account/views/mrp_production_views.xml b/addons/mrp_account/views/mrp_production_views.xml index 1ac5394ca3e..764b7f84101 100644 --- a/addons/mrp_account/views/mrp_production_views.xml +++ b/addons/mrp_account/views/mrp_production_views.xml @@ -4,11 +4,14 @@ mrp.production + + +