From 6d553a36fda98f2efa61d2a957dd94ad67eb8c1a Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 29 Apr 2009 18:13:19 +0200 Subject: [PATCH 1/5] [IMP] base_setup: pre-fill the fields with the address of the main company bzr revid: christophe@tinyerp.com-20090429161319-3jh2wmde29myy6l7 --- addons/base_setup/wizard/wizard_base_setup.py | 63 ++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/addons/base_setup/wizard/wizard_base_setup.py b/addons/base_setup/wizard/wizard_base_setup.py index 10c75bd092e..f095e4b78cb 100644 --- a/addons/base_setup/wizard/wizard_base_setup.py +++ b/addons/base_setup/wizard/wizard_base_setup.py @@ -111,43 +111,51 @@ class wizard_base_setup(wizard.interface): return res def _get_company(self, cr, uid, data, context): - pool=pooler.get_pool(cr.dbname) - company_obj=pool.get('res.company') + pool = pooler.get_pool(cr.dbname) + company_obj = pool.get('res.company') ids=company_obj.search(cr, uid, []) if not ids: return {} - company=company_obj.browse(cr, uid, ids)[0] - self.fields['name']['default']=company.name - self.fields['currency']['default']=company.currency_id.id - serv_pro_id = pooler.get_pool(cr.dbname).get('ir.module.module').search(cr, uid, [('name','=','profile_service')]) or False + company = company_obj.browse(cr, uid, ids)[0] + + res = { + 'name': company.name, + 'currency': company.currency_id.id, + } + + if company.partner_id.address: + address = company.partner_id.address[0] + for field in 'street street2 zip city email phone'.split(): + res[field] = address[field] + + for field in 'country_id state_id'.split(): + if address[field]: + res[field] = address[field].id + + serv_pro_id = pool.get('ir.module.module').search(cr, uid, [('name','=','profile_service')]) or False if serv_pro_id: - return {'profile':serv_pro_id[0]} - return {} + res['profile'] = serv_pro_id[0] + + return res + + + def _get_all(self, cr, uid, context, model): + pool = pooler.get_pool(cr.dbname) + obj = pool.get(model) + ids = obj.search(cr, uid, []) + res = [(o.id, o.name) for o in obj.browse(cr, uid, ids, context=context)] + res.append((-1, '')) + res.sort(key=lambda x: x[1]) + return res def _get_states(self, cr, uid, context): - pool=pooler.get_pool(cr.dbname) - state_obj=pool.get('res.country.state') - ids=state_obj.search(cr, uid, []) - res=[(state.id, state.name) for state in state_obj.browse(cr, uid, ids, context=context)] - res.append((-1, '')) - res.sort(lambda x,y: cmp(x[1],y[1])) - return res + return self._get_all(cr, uid, context, 'res.country.state') def _get_countries(self, cr, uid, context): - pool=pooler.get_pool(cr.dbname) - country_obj=pool.get('res.country') - ids=country_obj.search(cr, uid, []) - res=[(country.id, country.name) for country in country_obj.browse(cr, uid, ids, context=context)] - res.sort(lambda x,y: cmp(x[1],y[1])) - return res + return self._get_all(cr, uid, context, 'res.country') def _get_currency(self, cr, uid, context): - pool=pooler.get_pool(cr.dbname) - currency_obj=pool.get('res.currency') - ids=currency_obj.search(cr, uid, []) - res=[(currency.id, currency.name) for currency in currency_obj.browse(cr, uid, ids, context=context)] - res.sort(lambda x,y: cmp(x[1],y[1])) - return res + return self._get_all(cr, uid, context, 'res.currency') def _update(self, cr, uid, data, context): pool=pooler.get_pool(cr.dbname) @@ -256,7 +264,6 @@ class wizard_base_setup(wizard.interface): 'string':'Profile', 'type':'selection', 'selection':_get_profiles, -# 'default': _get_service_profile, 'required': True, }, From 9c960eee26d72ffa877229608d9e5e4f89144b36 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 29 Apr 2009 18:20:16 +0200 Subject: [PATCH 2/5] [IMP] base_setup: also pre-fill the fields of the second tab bzr revid: christophe@tinyerp.com-20090429162016-hph7aum99l4z8b57 --- addons/base_setup/wizard/wizard_base_setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/base_setup/wizard/wizard_base_setup.py b/addons/base_setup/wizard/wizard_base_setup.py index f095e4b78cb..aca4b185ade 100644 --- a/addons/base_setup/wizard/wizard_base_setup.py +++ b/addons/base_setup/wizard/wizard_base_setup.py @@ -118,10 +118,10 @@ class wizard_base_setup(wizard.interface): return {} company = company_obj.browse(cr, uid, ids)[0] - res = { - 'name': company.name, - 'currency': company.currency_id.id, - } + res = {'currency': company.currency_id.id} + + for field in 'name logo rml_header1 rml_footer1 rml_footer2'.split(): + res[field] = company[field] if company.partner_id.address: address = company.partner_id.address[0] From 0a80db1ee3a935b97800156ae75d419ab3e58069 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Fri, 1 May 2009 12:51:09 +0530 Subject: [PATCH 3/5] [FIX] Bug 367471 : Timesheet lines notification on chaning saved record's date bzr revid: jvo@tinyerp.com-20090501072109-nsk4y8dyrzzn4udi --- addons/hr_timesheet/hr_timesheet.py | 10 +++++++++- addons/hr_timesheet/hr_timesheet_view.xml | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py index a74efd53cdd..70d4a80c501 100644 --- a/addons/hr_timesheet/hr_timesheet.py +++ b/addons/hr_timesheet/hr_timesheet.py @@ -111,7 +111,15 @@ class hr_analytic_timesheet(osv.osv): } def on_change_account_id(self, cr, uid, ids, account_id): return {'value':{}} - + + def on_change_date(self, cr, uid, ids, date): + if ids: + new_date = self.read(cr,uid,ids[0],['date'])['date'] + if date != new_date: + warning = {'title':'User Alert!','message':'Changing the date will let this entry appear in the timesheet of the new date.'} + return {'value':{},'warning':warning} + return {'value':{}} + def create(self, cr, uid, vals, context={}): try: res = super(hr_analytic_timesheet, self).create(cr, uid, vals, context) diff --git a/addons/hr_timesheet/hr_timesheet_view.xml b/addons/hr_timesheet/hr_timesheet_view.xml index e44a50ace19..c9f7214ecca 100644 --- a/addons/hr_timesheet/hr_timesheet_view.xml +++ b/addons/hr_timesheet/hr_timesheet_view.xml @@ -8,7 +8,7 @@ - + @@ -25,9 +25,9 @@ form
- + - + From 25177a0fe57f7da57b6af23f3215ddc78b4c091d Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Fri, 1 May 2009 15:26:06 +0530 Subject: [PATCH 4/5] [FIX] Bug 368698 : Warning resolved(ref:.GPA) bzr revid: jvo@tinyerp.com-20090501095606-te74htk5inczcmit --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 1aa4673ce8a..17eabbc2f16 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -369,7 +369,7 @@ class hr_timesheet_line(osv.osv): elif (x[2] is False) and (x[1] == '<>' or x[1] == '!='): qu1.append('(s.id IS NOT NULL)') else: - qu1.append('(s.id %s %s)' % (x[1], '%d')) + qu1.append('(s.id %s %s)' % (x[1], '%s')) qu2.append(x[2]) elif x[1] == 'in': if len(x[2]) > 0: @@ -486,7 +486,7 @@ class hr_attendance(osv.osv): elif (x[2] is False) and (x[1] == '<>' or x[1] == '!='): qu1.append('(s.id IS NOT NULL)') else: - qu1.append('(s.id %s %s)' % (x[1], '%d')) + qu1.append('(s.id %s %s)' % (x[1], '%s')) qu2.append(x[2]) elif x[1] == 'in': if len(x[2]) > 0: From c07b4784127f050669eb3327008617d39f7ede6a Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Fri, 1 May 2009 17:42:38 +0530 Subject: [PATCH 5/5] [FIX] Bug 362727 : Report creator now lists only related models,filter wizard bugfixes bzr revid: jvo@tinyerp.com-20090501121238-0pyzyo6avpoj7jfm --- .../base_report_creator.py | 30 +++++++++++++++++-- .../base_report_creator_view.xml | 2 +- .../wizard/wiz_set_filter_fields.py | 15 +++++----- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/addons/base_report_creator/base_report_creator.py b/addons/base_report_creator/base_report_creator.py index 12e95186217..93f2ff837c0 100644 --- a/addons/base_report_creator/base_report_creator.py +++ b/addons/base_report_creator/base_report_creator.py @@ -47,6 +47,32 @@ from tools.translate import _ # return super(ir_model_fields, self).search(cr, uid, args, offset, limit, order, context) #ir_model_fields() +class ir_model(osv.osv): + _inherit = 'ir.model' + + def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): + res_model_ids = super(ir_model,self).search(cr, uid, args, offset, limit, order, context=context, count=count) + try: + if 'model_ids' in context and context['model_ids'][0][2]: + model_ids = context['model_ids'][0][2] + result = [] + name_list = [] + if model_ids: + obj = self.read(cr, uid, model_ids,['model']) + for name in obj: + name_list.append(name['model']) + cr.execute("SELECT model_id, relation FROM ir_model_fields WHERE relation in (%s)" % (','.join(map(lambda x: "'"+str(x)+"'",name_list)))) + + for r in cr.fetchall(): + result.append(r[0]) + return result + return res_model_ids + + except Exception,e: + pass + +ir_model() + class report_creator(osv.osv): _name = "base_report_creator.report" _description = "Report" @@ -354,8 +380,8 @@ class report_creator(osv.osv): _constraints = [ (_function_field, 'You can not display field which are not stored in Database.', ['field_ids']), - (_aggregation_error, 'You can apply agregate function to the non calculated field.', ['field_ids']), - (_calander_view_error, "You must have to give calander view's color,start date and delay.", ['field_ids']), + (_aggregation_error, 'You can apply aggregate function to the non calculated field.', ['field_ids']), + (_calander_view_error, "You must have to give calendar view's color,start date and delay.", ['field_ids']), ] report_creator() diff --git a/addons/base_report_creator/base_report_creator_view.xml b/addons/base_report_creator/base_report_creator_view.xml index 494e98d7d02..7ae858012ed 100644 --- a/addons/base_report_creator/base_report_creator_view.xml +++ b/addons/base_report_creator/base_report_creator_view.xml @@ -38,7 +38,7 @@ - +