[FIX] mrp: wrong use of self
The method _workorder_line_ids() is defined on mrp.workorder while `self` is an instance of change_production_qty wizard in this case. Without this commit, changing the quantity to produce of a manufactoring order with workorders already planned raised a traceback.
This commit is contained in:
@@ -827,3 +827,26 @@ class TestWorkOrderProcess(TestMrpCommon):
|
||||
# Check that the workorder is planned now and that it lasts one hour
|
||||
self.assertEqual(workorder.date_planned_start, date_start, msg="Workorder should be planned tomorrow.")
|
||||
self.assertEqual(workorder.date_planned_finished, date_start + timedelta(hours=1), msg="Workorder should be done one hour later.")
|
||||
|
||||
def test_change_production_1(self):
|
||||
"""Change the quantity to produce on the MO while workorders are already planned."""
|
||||
dining_table = self.env.ref("mrp.product_product_computer_desk")
|
||||
dining_table.tracking = 'lot'
|
||||
production_table_form = Form(self.env['mrp.production'])
|
||||
production_table_form.product_id = dining_table
|
||||
production_table_form.bom_id = self.env.ref("mrp.mrp_bom_desk")
|
||||
production_table_form.product_qty = 1.0
|
||||
production_table_form.product_uom_id = dining_table.uom_id
|
||||
production_table = production_table_form.save()
|
||||
production_table.action_confirm()
|
||||
|
||||
# Create work order
|
||||
production_table.button_plan()
|
||||
|
||||
context = {'active_id': production_table.id, 'active_model': 'mrp.production'}
|
||||
change_qty_form = Form(self.env['change.production.qty'].with_context(context))
|
||||
change_qty_form.product_qty = 2.00
|
||||
change_qty = change_qty_form.save()
|
||||
change_qty.change_prod_qty()
|
||||
|
||||
self.assertEqual(production_table.workorder_ids[0].qty_producing, 2, "Quantity to produce not updated")
|
||||
|
||||
@@ -106,7 +106,7 @@ class ChangeProductionQty(models.TransientModel):
|
||||
(moves_finished + moves_raw).write({'workorder_id': wo.id})
|
||||
if wo.state not in ('done', 'cancel'):
|
||||
line_values = wo._update_workorder_lines()
|
||||
self._workorder_line_ids().create(line_values['to_create'])
|
||||
wo._workorder_line_ids().create(line_values['to_create'])
|
||||
if line_values['to_delete']:
|
||||
line_values['to_delete'].unlink()
|
||||
for line, vals in line_values['to_update'].items():
|
||||
|
||||
Reference in New Issue
Block a user