diff options
| author | William Henrotin <whe@odoo.com> | 2019-12-04 12:53:43 +0000 |
|---|---|---|
| committer | William Henrotin <whe@odoo.com> | 2019-12-04 12:53:43 +0000 |
| commit | 9debcaf377f4ce371150950dd4e501dde1d40551 (patch) | |
| tree | 1bec892731cba5bd7924cce954dba1e79b3c5b2d /addons/mrp_account | |
| parent | 21834430a15a12dae2f94426533df99384a1a1ea (diff) | |
[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
Diffstat (limited to 'addons/mrp_account')
| -rw-r--r-- | addons/mrp_account/models/mrp_production.py | 6 | ||||
| -rw-r--r-- | 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 @@ <field name="model">mrp.production</field> <field name="inherit_id" ref="mrp.mrp_production_form_view" /> <field name="arch" type="xml"> + <xpath expr="//field[@name='finished_move_line_ids']" position="before"> + <field name="show_valuation" invisible="1"/> + </xpath> <xpath expr="//div[@name='button_box']" position="inside"> <button string="Valuation" type="object" name="action_view_stock_valuation_layers" class="oe_stat_button" icon="fa-dollar" groups="stock.group_stock_manager" - attrs="{'invisible': [('state', 'not in', ['done'])]}" /> + attrs="{'invisible': [('show_valuation', '=', False)]}" /> </xpath> </field> </record> |
