Override _get_invoice_sale instead of create_invoice to set agent on invoice

This avoids saving invoices one by one.
This commit is contained in:
Sergi Almacellas Abellana committed 2024-12-28 00:38:13 +01:00
1 parent b72a6f0e7d
commit f9e4940ed7
1 file changed
+3 -5
+3 -5
View File
@@ -20,11 +20,9 @@ class Sale(metaclass=PoolMeta):
},
help="The agent who receives a commission for the sale.")
def create_invoice(self):
invoice = super(Sale, self).create_invoice()
if invoice:
invoice.agent = self.agent
invoice.save()
def _get_invoice_sale(self):
invoice = super()._get_invoice_sale()
invoice.agent = self.agent
return invoice
@classmethod