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)
|
user = User(Transaction().user)
|
||||||
return user.sale_device and user.sale_device.id or None
|
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
|
@classmethod
|
||||||
def workflow_to_end(cls, sales):
|
def workflow_to_end(cls, sales):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Invoice = pool.get('account.invoice')
|
Invoice = pool.get('account.invoice')
|
||||||
StatementLine = pool.get('account.statement.line')
|
StatementLine = pool.get('account.statement.line')
|
||||||
Date = pool.get('ir.date')
|
|
||||||
|
|
||||||
invoices = []
|
invoices = []
|
||||||
to_post = set()
|
to_post = set()
|
||||||
@ -76,11 +85,7 @@ class Sale(metaclass=PoolMeta):
|
|||||||
for invoice in sale.invoices:
|
for invoice in sale.invoices:
|
||||||
if not invoice.state == 'draft':
|
if not invoice.state == 'draft':
|
||||||
continue
|
continue
|
||||||
if not getattr(invoice, 'invoice_date', False):
|
sale.set_values_to_invoice(invoice)
|
||||||
invoice.invoice_date = Date.today()
|
|
||||||
if not getattr(invoice, 'accounting_date', False):
|
|
||||||
invoice.accounting_date = Date.today()
|
|
||||||
invoice.description = sale.reference
|
|
||||||
invoices.extend(([invoice], invoice._save_values))
|
invoices.extend(([invoice], invoice._save_values))
|
||||||
to_post.add(invoice)
|
to_post.add(invoice)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ Imports::
|
|||||||
|
|
||||||
Install sale::
|
Install sale::
|
||||||
|
|
||||||
>>> config = activate_modules('sale_payment')
|
>>> config = activate_modules(['party', 'sale_payment'])
|
||||||
|
|
||||||
Create company::
|
Create company::
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user