From 33a6d24bcd82c5b2a05e3f5078f545f7c04f9a8a Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Wed, 26 Oct 2011 16:56:43 +0200 Subject: [PATCH] [IMP] account: Hide the company_id only if there is a default company (only one) bzr revid: stw@openerp.com-20111026145643-nw9rza8g8u08i7bg --- addons/account/account_installer.xml | 3 ++- addons/account/installer.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index b35b37aa972..230078c4e33 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -28,7 +28,8 @@ - + + diff --git a/addons/account/installer.py b/addons/account/installer.py index 530ea7ccc6f..a91af8f0862 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -59,12 +59,17 @@ class account_installer(osv.osv_memory): 'sale_tax': fields.float('Sale Tax(%)'), 'purchase_tax': fields.float('Purchase Tax(%)'), 'company_id': fields.many2one('res.company', 'Company', required=True), + 'has_default_company' : fields.boolean('Has Default Company', readonly=True), } def _default_company(self, cr, uid, context=None): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) return user.company_id and user.company_id.id or False + def _default_has_default_company(self, cr, uid, context=None): + count = self.pool.get('res.company').search_count(cr, uid, [], context=context) + return bool(count == 1) + _defaults = { 'date_start': lambda *a: time.strftime('%Y-01-01'), 'date_stop': lambda *a: time.strftime('%Y-12-31'), @@ -72,6 +77,7 @@ class account_installer(osv.osv_memory): 'sale_tax': 0.0, 'purchase_tax': 0.0, 'company_id': _default_company, + 'has_default_company': _default_has_default_company, 'charts': 'configurable' }