From 4dd2316d67d5ced088b04786a4a86ecd22f567ad Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Wed, 23 Nov 2022 20:12:34 +0100 Subject: [PATCH] [FIX] rma_account: Auto-reconcile supplier refunds --- rma_account/models/account_move.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/rma_account/models/account_move.py b/rma_account/models/account_move.py index ac9ad0c8..5208a878 100644 --- a/rma_account/models/account_move.py +++ b/rma_account/models/account_move.py @@ -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