[FIX][REF] account_voucher: remove old on_change and convert to new API
Since v9 commit of new accounting a mix of old and new onchange exists in account voucher. This commit effectively converts the onchange to the new API and fixes the behavior.
This commit is contained in:
@@ -345,6 +345,20 @@ class AccountVoucherLine(models.Model):
|
||||
taxes = self.tax_ids.compute_all(self.price_unit, self.voucher_id.currency_id, self.quantity, product=self.product_id, partner=self.voucher_id.partner_id)
|
||||
self.price_subtotal = taxes['total_excluded']
|
||||
|
||||
@api.onchange('product_id', 'voucher_id', 'price_unit', 'company_id')
|
||||
def _onchange_line_details(self):
|
||||
if not self.voucher_id or not self.product_id or not self.voucher_id.partner_id:
|
||||
return
|
||||
onchange_res = self.product_id_change(
|
||||
self.product_id.id,
|
||||
self.voucher_id.partner_id.id,
|
||||
self.price_unit,
|
||||
self.company_id.id,
|
||||
self.voucher_id.currency_id.id,
|
||||
self.voucher_id.voucher_type)
|
||||
for fname, fvalue in onchange_res['values'].iteritems():
|
||||
setattr(self, fname, fvalue)
|
||||
|
||||
def _get_account(self, product, fpos, type):
|
||||
accounts = product.product_tmpl_id.get_product_accounts(fpos)
|
||||
if type == 'sale':
|
||||
@@ -353,6 +367,7 @@ class AccountVoucherLine(models.Model):
|
||||
|
||||
@api.multi
|
||||
def product_id_change(self, product_id, partner_id=False, price_unit=False, company_id=None, currency_id=None, type=None):
|
||||
# TDE note: mix of old and new onchange badly written in 9, multi but does not use record set
|
||||
context = self._context
|
||||
company_id = company_id if company_id is not None else context.get('company_id', False)
|
||||
company = self.env['res.company'].browse(company_id)
|
||||
|
||||
@@ -100,8 +100,7 @@
|
||||
<field name="model">account.voucher.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Voucher Lines" editable="bottom">
|
||||
<field name="product_id"
|
||||
on_change="product_id_change(product_id, parent.partner_id, price_unit, company_id, parent.currency_id, parent.voucher_type)" />
|
||||
<field name="product_id"/>
|
||||
<field name="name"/>
|
||||
<field name="account_id"/>
|
||||
<field name="account_analytic_id" domain="[('company_id', '=', company_id)]" groups="analytic.group_analytic_accounting"/>
|
||||
@@ -248,8 +247,7 @@
|
||||
<page string="Sales Information">
|
||||
<field name="line_ids">
|
||||
<tree string="Voucher Lines" editable="bottom">
|
||||
<field name="product_id"
|
||||
on_change="product_id_change(product_id, parent.partner_id, price_unit, company_id, parent.currency_id, parent.voucher_type)" />
|
||||
<field name="product_id"/>
|
||||
<field name="name"/>
|
||||
<field name="account_id"/>
|
||||
<field name="account_analytic_id" domain="[('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_accounting"/>
|
||||
@@ -365,8 +363,7 @@
|
||||
<page string="Bill Information">
|
||||
<field name="line_ids">
|
||||
<tree string="Voucher Lines" editable="bottom">
|
||||
<field name="product_id"
|
||||
on_change="product_id_change(product_id, parent.partner_id, price_unit, company_id, parent.currency_id, parent.voucher_type)" />
|
||||
<field name="product_id"/>
|
||||
<field name="name"/>
|
||||
<field name="account_id"/>
|
||||
<field name="account_analytic_id" domain="[('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_accounting"/>
|
||||
|
||||
Reference in New Issue
Block a user