summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPratima Gupta <pgu@odoo.com>2021-04-08 12:26:02 +0000
committerRémy Voet (ryv) <ryv@odoo.com>2021-04-30 09:37:14 +0000
commit5bbc234d43a415be18fcfa42dad33b1577644719 (patch)
tree932a101b9892bb6abbd671ff3ac9e1de495ef7c5
parented2e11265eb8032c3a54b3eabedfce345352284b (diff)
[FIX] mrp: suggest the qty to produce instead of 0 in workorders
Before this commit, if any workorder is stared to produce, qty producing was 0. After this commit, if product tracking is none then system will suggest the remaining qty of workorder to produce when user is start it. TaskId - 2480775 closes odoo/odoo#70153 Related: odoo/enterprise#18063 Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
-rw-r--r--addons/mrp/models/mrp_workorder.py2
-rw-r--r--addons/mrp/tests/test_order.py29
2 files changed, 31 insertions, 0 deletions
diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py
index 7f3d2cd6009..9be0fdc7d00 100644
--- a/addons/mrp/models/mrp_workorder.py
+++ b/addons/mrp/models/mrp_workorder.py
@@ -517,6 +517,8 @@ class MrpWorkorder(models.Model):
if self.product_tracking == 'serial':
self.qty_producing = 1.0
+ else:
+ self.qty_producing = self.qty_remaining
self.env['mrp.workcenter.productivity'].create(
self._prepare_timeline_vals(self.duration, datetime.now())
diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py
index e42eb695af8..90f0fe9d8db 100644
--- a/addons/mrp/tests/test_order.py
+++ b/addons/mrp/tests/test_order.py
@@ -316,6 +316,35 @@ class TestMrpOrder(TestMrpCommon):
production = mo_form.save()
self.assertEqual(production.workorder_ids.duration_expected, 90)
+ def test_qty_producing(self):
+ """Qty producing should be the qty remain to produce, instead of 0"""
+ bom = self.env['mrp.bom'].create({
+ 'product_id': self.product_6.id,
+ 'product_tmpl_id': self.product_6.product_tmpl_id.id,
+ 'product_qty': 1,
+ 'product_uom_id': self.product_6.uom_id.id,
+ 'type': 'normal',
+ 'bom_line_ids': [
+ (0, 0, {'product_id': self.product_2.id, 'product_qty': 2.00}),
+ ],
+ })
+ production_form = Form(self.env['mrp.production'])
+ production_form.product_id = self.product_6
+ production_form.bom_id = bom
+ production_form.product_qty = 5
+ production_form.product_uom_id = self.product_6.uom_id
+ production = production_form.save()
+ production_form = Form(production)
+ with production_form.workorder_ids.new() as wo:
+ wo.name = 'OP1'
+ wo.workcenter_id = self.workcenter_1
+ wo.duration_expected = 40
+ production = production_form.save()
+ production.action_confirm()
+ production.button_plan()
+ production.workorder_ids[0].button_start()
+ self.assertEqual(production.workorder_ids.qty_producing, 5, "Wrong quantity is suggested to produce.")
+
def test_update_plan_date(self):
"""Editing the scheduled date after planning the MO should unplan the MO, and adjust the date on the stock moves"""
planned_date = datetime(2023, 5, 15, 9, 0)