From: Xavier Morel Date: Tue, 13 Dec 2011 16:25:05 +0000 (+0100) Subject: [FIX] account_voucher: don't break non-form views when overriding fields_view_get... X-Git-Tag: 6.1.0-rc1-addons~675 X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=515ff465a071a359cb570e4a3a816cc9e80411da;p=odoo%2Fodoo.git [FIX] account_voucher: don't break non-form views when overriding fields_view_get to manipulate the form view bzr revid: xmo@openerp.com-20111213162505-fcy8xnq4q3rcrx9v --- diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 535f76b..2b63157 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -91,10 +91,10 @@ class account_voucher(osv.osv): return False def _get_payment_rate_currency(self, cr, uid, context=None): - ''' + """ Return the default value for field payment_rate_currency_id: the currency of the journal if there is one, otherwise the currency of the user's company - ''' + """ if context is None: context = {} journal_pool = self.pool.get('account.journal') journal_id = context.get('journal_id', False) @@ -141,20 +141,22 @@ class account_voucher(osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): mod_obj = self.pool.get('ir.model.data') if context is None: context = {} - if not view_id and context.get('invoice_type', False): - if context.get('invoice_type', False) in ('out_invoice', 'out_refund'): - result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form') - else: - result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form') - result = result and result[1] or False - view_id = result - if not view_id and view_type == 'form' and context.get('line_type', False): - if context.get('line_type', False) == 'customer': - result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form') - else: - result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form') - result = result and result[1] or False - view_id = result + + if view_type == 'form': + if not view_id and context.get('invoice_type'): + if context.get('invoice_type') in ('out_invoice', 'out_refund'): + result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form') + else: + result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form') + result = result and result[1] or False + view_id = result + if not view_id and context.get('line_type'): + if context.get('line_type') == 'customer': + result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form') + else: + result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form') + result = result and result[1] or False + view_id = result res = super(account_voucher, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) doc = etree.XML(res['arch'])