diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-06-21 15:16:54 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-06-21 15:16:54 +0200 |
| commit | 78b2063b29a321d152df9badb2d0324578ffe2ec (patch) | |
| tree | 8ecfa4d4acec837795d84f75c39dc10ab98929d8 /addons/mrp | |
| parent | e416428669fb18b59893b63f1d9769e871ac9321 (diff) | |
| parent | 8747d72f1efbc3f32c41c20d4d3198410639d2aa (diff) | |
[MERGE] forward port branch saas-12.2 up to 8747d72f1ef
Diffstat (limited to 'addons/mrp')
| -rw-r--r-- | addons/mrp/data/mrp_data.xml | 1 | ||||
| -rw-r--r-- | addons/mrp/models/mrp_production.py | 7 | ||||
| -rw-r--r-- | addons/mrp/tests/test_order.py | 33 | ||||
| -rw-r--r-- | addons/mrp/wizard/change_production_qty.py | 3 |
4 files changed, 40 insertions, 4 deletions
diff --git a/addons/mrp/data/mrp_data.xml b/addons/mrp/data/mrp_data.xml index 1343cbcf146..c9f6b8e608f 100644 --- a/addons/mrp/data/mrp_data.xml +++ b/addons/mrp/data/mrp_data.xml @@ -9,6 +9,7 @@ <field name="padding">5</field> <field name="number_next">1</field> <field name="number_increment">1</field> + <field name="company_id" eval="False"/> </record> <record id="sequence_mrp_unbuild" model="ir.sequence"> diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 8b30be3da44..e6f44a6182b 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -506,6 +506,9 @@ class MrpProduction(models.Model): factor = production.product_uom_id._compute_quantity(production.product_qty, production.bom_id.product_uom_id) / production.bom_id.product_qty boms, lines = production.bom_id.explode(production.product_id, factor, picking_type=production.bom_id.picking_type_id) for bom_line, line_data in lines: + if bom_line.child_bom_id and bom_line.child_bom_id.type == 'phantom' or\ + bom_line.product_id.type not in ['product', 'consu']: + continue moves.append(production._get_move_raw_values(bom_line, line_data)) return moves @@ -513,10 +516,6 @@ class MrpProduction(models.Model): quantity = line_data['qty'] # alt_op needed for the case when you explode phantom bom and all the lines will be consumed in the operation given by the parent bom line alt_op = line_data['parent_line'] and line_data['parent_line'].operation_id.id or False - if bom_line.child_bom_id and bom_line.child_bom_id.type == 'phantom': - return self.env['stock.move'] - if bom_line.product_id.type not in ['product', 'consu']: - return self.env['stock.move'] source_location = self.location_src_id data = { 'sequence': bom_line.sequence, diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py index ddde7e6a064..c7092e539f9 100644 --- a/addons/mrp/tests/test_order.py +++ b/addons/mrp/tests/test_order.py @@ -989,3 +989,36 @@ class TestMrpOrder(TestMrpCommon): self.assertEqual(product_produce.raw_workorder_line_ids[0].product_uom_id, unit, 'Should be the product uom so "unit"') self.assertEqual(product_produce.raw_workorder_line_ids[1].qty_to_consume, 1, 'Should be 1 unit since the tracking is serial and quantity 2.') self.assertEqual(product_produce.raw_workorder_line_ids[1].product_uom_id, unit, 'should be the product uom so "unit"') + + def test_product_type_service_1(self): + # Create finished product + finished_product = self.env['product.product'].create({ + 'name': 'Geyser', + 'type': 'product', + }) + + # Create service type product + product_raw = self.env['product.product'].create({ + 'name': 'raw Geyser', + 'type': 'service', + }) + + # Create bom for finish product + bom = self.env['mrp.bom'].create({ + 'product_id': finished_product.id, + 'product_tmpl_id': finished_product.product_tmpl_id.id, + 'product_uom_id': self.env.ref('uom.product_uom_unit').id, + 'product_qty': 1.0, + 'type': 'normal', + 'bom_line_ids': [(5, 0), (0, 0, {'product_id': product_raw.id})] + }) + + mo_form = Form(self.env['mrp.production']) + mo_form.product_id = finished_product + mo_form.bom_id = bom + mo_form.product_uom_id = self.env.ref('uom.product_uom_unit') + mo_form.product_qty = 1 + mo = mo_form.save() + + # Check Mo is created or not + self.assertTrue(mo, "Mo is created") diff --git a/addons/mrp/wizard/change_production_qty.py b/addons/mrp/wizard/change_production_qty.py index d6ac8296356..6cefbd89261 100644 --- a/addons/mrp/wizard/change_production_qty.py +++ b/addons/mrp/wizard/change_production_qty.py @@ -57,6 +57,9 @@ class ChangeProductionQty(models.TransientModel): boms, lines = production.bom_id.explode(production.product_id, factor, picking_type=production.bom_id.picking_type_id) documents = {} for line, line_data in lines: + if line.child_bom_id and line.child_bom_id.type == 'phantom' or\ + line.product_id.type not in ['product', 'consu']: + continue move, old_qty, new_qty = production._update_raw_move(line, line_data) iterate_key = production._get_document_iterate_key(move) if iterate_key: |
