[FIX] account_analytic_analysis: currency were wrong when preparing recurring invoices

The id of the sale pricelist of the customer was set as currency_id, instead of using the id of the currency of the pricelist. (Obviously)
Furthermore, the currency of the contract pricelist takes the lead.
Then, if none of these two are set, we choose the currency of the company, finally.

bzr revid: dle@openerp.com-20140204115226-rowmbr5223fcu08k
This commit is contained in:
Denis Ledoux 2014-02-04 12:52:26 +01:00
parent bd4f015533
commit 5aedbce448
1 changed files with 8 additions and 1 deletions

View File

@ -664,13 +664,20 @@ class account_analytic_account(osv.osv):
partner_payment_term = contract.partner_id.property_payment_term and contract.partner_id.property_payment_term.id or False
currency_id = False
if contract.pricelist_id:
currency_id = contract.pricelist_id.currency_id.id
elif contract.partner_id.property_product_pricelist:
currency_id = contract.partner_id.property_product_pricelist.currency_id.id
elif contract.company_id:
currency_id = contract.company_id.currency_id.id
inv_data = {
'reference': contract.code or False,
'account_id': contract.partner_id.property_account_receivable.id,
'type': 'out_invoice',
'partner_id': contract.partner_id.id,
'currency_id': contract.partner_id.property_product_pricelist.id or False,
'currency_id': currency_id,
'journal_id': len(journal_ids) and journal_ids[0] or False,
'date_invoice': contract.recurring_next_date,
'origin': contract.name,