From f453767ea1c6ff4a7337127e101ebc66e2aeb2d2 Mon Sep 17 00:00:00 2001 From: Akim Juillerat Date: Tue, 12 Mar 2019 16:10:30 +0100 Subject: [PATCH] [MIG] repair_refurbish (mrp_repair_refurbish): Migration to 12.0 --- mrp_repair_refurbish/tests/__init__.py | 1 - .../README.rst | 0 .../__init__.py | 0 .../__manifest__.py | 6 ++--- .../data/stock_data.xml | 0 .../i18n/de.po | 0 .../i18n/mrp_repair_refurbish.pot | 0 .../models/__init__.py | 3 ++- .../models/product_product.py | 0 .../models/product_template.py | 0 .../models/repair.py | 14 +++++++----- repair_refurbish/models/stock_move.py | 15 +++++++++++++ .../readme/CONFIGURE.rst | 0 .../readme/CONTRIBUTORS.rst | 1 + .../readme/CREDITS.rst | 0 .../readme/DESCRIPTION.rst | 0 .../readme/USAGE.rst | 0 .../static/description/icon.png | Bin .../static/description/index.html | 0 repair_refurbish/tests/__init__.py | 1 + .../tests/test_repair_refurbish.py | 6 ++--- .../views/product_product_view.xml | 0 .../views/product_template_view.xml | 0 .../views/repair_view.xml | 21 ++++++++++-------- 24 files changed, 46 insertions(+), 22 deletions(-) delete mode 100644 mrp_repair_refurbish/tests/__init__.py rename {mrp_repair_refurbish => repair_refurbish}/README.rst (100%) rename {mrp_repair_refurbish => repair_refurbish}/__init__.py (100%) rename {mrp_repair_refurbish => repair_refurbish}/__manifest__.py (87%) rename {mrp_repair_refurbish => repair_refurbish}/data/stock_data.xml (100%) rename {mrp_repair_refurbish => repair_refurbish}/i18n/de.po (100%) rename {mrp_repair_refurbish => repair_refurbish}/i18n/mrp_repair_refurbish.pot (100%) rename {mrp_repair_refurbish => repair_refurbish}/models/__init__.py (57%) rename {mrp_repair_refurbish => repair_refurbish}/models/product_product.py (100%) rename {mrp_repair_refurbish => repair_refurbish}/models/product_template.py (100%) rename mrp_repair_refurbish/models/mrp_repair.py => repair_refurbish/models/repair.py (88%) create mode 100644 repair_refurbish/models/stock_move.py rename {mrp_repair_refurbish => repair_refurbish}/readme/CONFIGURE.rst (100%) rename {mrp_repair_refurbish => repair_refurbish}/readme/CONTRIBUTORS.rst (65%) rename {mrp_repair_refurbish => repair_refurbish}/readme/CREDITS.rst (100%) rename {mrp_repair_refurbish => repair_refurbish}/readme/DESCRIPTION.rst (100%) rename {mrp_repair_refurbish => repair_refurbish}/readme/USAGE.rst (100%) rename {mrp_repair_refurbish => repair_refurbish}/static/description/icon.png (100%) rename {mrp_repair_refurbish => repair_refurbish}/static/description/index.html (100%) create mode 100644 repair_refurbish/tests/__init__.py rename mrp_repair_refurbish/tests/test_mrp_repair_refurbish.py => repair_refurbish/tests/test_repair_refurbish.py (95%) rename {mrp_repair_refurbish => repair_refurbish}/views/product_product_view.xml (100%) rename {mrp_repair_refurbish => repair_refurbish}/views/product_template_view.xml (100%) rename mrp_repair_refurbish/views/mrp_repair_view.xml => repair_refurbish/views/repair_view.xml (71%) diff --git a/mrp_repair_refurbish/tests/__init__.py b/mrp_repair_refurbish/tests/__init__.py deleted file mode 100644 index 9669c5448..000000000 --- a/mrp_repair_refurbish/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import test_mrp_repair_refurbish diff --git a/mrp_repair_refurbish/README.rst b/repair_refurbish/README.rst similarity index 100% rename from mrp_repair_refurbish/README.rst rename to repair_refurbish/README.rst diff --git a/mrp_repair_refurbish/__init__.py b/repair_refurbish/__init__.py similarity index 100% rename from mrp_repair_refurbish/__init__.py rename to repair_refurbish/__init__.py diff --git a/mrp_repair_refurbish/__manifest__.py b/repair_refurbish/__manifest__.py similarity index 87% rename from mrp_repair_refurbish/__manifest__.py rename to repair_refurbish/__manifest__.py index 61b63513d..10b60bdbc 100644 --- a/mrp_repair_refurbish/__manifest__.py +++ b/repair_refurbish/__manifest__.py @@ -3,7 +3,7 @@ { "name": "MRP Repair Refurbish", "summary": "Create refurbished products during repair", - "version": "11.0.1.0.1", + "version": "12.0.1.0.1", "category": "Manufacturing", "website": "https://github.com/OCA/manufacture", "author": "Eficent, Odoo Community Association (OCA)", @@ -11,10 +11,10 @@ "application": False, "installable": True, "depends": [ - 'mrp_repair', + 'repair', ], "data": [ - "views/mrp_repair_view.xml", + "views/repair_view.xml", "data/stock_data.xml", "views/product_template_view.xml", "views/product_product_view.xml", diff --git a/mrp_repair_refurbish/data/stock_data.xml b/repair_refurbish/data/stock_data.xml similarity index 100% rename from mrp_repair_refurbish/data/stock_data.xml rename to repair_refurbish/data/stock_data.xml diff --git a/mrp_repair_refurbish/i18n/de.po b/repair_refurbish/i18n/de.po similarity index 100% rename from mrp_repair_refurbish/i18n/de.po rename to repair_refurbish/i18n/de.po diff --git a/mrp_repair_refurbish/i18n/mrp_repair_refurbish.pot b/repair_refurbish/i18n/mrp_repair_refurbish.pot similarity index 100% rename from mrp_repair_refurbish/i18n/mrp_repair_refurbish.pot rename to repair_refurbish/i18n/mrp_repair_refurbish.pot diff --git a/mrp_repair_refurbish/models/__init__.py b/repair_refurbish/models/__init__.py similarity index 57% rename from mrp_repair_refurbish/models/__init__.py rename to repair_refurbish/models/__init__.py index 3af712765..9261e7fb8 100644 --- a/mrp_repair_refurbish/models/__init__.py +++ b/repair_refurbish/models/__init__.py @@ -1,3 +1,4 @@ from . import product_product from . import product_template -from . import mrp_repair +from . import repair +from . import stock_move diff --git a/mrp_repair_refurbish/models/product_product.py b/repair_refurbish/models/product_product.py similarity index 100% rename from mrp_repair_refurbish/models/product_product.py rename to repair_refurbish/models/product_product.py diff --git a/mrp_repair_refurbish/models/product_template.py b/repair_refurbish/models/product_template.py similarity index 100% rename from mrp_repair_refurbish/models/product_template.py rename to repair_refurbish/models/product_template.py diff --git a/mrp_repair_refurbish/models/mrp_repair.py b/repair_refurbish/models/repair.py similarity index 88% rename from mrp_repair_refurbish/models/mrp_repair.py rename to repair_refurbish/models/repair.py index dded10d87..dc0033c11 100644 --- a/mrp_repair_refurbish/models/mrp_repair.py +++ b/repair_refurbish/models/repair.py @@ -4,10 +4,12 @@ from odoo import api, fields, models -class MrpRepair(models.Model): - _inherit = 'mrp.repair' +class RepairOrder(models.Model): + _inherit = 'repair.order' to_refurbish = fields.Boolean() + location_dest_id = fields.Many2one( + string='Delivery Location', comodel_name='stock.location') refurbish_location_dest_id = fields.Many2one( string='Refurbished Delivery Location', comodel_name='stock.location') refurbish_product_id = fields.Many2one( @@ -19,7 +21,7 @@ class MrpRepair(models.Model): @api.onchange('product_id') def onchange_product_id(self): - res = super(MrpRepair, self).onchange_product_id() + res = super().onchange_product_id() self.to_refurbish = True if \ self.product_id.refurbish_product_id else False return res @@ -52,7 +54,9 @@ class MrpRepair(models.Model): @api.multi def action_repair_done(self): - res = super(MrpRepair, self).action_repair_done() + res = super(RepairOrder, self.with_context( + force_refurbish_location_dest_id=self.location_dest_id.id + )).action_repair_done() for repair in self: if repair.to_refurbish: move = self.env['stock.move'].create( @@ -64,7 +68,7 @@ class MrpRepair(models.Model): class RepairLine(models.Model): - _inherit = 'mrp.repair.line' + _inherit = 'repair.line' @api.onchange('type', 'repair_id') def onchange_operation_type(self): diff --git a/repair_refurbish/models/stock_move.py b/repair_refurbish/models/stock_move.py new file mode 100644 index 000000000..fc25c6c0a --- /dev/null +++ b/repair_refurbish/models/stock_move.py @@ -0,0 +1,15 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from odoo import models, api + + +class StockMove(models.Model): + + _inherit = 'stock.move' + + @api.model + def create(self, vals): + if 'force_refurbish_location_dest_id' in self.env.context: + vals['location_dest_id'] = self.env.context[ + 'force_refurbish_location_dest_id'] + return super().create(vals) diff --git a/mrp_repair_refurbish/readme/CONFIGURE.rst b/repair_refurbish/readme/CONFIGURE.rst similarity index 100% rename from mrp_repair_refurbish/readme/CONFIGURE.rst rename to repair_refurbish/readme/CONFIGURE.rst diff --git a/mrp_repair_refurbish/readme/CONTRIBUTORS.rst b/repair_refurbish/readme/CONTRIBUTORS.rst similarity index 65% rename from mrp_repair_refurbish/readme/CONTRIBUTORS.rst rename to repair_refurbish/readme/CONTRIBUTORS.rst index daeadd46d..30781998a 100644 --- a/mrp_repair_refurbish/readme/CONTRIBUTORS.rst +++ b/repair_refurbish/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Jordi Ballester Alomar * Lois Rilo +* Akim Juillerat diff --git a/mrp_repair_refurbish/readme/CREDITS.rst b/repair_refurbish/readme/CREDITS.rst similarity index 100% rename from mrp_repair_refurbish/readme/CREDITS.rst rename to repair_refurbish/readme/CREDITS.rst diff --git a/mrp_repair_refurbish/readme/DESCRIPTION.rst b/repair_refurbish/readme/DESCRIPTION.rst similarity index 100% rename from mrp_repair_refurbish/readme/DESCRIPTION.rst rename to repair_refurbish/readme/DESCRIPTION.rst diff --git a/mrp_repair_refurbish/readme/USAGE.rst b/repair_refurbish/readme/USAGE.rst similarity index 100% rename from mrp_repair_refurbish/readme/USAGE.rst rename to repair_refurbish/readme/USAGE.rst diff --git a/mrp_repair_refurbish/static/description/icon.png b/repair_refurbish/static/description/icon.png similarity index 100% rename from mrp_repair_refurbish/static/description/icon.png rename to repair_refurbish/static/description/icon.png diff --git a/mrp_repair_refurbish/static/description/index.html b/repair_refurbish/static/description/index.html similarity index 100% rename from mrp_repair_refurbish/static/description/index.html rename to repair_refurbish/static/description/index.html diff --git a/repair_refurbish/tests/__init__.py b/repair_refurbish/tests/__init__.py new file mode 100644 index 000000000..4e9f9ec0c --- /dev/null +++ b/repair_refurbish/tests/__init__.py @@ -0,0 +1 @@ +from . import test_repair_refurbish diff --git a/mrp_repair_refurbish/tests/test_mrp_repair_refurbish.py b/repair_refurbish/tests/test_repair_refurbish.py similarity index 95% rename from mrp_repair_refurbish/tests/test_mrp_repair_refurbish.py rename to repair_refurbish/tests/test_repair_refurbish.py index acf44bafe..28bfba265 100644 --- a/mrp_repair_refurbish/tests/test_mrp_repair_refurbish.py +++ b/repair_refurbish/tests/test_repair_refurbish.py @@ -8,15 +8,15 @@ class TestMrpMtoWithStock(TransactionCase): def setUp(self, *args, **kwargs): super(TestMrpMtoWithStock, self).setUp(*args, **kwargs) - self.repair_obj = self.env['mrp.repair'] - self.repair_line_obj = self.env['mrp.repair.line'] + self.repair_obj = self.env['repair.order'] + self.repair_line_obj = self.env['repair.line'] self.product_obj = self.env['product.product'] self.move_obj = self.env['stock.move'] self.stock_location_stock = self.env.ref('stock.stock_location_stock') self.customer_location = self.env.ref('stock.stock_location_customers') self.refurbish_loc = self.env.ref( - 'mrp_repair_refurbish.stock_location_refurbish') + 'repair_refurbish.stock_location_refurbish') self.refurbish_product = self.product_obj.create({ 'name': 'Refurbished Awesome Screen', diff --git a/mrp_repair_refurbish/views/product_product_view.xml b/repair_refurbish/views/product_product_view.xml similarity index 100% rename from mrp_repair_refurbish/views/product_product_view.xml rename to repair_refurbish/views/product_product_view.xml diff --git a/mrp_repair_refurbish/views/product_template_view.xml b/repair_refurbish/views/product_template_view.xml similarity index 100% rename from mrp_repair_refurbish/views/product_template_view.xml rename to repair_refurbish/views/product_template_view.xml diff --git a/mrp_repair_refurbish/views/mrp_repair_view.xml b/repair_refurbish/views/repair_view.xml similarity index 71% rename from mrp_repair_refurbish/views/mrp_repair_view.xml rename to repair_refurbish/views/repair_view.xml index 99e209be3..f47ce2524 100644 --- a/mrp_repair_refurbish/views/mrp_repair_view.xml +++ b/repair_refurbish/views/repair_view.xml @@ -2,9 +2,9 @@ - mrp.repair.tree - mrp.repair - + repair.order.tree + repair.order + @@ -13,10 +13,13 @@ - mrp.repair.form - mrp.repair - + repair.order.form + repair.order + + + + @@ -40,9 +43,9 @@ - mrp.repair.select - mrp.repair - + repair.order.select + repair.order +