mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[MIG] rma_reason_code: Migration to 17.0
This commit is contained in:
@@ -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",
|
||||
|
||||
17
rma_reason_code/migrations/17.0.1.0.0/pre-migration.py
Normal file
17
rma_reason_code/migrations/17.0.1.0.0/pre-migration.py
Normal file
@@ -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",
|
||||
"rma_type",
|
||||
)
|
||||
],
|
||||
)
|
||||
@@ -13,14 +13,15 @@ class RMAReasonCode(models.Model):
|
||||
return randint(1, 11)
|
||||
|
||||
name = fields.Char("Code", required=True)
|
||||
description = fields.Text("Description")
|
||||
type = fields.Selection(
|
||||
description = fields.Text()
|
||||
rma_type = fields.Selection(
|
||||
[
|
||||
("customer", "Customer RMA"),
|
||||
("supplier", "Supplier RTV"),
|
||||
("both", "Both Customer and Supplier"),
|
||||
],
|
||||
default="both",
|
||||
string="RMA Type",
|
||||
required=True,
|
||||
)
|
||||
color = fields.Integer("Color", default=_get_default_color)
|
||||
color = fields.Integer(default=_get_default_color)
|
||||
|
||||
@@ -24,9 +24,9 @@ class RMAOrderLine(models.Model):
|
||||
for rec in self:
|
||||
codes = self.env["rma.reason.code"]
|
||||
if rec.type == "customer":
|
||||
codes = codes.search([("type", "in", ["customer", "both"])])
|
||||
codes = codes.search([("rma_type", "in", ["customer", "both"])])
|
||||
else:
|
||||
codes = codes.search([("type", "in", ["supplier", "both"])])
|
||||
codes = codes.search([("rma_type", "in", ["supplier", "both"])])
|
||||
rec.allowed_reason_code_ids = codes
|
||||
|
||||
@api.constrains("reason_code_ids", "product_id")
|
||||
|
||||
@@ -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")])
|
||||
rma_type = fields.Selection([("customer", "Customer"), ("supplier", "Supplier")])
|
||||
company_id = fields.Many2one(comodel_name="res.company")
|
||||
|
||||
def _select(self):
|
||||
@@ -20,7 +20,7 @@ class RmaReasonCodeReport(models.Model):
|
||||
SELECT
|
||||
row_number() OVER () AS id,
|
||||
rma.id as rma_order_line_id,
|
||||
rma.type,
|
||||
rma.type AS rma_type,
|
||||
rrc.id as reason_code_id,
|
||||
rma.date_rma,
|
||||
rma.company_id
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<field name="rma_order_line_id" />
|
||||
<field name="reason_code_id" />
|
||||
<field name="date_rma" optional="show" />
|
||||
<field name="type" optional="hide" />
|
||||
<field name="rma_type" optional="hide" />
|
||||
<field name="company_id" optional="hide" />
|
||||
</tree>
|
||||
</field>
|
||||
@@ -35,12 +35,12 @@
|
||||
<filter
|
||||
name="is_customer"
|
||||
string="Customer"
|
||||
domain="[('type', '=', 'customer')]"
|
||||
domain="[('rma_type', '=', 'customer')]"
|
||||
/>
|
||||
<filter
|
||||
name="is_supplier"
|
||||
string="Supplier"
|
||||
domain="[('type', '=', 'supplier')]"
|
||||
domain="[('rma_type', '=', 'supplier')]"
|
||||
/>
|
||||
</group>
|
||||
<separator />
|
||||
|
||||
@@ -6,7 +6,7 @@ from odoo.exceptions import ValidationError
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class RMAOrderLine(common.SavepointCase):
|
||||
class RMAOrderLine(common.TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
@@ -105,21 +105,21 @@ class RMAOrderLine(common.SavepointCase):
|
||||
{
|
||||
"name": "Test Code 1",
|
||||
"description": "Test description",
|
||||
"type": "both",
|
||||
"rma_type": "both",
|
||||
}
|
||||
)
|
||||
cls.reason_code_customer = cls.env["rma.reason.code"].create(
|
||||
{
|
||||
"name": "Test Code 2",
|
||||
"description": "Test description",
|
||||
"type": "customer",
|
||||
"rma_type": "customer",
|
||||
}
|
||||
)
|
||||
cls.reason_code_supplier = cls.env["rma.reason.code"].create(
|
||||
{
|
||||
"name": "Test Code 3",
|
||||
"description": "Test description",
|
||||
"type": "supplier",
|
||||
"rma_type": "supplier",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
nolabel="1"
|
||||
colspan="2"
|
||||
/>
|
||||
<field name="type" />
|
||||
<field name="rma_type" />
|
||||
<field name="color" widget="color_picker" />
|
||||
</group>
|
||||
</sheet>
|
||||
@@ -32,10 +32,10 @@
|
||||
<field name="name">rma.reason.code.list</field>
|
||||
<field name="model">rma.reason.code</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Reason Codes">
|
||||
<tree>
|
||||
<field name="name" />
|
||||
<field name="description" />
|
||||
<field name="type" />
|
||||
<field name="rma_type" />
|
||||
<field name="color" widget="color_picker" />
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
widget="many2many_tags"
|
||||
options="{'color_field': 'color', 'no_create': True}"
|
||||
/>
|
||||
<field name="allowed_reason_code_ids" invisible="1" />
|
||||
<field name="allowed_reason_code_ids" column_invisible="1" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -32,7 +32,7 @@
|
||||
widget="many2many_tags"
|
||||
options="{'color_field': 'color', 'no_create': True}"
|
||||
/>
|
||||
<field name="allowed_reason_code_ids" invisible="1" />
|
||||
<field name="allowed_reason_code_ids" column_invisible="1" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -66,8 +66,8 @@
|
||||
string="Reason Code"
|
||||
context="{'group_by':'reason_code_ids'}"
|
||||
/>
|
||||
<field name="allowed_reason_code_ids" invisible="1" />
|
||||
<field name="allowed_reason_code_ids" invisible="1" />
|
||||
<field name="allowed_reason_code_ids" column_invisible="1" />
|
||||
<field name="allowed_reason_code_ids" column_invisible="1" />
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user