[FIX] rma_account: Auto-reconcile supplier refunds

This commit is contained in:
Jordi Ballester Alomar
2022-11-23 20:12:34 +01:00
parent b0f3dd97e5
commit 4dd2316d67

View File

@@ -99,15 +99,19 @@ class AccountMove(models.Model):
def _stock_account_get_last_step_stock_moves(self):
rslt = super(AccountMove, self)._stock_account_get_last_step_stock_moves()
for invoice in self.filtered(lambda x: x.move_type == "out_invoice"):
rslt += invoice.mapped("line_ids.rma_line_id.move_ids").filtered(
lambda x: x.state == "done" and x.location_dest_id.usage == "customer"
)
for invoice in self.filtered(lambda x: x.move_type == "out_refund"):
# Add refunds generated from the RMA
for invoice in self.filtered(
lambda x: x.move_type in ("out_invoice", "out_refund")
):
rslt += invoice.mapped("line_ids.rma_line_id.move_ids").filtered(
lambda x: x.state == "done" and x.location_id.usage == "customer"
)
for invoice in self.filtered(
lambda x: x.move_type in ("in_invoice", "in_refund")
):
# Add refunds generated from the RMA
rslt += invoice.mapped("line_ids.rma_line_id.move_ids").filtered(
lambda x: x.state == "done" and x.location_dest_id.usage == "supplier"
)
return rslt