[FIX] mrp : error when using a lot on a MO
Trying to set multiple lines with different lot on a MO
will raise an odoo server error with the field product_uom
on model stock.move.line.
This bug is linked to stock refactoring commit 0469d2e712
where the uom become required on move line. In order to get a default
value on create call the uom should be pass in the view's context.
This commit is contained in:
@@ -203,7 +203,8 @@ class MrpWorkorder(models.Model):
|
||||
'move_id': move.id,
|
||||
'product_id': move.product_id.id,
|
||||
'lot_id': False,
|
||||
'product_qty': 0.0,
|
||||
'product_uom_qty': 0.0,
|
||||
'product_uom_id': move.product_uom.id,
|
||||
'qty_done': min(1.0, qty_todo),
|
||||
'workorder_id': self.id,
|
||||
'done_wo': False,
|
||||
|
||||
@@ -26,14 +26,20 @@
|
||||
</div>
|
||||
<field name="is_done" invisible="1"/>
|
||||
<field name="workorder_id" invisible="1"/>
|
||||
<field name="location_id" invisible="1"/>
|
||||
<field name="location_dest_id" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<field name="active_move_line_ids" attrs="{'readonly': [('is_done', '=', True)]}" context="{'default_workorder_id': workorder_id}">
|
||||
<field name="active_move_line_ids" attrs="{'readonly': [('is_done', '=', True)]}" context="{'default_workorder_id': workorder_id, 'default_product_uom_id': product_uom, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}">
|
||||
<tree editable="bottom" decoration-success="product_qty==qty_done" decoration-danger="(product_qty > 0) and (qty_done>product_qty)">
|
||||
<field name="lot_id" domain="[('product_id', '=', parent.product_id)]" context="{'default_product_id': parent.product_id}"/>
|
||||
<field name="product_qty" invisible="not context.get('show_reserved') or context.get('serial') or context.get('state_done')" readonly="1"/>
|
||||
<field name="qty_done"/>
|
||||
<field name="workorder_id" invisible="1"/>
|
||||
<field name="product_id" invisible="1"/>
|
||||
<field name="product_uom_id" invisible="1"/>
|
||||
<field name="location_id" invisible="1"/>
|
||||
<field name="location_dest_id" invisible="1"/>
|
||||
<field name="done_wo" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user