'partner_id': fields.related('invoice_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True)
}
- def _default_account_id(self, cr, uid, ids, context=None):
+ def _default_account_id(self, cr, uid, context=None):
+ # XXX this gets the default account for the user's company,
+ # it should get the default account for the invoice's company
+ # however, the invoice's company does not reach this point
prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context)
return prop and prop.id or False
context = {}
company_id = company_id if company_id != None else context.get('company_id',False)
context = dict(context)
- context.update({'company_id': company_id})
+ context.update({'company_id': company_id, 'force_company': company_id})
if not partner_id:
raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") )
if not product:
def onchange_account_id(self, cr, uid, ids, product_id, partner_id, inv_type, fposition_id, account_id):
if not account_id:
return {}
- taxes = self.pool.get('account.account').browse(cr, uid, account_id).tax_ids
+ account = self.pool.get('account.account').browse(cr, uid, account_id)
+ taxes = account.tax_ids
fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
tax_ids = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
product_change_result = self.product_id_change(cr, uid, ids, product_id, False, type=inv_type,
- partner_id=partner_id, fposition_id=fposition_id)
+ partner_id=partner_id, fposition_id=fposition_id,
+ company_id=account.company_id.id)
unique_tax_ids = set(tax_ids)
if product_change_result and 'value' in product_change_result and 'invoice_line_tax_id' in product_change_result['value']:
unique_tax_ids |= set(product_change_result['value']['invoice_line_tax_id'])