mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[12.0][IMP] - Add an action for contracts manual invoicing
It happen that a company has to trigger the invoicing action to generate invoices before the scheduled date (to print and prepare invoices documents, check invoices, etc.). This requires technical access for end users with the risk that this represents. This commit adds a new wizard to run the invoicing action for a given date with a helper to see and check the contract that will be invoiced. When the manual action is called, the system displays all created invoices. [12.0][IMP] - log the manual invoice action in contract chatter [IMP] - Add alink to the invoice in contract message at manual invoicing [IMP] - Improve code [FIX] - log message for invoice creation only when there is an invoice [IMP] - split the manual invoice menu into to menus sale & purhcase [IMP] - hide invoice button if there is nothing to invoice
This commit is contained in:
@@ -457,7 +457,17 @@ class ContractContract(models.Model):
|
||||
This method triggers the creation of the next invoices of the contracts
|
||||
even if their next invoicing date is in the future.
|
||||
"""
|
||||
return self._recurring_create_invoice()
|
||||
invoice = self._recurring_create_invoice()
|
||||
if invoice:
|
||||
self.message_post(
|
||||
body=_(
|
||||
'Contract manually invoiced: '
|
||||
'<a href="#" data-oe-model="%s" data-oe-id="%s">Invoice'
|
||||
'</a>'
|
||||
)
|
||||
% (invoice._name, invoice.id)
|
||||
)
|
||||
return invoice
|
||||
|
||||
@api.multi
|
||||
def _recurring_create_invoice(self, date_ref=False):
|
||||
@@ -465,8 +475,9 @@ class ContractContract(models.Model):
|
||||
return self._finalize_and_create_invoices(invoices_values)
|
||||
|
||||
@api.model
|
||||
def cron_recurring_create_invoice(self):
|
||||
domain = self._get_contracts_to_invoice_domain()
|
||||
def cron_recurring_create_invoice(self, date_ref=None):
|
||||
if not date_ref:
|
||||
date_ref = fields.Date.context_today(self)
|
||||
domain = self._get_contracts_to_invoice_domain(date_ref)
|
||||
contracts_to_invoice = self.search(domain)
|
||||
date_ref = fields.Date.context_today(contracts_to_invoice)
|
||||
contracts_to_invoice._recurring_create_invoice(date_ref)
|
||||
return contracts_to_invoice._recurring_create_invoice(date_ref)
|
||||
|
||||
Reference in New Issue
Block a user