diff --git a/rma/__manifest__.py b/rma/__manifest__.py index 015ed11d1..a290b3ed3 100644 --- a/rma/__manifest__.py +++ b/rma/__manifest__.py @@ -30,7 +30,7 @@ "views/rma_menu.xml", "wizards/rma_make_picking_view.xml", "wizards/rma_add_stock_move_view.xml", - "wizards/rma_order_line_make_supplier_rma_view.xml", + "wizards/rma_make_supplier_rma_view.xml", "report/report_deliveryslip.xml", "wizards/rma_add_serial_views.xml", ], diff --git a/rma/security/ir.model.access.csv b/rma/security/ir.model.access.csv index 3643627b0..32357097f 100644 --- a/rma/security/ir.model.access.csv +++ b/rma/security/ir.model.access.csv @@ -15,8 +15,8 @@ access_rma_picking_wizard_supplier,rma.order.manager,model_rma_make_picking_wiza access_rma_picking_wizard_item,rma.order.manager,model_rma_make_picking_wizard_item,group_rma_manager,1,1,1,1 access_rma_picking_wizard_item_customer,rma.order.manager,model_rma_make_picking_wizard_item,group_rma_customer_user,1,1,1,1 access_rma_picking_wizard_item_supplier,rma.order.manager,model_rma_make_picking_wizard_item,group_rma_supplier_user,1,1,1,1 -access_rma_order_line_make_supplier_rma_customer_user,rma.order.line.make.supplier.rma.customer.user,model_rma_order_line_make_supplier_rma,rma.group_rma_customer_user,1,1,1,1 -access_rma_order_line_make_supplier_rmasupplier_user,rma.order.line.make.supplier.rma.supplier.user,model_rma_order_line_make_supplier_rma,rma.group_rma_supplier_user,1,1,1,1 +access_rma_make_supplier_rma_customer_user,rma.make.supplier.rma.customer.user,model_rma_make_supplier_rma,rma.group_rma_customer_user,1,1,1,1 +access_rma_make_supplier_rma_supplier_user,rma.make.supplier.rma.supplier.user,model_rma_make_supplier_rma,rma.group_rma_supplier_user,1,1,1,1 access_rma_order_line_make_supplier_rma_customer_user_item,rma.order.line.make.supplier.rma.item.customer.user,model_rma_order_line_make_supplier_rma_item,rma.group_rma_customer_user,1,1,1,1 access_rma_order_line_make_supplier_rmasupplier_user_item,rma.order.line.make.supplier.rma.item.supplier.user,model_rma_order_line_make_supplier_rma_item,rma.group_rma_supplier_user,1,1,1,1 access_rma_add_stock_move_customer_user_item,rma.add.stock.move.customer.user,model_rma_add_stock_move,rma.group_rma_customer_user,1,1,1,1 diff --git a/rma/tests/test_rma.py b/rma/tests/test_rma.py index 5ab4bbd40..4d1b2b0dc 100644 --- a/rma/tests/test_rma.py +++ b/rma/tests/test_rma.py @@ -13,7 +13,7 @@ def setUpClass(cls): super(TestRma, cls).setUpClass() # models cls.rma_make_picking = cls.env["rma_make_picking.wizard"] - cls.make_supplier_rma = cls.env["rma.order.line.make.supplier.rma"] + cls.make_supplier_rma = cls.env["rma.make.supplier.rma"] cls.rma_add_stock_move = cls.env["rma_add_stock_move"] cls.product_ctg_model = cls.env["product.category"] cls.stockpicking = cls.env["stock.picking"] diff --git a/rma/wizards/__init__.py b/rma/wizards/__init__.py index 7989b0771..dcc3fc9b8 100644 --- a/rma/wizards/__init__.py +++ b/rma/wizards/__init__.py @@ -1,4 +1,4 @@ from . import rma_add_stock_move from . import rma_make_picking -from . import rma_order_line_make_supplier_rma +from . import rma_make_supplier_rma from . import rma_add_serial diff --git a/rma/wizards/rma_make_picking.py b/rma/wizards/rma_make_picking.py index a8afdb439..1633ccbdb 100644 --- a/rma/wizards/rma_make_picking.py +++ b/rma/wizards/rma_make_picking.py @@ -10,7 +10,7 @@ class RmaMakePicking(models.TransientModel): _name = "rma_make_picking.wizard" - _description = "Wizard to create pickings from rma lines" + _description = "Wizard to create Pickings from rma" @api.returns("rma.order.line") def _prepare_item(self, line): @@ -35,8 +35,8 @@ def default_get(self, fields_list): res = super().default_get(fields_list) rma_line_obj = self.env["rma.order.line"] rma_obj = self.env["rma.order"] - active_ids = self.env.context["active_ids"] or [] - active_model = self.env.context["active_model"] + active_ids = context.get("active_ids") or [] + active_model = context.get("active_model") if not active_ids: return res assert active_model in [ diff --git a/rma/wizards/rma_order_line_make_supplier_rma.py b/rma/wizards/rma_make_supplier_rma.py similarity index 90% rename from rma/wizards/rma_order_line_make_supplier_rma.py rename to rma/wizards/rma_make_supplier_rma.py index 0fcc544d8..1f651715e 100644 --- a/rma/wizards/rma_order_line_make_supplier_rma.py +++ b/rma/wizards/rma_make_supplier_rma.py @@ -5,9 +5,9 @@ from odoo.exceptions import ValidationError -class RmaLineMakeSupplierRma(models.TransientModel): - _name = "rma.order.line.make.supplier.rma" - _description = "RMA Line Make Supplier RMA" +class RmaMakeSupplierRma(models.TransientModel): + _name = "rma.make.supplier.rma" + _description = "Wizard to create Supplier RMA from rma" partner_id = fields.Many2one( comodel_name="res.partner", @@ -50,17 +50,26 @@ def _prepare_item(self, line): @api.model def default_get(self, fields_list): - res = super(RmaLineMakeSupplierRma, self).default_get(fields_list) + context = self._context.copy() + res = super().default_get(fields_list) rma_line_obj = self.env["rma.order.line"] - rma_line_ids = self.env.context["active_ids"] or [] - active_model = self.env.context["active_model"] + rma_obj = self.env["rma.order"] + active_ids = context.get("active_ids") or [] + active_model = context.get("active_model") - if not rma_line_ids: + if not active_ids: return res - assert active_model == "rma.order.line", "Bad context propagation" + assert active_model in [ + "rma.order.line", + "rma.order", + ], "Bad context propagation" items = [] - lines = rma_line_obj.browse(rma_line_ids) + if active_model == "rma.order": + rma = rma_obj.browse(active_ids) + lines = rma.rma_line_ids + else: + lines = rma_line_obj.browse(active_ids) for line in lines: items.append([0, 0, self._prepare_item(line)]) suppliers = lines.mapped( @@ -177,7 +186,7 @@ class RmaLineMakeRmaOrderItem(models.TransientModel): _description = "RMA Line Make Supplier RMA Item" wiz_id = fields.Many2one( - "rma.order.line.make.supplier.rma", + "rma.make.supplier.rma", string="Wizard", required=True, ondelete="cascade", diff --git a/rma/wizards/rma_order_line_make_supplier_rma_view.xml b/rma/wizards/rma_make_supplier_rma_view.xml similarity index 77% rename from rma/wizards/rma_order_line_make_supplier_rma_view.xml rename to rma/wizards/rma_make_supplier_rma_view.xml index e145b34cd..9c88f007f 100644 --- a/rma/wizards/rma_order_line_make_supplier_rma_view.xml +++ b/rma/wizards/rma_make_supplier_rma_view.xml @@ -4,7 +4,7 @@ RMA Line Make Supplier RMA - rma.order.line.make.supplier.rma + rma.make.supplier.rma form
@@ -49,10 +49,10 @@ - + Create Supplier RMA ir.actions.act_window - rma.order.line.make.supplier.rma + rma.make.supplier.rma form new @@ -66,7 +66,23 @@
+
+
+ + + rma.supplier.rma.form + rma.order + + +
+