From b45b35d22437673879355d8dcc1f16233528a6d9 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Wed, 9 Mar 2011 10:40:47 +0530 Subject: [PATCH 1/2] [FIX] account: [6.0] invoice - must check if product is to_sell, to_purchase lp bug: https://launchpad.net/bugs/729602 fixed bzr revid: ara@tinyerp.com-20110309051047-y52k8fez7hs2tvle --- addons/account/account_invoice_view.xml | 4 ++-- addons/account/invoice.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 6fa3b8c09d2..b41c4db08e9 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -172,7 +172,7 @@ - + @@ -280,7 +280,7 @@ - + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 8de48514387..290be952cee 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -1290,6 +1290,20 @@ class account_invoice_line(osv.osv): 'price_unit': _price_unit_default, } + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + if context is None: + context = {} + res = super(account_invoice_line,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) + if context.get('type', False): + doc = etree.XML(res['arch']) + for node in doc.xpath("//field[@name='product_id']"): + if context['type'] in ('in_invoice','in_refund'): + node.set('domain', "[('purchase_ok', '=', True)]") + else: + node.set('domain', "[('sale_ok', '=', True)]") + res['arch'] = etree.tostring(doc) + return res + def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} From 25ee7aff549a86ffd1190c476ccbf0d66284f0c3 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Wed, 9 Mar 2011 11:19:13 +0530 Subject: [PATCH 2/2] [FIX] account: [6.0] invoice - must check if product is to_sell, to_purchase bzr revid: ara@tinyerp.com-20110309054913-ohllm2ppeyprk8n1 --- addons/account/account_invoice_view.xml | 4 ++-- addons/account/invoice.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index b41c4db08e9..2ef71e5014f 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -172,7 +172,7 @@ - + @@ -280,7 +280,7 @@ - + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 290be952cee..9cda94efeea 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -1297,7 +1297,7 @@ class account_invoice_line(osv.osv): if context.get('type', False): doc = etree.XML(res['arch']) for node in doc.xpath("//field[@name='product_id']"): - if context['type'] in ('in_invoice','in_refund'): + if context['type'] in ('in_invoice', 'in_refund'): node.set('domain', "[('purchase_ok', '=', True)]") else: node.set('domain', "[('sale_ok', '=', True)]")