diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 4b1703e4da5..250935da182 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -102,7 +102,7 @@ class MrpProduction(models.Model): lot_producing_id = fields.Many2one( 'stock.production.lot', string='Lot/Serial Number', copy=False, domain="[('product_id', '=', product_id), ('company_id', '=', company_id)]", check_company=True) - qty_producing = fields.Float(string="Quantity Producing", copy=False) + qty_producing = fields.Float(string="Quantity Producing", digits='Product Unit of Measure', copy=False) product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id') product_uom_qty = fields.Float(string='Total Quantity', compute='_compute_product_uom_qty', store=True) picking_type_id = fields.Many2one( diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index 2f76496467c..044c6208fc9 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -107,7 +107,7 @@ class StockMove(models.Model): store=True, help='Technical Field to order moves') order_finished_lot_ids = fields.Many2many('stock.production.lot', string="Finished Lot/Serial Number", compute='_compute_order_finished_lot_ids') - should_consume_qty = fields.Float('Quantity To Consume', compute='_compute_should_consume_qty') + should_consume_qty = fields.Float('Quantity To Consume', compute='_compute_should_consume_qty', digits='Product Unit of Measure') def _unreserve_initial_demand(self, new_move): # If you were already putting stock.move.lots on the next one in the work order, transfer those to the new move diff --git a/addons/mrp/static/src/js/mrp_should_consume.js b/addons/mrp/static/src/js/mrp_should_consume.js index dcf236a09f1..d432c5cf3f7 100644 --- a/addons/mrp/static/src/js/mrp_should_consume.js +++ b/addons/mrp/static/src/js/mrp_should_consume.js @@ -20,8 +20,7 @@ const MrpShouldConsume = FieldFloat.extend({ init: function (parent, name, params) { this._super.apply(this, arguments); this.displayShouldConsume = !['done', 'draft', 'cancel'].includes(params.data.state); - const options = {'digits': [false, 3]}; - this.should_consume_qty = field_utils.format.float(params.data.should_consume_qty, false, options); + this.should_consume_qty = field_utils.format.float(params.data.should_consume_qty, params.fields.should_consume_qty, this.nodeOptions); }, //-------------------------------------------------------------------------- diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py index a7e024f146e..940aedfd5ee 100644 --- a/addons/mrp/tests/test_order.py +++ b/addons/mrp/tests/test_order.py @@ -1118,69 +1118,6 @@ class TestMrpOrder(TestMrpCommon): details_operation_form.save() mo2.button_mark_done() - def test_product_produce_uom(self): - """ Produce a finished product tracked by serial number. Set another - UoM on the bom. The produce wizard should keep the UoM of the product (unit) - and quantity = 1.""" - dozen = self.env.ref('uom.product_uom_dozen') - unit = self.env.ref('uom.product_uom_unit') - plastic_laminate = self.env['product.product'].create({ - 'name': 'Plastic Laminate', - 'type': 'product', - 'uom_id': unit.id, - 'uom_po_id': unit.id, - 'tracking': 'serial', - }) - ply_veneer = self.env['product.product'].create({ - 'name': 'Ply Veneer', - 'type': 'product', - 'uom_id': unit.id, - 'uom_po_id': unit.id, - }) - bom = self.env['mrp.bom'].create({ - 'product_tmpl_id': plastic_laminate.product_tmpl_id.id, - 'product_uom_id': unit.id, - 'sequence': 1, - 'bom_line_ids': [(0, 0, { - 'product_id': ply_veneer.id, - 'product_qty': 1, - 'product_uom_id': unit.id, - 'sequence': 1, - })] - }) - - mo_form = Form(self.env['mrp.production']) - mo_form.product_id = plastic_laminate - mo_form.bom_id = bom - mo_form.product_uom_id = dozen - mo_form.product_qty = 1 - mo = mo_form.save() - - final_product_lot = self.env['stock.production.lot'].create({ - 'name': 'lot1', - 'product_id': plastic_laminate.id, - 'company_id': self.env.company.id, - }) - - mo.action_confirm() - mo.action_assign() - self.assertEqual(mo.move_raw_ids.product_qty, 12, '12 units should be reserved.') - - # produce product - mo_form = Form(mo) - mo_form.qty_producing = 1/12.0 - mo_form.lot_producing_id = final_product_lot - mo = mo_form.save() - - move_line_raw = mo.move_raw_ids.mapped('move_line_ids').filtered(lambda m: m.qty_done) - self.assertEqual(move_line_raw.qty_done, 1) - self.assertEqual(move_line_raw.product_uom_id, unit, 'Should be 1 unit since the tracking is serial.') - - mo._post_inventory() - move_line_finished = mo.move_finished_ids.mapped('move_line_ids').filtered(lambda m: m.qty_done) - self.assertEqual(move_line_finished.qty_done, 1) - self.assertEqual(move_line_finished.product_uom_id, unit, 'Should be 1 unit since the tracking is serial.') - def test_product_type_service_1(self): # Create finished product finished_product = self.env['product.product'].create({ diff --git a/addons/mrp/tests/test_traceability.py b/addons/mrp/tests/test_traceability.py index ea861c2cefe..502cac0519d 100644 --- a/addons/mrp/tests/test_traceability.py +++ b/addons/mrp/tests/test_traceability.py @@ -107,7 +107,7 @@ class TestTraceability(TestMrpCommon): for line in lines: tracking = line['columns'][1].split(' ')[1] self.assertEqual( - line['columns'][-1], "1.000 Units", 'Part with tracking type "%s", should have quantity = 1' % (tracking) + line['columns'][-1], "1.00 Units", 'Part with tracking type "%s", should have quantity = 1' % (tracking) ) unfoldable = False if tracking == 'none' else True self.assertEqual( diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index b05c6970e55..c45c6524027 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -151,7 +151,7 @@