diff --git a/agreement_rebate/models/agreement_rebate_settlement.py b/agreement_rebate/models/agreement_rebate_settlement.py index 65404c1a..f97bb5e9 100644 --- a/agreement_rebate/models/agreement_rebate_settlement.py +++ b/agreement_rebate/models/agreement_rebate_settlement.py @@ -68,7 +68,9 @@ def _reverse_type_map(self, inv_type): def create_invoice(self): invoice_dic = {} - for line in self.mapped("line_ids"): + for line in self.mapped("line_ids").filtered( + lambda ln: ln.invoice_status == "to_invoice" + ): key = line._get_invoice_key() if key not in invoice_dic: invoice_dic[key] = line._prepare_invoice() diff --git a/agreement_rebate/wizards/invoice_create.py b/agreement_rebate/wizards/invoice_create.py index fbfe5a4b..0c28cd7e 100644 --- a/agreement_rebate/wizards/invoice_create.py +++ b/agreement_rebate/wizards/invoice_create.py @@ -97,9 +97,11 @@ def action_create_invoice(self): settlements -= settlements.filtered( lambda s: any( ail.move_id.move_type == self.invoice_type - for ail in s.line_ids.mapped("invoice_line_ids").filtered( - lambda ln: ln.parent_state != "cancel" + for ail in s.line_ids.filtered( + lambda st_line: st_line.invoice_status == "to_invoice" ) + .mapped("invoice_line_ids") + .filtered(lambda ln: ln.parent_state != "cancel") ) ) invoices = settlements.with_context(