From 7737ceddfb0974bcae299195d61f08cab58e032f Mon Sep 17 00:00:00 2001 From: Juany Davila Date: Mon, 20 Mar 2023 15:31:53 -0500 Subject: [PATCH] [MIG] rma_operating_unit: migration to 14.0 --- rma_operating_unit/README.rst | 7 +- rma_operating_unit/__manifest__.py | 6 +- rma_operating_unit/models/rma_order.py | 3 +- rma_operating_unit/models/rma_order_line.py | 2 +- rma_operating_unit/security/rma_security.xml | 2 +- .../tests/test_rma_operating_unit.py | 74 +++++++++++-------- .../views/rma_order_line_view.xml | 15 +--- rma_operating_unit/views/rma_order_view.xml | 38 +++++----- .../wizards/rma_add_stock_move.py | 4 +- 9 files changed, 79 insertions(+), 72 deletions(-) diff --git a/rma_operating_unit/README.rst b/rma_operating_unit/README.rst index 1545840d..34879cd3 100644 --- a/rma_operating_unit/README.rst +++ b/rma_operating_unit/README.rst @@ -24,10 +24,11 @@ Usage Contributors ------------ -* Aaron Henriquez -* Beñat Jimenez +* Aaron Henriquez +* Beñat Jimenez +* Juany Davila Maintainer ---------- -This module is maintained by Eficent. \ No newline at end of file +This module is maintained by ForgeFlow. diff --git a/rma_operating_unit/__manifest__.py b/rma_operating_unit/__manifest__.py index bb87fad0..81a40343 100644 --- a/rma_operating_unit/__manifest__.py +++ b/rma_operating_unit/__manifest__.py @@ -1,10 +1,10 @@ -# © 2017-19 Eficent Business and IT Consulting Services S.L. +# Copyright 2017-19 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). { "name": "Operating Unit in RMA Groups", - "version": "12.0.1.0.0", - "author": "Eficent", + "version": "14.0.1.0.0", + "author": "ForgeFlow", "license": "LGPL-3", "website": "https://github.com/ForgeFlow/stock-rma", "category": "Operating Units", diff --git a/rma_operating_unit/models/rma_order.py b/rma_operating_unit/models/rma_order.py index 4d2dbb5b..2eb0889e 100644 --- a/rma_operating_unit/models/rma_order.py +++ b/rma_operating_unit/models/rma_order.py @@ -1,4 +1,4 @@ -# © 2017-19 Eficent Business and IT Consulting Services S.L. +# Copyright 2017-23 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import _, api, fields, models @@ -9,7 +9,6 @@ class RmaOrder(models.Model): _inherit = "rma.order" - @api.multi @api.constrains("rma_line_ids", "rma_line_ids.operating_unit_id") def _check_operating_unit(self): for rma in self: diff --git a/rma_operating_unit/models/rma_order_line.py b/rma_operating_unit/models/rma_order_line.py index 0059ccd6..b00806cd 100644 --- a/rma_operating_unit/models/rma_order_line.py +++ b/rma_operating_unit/models/rma_order_line.py @@ -1,4 +1,4 @@ -# © 2017-19 Eficent Business and IT Consulting Services S.L. +# Copyright 2017-19 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import api, fields, models diff --git a/rma_operating_unit/security/rma_security.xml b/rma_operating_unit/security/rma_security.xml index f0c15fd5..0384ead5 100644 --- a/rma_operating_unit/security/rma_security.xml +++ b/rma_operating_unit/security/rma_security.xml @@ -1,5 +1,5 @@ - diff --git a/rma_operating_unit/tests/test_rma_operating_unit.py b/rma_operating_unit/tests/test_rma_operating_unit.py index 50adb738..d1328496 100644 --- a/rma_operating_unit/tests/test_rma_operating_unit.py +++ b/rma_operating_unit/tests/test_rma_operating_unit.py @@ -1,4 +1,4 @@ -# © 2017-19 Eficent Business and IT Consulting Services S.L. +# Copyright 2017-19 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import exceptions from odoo.tests import common @@ -68,45 +68,61 @@ class TestRmaOperatingUnit(common.TransactionCase): def _create_rma(self, uid, operating_unit=False): """Creates an RMA""" if not operating_unit: - operating_unit = self.rma_model.sudo(uid)._default_operating_unit() - rma_order = self.rma_model.sudo(uid).create( - { - "operating_unit_id": operating_unit.id, - "partner_id": self.partner.id, - "user_id": uid, - } + operating_unit = ( + self.rma_model.sudo().with_user(uid)._default_operating_unit() + ) + rma_order = ( + self.rma_model.sudo() + .with_user(uid) + .create( + { + "operating_unit_id": operating_unit.id, + "partner_id": self.partner.id, + } + ) ) return rma_order def _create_rma_line(self, rma, uid, operating_unit): """Creates an RMA""" - rma_order_line = self.rma_line_model.sudo(uid).create( - { - "operating_unit_id": operating_unit.id, - "rma_id": rma.id, - "partner_id": self.partner.id, - "in_route_id": 1, - "out_route_id": 1, - "in_warehouse_id": 1, - "out_warehouse_id": 1, - "location_id": 1, - "receipt_policy": "ordered", - "delivery_policy": "ordered", - "name": self.product.name, - "product_id": self.product.id, - "uom_id": self.product.uom_id.id, - } + rma_order_line = ( + self.rma_line_model.sudo() + .with_user(uid) + .create( + { + "operating_unit_id": operating_unit.id, + "operation_id": self.env.ref( + "rma.rma_operation_supplier_replace" + ).id, + "rma_id": rma.id, + "partner_id": self.partner.id, + "in_route_id": 1, + "out_route_id": 1, + "in_warehouse_id": 1, + "out_warehouse_id": 1, + "location_id": 1, + "receipt_policy": "ordered", + "delivery_policy": "ordered", + "name": self.product.name, + "product_id": self.product.id, + "uom_id": self.product.uom_id.id, + } + ) ) return rma_order_line def test_security(self): # User 2 is only assigned to Operating Unit B2C, and cannot # access RMA of Main Operating Unit. - record = self.rma_model.sudo(self.user2.id).search( - [ - ("id", "=", self.rma_order1.id), - ("operating_unit_id", "=", self.main_OU.id), - ] + record = ( + self.rma_model.sudo() + .with_user(self.user2.id) + .search( + [ + ("id", "=", self.rma_order1.id), + ("operating_unit_id", "=", self.main_OU.id), + ] + ) ) self.assertEqual( record.ids, diff --git a/rma_operating_unit/views/rma_order_line_view.xml b/rma_operating_unit/views/rma_order_line_view.xml index a3d19f60..e7bb3eb1 100644 --- a/rma_operating_unit/views/rma_order_line_view.xml +++ b/rma_operating_unit/views/rma_order_line_view.xml @@ -1,5 +1,5 @@ - @@ -30,19 +30,6 @@ - - rma.order.supplier.tree - rma.order - - - - - - - rma.order.line.supplier.form rma.order.line diff --git a/rma_operating_unit/views/rma_order_view.xml b/rma_operating_unit/views/rma_order_view.xml index 391c5e94..82b4310b 100644 --- a/rma_operating_unit/views/rma_order_view.xml +++ b/rma_operating_unit/views/rma_order_view.xml @@ -1,5 +1,5 @@ - @@ -35,14 +35,16 @@ rma.order - - - + + + + + @@ -52,14 +54,16 @@ rma.order - - - + + + + + diff --git a/rma_operating_unit/wizards/rma_add_stock_move.py b/rma_operating_unit/wizards/rma_add_stock_move.py index 11062796..7b35b7a7 100644 --- a/rma_operating_unit/wizards/rma_add_stock_move.py +++ b/rma_operating_unit/wizards/rma_add_stock_move.py @@ -1,4 +1,4 @@ -# © 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2017 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import _, models @@ -33,7 +33,7 @@ class RmaAddStockMove(models.TransientModel): [ ("company_id", "=", self.rma_id.company_id.id), ("lot_rma_id", "!=", False), - ("operating_unit_id", "=", self.line_id.operating_unit_id.id), + ("operating_unit_id", "=", self.rma_id.operating_unit_id.id), ], limit=1, )