From 685370373e738063d5f80ff27cee83a48459a705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A0n=20Todorovich?= Date: Tue, 25 Oct 2022 15:41:00 -0300 Subject: [PATCH] [MIG] mrp_bom_attribute_match: Migration to 15.0 Notes: * `_get_product2bom` renamed to `_bom_find` * Test case `test_manufacturing_order_2`: * No longer check for "Add some materials to consume before marking this MO as to do.", as it's already supported in core since https://github.com/odoo/odoo/commit/bf5e1debf --- mrp_bom_attribute_match/__manifest__.py | 5 +---- mrp_bom_attribute_match/models/mrp_bom.py | 7 ++----- mrp_bom_attribute_match/models/mrp_production.py | 15 +++++++-------- mrp_bom_attribute_match/models/product.py | 2 +- mrp_bom_attribute_match/readme/CONTRIBUTORS.rst | 4 ++++ mrp_bom_attribute_match/tests/common.py | 4 ++-- .../tests/test_mrp_bom_attribute_match.py | 4 +--- mrp_bom_attribute_match/views/mrp_bom_views.xml | 3 +-- 8 files changed, 19 insertions(+), 25 deletions(-) diff --git a/mrp_bom_attribute_match/__manifest__.py b/mrp_bom_attribute_match/__manifest__.py index 825505c65..ad3620ace 100644 --- a/mrp_bom_attribute_match/__manifest__.py +++ b/mrp_bom_attribute_match/__manifest__.py @@ -1,6 +1,6 @@ { "name": "BOM Attribute Match", - "version": "14.0.1.0.2", + "version": "15.0.1.0.0", "category": "Manufacturing", "author": "Ilyas, Ooops, Odoo Community Association (OCA)", "summary": "Dynamic BOM component based on product attribute", @@ -10,7 +10,4 @@ "data": [ "views/mrp_bom_views.xml", ], - "qweb": [], - "application": False, - "installable": True, } diff --git a/mrp_bom_attribute_match/models/mrp_bom.py b/mrp_bom_attribute_match/models/mrp_bom.py index e3552e166..4d8137d54 100644 --- a/mrp_bom_attribute_match/models/mrp_bom.py +++ b/mrp_bom_attribute_match/models/mrp_bom.py @@ -109,9 +109,6 @@ class MrpBomLine(models.Model): ) ) - def write(self, vals): - super(MrpBomLine, self).write(vals) - class MrpBom(models.Model): _inherit = "mrp.bom" @@ -149,7 +146,7 @@ class MrpBom(models.Model): def update_product_boms(): products = self.env["product.product"].browse(product_ids) product_boms.update( - self._get_product2bom( + self._bom_find( products, bom_type="phantom", picking_type=picking_type or self.picking_type_id, @@ -310,7 +307,7 @@ class MrpBom(models.Model): return line_product_id def write(self, vals): - res = super(MrpBom, self).write(vals) + res = super().write(vals) for line in self.bom_line_ids: line.update_component_attributes() return res diff --git a/mrp_bom_attribute_match/models/mrp_production.py b/mrp_bom_attribute_match/models/mrp_production.py index b276a491a..71b89d025 100644 --- a/mrp_bom_attribute_match/models/mrp_production.py +++ b/mrp_bom_attribute_match/models/mrp_production.py @@ -5,15 +5,14 @@ class MrpProduction(models.Model): _inherit = "mrp.production" def action_confirm(self): - res = super(MrpProduction, self).action_confirm() - if self and self.bom_id: - for bom_line in self.bom_id.bom_line_ids: - if bom_line.component_template_id: - # product_id was set in mrp.bom.explode for correct flow. Need to remove it. - bom_line.product_id = False + res = super().action_confirm() + for bom_line in self.bom_id.bom_line_ids: + if bom_line.component_template_id: + # product_id was set in mrp.bom.explode for correct flow. Need to remove it. + bom_line.product_id = False return res def write(self, vals): - for bl in self.bom_id.bom_line_ids.filtered(lambda x: x.component_template_id): + for bl in self.bom_id.bom_line_ids.filtered("component_template_id"): bl.check_component_attributes() - return super(MrpProduction, self).write(vals) + return super().write(vals) diff --git a/mrp_bom_attribute_match/models/product.py b/mrp_bom_attribute_match/models/product.py index b9b0cc4c5..da1012b46 100644 --- a/mrp_bom_attribute_match/models/product.py +++ b/mrp_bom_attribute_match/models/product.py @@ -6,7 +6,7 @@ class ProductTemplate(models.Model): _inherit = "product.template" def write(self, vals): - res = super(ProductTemplate, self).write(vals) + res = super().write(vals) self.check_product_with_component_change_allowed() self.check_component_change_allowed() return res diff --git a/mrp_bom_attribute_match/readme/CONTRIBUTORS.rst b/mrp_bom_attribute_match/readme/CONTRIBUTORS.rst index a1c144e4c..1a74944ba 100644 --- a/mrp_bom_attribute_match/readme/CONTRIBUTORS.rst +++ b/mrp_bom_attribute_match/readme/CONTRIBUTORS.rst @@ -1,3 +1,7 @@ * Ooops404 * Ilyas + +* `Camptocamp `_ + + * Iván Todorovich diff --git a/mrp_bom_attribute_match/tests/common.py b/mrp_bom_attribute_match/tests/common.py index 5307b8e18..82f747818 100644 --- a/mrp_bom_attribute_match/tests/common.py +++ b/mrp_bom_attribute_match/tests/common.py @@ -1,7 +1,7 @@ -from odoo.tests import Form, common +from odoo.tests import Form, TransactionCase -class TestMrpAttachmentMgmtBase(common.SavepointCase): +class TestMrpAttachmentMgmtBase(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/mrp_bom_attribute_match/tests/test_mrp_bom_attribute_match.py b/mrp_bom_attribute_match/tests/test_mrp_bom_attribute_match.py index 62a30adb1..2a88899d9 100644 --- a/mrp_bom_attribute_match/tests/test_mrp_bom_attribute_match.py +++ b/mrp_bom_attribute_match/tests/test_mrp_bom_attribute_match.py @@ -81,9 +81,7 @@ class TestMrpAttachmentMgmt(TestMrpAttachmentMgmtBase): mo_form.bom_id = self.bom_id mo_form.product_qty = 1 self.mo_sword = mo_form.save() - with self.assertRaises(UserError): - # Add some materials to consume before marking this MO as to do. - self.mo_sword.action_confirm() + self.mo_sword.action_confirm() def test_manufacturing_order_3(self): # Delete attribute from sword diff --git a/mrp_bom_attribute_match/views/mrp_bom_views.xml b/mrp_bom_attribute_match/views/mrp_bom_views.xml index 90126ae7e..61db60afc 100644 --- a/mrp_bom_attribute_match/views/mrp_bom_views.xml +++ b/mrp_bom_attribute_match/views/mrp_bom_views.xml @@ -1,7 +1,6 @@ - - mrp.bom.view.form.inherit.bom.match + mrp.bom