[MIG] rma_repair: Migration to 14.0

This commit is contained in:
Mateu Griful
2021-01-27 13:24:14 +01:00
committed by JasminSForgeFlow
parent 1fd2fb738f
commit 2463db943b
4 changed files with 22 additions and 11 deletions

View File

@@ -2,7 +2,7 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "RMA Repair",
"version": "13.0.1.0.0",
"version": "14.0.1.0.0",
"license": "LGPL-3",
"category": "RMA",
"summary": "Links RMA with Repairs.",
@@ -10,6 +10,7 @@
"website": "https://github.com/OCA/https://github.com/ForgeFlow/stock-rma",
"depends": ["rma_account", "repair_refurbish"],
"data": [
"security/ir.model.access.csv",
"views/rma_order_view.xml",
"views/rma_operation_view.xml",
"views/repair_view.xml",

View File

@@ -84,7 +84,8 @@ class RmaOrderLine(models.Model):
)
delivery_policy = fields.Selection(
selection_add=[("repair", "Based on Repair Quantities")]
selection_add=[("repair", "Based on Repair Quantities")],
ondelete={"repair": lambda recs: recs.write({"delivery_policy": "no"})},
)
qty_to_pay = fields.Float(compute="_compute_qty_to_pay")
qty_to_deliver = fields.Float(compute="_compute_qty_to_deliver")
@@ -100,13 +101,17 @@ class RmaOrderLine(models.Model):
"repair_ids.invoice_status",
)
def _compute_qty_to_pay(self):
for rec in self.filtered(lambda l: l.delivery_policy == "repair"):
for rec in self:
if rec.delivery_policy == "repair":
qty_to_pay = 0.0
for repair in rec.repair_ids.filtered(
lambda r: r.invoice_method != "none" and r.invoice_status != "posted"
lambda r: r.invoice_method != "none"
and r.invoice_status != "posted"
):
qty_to_pay += repair.product_qty
rec.qty_to_pay = qty_to_pay
else:
rec.qty_to_pay = 0.0
def action_view_repair_order(self):
action = self.env.ref("repair.action_repair_order_tree")

View File

@@ -0,0 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_rma_order_line_make_repair_customer_user_item,rma.order.line.make.repair.customer.user,model_rma_order_line_make_repair,rma.group_rma_customer_user,1,1,1,1
access_rma_order_line_make_supplier_user_item,rma.order.line.make.repair.supplier.user,model_rma_order_line_make_repair,rma.group_rma_supplier_user,1,1,1,1
access_rma_order_line_make_repair_item_customer_user_item,rma.order.line.make.repair.item.customer.user,model_rma_order_line_make_repair_item,rma.group_rma_customer_user,1,1,1,1
access_rma_order_line_make_repair_item_supplier_user_item,rma.order.line.make.repair.item.supplier.user,model_rma_order_line_make_repair_item,rma.group_rma_supplier_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_rma_order_line_make_repair_customer_user_item rma.order.line.make.repair.customer.user model_rma_order_line_make_repair rma.group_rma_customer_user 1 1 1 1
3 access_rma_order_line_make_supplier_user_item rma.order.line.make.repair.supplier.user model_rma_order_line_make_repair rma.group_rma_supplier_user 1 1 1 1
4 access_rma_order_line_make_repair_item_customer_user_item rma.order.line.make.repair.item.customer.user model_rma_order_line_make_repair_item rma.group_rma_customer_user 1 1 1 1
5 access_rma_order_line_make_repair_item_supplier_user_item rma.order.line.make.repair.item.supplier.user model_rma_order_line_make_repair_item rma.group_rma_supplier_user 1 1 1 1

View File

@@ -98,7 +98,7 @@ class TestRmaRepair(common.SingleTransactionCase):
cls.inv_customer = cls.env["account.move"].create(
[
{
"type": "out_invoice",
"move_type": "out_invoice",
"partner_id": cls.customer1.id,
"invoice_date": fields.Date.from_string("2016-01-01"),
"currency_id": cls.currency_id.id,
@@ -263,7 +263,7 @@ class TestRmaRepair(common.SingleTransactionCase):
self.assertEqual(rma.qty_repaired, 1.0)
self.assertEqual(rma.qty_to_deliver, 1.0)
repair.invoice_id.post()
repair.invoice_id.action_invoice_register_payment()
repair.invoice_id.action_register_payment()
self.assertEqual(repair.invoice_status, "posted")
self.assertEqual(rma.qty_to_pay, 0.0)
self.assertEqual(rma.qty_repaired, 1.0)