Refactor of the workoflow_to_end method to allow to modify in another modules what
happens to the invoices created.
This commit is contained in:
parent
5174a64ad6
commit
09516007ad
17
sale.py
17
sale.py
@ -48,12 +48,21 @@ class Sale(metaclass=PoolMeta):
|
||||
user = User(Transaction().user)
|
||||
return user.sale_device and user.sale_device.id or None
|
||||
|
||||
def set_values_to_invoice(self, invoice):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
today = Date.today()
|
||||
if not getattr(invoice, 'invoice_date', False):
|
||||
invoice.invoice_date = today
|
||||
if not getattr(invoice, 'accounting_date', False):
|
||||
invoice.accounting_date = today
|
||||
invoice.description = self.reference
|
||||
|
||||
@classmethod
|
||||
def workflow_to_end(cls, sales):
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
StatementLine = pool.get('account.statement.line')
|
||||
Date = pool.get('ir.date')
|
||||
|
||||
invoices = []
|
||||
to_post = set()
|
||||
@ -76,11 +85,7 @@ class Sale(metaclass=PoolMeta):
|
||||
for invoice in sale.invoices:
|
||||
if not invoice.state == 'draft':
|
||||
continue
|
||||
if not getattr(invoice, 'invoice_date', False):
|
||||
invoice.invoice_date = Date.today()
|
||||
if not getattr(invoice, 'accounting_date', False):
|
||||
invoice.accounting_date = Date.today()
|
||||
invoice.description = sale.reference
|
||||
sale.set_values_to_invoice(invoice)
|
||||
invoices.extend(([invoice], invoice._save_values))
|
||||
to_post.add(invoice)
|
||||
|
||||
|
@ -20,7 +20,7 @@ Imports::
|
||||
|
||||
Install sale::
|
||||
|
||||
>>> config = activate_modules('sale_payment')
|
||||
>>> config = activate_modules(['party', 'sale_payment'])
|
||||
|
||||
Create company::
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user