[FIX] account: remove domain that depend of purchase when not installed

This commit avoid a traceback when you open the form account_invoice_line
for a supllier invoice without having installed purchase.

The fields_view_get method add domain with purchase_ok field, but this
field can be missing on the model product.template because purchase is not
a dependence of account.

Invalid field 'purchase_ok' in leaf "<osv.ExtendedLeaf:
('purchase_ok', '=', True) on product_product

In stable version, the best fix found, is to remove the domain.
But we need to fix it in master, moving this field from purchase module to
product module. (odoo/odoo##13271)

This commit closes #13268 and closes #315 for stable version.
Todo: merge odoo/odoo#13271 in master (@qdp-odoo agreement)
This commit is contained in:
Jeremy Kersten 2016-08-24 10:59:58 +02:00
parent 4faed0b792
commit abf17354f8
1 changed files with 4 additions and 1 deletions

View File

@ -1302,7 +1302,10 @@ class account_invoice_line(models.Model):
doc = etree.XML(res['arch'])
for node in doc.xpath("//field[@name='product_id']"):
if self._context['type'] in ('in_invoice', 'in_refund'):
node.set('domain', "[('purchase_ok', '=', True)]")
# Hack to fix the stable version 8.0 -> saas-12
# purchase_ok will be moved from purchase to product in master #13271
if 'purchase_ok' in self.env['product.template']._fields:
node.set('domain', "[('purchase_ok', '=', True)]")
else:
node.set('domain', "[('sale_ok', '=', True)]")
res['arch'] = etree.tostring(doc)