From 8f91b2b0346145907e81b42dd26084d04a626881 Mon Sep 17 00:00:00 2001 From: "hda@tinyerp.com" <> Date: Tue, 23 Sep 2008 13:45:37 +0530 Subject: [PATCH 01/46] fix crash problem after configuration wizard bzr revid: hda@tinyerp.com-20080923081537-wqlqgiynp8mw1pwv --- bin/addons/base/module/module.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py index fa8ce19fd57..30b154a1145 100644 --- a/bin/addons/base/module/module.py +++ b/bin/addons/base/module/module.py @@ -268,7 +268,7 @@ class module(osv.osv): raise orm.except_orm(_('Error'), _('You try to remove a module that is installed or will be installed')) return super(module, self).unlink(cr, uid, ids, context=context) - + def state_update(self, cr, uid, ids, newstate, states_to_update, context={}, level=50): if level<1: raise orm.except_orm(_('Error'), _('Recursion error in modules dependencies !')) @@ -471,14 +471,14 @@ class module(osv.osv): match = re.search('-([a-zA-Z0-9\._-]+)(\.zip)', mod.url, re.I) version = '0' if match: - version = match.group(1) + version = match.group(1) if vercmp(mod.installed_version or '0', version) >= 0: continue res.append(mod.url) if not download: continue zipfile = urllib.urlopen(mod.url).read() - fname = addons.get_module_path(mod.name+'.zip') + fname = addons.get_module_path(mod.name+'.zip') try: fp = file(fname, 'wb') fp.write(zipfile) @@ -528,12 +528,12 @@ class module(osv.osv): self.write(cr, uid, [id], {'category_id': p_id}) def action_install(self,cr,uid,ids,context=None): - self.write(cr , uid, ids ,{'state' : 'to install'}) + self.write(cr , uid, ids ,{'state' : 'to install'}) self.download(cr, uid, ids, context=context) for id in ids: cr.execute("select m.id as id from ir_module_module_dependency d inner join ir_module_module m on (m.name=d.name) where d.module_id=%d and m.state='uninstalled'",(id,)) dep_ids = map(lambda x:x[0],cr.fetchall()) - if len(dep_ids): + if len(dep_ids): self.action_install(cr,uid,dep_ids,context=context) def update_translations(self, cr, uid, ids, filter_lang=None): @@ -550,7 +550,7 @@ class module(osv.osv): for mod in self.browse(cr, uid, ids): if mod.state != 'installed': continue - + for lang in filter_lang: f = os.path.join(tools.config['addons_path'], mod.name, 'i18n', lang + '.po') if os.path.exists(f): @@ -680,6 +680,18 @@ class module_configuration(osv.osv_memory): 'type': item.action_id.type, 'target':item.action_id.target, } + user_action=self.pool.get('res.users').browse(cr,uid,uid) + act_obj=self.pool.get(user_action.action_id.type) + action_ids=act_obj.search(cr,uid,[('name','=',user_action.action_id.name)]) + action_open=act_obj.browse(cr,uid,action_ids)[0] + if context.get('menu',False): + return{ + 'view_type': action_open.view_type, + 'view_id':action_open.view_id and [action_open.view_id.id] or False, + 'res_model': action_open.res_model, + 'type': action_open.type, + 'domain':action_open.domain + } return {'type':'ir.actions.act_window_close' } module_configuration() From 17eb1ec7dafa56196faff9a3df4105d59228021f Mon Sep 17 00:00:00 2001 From: "hda@tinyerp.com" <> Date: Tue, 23 Sep 2008 15:52:28 +0530 Subject: [PATCH 02/46] bug fix bzr revid: hda@tinyerp.com-20080923102228-npiylcw40qahdyh3 --- bin/osv/fields.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/osv/fields.py b/bin/osv/fields.py index 825420b1ec6..5079100f654 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -648,8 +648,8 @@ class related(function): # return True - def _fnct_write(self,obj,cr, uid, ids, field_name, args, context=None): - raise 'Not Implemented Yet' +# def _fnct_write(self,obj,cr, uid, ids,values, field_name, args, context=None): +# raise 'Not Implemented Yet' def _fnct_read(self,obj,cr, uid, ids, field_name, args, context=None): if not ids: return {} @@ -678,7 +678,7 @@ class related(function): def __init__(self,*arg,**args): print arg self.arg = arg - super(related, self).__init__(self._fnct_read, arg, fnct_inv=self._fnct_write, fnct_inv_arg=arg,method=True, fnct_search=self._fnct_search,**args) + super(related, self).__init__(self._fnct_read, arg, fnct_inv_arg=arg,method=True, fnct_search=self._fnct_search,**args) # TODO: call field_get on the object, not in the DB def _field_get(self, cr, uid, obj, model_name, prop): From 500e964ebbe6e7fa646b4bff0832beacdca8a43d Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 23 Sep 2008 12:47:45 +0200 Subject: [PATCH 03/46] get_binary_size is renamed bin_size and its behavior is reversed (False by default) bzr revid: christophe@tinyerp.com-20080923104745-m5osg61ukqtk0szi --- bin/osv/fields.py | 4 ++-- bin/osv/orm.py | 4 ++-- bin/report/report_sxw.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/osv/fields.py b/bin/osv/fields.py index 5079100f654..daee0e4e40a 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -223,7 +223,7 @@ class binary(_column): val = v[name] break res.setdefault(i, val) - if context.get('get_binary_size', True): + if context.get('bin_size', False): res[i] = tools.human_size(val) return res @@ -620,7 +620,7 @@ class function(_column): else: res = self._fnct(cr, obj._table, ids, name, self._arg, context) - if self._type == 'binary' and context.get('get_binary_size', True): + if self._type == 'binary' and context.get('bin_size', False): # convert the data returned by the function with the size of that data... res = dict(map(lambda (x, y): (x, tools.human_size(len(y))), res.items())) return res diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 00e2f30b35f..0c636acdd03 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1127,7 +1127,7 @@ class orm_memory(orm_template): for f in fields_to_read: if id in self.datas: r[f] = self.datas[id].get(f, False) - if r[f] and isinstance(self._columns[f], fields.binary) and context.get('get_binary_size', True): + if r[f] and isinstance(self._columns[f], fields.binary) and context.get('bin_size', False): r[f] = len(r[f]) result.append(r) if id in self.datas: @@ -1721,7 +1721,7 @@ class orm(orm_template): def convert_field(f): if f in ('create_date', 'write_date'): return "date_trunc('second', %s) as %s" % (f, f) - if isinstance(self._columns[f], fields.binary) and context.get('get_binary_size', True): + if isinstance(self._columns[f], fields.binary) and context.get('bin_size', False): return "length(%s) as %s" % (f,f) return '"%s"' % (f,) #fields_pre2 = map(lambda x: (x in ('create_date', 'write_date')) and ('date_trunc(\'second\', '+x+') as '+x) or '"'+x+'"', fields_pre) diff --git a/bin/report/report_sxw.py b/bin/report/report_sxw.py index 5b9a78c630a..a5f7ee8d7ef 100644 --- a/bin/report/report_sxw.py +++ b/bin/report/report_sxw.py @@ -566,7 +566,6 @@ class report_sxw(report_rml): if not context: context={} context = context.copy() - context['get_binary_size'] = False pool = pooler.get_pool(cr.dbname) ir_actions_report_xml_obj = pool.get('ir.actions.report.xml') From bb3743070d2840750b57675f64c3f95824d948b7 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 23 Sep 2008 13:25:21 +0200 Subject: [PATCH 04/46] improvement bzr revid: fp@tinyerp.com-20080923112521-gd45nckoeqq29jmx --- addons/product/product.py | 9 ++++--- .../stock/wizard/wizard_location_product.py | 25 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index 671433bd0fe..627bbf75c51 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -329,10 +329,11 @@ product_template() class product_product(osv.osv): def view_header_get(self, cr, uid, view_id, view_type, context): res = super(product_product, self).view_header_get(cr, uid, view_id, view_type, context) - if res: return res - if (not context.get('categ_id', False)): - return False - return _('Products: ')+self.pool.get('product.category').browse(cr, uid, context['categ_id'], context).name + if (context.get('categ_id', False)): + return _('Products: ')+self.pool.get('product.category').browse(cr, uid, context['categ_id'], context).name + if (context.get('location', False)): + return _('Products: ')+self.pool.get('stock.location').browse(cr, uid, context['location'], context).name + return res def _product_price(self, cr, uid, ids, name, arg, context={}): res = {} diff --git a/addons/stock/wizard/wizard_location_product.py b/addons/stock/wizard/wizard_location_product.py index 0083c0e9863..f6190c023d2 100755 --- a/addons/stock/wizard/wizard_location_product.py +++ b/addons/stock/wizard/wizard_location_product.py @@ -34,24 +34,27 @@ import time def _action_open_window(self, cr, uid, data, context): return { - 'view_type': 'form', - "view_mode": 'tree,form', - 'res_model': 'product.product', - 'type': 'ir.actions.act_window', - 'context':{'location': data['ids'][0],'from_date':data['form']['from_date'],'to_date':data['form']['to_date']}, - 'domain':[('type','<>','service')] - } + 'name': False, + 'view_type': 'form', + "view_mode": 'tree,form', + 'res_model': 'product.product', + 'type': 'ir.actions.act_window', + 'context':{'location': data['ids'][0],'from_date':data['form']['from_date'],'to_date':data['form']['to_date']}, + 'domain':[('type','<>','service')] + } class product_by_location(wizard.interface): - form1 = '''
+ + + -