[FIX] mrp: domain on field final_lot_id in mrp.production.work.order.form
Steps to reproduce the bug:
Let's consider two storable products P1 and P2 where P1 is tracked by serial number
- Create a BOM B for P1 where P2 is a component
- Create a serial numberv SN for P1 with no quantity
- Create a MO M1 for P1 and click on button "Produce"
- In the view MRP Product Produce, SN is selectable in the field lot_id
- Now change B and set a routing on it
- Create a new MO M2 for P1 and click on produce
- At least one WO has been created, click on the first one
Bug:
- SN is not selectable in the field final_lot_id
The domain set on the field final_lot_id:
"['|', '&', ('product_id', '=', product_id), ('product_id.tracking', '!=', 'serial'), ('use_next_on_work_order_id', '=', id)]"
didn't allow to chose SN.
With this fix, it's now possible to chose SN on the first WO created for M2
opw:2059745
closes odoo/odoo#36425
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
@@ -63,6 +63,9 @@ class MrpWorkorder(models.Model):
|
||||
is_produced = fields.Boolean(string="Has Been Produced",
|
||||
compute='_compute_is_produced')
|
||||
|
||||
is_first_wo = fields.Boolean(string="Is the first WO to produce",
|
||||
compute='_compute_is_first_wo')
|
||||
|
||||
state = fields.Selection([
|
||||
('pending', 'Pending'),
|
||||
('ready', 'Ready'),
|
||||
@@ -140,6 +143,11 @@ class MrpWorkorder(models.Model):
|
||||
rounding = self.production_id.product_uom_id.rounding
|
||||
self.is_produced = float_compare(self.qty_produced, self.production_id.product_qty, precision_rounding=rounding) >= 0
|
||||
|
||||
@api.multi
|
||||
def _compute_is_first_wo(self):
|
||||
for wo in self:
|
||||
wo.is_first_wo = (wo.production_id.workorder_ids[0] == wo)
|
||||
|
||||
@api.one
|
||||
@api.depends('time_ids.duration', 'qty_produced')
|
||||
def _compute_duration(self):
|
||||
|
||||
@@ -141,7 +141,8 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="qty_producing" string="Current Qty" attrs="{'readonly': ['|', ('product_tracking', '=', 'serial'), ('state', 'in', ('done', 'cancel'))]}"/>
|
||||
<field name="final_lot_id" context="{'default_product_id': product_id}" domain="['|', '&', ('product_id', '=', product_id), ('product_id.tracking', '!=', 'serial'), ('use_next_on_work_order_id', '=', id)]" attrs="{'invisible': [('product_tracking', '=', 'none')]}" groups="stock.group_production_lot"/>
|
||||
<field name='is_first_wo' invisible="1"/>
|
||||
<field name="final_lot_id" context="{'default_product_id': product_id}" domain="['|', '&', ('product_id', '=', product_id), '|', ('product_id.tracking', '!=', 'serial'), '&', ('use_next_on_work_order_id', '=', False), ('use_next_on_work_order_id', '!=', 'is_first_wo'), ('use_next_on_work_order_id', '=', id)]" attrs="{'invisible': [('product_tracking', '=', 'none')]}" groups="stock.group_production_lot"/>
|
||||
<field name="product_tracking" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user