mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[FIX] rma_account: maintain refund_line_id
This commit is contained in:
committed by
Aaron ForgeFlow
parent
8ec2bde6e5
commit
72eca30681
@@ -279,12 +279,10 @@ class TestAccountMoveLineRmaOrderLine(common.SavepointCase):
|
||||
}
|
||||
)
|
||||
make_refund.invoice_refund()
|
||||
rma_line.move_line_ids.move_id.filtered(
|
||||
rma_line.refund_line_ids.move_id.filtered(
|
||||
lambda x: x.state != "posted"
|
||||
).action_post()
|
||||
for aml in rma_line.move_line_ids.move_id.filtered(
|
||||
lambda x: x.move_type in ("out_refund", "in_refund")
|
||||
).invoice_line_ids:
|
||||
for aml in rma_line.refund_line_ids.move_id.invoice_line_ids:
|
||||
if aml.product_id == rma_line.product_id and aml.move_id:
|
||||
self.assertEqual(
|
||||
aml.rma_line_id,
|
||||
|
||||
@@ -9,9 +9,7 @@ class RmaOrder(models.Model):
|
||||
|
||||
def _compute_invoice_refund_count(self):
|
||||
for rec in self:
|
||||
invoices = rec.mapped("rma_line_ids.move_line_ids.move_id").filtered(
|
||||
lambda m: m.move_type in ["in_refund", "out_refund"]
|
||||
)
|
||||
invoices = rec.mapped("rma_line_ids.refund_line_ids.move_id")
|
||||
rec.invoice_refund_count = len(invoices)
|
||||
|
||||
def _compute_invoice_count(self):
|
||||
|
||||
@@ -21,9 +21,8 @@ class RmaOrderLine(models.Model):
|
||||
def _compute_qty_refunded(self):
|
||||
for rec in self:
|
||||
rec.qty_refunded = sum(
|
||||
rec.move_line_ids.filtered(
|
||||
rec.refund_line_ids.filtered(
|
||||
lambda i: i.move_id.state in ("posted")
|
||||
and i.move_id.move_type in ["out_refund", "in_refund"]
|
||||
).mapped("quantity")
|
||||
)
|
||||
|
||||
@@ -48,11 +47,7 @@ class RmaOrderLine(models.Model):
|
||||
|
||||
def _compute_refund_count(self):
|
||||
for rec in self:
|
||||
rec.refund_count = len(
|
||||
rec.move_line_ids.mapped("move_id").filtered(
|
||||
lambda m: m.move_type in ["out_refund", "in_refund"]
|
||||
)
|
||||
)
|
||||
rec.refund_count = len(rec.refund_line_ids.mapped("move_id"))
|
||||
|
||||
invoice_address_id = fields.Many2one(
|
||||
"res.partner",
|
||||
@@ -81,6 +76,18 @@ class RmaOrderLine(models.Model):
|
||||
index=True,
|
||||
readonly=True,
|
||||
)
|
||||
refund_line_ids = fields.One2many(
|
||||
comodel_name="account.move.line",
|
||||
inverse_name="rma_line_id",
|
||||
string="Refund Lines",
|
||||
domain=[
|
||||
("move_id.move_type", "in", ["in_refund", "out_refund"]),
|
||||
("exclude_from_invoice_tab", "=", False),
|
||||
],
|
||||
copy=False,
|
||||
index=True,
|
||||
readonly=True,
|
||||
)
|
||||
move_id = fields.Many2one(
|
||||
"account.move",
|
||||
string="Source",
|
||||
@@ -274,9 +281,7 @@ class RmaOrderLine(models.Model):
|
||||
}
|
||||
|
||||
def action_view_refunds(self):
|
||||
moves = self.mapped("move_line_ids.move_id").filtered(
|
||||
lambda m: m.move_type in ["out_refund", "in_refund"]
|
||||
)
|
||||
moves = self.mapped("refund_line_ids.move_id")
|
||||
form_view_ref = self.env.ref("account.view_move_form", False)
|
||||
tree_view_ref = self.env.ref("account.view_move_tree", False)
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ class TestRmaAccount(common.SingleTransactionCase):
|
||||
}
|
||||
).create({"description": "Test refund"})
|
||||
make_refund.invoice_refund()
|
||||
rma.move_line_ids.move_id.action_post()
|
||||
rma.refund_line_ids.move_id.action_post()
|
||||
rma._compute_refund_count()
|
||||
self.assertEqual(rma.refund_count, 1)
|
||||
self.assertEqual(rma.qty_to_refund, 0.0)
|
||||
@@ -266,8 +266,8 @@ class TestRmaAccount(common.SingleTransactionCase):
|
||||
}
|
||||
).create({"description": "Test refund"})
|
||||
make_refund.invoice_refund()
|
||||
rma.move_line_ids.move_id.action_post()
|
||||
rma.refund_line_ids.move_id.action_post()
|
||||
rma._compute_refund_count()
|
||||
self.assertEqual(
|
||||
self.operation_1.refund_journal_id, rma.move_line_ids.journal_id
|
||||
self.operation_1.refund_journal_id, rma.refund_line_ids.journal_id
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user