diff --git a/recurring_contract/models/contract_group.py b/recurring_contract/models/contract_group.py index f14ef2ef..549fe506 100644 --- a/recurring_contract/models/contract_group.py +++ b/recurring_contract/models/contract_group.py @@ -342,7 +342,9 @@ def _should_skip_invoice_generation(self, invoicing_date, contract=None): ), ] - has_all_invoices = bool(self.env["account.move"].search_count(search_filter)) + has_all_invoices = bool( + self.env["account.move"].search_count(search_filter) + ) else: search_filter = [ ("invoice_date_due", "=", invoicing_date), @@ -354,13 +356,18 @@ def _should_skip_invoice_generation(self, invoicing_date, contract=None): "in", self.active_contract_ids.mapped("product_ids").ids, ), - ('state', '!=', 'cancel') + ("state", "!=", "cancel"), ] open_invoices = self.env["account.move"].search(search_filter) - has_all_invoices = len(self.active_contract_ids - - open_invoices.mapped("line_ids.contract_id")) == 0 + has_all_invoices = ( + len( + self.active_contract_ids + - open_invoices.mapped("line_ids.contract_id") + ) + == 0 + ) is_suspended = ( self.invoice_suspended_until @@ -437,8 +444,8 @@ def _process_invoice_generation(self, invoicer, invoicing_date, contract=None): "payment_mode_id": self.payment_mode_id.id, } ) - open_invoice.mapped('invoice_line_ids').filtered( - lambda line : line.contract_id in contract_lines_to_inv.contract_id + open_invoice.mapped("invoice_line_ids").filtered( + lambda line: line.contract_id in contract_lines_to_inv.contract_id ).create_analytic_lines() else: # Building invoices data diff --git a/recurring_contract/models/recurring_contract.py b/recurring_contract/models/recurring_contract.py index ac29523f..2d074604 100644 --- a/recurring_contract/models/recurring_contract.py +++ b/recurring_contract/models/recurring_contract.py @@ -593,10 +593,12 @@ def _cancel_invoices(self): ) if remaining_lines: # We can move or remove the line - invoice.write({ - "invoice_line_ids": [(2, inv_line.id)], - "payment_mode_id": invoice.payment_mode_id.id, - }) + invoice.write( + { + "invoice_line_ids": [(2, inv_line.id)], + "payment_mode_id": invoice.payment_mode_id.id, + } + ) else: # The invoice would be empty if we remove the line empty_invoices |= invoice