Browse Source

[FIX] account_analytic_analysis_recurring: Currency for created invoices.

pull/121/head
Pedro M. Baeza 10 years ago
parent
commit
38a0eb8b58
  1. 21
      contract/account_analytic_analysis_recurring.py

21
contract/account_analytic_analysis_recurring.py

@ -141,8 +141,8 @@ class account_analytic_account(osv.osv):
return value return value
def _prepare_invoice(self, cr, uid, contract, context=None): def _prepare_invoice(self, cr, uid, contract, context=None):
context = context or {}
if context is None:
context = {}
inv_obj = self.pool.get('account.invoice') inv_obj = self.pool.get('account.invoice')
journal_obj = self.pool.get('account.journal') journal_obj = self.pool.get('account.journal')
fpos_obj = self.pool.get('account.fiscal.position') fpos_obj = self.pool.get('account.fiscal.position')
@ -153,8 +153,8 @@ class account_analytic_account(osv.osv):
_('No Customer Defined!'), _('No Customer Defined!'),
_("You must first select a Customer for Contract %s!") % _("You must first select a Customer for Contract %s!") %
contract.name) contract.name)
fpos = contract.partner_id.property_account_position or False
partner = contract.partner_id
fpos = partner.property_account_position or False
journal_ids = journal_obj.search( journal_ids = journal_obj.search(
cr, uid, cr, uid,
[('type', '=', 'sale'), [('type', '=', 'sale'),
@ -165,15 +165,13 @@ class account_analytic_account(osv.osv):
_('Error!'), _('Error!'),
_('Please define a sale journal for the company "%s".') % _('Please define a sale journal for the company "%s".') %
(contract.company_id.name or '', )) (contract.company_id.name or '', ))
partner_payment_term = contract.partner_id.property_payment_term.id partner_payment_term = contract.partner_id.property_payment_term.id
inv_data = { inv_data = {
'reference': contract.code or False, 'reference': contract.code or False,
'account_id': contract.partner_id.property_account_receivable.id,
'account_id': partner.property_account_receivable.id,
'type': 'out_invoice', 'type': 'out_invoice',
'partner_id': contract.partner_id.id,
'currency_id': contract.partner_id.property_product_pricelist.id,
'partner_id': partner.id,
'currency_id': partner.property_product_pricelist.currency_id.id,
'journal_id': len(journal_ids) and journal_ids[0] or False, 'journal_id': len(journal_ids) and journal_ids[0] or False,
'date_invoice': contract.recurring_next_date, 'date_invoice': contract.recurring_next_date,
'origin': contract.name, 'origin': contract.name,
@ -182,18 +180,14 @@ class account_analytic_account(osv.osv):
'company_id': contract.company_id.id or False, 'company_id': contract.company_id.id or False,
} }
invoice_id = inv_obj.create(cr, uid, inv_data, context=context) invoice_id = inv_obj.create(cr, uid, inv_data, context=context)
for line in contract.recurring_invoice_line_ids: for line in contract.recurring_invoice_line_ids:
res = line.product_id res = line.product_id
account_id = res.property_account_income.id account_id = res.property_account_income.id
if not account_id: if not account_id:
account_id = res.categ_id.property_account_income_categ.id account_id = res.categ_id.property_account_income_categ.id
account_id = fpos_obj.map_account(cr, uid, fpos, account_id) account_id = fpos_obj.map_account(cr, uid, fpos, account_id)
taxes = res.taxes_id or False taxes = res.taxes_id or False
tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes) tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
if 'old_date' in context: if 'old_date' in context:
lang_ids = lang_obj.search( lang_ids = lang_obj.search(
cr, uid, [('code', '=', contract.partner_id.lang)], cr, uid, [('code', '=', contract.partner_id.lang)],
@ -204,7 +198,6 @@ class account_analytic_account(osv.osv):
'#START#', context['old_date'].strftime(format)) '#START#', context['old_date'].strftime(format))
line.name = line.name.replace( line.name = line.name.replace(
'#END#', context['next_date'].strftime(format)) '#END#', context['next_date'].strftime(format))
invoice_line_vals = { invoice_line_vals = {
'name': line.name, 'name': line.name,
'account_id': account_id, 'account_id': account_id,

Loading…
Cancel
Save