[FIX] account.invoice.line: move context to last position in onchange methods
The methods product_id_change() and uos_id_change() have been converted to the new api, and now use the decorator @multi. When invoked with the old api, by convention the methods will take the last argument as the context. But this will not work properly for those methods, as the context is passed in another position. In order to avoid an argument swap in the api wrapper, we moved the context to its expected position. Fixes #1943
This commit is contained in:
parent
5388eee321
commit
ecd8b5222b
|
@ -1290,8 +1290,8 @@ class account_invoice_line(models.Model):
|
|||
@api.multi
|
||||
def product_id_change(self, product, uom_id, qty=0, name='', type='out_invoice',
|
||||
partner_id=False, fposition_id=False, price_unit=False, currency_id=False,
|
||||
context=None, company_id=None):
|
||||
context = context or {}
|
||||
company_id=None):
|
||||
context = self._context
|
||||
company_id = company_id if company_id is not None else context.get('company_id', False)
|
||||
self = self.with_context(company_id=company_id, force_company=company_id)
|
||||
|
||||
|
@ -1358,14 +1358,14 @@ class account_invoice_line(models.Model):
|
|||
|
||||
@api.multi
|
||||
def uos_id_change(self, product, uom, qty=0, name='', type='out_invoice', partner_id=False,
|
||||
fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None):
|
||||
context = context or {}
|
||||
fposition_id=False, price_unit=False, currency_id=False, company_id=None):
|
||||
context = self._context
|
||||
company_id = company_id if company_id != None else context.get('company_id', False)
|
||||
self = self.with_context(company_id=company_id)
|
||||
|
||||
result = self.product_id_change(
|
||||
product, uom, qty, name, type, partner_id, fposition_id, price_unit,
|
||||
currency_id, context=context, company_id=company_id,
|
||||
currency_id, company_id=company_id,
|
||||
)
|
||||
warning = {}
|
||||
if not uom:
|
||||
|
|
|
@ -48,12 +48,12 @@
|
|||
<form string="Invoice Line">
|
||||
<group>
|
||||
<group>
|
||||
<field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
||||
<field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
|
||||
<label for="quantity"/>
|
||||
<div>
|
||||
<field name="quantity" class="oe_inline"/>
|
||||
<field name="uos_id" class="oe_inline" groups="product.group_uom"
|
||||
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
||||
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
|
||||
</div>
|
||||
<field name="price_unit"/>
|
||||
<field name="discount" groups="sale.group_discount_per_so_line"/>
|
||||
|
@ -194,7 +194,7 @@
|
|||
<tree string="Invoice lines" editable="bottom">
|
||||
<field name="sequence" widget="handle" />
|
||||
<field name="product_id"
|
||||
on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
||||
on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
|
||||
<field name="name"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="account_id" groups="account.group_account_user"
|
||||
|
@ -204,7 +204,7 @@
|
|||
domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled'))]"/>
|
||||
<field name="quantity"/>
|
||||
<field name="uos_id" groups="product.group_uom"
|
||||
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
||||
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
|
||||
<field name="price_unit"/>
|
||||
<field name="discount" groups="sale.group_discount_per_so_line"/>
|
||||
<field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"
|
||||
|
@ -351,7 +351,7 @@
|
|||
<tree string="Invoice Lines" editable="bottom">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="product_id"
|
||||
on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
||||
on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
|
||||
<field name="name"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="account_id" groups="account.group_account_user"
|
||||
|
@ -361,7 +361,7 @@
|
|||
domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled'))]"/>
|
||||
<field name="quantity"/>
|
||||
<field name="uos_id" groups="product.group_uom"
|
||||
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
|
||||
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
|
||||
<field name="price_unit"/>
|
||||
<field name="discount" groups="sale.group_discount_per_so_line"/>
|
||||
<field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"
|
||||
|
|
|
@ -76,8 +76,8 @@ class account_invoice_line(osv.osv):
|
|||
_inherit = "account.invoice.line"
|
||||
_description = "Invoice Line"
|
||||
|
||||
def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None):
|
||||
res_prod = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom_id, qty, name, type, partner_id, fposition_id, price_unit, currency_id=currency_id, context=context, company_id=company_id)
|
||||
def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, company_id=None, context=None):
|
||||
res_prod = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom_id, qty, name, type, partner_id, fposition_id, price_unit, currency_id=currency_id, company_id=company_id, context=context)
|
||||
rec = self.pool.get('account.analytic.default').account_get(cr, uid, product, partner_id, uid, time.strftime('%Y-%m-%d'), company_id=company_id, context=context)
|
||||
if rec:
|
||||
res_prod['value'].update({'account_analytic_id': rec.analytic_id.id})
|
||||
|
|
|
@ -302,8 +302,8 @@ class account_invoice_line(osv.osv):
|
|||
res ['analytics_id'] = line.analytics_id and line.analytics_id.id or False
|
||||
return res
|
||||
|
||||
def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None):
|
||||
res_prod = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom_id, qty, name, type, partner_id, fposition_id, price_unit, currency_id, context=context, company_id=company_id)
|
||||
def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, company_id=None, context=None):
|
||||
res_prod = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom_id, qty, name, type, partner_id, fposition_id, price_unit, currency_id, company_id=company_id, context=context)
|
||||
rec = self.pool.get('account.analytic.default').account_get(cr, uid, product, partner_id, uid, time.strftime('%Y-%m-%d'), context=context)
|
||||
if rec and rec.analytics_id:
|
||||
res_prod['value'].update({'analytics_id': rec.analytics_id.id})
|
||||
|
|
|
@ -153,9 +153,9 @@ class account_invoice_line(osv.osv):
|
|||
res += diff_res
|
||||
return res
|
||||
|
||||
def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None):
|
||||
def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, company_id=None, context=None):
|
||||
fiscal_pool = self.pool.get('account.fiscal.position')
|
||||
res = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom_id, qty, name, type, partner_id, fposition_id, price_unit, currency_id, context, company_id)
|
||||
res = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom_id, qty, name, type, partner_id, fposition_id, price_unit, currency_id, company_id, context)
|
||||
if not product:
|
||||
return res
|
||||
if type in ('in_invoice','in_refund'):
|
||||
|
|
Loading…
Reference in New Issue