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:
committed by
Christopher Rogos
parent
8cdc1516d4
commit
8412378133
@@ -1737,6 +1737,39 @@ class TestContract(TestContractBase):
|
||||
len(invoice_lines),
|
||||
)
|
||||
|
||||
def test_contract_manually_create_invoice(self):
|
||||
self.acct_line.date_start = '2018-01-01'
|
||||
self.acct_line.recurring_invoicing_type = 'post-paid'
|
||||
self.acct_line.date_end = '2018-03-15'
|
||||
self.acct_line._onchange_date_start()
|
||||
self.contract2.unlink()
|
||||
contracts = self.contract
|
||||
for i in range(10):
|
||||
contracts |= self.contract.copy()
|
||||
wizard = self.env['contract.manually.create.invoice'].create({
|
||||
'invoice_date': self.today
|
||||
})
|
||||
wizard.action_show_contract_to_invoice()
|
||||
contract_to_invoice_count = wizard.contract_to_invoice_count
|
||||
self.assertEqual(
|
||||
contracts,
|
||||
self.env['contract.contract'].search(
|
||||
wizard.action_show_contract_to_invoice()['domain']
|
||||
),
|
||||
)
|
||||
action = wizard.create_invoice()
|
||||
invoice_lines = self.env['account.invoice.line'].search(
|
||||
[('contract_line_id', 'in',
|
||||
contracts.mapped('contract_line_ids').ids)]
|
||||
)
|
||||
self.assertEqual(
|
||||
len(contracts.mapped('contract_line_ids')),
|
||||
len(invoice_lines),
|
||||
)
|
||||
invoices = self.env['account.invoice'].search(action['domain'])
|
||||
self.assertEqual(invoice_lines.mapped('invoice_id'), invoices)
|
||||
self.assertEqual(len(invoices), contract_to_invoice_count)
|
||||
|
||||
def test_get_period_to_invoice_monthlylastday_postpaid(self):
|
||||
self.acct_line.date_start = '2018-01-05'
|
||||
self.acct_line.recurring_invoicing_type = 'post-paid'
|
||||
|
||||
Reference in New Issue
Block a user