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).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
{
|
{
|
||||||
"name": "RMA Reason Code",
|
"name": "RMA Reason Code",
|
||||||
"version": "14.0.1.1.0",
|
"version": "17.0.1.0.0",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"summary": "Reason code for RMA",
|
"summary": "Reason code for RMA",
|
||||||
"author": "ForgeFlow",
|
"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)
|
return randint(1, 11)
|
||||||
|
|
||||||
name = fields.Char("Code", required=True)
|
name = fields.Char("Code", required=True)
|
||||||
description = fields.Text("Description")
|
description = fields.Text()
|
||||||
type = fields.Selection(
|
rma_type = fields.Selection(
|
||||||
[
|
[
|
||||||
("customer", "Customer RMA"),
|
("customer", "Customer RMA"),
|
||||||
("supplier", "Supplier RTV"),
|
("supplier", "Supplier RTV"),
|
||||||
("both", "Both Customer and Supplier"),
|
("both", "Both Customer and Supplier"),
|
||||||
],
|
],
|
||||||
default="both",
|
default="both",
|
||||||
|
string="RMA Type",
|
||||||
required=True,
|
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:
|
for rec in self:
|
||||||
codes = self.env["rma.reason.code"]
|
codes = self.env["rma.reason.code"]
|
||||||
if rec.type == "customer":
|
if rec.type == "customer":
|
||||||
codes = codes.search([("type", "in", ["customer", "both"])])
|
codes = codes.search([("rma_type", "in", ["customer", "both"])])
|
||||||
else:
|
else:
|
||||||
codes = codes.search([("type", "in", ["supplier", "both"])])
|
codes = codes.search([("rma_type", "in", ["supplier", "both"])])
|
||||||
rec.allowed_reason_code_ids = codes
|
rec.allowed_reason_code_ids = codes
|
||||||
|
|
||||||
@api.constrains("reason_code_ids", "product_id")
|
@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")
|
rma_order_line_id = fields.Many2one(comodel_name="rma.order.line")
|
||||||
reason_code_id = fields.Many2one(comodel_name="rma.reason.code")
|
reason_code_id = fields.Many2one(comodel_name="rma.reason.code")
|
||||||
date_rma = fields.Datetime(string="Order Date")
|
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")
|
company_id = fields.Many2one(comodel_name="res.company")
|
||||||
|
|
||||||
def _select(self):
|
def _select(self):
|
||||||
@@ -20,7 +20,7 @@ class RmaReasonCodeReport(models.Model):
|
|||||||
SELECT
|
SELECT
|
||||||
row_number() OVER () AS id,
|
row_number() OVER () AS id,
|
||||||
rma.id as rma_order_line_id,
|
rma.id as rma_order_line_id,
|
||||||
rma.type,
|
rma.type AS rma_type,
|
||||||
rrc.id as reason_code_id,
|
rrc.id as reason_code_id,
|
||||||
rma.date_rma,
|
rma.date_rma,
|
||||||
rma.company_id
|
rma.company_id
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<field name="rma_order_line_id" />
|
<field name="rma_order_line_id" />
|
||||||
<field name="reason_code_id" />
|
<field name="reason_code_id" />
|
||||||
<field name="date_rma" optional="show" />
|
<field name="date_rma" optional="show" />
|
||||||
<field name="type" optional="hide" />
|
<field name="rma_type" optional="hide" />
|
||||||
<field name="company_id" optional="hide" />
|
<field name="company_id" optional="hide" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
@@ -35,12 +35,12 @@
|
|||||||
<filter
|
<filter
|
||||||
name="is_customer"
|
name="is_customer"
|
||||||
string="Customer"
|
string="Customer"
|
||||||
domain="[('type', '=', 'customer')]"
|
domain="[('rma_type', '=', 'customer')]"
|
||||||
/>
|
/>
|
||||||
<filter
|
<filter
|
||||||
name="is_supplier"
|
name="is_supplier"
|
||||||
string="Supplier"
|
string="Supplier"
|
||||||
domain="[('type', '=', 'supplier')]"
|
domain="[('rma_type', '=', 'supplier')]"
|
||||||
/>
|
/>
|
||||||
</group>
|
</group>
|
||||||
<separator />
|
<separator />
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from odoo.exceptions import ValidationError
|
|||||||
from odoo.tests import common
|
from odoo.tests import common
|
||||||
|
|
||||||
|
|
||||||
class RMAOrderLine(common.SavepointCase):
|
class RMAOrderLine(common.TransactionCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
@@ -105,21 +105,21 @@ class RMAOrderLine(common.SavepointCase):
|
|||||||
{
|
{
|
||||||
"name": "Test Code 1",
|
"name": "Test Code 1",
|
||||||
"description": "Test description",
|
"description": "Test description",
|
||||||
"type": "both",
|
"rma_type": "both",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
cls.reason_code_customer = cls.env["rma.reason.code"].create(
|
cls.reason_code_customer = cls.env["rma.reason.code"].create(
|
||||||
{
|
{
|
||||||
"name": "Test Code 2",
|
"name": "Test Code 2",
|
||||||
"description": "Test description",
|
"description": "Test description",
|
||||||
"type": "customer",
|
"rma_type": "customer",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
cls.reason_code_supplier = cls.env["rma.reason.code"].create(
|
cls.reason_code_supplier = cls.env["rma.reason.code"].create(
|
||||||
{
|
{
|
||||||
"name": "Test Code 3",
|
"name": "Test Code 3",
|
||||||
"description": "Test description",
|
"description": "Test description",
|
||||||
"type": "supplier",
|
"rma_type": "supplier",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
nolabel="1"
|
nolabel="1"
|
||||||
colspan="2"
|
colspan="2"
|
||||||
/>
|
/>
|
||||||
<field name="type" />
|
<field name="rma_type" />
|
||||||
<field name="color" widget="color_picker" />
|
<field name="color" widget="color_picker" />
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
@@ -32,10 +32,10 @@
|
|||||||
<field name="name">rma.reason.code.list</field>
|
<field name="name">rma.reason.code.list</field>
|
||||||
<field name="model">rma.reason.code</field>
|
<field name="model">rma.reason.code</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Reason Codes">
|
<tree>
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="description" />
|
<field name="description" />
|
||||||
<field name="type" />
|
<field name="rma_type" />
|
||||||
<field name="color" widget="color_picker" />
|
<field name="color" widget="color_picker" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
widget="many2many_tags"
|
widget="many2many_tags"
|
||||||
options="{'color_field': 'color', 'no_create': True}"
|
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>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
widget="many2many_tags"
|
widget="many2many_tags"
|
||||||
options="{'color_field': 'color', 'no_create': True}"
|
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>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -66,8 +66,8 @@
|
|||||||
string="Reason Code"
|
string="Reason Code"
|
||||||
context="{'group_by':'reason_code_ids'}"
|
context="{'group_by':'reason_code_ids'}"
|
||||||
/>
|
/>
|
||||||
<field name="allowed_reason_code_ids" invisible="1" />
|
<field name="allowed_reason_code_ids" column_invisible="1" />
|
||||||
<field name="allowed_reason_code_ids" invisible="1" />
|
<field name="allowed_reason_code_ids" column_invisible="1" />
|
||||||
</filter>
|
</filter>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user