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:
1 parent
b72a6f0e7d
commit
f9e4940ed7
1 file changed
+3
-5
@@ -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
|
||||
|
||||
Reference in new issue
Block a user