mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
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:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user