Merge pull request #255 from ForgeFlow/14.0-mig-product_template_multicompany

[14.0][FIX/IMP] Make RMA Operation settings company dependent
This commit is contained in:
Jordi Ballester Alomar
2022-05-19 19:57:10 +02:00
committed by GitHub
4 changed files with 51 additions and 6 deletions

View File

@@ -10,7 +10,7 @@
"in odoo",
"author": "ForgeFlow",
"website": "https://github.com/ForgeFlow/stock-rma",
"depends": ["stock", "mail", "web"],
"depends": ["stock", "mail", "web", "account"],
"demo": ["demo/stock_demo.xml"],
"data": [
"security/rma.xml",

View File

@@ -8,10 +8,14 @@ class ProductTemplate(models.Model):
_inherit = "product.template"
rma_customer_operation_id = fields.Many2one(
comodel_name="rma.operation", string="Default RMA Customer Operation"
company_dependent=True,
comodel_name="rma.operation",
string="Default RMA Customer Operation",
)
rma_supplier_operation_id = fields.Many2one(
comodel_name="rma.operation", string="Default RMA Supplier Operation"
company_dependent=True,
comodel_name="rma.operation",
string="Default RMA Supplier Operation",
)
rma_approval_policy = fields.Selection(
related="categ_id.rma_approval_policy", readonly=True

View File

@@ -19,8 +19,12 @@ class ProductCategory(models.Model):
"this policy will request the RMA manager approval.",
)
rma_customer_operation_id = fields.Many2one(
comodel_name="rma.operation", string="Default RMA Customer Operation"
company_dependent=True,
comodel_name="rma.operation",
string="Default RMA Customer Operation",
)
rma_supplier_operation_id = fields.Many2one(
comodel_name="rma.operation", string="Default RMA Supplier Operation"
company_dependent=True,
comodel_name="rma.operation",
string="Default RMA Supplier Operation",
)

View File

@@ -980,4 +980,41 @@ class TestRma(common.SavepointCase):
)
for line in self.rma_supplier_id.rma_line_ids:
line.action_rma_done()
self.assertEqual(line.mapped("state"), ["done"], "Wrong State")
self.assertEqual(line.state, "done", "Wrong State")
def test_05_rma_order_line(self):
"""Property rma_customer_operation_id on product or product category
correctly handled inside _onchange_product_id()
"""
rma_operation = self.env["rma.operation"].search([], limit=1)
self.assertTrue(rma_operation)
# Case of product template
self.rma_customer_id.rma_line_ids.mapped("product_id").sudo().write(
{"rma_customer_operation_id": rma_operation.id}
)
for line in self.rma_customer_id.rma_line_ids:
data = {"product_id": line.product_id.id}
new_line = self.rma_line.new(data)
self.assertFalse(new_line.operation_id)
self.assertTrue(new_line.product_id.rma_customer_operation_id)
self.assertTrue(new_line.product_id.categ_id.rma_customer_operation_id)
new_line._onchange_product_id()
self.assertEqual(new_line.operation_id, rma_operation)
# Case of product category
self.rma_customer_id.rma_line_ids.mapped("product_id").sudo().write(
{"rma_customer_operation_id": False}
)
self.rma_customer_id.rma_line_ids.mapped("product_id.categ_id").sudo().write(
{"rma_customer_operation_id": rma_operation.id}
)
for line in self.rma_customer_id.rma_line_ids:
data = {"product_id": line.product_id.id}
new_line = self.rma_line.new(data)
self.assertFalse(new_line.operation_id)
self.assertFalse(new_line.product_id.rma_customer_operation_id)
self.assertTrue(new_line.product_id.categ_id.rma_customer_operation_id)
new_line._onchange_product_id()
self.assertEqual(new_line.operation_id, rma_operation)