2013-03-01 08:36:10 +00:00
|
|
|
-
|
|
|
|
In order to test Contract Recurrent Invoice I create a new Contract Template
|
|
|
|
-
|
|
|
|
!record {model: account.analytic.account, id: account_analytic_account_0}:
|
|
|
|
name: Loan EMI Agrement
|
|
|
|
company_id: base.main_company
|
|
|
|
partner_id: base.main_partner
|
|
|
|
recurring_invoices : 1
|
|
|
|
interval : 1
|
|
|
|
invoice_line_ids:
|
|
|
|
- product_id: product.product_product_consultant
|
2013-03-04 11:52:45 +00:00
|
|
|
name: 'Service'
|
2013-03-01 08:36:10 +00:00
|
|
|
quantity: 1.0
|
|
|
|
price_unit: 75.0
|
|
|
|
-
|
2013-03-04 09:05:08 +00:00
|
|
|
Genrate 'Agrement of the loan EMI' Contract from 'Loan EMI Agrement' template.
|
2013-03-01 08:36:10 +00:00
|
|
|
-
|
|
|
|
!python {model: account.analytic.account}: |
|
|
|
|
data = {
|
|
|
|
'name': 'Agrement of the loan EMI',
|
|
|
|
'template_id': ref("account_analytic_account_0"),
|
|
|
|
}
|
|
|
|
contract_id = self.create(cr, uid, data)
|
|
|
|
assert contract_id, "contract has not been created correctly"
|
|
|
|
-
|
2013-03-04 09:05:08 +00:00
|
|
|
Genrate Invoice of 'Agrement of the loan EMI' for current month
|
2013-03-01 08:36:10 +00:00
|
|
|
-
|
|
|
|
!python {model: account.analytic.account}: |
|
2013-03-06 13:45:05 +00:00
|
|
|
from dateutil.relativedelta import relativedelta
|
|
|
|
import datetime
|
2013-03-01 08:36:10 +00:00
|
|
|
data = {
|
|
|
|
'name': 'Agrement of the loan for current month',
|
|
|
|
'template_id': ref("account_analytic_account_0"),
|
|
|
|
}
|
|
|
|
contract_id = self.create(cr, uid, data)
|
|
|
|
assert contract_id, "contract has not been created correctly"
|
2013-03-07 06:02:59 +00:00
|
|
|
context = None
|
|
|
|
self._amount_all(cr, uid, [contract_id], '', {}, context=context)
|
|
|
|
template = self.browse(cr, uid, ref('account_analytic_account_0'),context=context)
|
|
|
|
res = self.on_change_template(cr, uid, [contract_id], template.id, context=context)
|
|
|
|
self.write(cr, uid, [contract_id], res['value'], context=context)
|
2013-03-01 08:36:10 +00:00
|
|
|
line_obj = self.pool.get('account.analytic.invoice.line')
|
2013-03-07 06:02:59 +00:00
|
|
|
contract = self.browse(cr, uid, contract_id, context=context)
|
2013-03-01 08:36:10 +00:00
|
|
|
assert template.partner_id.id == contract.partner_id.id or res['value']['partner_id'], "Customer of contract is not match with Contract Template"
|
|
|
|
assert template.company_id.id == contract.company_id.id, "Company of contract is not match with Contract Template"
|
|
|
|
assert template.date_start == contract.date_start, "Start Date of contract is not match with Contract Template"
|
|
|
|
assert template.interval == contract.interval, "Interval of contract is not match with Contract Template"
|
|
|
|
self.cron_create_invoice(cr, uid, False, False, None)
|
|
|
|
invoice_obj = self.pool.get('account.invoice')
|
|
|
|
contract_invoice = invoice_obj.search(cr, uid, [('origin','=','Agrement of the loan for current month')])
|
|
|
|
template_invoice = invoice_obj.search(cr, uid, [('origin','=','Loan EMI Agrement')])
|
2013-03-07 06:02:59 +00:00
|
|
|
inv = invoice_obj.browse(cr ,uid, contract_invoice, context=context)[0]
|
2013-03-01 08:36:10 +00:00
|
|
|
result = invoice_obj._amount_all(cr, uid, contract_invoice, '', {}, {})
|
|
|
|
assert inv.state == 'draft', 'Contract created invoice not in draft state.'
|
|
|
|
assert inv.amount_untaxed == contract.amount_untaxed, "Contract Invoice's Total tax excluded is not same as contract"
|
|
|
|
assert inv.amount_tax == contract.amount_tax, "Contract Invoice's Taxes is not same as contract"
|
|
|
|
assert inv.amount_total == contract.amount_total, "Contract Invoice's Total is not same as contract"
|