[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
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user