From b35a845b455d8db3ce481b14f0247b47b426ad24 Mon Sep 17 00:00:00 2001 From: Ruben Dario Bravo Date: Tue, 16 Apr 2019 17:39:29 -0400 Subject: [PATCH] [MIG] mrp_production_grouped_by_product: Migration to 12.0 --- .../__manifest__.py | 3 ++- .../models/__init__.py | 2 +- .../models/{procurement.py => stock_rule.py} | 6 +++--- .../test_mrp_production_grouped_by_product.py | 21 ++++++++++++------- 4 files changed, 20 insertions(+), 12 deletions(-) rename mrp_production_grouped_by_product/models/{procurement.py => stock_rule.py} (76%) diff --git a/mrp_production_grouped_by_product/__manifest__.py b/mrp_production_grouped_by_product/__manifest__.py index d1ecdd69a..2b78bab60 100644 --- a/mrp_production_grouped_by_product/__manifest__.py +++ b/mrp_production_grouped_by_product/__manifest__.py @@ -1,10 +1,11 @@ # Copyright 2018 Tecnativa - David Vidal # Copyright 2018 Tecnativa - Pedro M. Baeza +# Copyright 2019 Rubén Bravo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Production Grouped By Product', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'MRP', 'author': 'Tecnativa, ' 'Odoo Community Association (OCA)', diff --git a/mrp_production_grouped_by_product/models/__init__.py b/mrp_production_grouped_by_product/models/__init__.py index b4b7e408a..a3df67902 100644 --- a/mrp_production_grouped_by_product/models/__init__.py +++ b/mrp_production_grouped_by_product/models/__init__.py @@ -1,4 +1,4 @@ from . import mrp_production -from . import procurement +from . import stock_rule from . import stock_picking_type diff --git a/mrp_production_grouped_by_product/models/procurement.py b/mrp_production_grouped_by_product/models/stock_rule.py similarity index 76% rename from mrp_production_grouped_by_product/models/procurement.py rename to mrp_production_grouped_by_product/models/stock_rule.py index 19368adc0..05ebe83a9 100644 --- a/mrp_production_grouped_by_product/models/procurement.py +++ b/mrp_production_grouped_by_product/models/stock_rule.py @@ -5,13 +5,13 @@ from odoo import models -class ProcurementRule(models.Model): - _inherit = 'procurement.rule' +class StockRule(models.Model): + _inherit = 'stock.rule' def _run_manufacture(self, product_id, product_qty, product_uom, location_id, name, origin, values): return super( - ProcurementRule, self.with_context(group_mo_by_product=True), + StockRule, self.with_context(group_mo_by_product=True), )._run_manufacture( product_id, product_qty, product_uom, location_id, name, origin, values, diff --git a/mrp_production_grouped_by_product/tests/test_mrp_production_grouped_by_product.py b/mrp_production_grouped_by_product/tests/test_mrp_production_grouped_by_product.py index 1425a67d7..3e91719e3 100644 --- a/mrp_production_grouped_by_product/tests/test_mrp_production_grouped_by_product.py +++ b/mrp_production_grouped_by_product/tests/test_mrp_production_grouped_by_product.py @@ -1,5 +1,6 @@ # Copyright 2018 Tecnativa - David Vidal # Copyright 2018 Tecnativa - Pedro M. Baeza +# Copyright 2019 Rubén Bravo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import exceptions @@ -17,7 +18,11 @@ class TestProductionGroupedByProduct(common.SavepointCase): cls.MrpProduction = cls.env['mrp.production'] cls.env.user.company_id.manufacturing_lead = 0 cls.env.user.tz = False # Make sure there's no timezone in user - cls.picking_type = cls.env.ref('mrp.picking_type_manufacturing') + + cls.picking_type = cls.env['stock.picking.type'].search([ + ('code', '=', 'mrp_operation'), + ('sequence_id.company_id', '=', cls.env.user.company_id.id) + ], limit=1) cls.product1 = cls.env['product.product'].create({ 'name': 'TEST Muffin', 'route_ids': [(6, 0, [ @@ -95,11 +100,13 @@ class TestProductionGroupedByProduct(common.SavepointCase): self.assertEqual(len(mo), 2) def test_check_mo_grouping_max_hour(self): - with self.assertRaises(exceptions.ValidationError): - self.picking_type.mo_grouping_max_hour = 25 - with self.assertRaises(exceptions.ValidationError): - self.picking_type.mo_grouping_max_hour = -1 + if self.picking_type: + with self.assertRaises(exceptions.ValidationError): + self.picking_type.mo_grouping_max_hour = 25 + with self.assertRaises(exceptions.ValidationError): + self.picking_type.mo_grouping_max_hour = -1 def test_check_mo_grouping_interval(self): - with self.assertRaises(exceptions.ValidationError): - self.picking_type.mo_grouping_interval = -1 + if self.picking_type: + with self.assertRaises(exceptions.ValidationError): + self.picking_type.mo_grouping_interval = -1