From b670558fdb0b4681a434d5c95e73d162fc7bf5d6 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Tue, 18 May 2010 17:52:20 +0530 Subject: [PATCH] [FIX] Setup : Currencies should appear as name(code) format bzr revid: jvo@tinyerp.com-20100518122220-njcg7b4eztrpsek1 --- addons/base_setup/gtk_contact_form.py | 24 +++++++++++++----------- addons/base_setup/todo.py | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/addons/base_setup/gtk_contact_form.py b/addons/base_setup/gtk_contact_form.py index c13ae39aee3..ad602025325 100644 --- a/addons/base_setup/gtk_contact_form.py +++ b/addons/base_setup/gtk_contact_form.py @@ -74,20 +74,22 @@ class base_gtkcontactform(osv.osv_memory): 'contact_me':fields.boolean('Contact Me'), } def execute(self, cr, uid, ids, context=None): - company_id = self.pool.get('base.setup.company').search(cr, uid, []) - company_data = self.pool.get('base.setup.company').read(cr, uid, company_id) - company_data = company_data and company_data[0] or False - country1 = '' - if company_data and company_data.get('country_id', False): - country = self.pool.get('res.country').read(cr, uid, company_data['country_id'],['name'])['name'] - for res in self.read(cr, uid, ids): + if context is None: + context = {} + company_id = self.pool.get('base.setup.company').search(cr, uid, [], context=context) + company_data = self.pool.get('base.setup.company').read(cr, uid, company_id, context=context) + company_data = company_data and company_data[0] or {} + country = '' + if company_data.get('country_id', False): + country = self.pool.get('res.country').read(cr, uid, company_data['country_id'],['name'], context=context)['name'] + for res in self.read(cr, uid, ids, context=context): email = res.get('email','') - result = "\ncompany: "+ str(company_data.get('name','')) - result += "\nname: " + str(res.get('name','')) + result = "\ncompany: "+ tools.ustr(company_data.get('name','')) + result += "\nname: " + tools.ustr(res.get('name','')) result += "\nphone: " + str(res.get('phone','')) - result += "\ncity: " + str(company_data.get('city','')) + result += "\ncity: " + tools.ustr(company_data.get('city','')) result += "\ncountry: " + str(country) - result += "\nindustry: " + str(res.get('industry', '')) + result += "\nindustry: " + tools.ustr(res.get('industry', '')) result += "\ntotal_employees: " + str(res.get('total_employees', '')) result += "\nplan_use: " + str(res.get('use_openerp', False)) result += "\nsell_openerp: " + str(res.get('sell_openerp', False)) diff --git a/addons/base_setup/todo.py b/addons/base_setup/todo.py index c072891179a..5f6318ec5a1 100644 --- a/addons/base_setup/todo.py +++ b/addons/base_setup/todo.py @@ -152,5 +152,23 @@ IBAN: BE74 1262 0121 6907 - SWIFT: CPDF BE71 - VAT: BE0477.472.701'''), context=context) base_setup_company() +class res_currency(osv.osv): + _inherit = 'res.currency' + + def name_get(self, cr, uid, ids, context=None): + if context is None: + context = {} +# We can use the following line,if we want to restrict this name_get for company setup only +# But, its better to show currencies as name(Code). +# if not (context.get('active_model','') == 'ir.actions.todo'): +# return super(res_currency,self).name_get(cr, uid, ids, context=context) + if not len(ids): + return [] + if isinstance(ids, (int, long)): + ids = [ids] + reads = self.read(cr, uid, ids, ['name','code'], context, load='_classic_write') + return [(x['id'], tools.ustr(x['name']) + ' (' + tools.ustr(x['code']) + ')') for x in reads] + +res_currency() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: