[IMP] purchase: fiscal positions

Automatic detection of a fiscal position is now working for Purchase.

opw:631554
This commit is contained in:
Goffin Simon 2015-04-28 08:51:21 +02:00
parent 622e00baa5
commit 1062905acb
1 changed files with 6 additions and 1 deletions

View File

@ -397,11 +397,16 @@ class purchase_order(osv.osv):
'fiscal_position': False,
'payment_term_id': False,
}}
company_id = self.pool.get('res.users')._get_company(cr, uid, context=context)
if not company_id:
raise osv.except_osv(_('Error!'), _('There is no default company for the current user!'))
fp = self.pool['account.fiscal.position'].get_fiscal_position(cr, uid, company_id, partner_id, context=context)
supplier_address = partner.address_get(cr, uid, [partner_id], ['default'], context=context)
supplier = partner.browse(cr, uid, partner_id, context=context)
return {'value': {
'pricelist_id': supplier.property_product_pricelist_purchase.id,
'fiscal_position': supplier.property_account_position and supplier.property_account_position.id or False,
'fiscal_position': fp or supplier.property_account_position and supplier.property_account_position.id,
'payment_term_id': supplier.property_supplier_payment_term.id or False,
}}