diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 72e3ed2be59..18773648e14 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -470,8 +470,10 @@ class account_invoice(osv.osv): osv.osv.unlink(self, cr, uid, unlink_ids, context=context) return True - def onchange_partner_id(self, cr, uid, ids, type, partner_id,\ - date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False, context=None): + def onchange_partner_id(self, cr, uid, ids, type, partner_id, + date_invoice=False, payment_term=False, + partner_bank_id=False, company_id=False, + context=None): partner_payment_term = False acc_id = False bank_id = False @@ -481,7 +483,8 @@ class account_invoice(osv.osv): if partner_id: opt.insert(0, ('id', partner_id)) - p = self.pool.get('res.partner').browse(cr, uid, partner_id) + p = self.pool.get('res.partner').browse(cr, uid, partner_id, + context=context) if company_id: if (p.property_account_receivable.company_id and (p.property_account_receivable.company_id.id != company_id)) and (p.property_account_payable.company_id and (p.property_account_payable.company_id.id != company_id)): property_obj = self.pool.get('ir.property') @@ -500,8 +503,10 @@ class account_invoice(osv.osv): msg = _('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.') raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) account_obj = self.pool.get('account.account') - rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id]) - pay_obj_acc = account_obj.browse(cr, uid, [pay_res_id]) + rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id], + context=context) + pay_obj_acc = account_obj.browse(cr, uid, [pay_res_id], + context=context) p.property_account_receivable = rec_obj_acc[0] p.property_account_payable = pay_obj_acc[0] diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index ffd7b874510..ef4edef7e14 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -165,7 +165,7 @@ @@ -320,7 +320,7 @@ diff --git a/addons/l10n_be_invoice_bba/invoice.py b/addons/l10n_be_invoice_bba/invoice.py index 7ecd348344d..337c5a3cdb4 100644 --- a/addons/l10n_be_invoice_bba/invoice.py +++ b/addons/l10n_be_invoice_bba/invoice.py @@ -64,18 +64,20 @@ class account_invoice(osv.osv): return True def onchange_partner_id(self, cr, uid, ids, type, partner_id, - date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): + date_invoice=False, payment_term=False, + partner_bank_id=False, company_id=False, + context=None): result = super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id, - date_invoice, payment_term, partner_bank_id, company_id) + date_invoice, payment_term, partner_bank_id, company_id, context) # reference_type = self.default_get(cr, uid, ['reference_type'])['reference_type'] # _logger.warning('partner_id %s' % partner_id) reference = False reference_type = 'none' if partner_id: if (type == 'out_invoice'): - reference_type = self.pool.get('res.partner').browse(cr, uid, partner_id).out_inv_comm_type + reference_type = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context).out_inv_comm_type if reference_type: - reference = self.generate_bbacomm(cr, uid, ids, type, reference_type, partner_id, '', context={})['value']['reference'] + reference = self.generate_bbacomm(cr, uid, ids, type, reference_type, partner_id, '', context=context)['value']['reference'] res_update = { 'reference_type': reference_type or 'none', 'reference': reference, diff --git a/addons/warning/warning.py b/addons/warning/warning.py index 55b198cc620..ee4b2099c98 100644 --- a/addons/warning/warning.py +++ b/addons/warning/warning.py @@ -111,7 +111,9 @@ class purchase_order(osv.osv): class account_invoice(osv.osv): _inherit = 'account.invoice' def onchange_partner_id(self, cr, uid, ids, type, partner_id, - date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): + date_invoice=False, payment_term=False, + partner_bank_id=False, company_id=False, + context=None): if not partner_id: return {'value': { 'account_id': False, @@ -121,7 +123,7 @@ class account_invoice(osv.osv): warning = {} title = False message = False - partner = self.pool.get('res.partner').browse(cr, uid, partner_id) + partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context) if partner.invoice_warn != 'no-message': title = _("Warning for %s") % partner.name message = partner.invoice_warn_msg @@ -135,7 +137,7 @@ class account_invoice(osv.osv): result = super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id, date_invoice=date_invoice, payment_term=payment_term, - partner_bank_id=partner_bank_id, company_id=company_id) + partner_bank_id=partner_bank_id, company_id=company_id, context=context) if result.get('warning',False): warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']