[IMP] account: add context in invoice onchange_partner_id method
(Manual rebase of PR #915)
This commit is contained in:
parent
7cc95f1671
commit
d78192c489
|
@ -470,8 +470,10 @@ class account_invoice(osv.osv):
|
||||||
osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
|
osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def onchange_partner_id(self, cr, uid, ids, type, partner_id,\
|
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):
|
date_invoice=False, payment_term=False,
|
||||||
|
partner_bank_id=False, company_id=False,
|
||||||
|
context=None):
|
||||||
partner_payment_term = False
|
partner_payment_term = False
|
||||||
acc_id = False
|
acc_id = False
|
||||||
bank_id = False
|
bank_id = False
|
||||||
|
@ -481,7 +483,8 @@ class account_invoice(osv.osv):
|
||||||
if partner_id:
|
if partner_id:
|
||||||
|
|
||||||
opt.insert(0, ('id', 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 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)):
|
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')
|
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.')
|
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'))
|
raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel'))
|
||||||
account_obj = self.pool.get('account.account')
|
account_obj = self.pool.get('account.account')
|
||||||
rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id])
|
rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id],
|
||||||
pay_obj_acc = account_obj.browse(cr, uid, [pay_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_receivable = rec_obj_acc[0]
|
||||||
p.property_account_payable = pay_obj_acc[0]
|
p.property_account_payable = pay_obj_acc[0]
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field string="Supplier" name="partner_id"
|
<field string="Supplier" name="partner_id"
|
||||||
on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)"
|
on_change="onchange_partner_id(type, partner_id, date_invoice, payment_term, partner_bank_id, company_id, context)"
|
||||||
context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}"
|
context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}"
|
||||||
domain="[('supplier', '=', True)]"/>
|
domain="[('supplier', '=', True)]"/>
|
||||||
<field name="fiscal_position" options="{'no_create': True}"/>
|
<field name="fiscal_position" options="{'no_create': True}"/>
|
||||||
|
@ -320,7 +320,7 @@
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field string="Customer" name="partner_id"
|
<field string="Customer" name="partner_id"
|
||||||
on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)"
|
on_change="onchange_partner_id(type, partner_id, date_invoice, payment_term, partner_bank_id, company_id, context)"
|
||||||
context="{'search_default_customer':1, 'show_address': 1}"
|
context="{'search_default_customer':1, 'show_address': 1}"
|
||||||
options='{"always_reload": True}'
|
options='{"always_reload": True}'
|
||||||
domain="[('customer', '=', True)]"/>
|
domain="[('customer', '=', True)]"/>
|
||||||
|
|
|
@ -64,18 +64,20 @@ class account_invoice(osv.osv):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def onchange_partner_id(self, cr, uid, ids, type, partner_id,
|
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,
|
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']
|
# reference_type = self.default_get(cr, uid, ['reference_type'])['reference_type']
|
||||||
# _logger.warning('partner_id %s' % partner_id)
|
# _logger.warning('partner_id %s' % partner_id)
|
||||||
reference = False
|
reference = False
|
||||||
reference_type = 'none'
|
reference_type = 'none'
|
||||||
if partner_id:
|
if partner_id:
|
||||||
if (type == 'out_invoice'):
|
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:
|
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 = {
|
res_update = {
|
||||||
'reference_type': reference_type or 'none',
|
'reference_type': reference_type or 'none',
|
||||||
'reference': reference,
|
'reference': reference,
|
||||||
|
|
|
@ -111,7 +111,9 @@ class purchase_order(osv.osv):
|
||||||
class account_invoice(osv.osv):
|
class account_invoice(osv.osv):
|
||||||
_inherit = 'account.invoice'
|
_inherit = 'account.invoice'
|
||||||
def onchange_partner_id(self, cr, uid, ids, type, partner_id,
|
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:
|
if not partner_id:
|
||||||
return {'value': {
|
return {'value': {
|
||||||
'account_id': False,
|
'account_id': False,
|
||||||
|
@ -121,7 +123,7 @@ class account_invoice(osv.osv):
|
||||||
warning = {}
|
warning = {}
|
||||||
title = False
|
title = False
|
||||||
message = 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':
|
if partner.invoice_warn != 'no-message':
|
||||||
title = _("Warning for %s") % partner.name
|
title = _("Warning for %s") % partner.name
|
||||||
message = partner.invoice_warn_msg
|
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,
|
result = super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id,
|
||||||
date_invoice=date_invoice, payment_term=payment_term,
|
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):
|
if result.get('warning',False):
|
||||||
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
||||||
|
|
Loading…
Reference in New Issue