[FIX] account_analytic_analysis: fiscal position should use the get_fiscal_position() function
When automatically generating invoices, contract should browse the fiscal position by calling the function get_fiscal_position of the account.fiscal.position class instead of checking the property field on the partner
This commit is contained in:
parent
f2fccdfaf0
commit
775ecc6cad
|
@ -671,35 +671,37 @@ class account_analytic_account(osv.osv):
|
||||||
context = context or {}
|
context = context or {}
|
||||||
|
|
||||||
journal_obj = self.pool.get('account.journal')
|
journal_obj = self.pool.get('account.journal')
|
||||||
|
fpos_obj = self.pool['account.fiscal.position']
|
||||||
|
partner = contract.partner_id
|
||||||
|
|
||||||
if not contract.partner_id:
|
if not partner:
|
||||||
raise osv.except_osv(_('No Customer Defined!'),_("You must first select a Customer for Contract %s!") % contract.name )
|
raise osv.except_osv(_('No Customer Defined!'),_("You must first select a Customer for Contract %s!") % contract.name )
|
||||||
|
|
||||||
fpos = contract.partner_id.property_account_position or False
|
fpos_id = fpos_obj.get_fiscal_position(cr, uid, partner.company_id.id, partner.id, context=context)
|
||||||
journal_ids = journal_obj.search(cr, uid, [('type', '=','sale'),('company_id', '=', contract.company_id.id or False)], limit=1)
|
journal_ids = journal_obj.search(cr, uid, [('type', '=','sale'),('company_id', '=', contract.company_id.id or False)], limit=1)
|
||||||
if not journal_ids:
|
if not journal_ids:
|
||||||
raise osv.except_osv(_('Error!'),
|
raise osv.except_osv(_('Error!'),
|
||||||
_('Please define a sale journal for the company "%s".') % (contract.company_id.name or '', ))
|
_('Please define a sale journal for the company "%s".') % (contract.company_id.name or '', ))
|
||||||
|
|
||||||
partner_payment_term = contract.partner_id.property_payment_term and contract.partner_id.property_payment_term.id or False
|
partner_payment_term = partner.property_payment_term and partner.property_payment_term.id or False
|
||||||
|
|
||||||
currency_id = False
|
currency_id = False
|
||||||
if contract.pricelist_id:
|
if contract.pricelist_id:
|
||||||
currency_id = contract.pricelist_id.currency_id.id
|
currency_id = contract.pricelist_id.currency_id.id
|
||||||
elif contract.partner_id.property_product_pricelist:
|
elif partner.property_product_pricelist:
|
||||||
currency_id = contract.partner_id.property_product_pricelist.currency_id.id
|
currency_id = partner.property_product_pricelist.currency_id.id
|
||||||
elif contract.company_id:
|
elif contract.company_id:
|
||||||
currency_id = contract.company_id.currency_id.id
|
currency_id = contract.company_id.currency_id.id
|
||||||
|
|
||||||
invoice = {
|
invoice = {
|
||||||
'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,
|
'partner_id': partner.id,
|
||||||
'currency_id': currency_id,
|
'currency_id': currency_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.code,
|
'origin': contract.code,
|
||||||
'fiscal_position': fpos and fpos.id,
|
'fiscal_position': fpos_id,
|
||||||
'payment_term': partner_payment_term,
|
'payment_term': partner_payment_term,
|
||||||
'company_id': contract.company_id.id or False,
|
'company_id': contract.company_id.id or False,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue