diff --git a/rma_reason_code/__manifest__.py b/rma_reason_code/__manifest__.py index 01b7ab7c1..bd9dd6d45 100644 --- a/rma_reason_code/__manifest__.py +++ b/rma_reason_code/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "RMA Reason Code", - "version": "14.0.1.1.0", + "version": "17.0.1.0.0", "license": "AGPL-3", "summary": "Reason code for RMA", "author": "ForgeFlow", diff --git a/rma_reason_code/migrations/17.0.1.0.0/pre-migration.py b/rma_reason_code/migrations/17.0.1.0.0/pre-migration.py new file mode 100644 index 000000000..ed98b8be0 --- /dev/null +++ b/rma_reason_code/migrations/17.0.1.0.0/pre-migration.py @@ -0,0 +1,17 @@ +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + if openupgrade.column_exists(env.cr, "rma_reason_code", "type"): + openupgrade.rename_fields( + env, + [ + ( + "rma.reason.code", + "rma_reason_code", + "type", + "item_type", + ) + ], + ) diff --git a/rma_reason_code/models/reason_code.py b/rma_reason_code/models/reason_code.py index b52ef0a7c..619e22989 100644 --- a/rma_reason_code/models/reason_code.py +++ b/rma_reason_code/models/reason_code.py @@ -13,8 +13,8 @@ def _get_default_color(self): return randint(1, 11) name = fields.Char("Code", required=True) - description = fields.Text("Description") - type = fields.Selection( + description = fields.Text() + item_type = fields.Selection( [ ("customer", "Customer RMA"), ("supplier", "Supplier RTV"), @@ -23,4 +23,4 @@ def _get_default_color(self): default="both", required=True, ) - color = fields.Integer("Color", default=_get_default_color) + color = fields.Integer(default=_get_default_color) diff --git a/rma_reason_code/models/rma_order_line.py b/rma_reason_code/models/rma_order_line.py index 5233085fd..03dfe4606 100644 --- a/rma_reason_code/models/rma_order_line.py +++ b/rma_reason_code/models/rma_order_line.py @@ -24,9 +24,9 @@ def _compute_allowed_reason_code_ids(self): for rec in self: codes = self.env["rma.reason.code"] if rec.type == "customer": - codes = codes.search([("type", "in", ["customer", "both"])]) + codes = codes.search([("item_type", "in", ["customer", "both"])]) else: - codes = codes.search([("type", "in", ["supplier", "both"])]) + codes = codes.search([("item_type", "in", ["supplier", "both"])]) rec.allowed_reason_code_ids = codes @api.constrains("reason_code_ids", "product_id") diff --git a/rma_reason_code/reports/rma_reason_code_report.py b/rma_reason_code/reports/rma_reason_code_report.py index cb6d1b27f..854dd8c57 100644 --- a/rma_reason_code/reports/rma_reason_code_report.py +++ b/rma_reason_code/reports/rma_reason_code_report.py @@ -12,7 +12,7 @@ class RmaReasonCodeReport(models.Model): rma_order_line_id = fields.Many2one(comodel_name="rma.order.line") reason_code_id = fields.Many2one(comodel_name="rma.reason.code") date_rma = fields.Datetime(string="Order Date") - type = fields.Selection([("customer", "Customer"), ("supplier", "Supplier")]) + item_type = fields.Selection([("customer", "Customer"), ("supplier", "Supplier")]) company_id = fields.Many2one(comodel_name="res.company") def _select(self): @@ -20,7 +20,7 @@ def _select(self): SELECT row_number() OVER () AS id, rma.id as rma_order_line_id, - rma.type, + rma.type AS item_type, rrc.id as reason_code_id, rma.date_rma, rma.company_id diff --git a/rma_reason_code/reports/rma_reason_code_report_views.xml b/rma_reason_code/reports/rma_reason_code_report_views.xml index dd72fb659..d57934395 100644 --- a/rma_reason_code/reports/rma_reason_code_report_views.xml +++ b/rma_reason_code/reports/rma_reason_code_report_views.xml @@ -8,7 +8,7 @@ - + @@ -35,12 +35,12 @@ diff --git a/rma_reason_code/tests/test_scrap_reason_code.py b/rma_reason_code/tests/test_scrap_reason_code.py index 71f006930..af8ce16d8 100644 --- a/rma_reason_code/tests/test_scrap_reason_code.py +++ b/rma_reason_code/tests/test_scrap_reason_code.py @@ -6,7 +6,7 @@ from odoo.tests import common -class RMAOrderLine(common.SavepointCase): +class RMAOrderLine(common.TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -105,21 +105,21 @@ def setUpClass(cls): { "name": "Test Code 1", "description": "Test description", - "type": "both", + "item_type": "both", } ) cls.reason_code_customer = cls.env["rma.reason.code"].create( { "name": "Test Code 2", "description": "Test description", - "type": "customer", + "item_type": "customer", } ) cls.reason_code_supplier = cls.env["rma.reason.code"].create( { "name": "Test Code 3", "description": "Test description", - "type": "supplier", + "item_type": "supplier", } ) diff --git a/rma_reason_code/views/reason_code_view.xml b/rma_reason_code/views/reason_code_view.xml index 60bc433c0..8b3af1c68 100644 --- a/rma_reason_code/views/reason_code_view.xml +++ b/rma_reason_code/views/reason_code_view.xml @@ -21,7 +21,7 @@ nolabel="1" colspan="2" /> - + @@ -32,10 +32,10 @@ rma.reason.code.list rma.reason.code - + - + diff --git a/rma_reason_code/views/rma_order_line_views.xml b/rma_reason_code/views/rma_order_line_views.xml index 9e010d0af..6195ace59 100644 --- a/rma_reason_code/views/rma_order_line_views.xml +++ b/rma_reason_code/views/rma_order_line_views.xml @@ -16,7 +16,7 @@ widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" /> - + @@ -32,7 +32,7 @@ widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" /> - + @@ -48,7 +48,7 @@ widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" /> - + @@ -66,8 +66,8 @@ string="Reason Code" context="{'group_by':'reason_code_ids'}" /> - - + +