From 484524995a995986e219b4b77707f50cc6d96760 Mon Sep 17 00:00:00 2001 From: jas Date: Mon, 11 Oct 2010 15:07:09 +0530 Subject: [PATCH 1/8] [IMP] : base : improved Warnings bzr revid: jas@tinyerp.com-20101011093709-4tfz25fmwcfs4vft --- bin/addons/base/ir/ir_actions.py | 5 ++--- bin/addons/base/ir/ir_values.py | 3 +-- bin/addons/base/res/partner/partner.py | 1 - bin/osv/orm.py | 6 ++---- bin/report/printscreen/ps_list.py | 1 - bin/report/report_sxw.py | 14 +------------- 6 files changed, 6 insertions(+), 24 deletions(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 074bfa04f85..7c22d1e3013 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -473,7 +473,7 @@ class actions_server(osv.osv): for field in fields: try: obj = getattr(obj, field) - except Exception,e : + except Exception: logger.notifyChannel('Workflow', netsvc.LOG_ERROR, 'Failed to parse : %s' % (field)) return obj @@ -494,7 +494,7 @@ class actions_server(osv.osv): for field in fields: try: obj = getattr(obj, field) - except Exception,e : + except Exception: logger.notifyChannel('Workflow', netsvc.LOG_ERROR, 'Failed to parse : %s' % (field)) return obj @@ -502,7 +502,6 @@ class actions_server(osv.osv): def merge_message(self, cr, uid, keystr, action, context=None): if context is None: context = {} - logger = netsvc.Logger() def merge(match): obj_pool = self.pool.get(action.model_id.model) id = context.get('active_id') diff --git a/bin/addons/base/ir/ir_values.py b/bin/addons/base/ir/ir_values.py index 310f3552403..f74ce746e12 100644 --- a/bin/addons/base/ir/ir_values.py +++ b/bin/addons/base/ir/ir_values.py @@ -22,7 +22,6 @@ from osv import osv,fields from osv.orm import except_orm import pickle -from tools.translate import _ class ir_values(osv.osv): _name = 'ir.values' @@ -205,7 +204,7 @@ class ir_values(osv.osv): pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) - except except_orm, e: + except except_orm: return False datas= datas and datas[0] or None if not datas: diff --git a/bin/addons/base/res/partner/partner.py b/bin/addons/base/res/partner/partner.py index 05630dea85b..b65dae6fa7d 100644 --- a/bin/addons/base/res/partner/partner.py +++ b/bin/addons/base/res/partner/partner.py @@ -23,7 +23,6 @@ import math from osv import fields,osv import tools -import ir import pooler from tools.translate import _ diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 55d2a4e226e..f5a82a392e3 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1283,7 +1283,6 @@ class orm_template(object): 'fields': xfields } attrs = {'views': views} - view = False fields = views.get('field', False) and views['field'].get('fields', False) if node.get('name'): attrs = {} @@ -2218,7 +2217,6 @@ class orm(orm_template): fget = self.fields_get(cr, uid, fields) float_int_fields = filter(lambda x: fget[x]['type'] in ('float', 'integer'), fields) - sum = {} flist = '' group_by = groupby if groupby: @@ -3922,7 +3920,7 @@ class orm(orm_template): return True def _apply_ir_rules(self, cr, uid, query, mode='read', context=None): - """Add what's missing in ``query`` to implement all appropriate ir.rules + """Add what's missing in ``query`` to implement all appropriate ir.rules (using the ``model_name``'s rules or the current model's rules if ``model_name`` is None) :param query: the current query object @@ -3978,7 +3976,7 @@ class orm(orm_template): # extract the first field name, to be able to qualify it and add desc/asc m2o_order = m2o_order.split(",",1)[0].strip().split(" ",1)[0] - # Join the dest m2o table if it's not joined yet. We use [LEFT] OUTER join here + # Join the dest m2o table if it's not joined yet. We use [LEFT] OUTER join here # as we don't want to exclude results that have NULL values for the m2o src_table, src_field = qualified_field.replace('"','').split('.', 1) query.join((src_table, dest_model._table, src_field, 'id'), outer=True) diff --git a/bin/report/printscreen/ps_list.py b/bin/report/printscreen/ps_list.py index 7fb20eab0dc..fd1169b199e 100644 --- a/bin/report/printscreen/ps_list.py +++ b/bin/report/printscreen/ps_list.py @@ -139,7 +139,6 @@ class report_printscreen_list(report_int): _append_node('header-date', str(rml_obj.formatLang(time.strftime("%Y-%m-%d"),date=True))+' ' + str(time.strftime("%H:%M"))) l = [] t = 0 - rowcount = 0; strmax = (pageSize[0]-40) * 2.8346 temp = [] tsum = [] diff --git a/bin/report/report_sxw.py b/bin/report/report_sxw.py index 2c505e98622..103e0989978 100644 --- a/bin/report/report_sxw.py +++ b/bin/report/report_sxw.py @@ -19,24 +19,18 @@ # ############################################################################## from lxml import etree -import traceback, sys import StringIO import cStringIO import base64 -import copy -import locale from datetime import datetime import os import re import time from interface import report_rml import preprocess -import ir import netsvc -import osv import pooler import tools -import warnings import zipfile import common from osv.fields import float as float_class, function as function_class @@ -210,13 +204,10 @@ class rml_parse(object): return res['datas'] else : return '' - except Exception,e: + except Exception: return '' def setLang(self, lang): - if not lang or self.default_lang.has_key(lang): - if not lang: - key = 'en_US' self.localcontext['lang'] = lang self.lang_dict_called = False for obj in self.objects: @@ -437,8 +428,6 @@ class report_sxw(report_rml, preprocess.report): ) cr.commit() except Exception,e: - import traceback, sys - tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) netsvc.Logger().notifyChannel('report', netsvc.LOG_ERROR,str(e)) results.append(result) if results: @@ -512,7 +501,6 @@ class report_sxw(report_rml, preprocess.report): xml_declaration=True) rml_dom = etree.XML(rml) - body = rml_dom[-1] elements = [] key1 = rml_parser.localcontext['name_space']["text"]+"p" key2 = rml_parser.localcontext['name_space']["text"]+"drop-down" From e232dd66384b0c4af20c2e7f2b859c053173cb50 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Mon, 11 Oct 2010 18:52:52 +0530 Subject: [PATCH 2/8] [IMP] base: if company_ids is empty, it will be set with deafult value on user creation bzr revid: hmo@tinyerp.com-20101011132252-wcej9vlsb6582w5x --- bin/addons/base/res/res_user.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/addons/base/res/res_user.py b/bin/addons/base/res/res_user.py index 929a7018f7d..2b9a3a05eb1 100644 --- a/bin/addons/base/res/res_user.py +++ b/bin/addons/base/res/res_user.py @@ -350,6 +350,12 @@ class users(osv.osv): # User can write to a few of her own fields (but not her groups for example) SELF_WRITEABLE_FIELDS = ['menu_tips','view', 'password', 'signature', 'action_id', 'company_id', 'user_email'] + def create(self, cr, uid, vals, context=None): + if (not vals.get('company_ids',[])): + company_ids = self._get_companies(cr, uid, context=context) + if company_ids and len(company_ids): vals['company_ids'] = [(6, 0, company_ids)] + return super(users, self).create(cr, uid, vals, context=context) + def write(self, cr, uid, ids, values, context=None): if not hasattr(ids, '__iter__'): ids = [ids] From b153bdce7088c24acb75ba3de83ad1167ba68a08 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Mon, 11 Oct 2010 19:01:44 +0530 Subject: [PATCH 3/8] [FIX] base: regression to get default value of group on res.user model bzr revid: hmo@tinyerp.com-20101011133144-ae3oue8865kbb0bp --- bin/addons/base/res/res_user.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/addons/base/res/res_user.py b/bin/addons/base/res/res_user.py index 2b9a3a05eb1..d770ef81a10 100644 --- a/bin/addons/base/res/res_user.py +++ b/bin/addons/base/res/res_user.py @@ -327,8 +327,9 @@ class users(osv.osv): return ids and ids[0] or False def _get_group(self,cr, uid, context=None): - dataobj = self.pool.get('ir.model.data') - data_id = dataobj._get_id(cr, 1, 'base', 'group_user') + data_pool = self.pool.get('ir.model.data') + res = data_pool.get_object_reference(cr, 1, 'base', 'group_user') + data_id = res and res[1] or False return data_id and [data_id] or False _defaults = { From 7c5dce1072bbb0d24b08bbdc9852c30a06c930f0 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 27 Oct 2010 19:06:01 +0530 Subject: [PATCH 4/8] [FIX]: Fixed translation of warning messages lp bug: https://launchpad.net/bugs/660494 fixed bzr revid: rpa@tinyerp.com-20101027133601-caqy1wdk9pduxyem --- bin/addons/__init__.py | 4 +- bin/addons/base/i18n/base.pot | 50 +++++++++++++++++++ bin/addons/base/ir/ir_model.py | 2 +- bin/addons/base/ir/ir_values.py | 2 +- .../base/module/wizard/base_module_upgrade.py | 2 +- 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 0b5c6dc09c5..5476dc198f3 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -30,7 +30,7 @@ import tools import tools.osutil from tools.safe_eval import safe_eval as eval import pooler - +from tools.translate import _ import netsvc @@ -806,7 +806,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): graph = create_graph(cr, ['base'], force) if not graph: logger.notifyChannel('init', netsvc.LOG_CRITICAL, 'module base cannot be loaded! (hint: verify addons-path)') - raise osv.osv.except_osv('Could not load base module', 'module base cannot be loaded! (hint: verify addons-path)') + raise osv.osv.except_osv(_('Could not load base module'), _('module base cannot be loaded! (hint: verify addons-path)')) has_updates = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report) if update_module: diff --git a/bin/addons/base/i18n/base.pot b/bin/addons/base/i18n/base.pot index 48ce827f149..51b5df3a8be 100644 --- a/bin/addons/base/i18n/base.pot +++ b/bin/addons/base/i18n/base.pot @@ -4303,6 +4303,7 @@ msgstr "" #: code:addons/base/res/res_config.py:0 #: code:addons/base/res/res_currency.py:0 #: code:addons/base/res/res_user.py:0 +#: code:addons/base/res/ir_property.py:) #, python-format msgid "Error" msgstr "" @@ -5754,6 +5755,7 @@ msgstr "" #. module: base #: code:addons/base/module/wizard/base_module_import.py:0 +#: code:addons/base/ir/ir_values.py: #, python-format msgid "Error !" msgstr "" @@ -8735,3 +8737,51 @@ msgstr "" msgid "Russian / русский язык" msgstr "" +#. module: base +#: code:addons/base/module/wizard/base_module_upgrade.py:0 +#, python-format +msgid "Unmet dependency !" +msgstr "" + +#. module: base +#: code:addons/base/module/wizard/base_module_upgrade.py:0 +#, python-format +msgid "Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages)" +msgstr "" + +#. module: base +#: code:addons/base/ir/ir_model.py:0 +#, python-format +msgid "Invalid search criterions" +msgstr "" + +#. module: base +#: code:addons/base/ir/ir_model.py:0 +#, python-format +msgid "The osv_memory field can only be compared with = and != operator." +msgstr "" + +#. module: base +#: code:addons/base/ir/ir_values.py:0 +#, python-format +msgid "You do not have the permission to perform this operation !!!" +msgstr "" + +#. module: base +#: code:addons/base/res/ir_property.py:0 +#, python-format +msgid "Invalid type" +msgstr "" + +#. module: base +#: code:addons/__init__.py:0 +#, python-format +msgid "Could not load base module" +msgstr "" + +#. module: base +#: code:addons/__init__.py:0 +#, python-format +msgid "module base cannot be loaded! (hint: verify addons-path)" +msgstr "" + diff --git a/bin/addons/base/ir/ir_model.py b/bin/addons/base/ir/ir_model.py index 3f3700b0e45..86bb6cc4dc5 100644 --- a/bin/addons/base/ir/ir_model.py +++ b/bin/addons/base/ir/ir_model.py @@ -57,7 +57,7 @@ class ir_model(osv.osv): return [] field, operator, value = domain[0] if operator not in ['=', '!=']: - raise osv.except_osv('Invalid search criterions','The osv_memory field can only be compared with = and != operator.') + raise osv.except_osv(_('Invalid search criterions'), _('The osv_memory field can only be compared with = and != operator.')) value = bool(value) if operator == '=' else not bool(value) all_model_ids = self.search(cr, uid, [], context=context) is_osv_mem = self._is_osv_memory(cr, uid, all_model_ids, 'osv_memory', arg=None, context=context) diff --git a/bin/addons/base/ir/ir_values.py b/bin/addons/base/ir/ir_values.py index f74ce746e12..a60fbdddb94 100644 --- a/bin/addons/base/ir/ir_values.py +++ b/bin/addons/base/ir/ir_values.py @@ -229,7 +229,7 @@ class ir_values(osv.osv): if not cnt: res2.remove(r) if r[1] == 'Menuitem' and not res2: - raise osv.except_osv('Error !','You do not have the permission to perform this operation !!!') + raise osv.except_osv(_('Error !'), _('You do not have the permission to perform this operation !!!')) return res2 ir_values() diff --git a/bin/addons/base/module/wizard/base_module_upgrade.py b/bin/addons/base/module/wizard/base_module_upgrade.py index 4db4028bdb0..b791aeea459 100644 --- a/bin/addons/base/module/wizard/base_module_upgrade.py +++ b/bin/addons/base/module/wizard/base_module_upgrade.py @@ -93,7 +93,7 @@ class base_module_upgrade(osv.osv_memory): if dep_mod.state in ('unknown','uninstalled'): unmet_packages.append(dep_mod.name) if len(unmet_packages): - raise osv.except_osv('Unmet dependency !', 'Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages)) + raise osv.except_osv(_('Unmet dependency !'), _('Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages))) mod_obj.download(cr, uid, ids, context=context) cr.commit() _, pool = pooler.restart_pool(cr.dbname, update_module=True) From bba8926e32ba74e5ae7047a2c59dd1be57409b1a Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Thu, 28 Oct 2010 17:41:43 +0530 Subject: [PATCH 5/8] [FIX] base: remove _(..) in sql_constraints in res.users model bzr revid: hmo@tinyerp.com-20101028121143-kgb3wcsl59k6hn05 --- bin/addons/base/res/res_user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/addons/base/res/res_user.py b/bin/addons/base/res/res_user.py index 4de6071f2fe..179825d95b4 100644 --- a/bin/addons/base/res/res_user.py +++ b/bin/addons/base/res/res_user.py @@ -263,7 +263,7 @@ class users(osv.osv): ] _sql_constraints = [ - ('login_key', 'UNIQUE (login)', _('You can not have two users with the same login !')) + ('login_key', 'UNIQUE (login)', 'You can not have two users with the same login !') ] def _get_email_from(self, cr, uid, ids, context=None): From 24c91a5e4194110d83833f9ba377e537e8edc720 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Thu, 28 Oct 2010 17:50:35 +0530 Subject: [PATCH 6/8] [FIX] base: missing import _ bzr revid: hmo@tinyerp.com-20101028122035-pv48msjk6pck4wen --- bin/addons/base/i18n/base.pot | 2 +- bin/addons/base/ir/ir_values.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/addons/base/i18n/base.pot b/bin/addons/base/i18n/base.pot index 51b5df3a8be..f0ad2bf8207 100644 --- a/bin/addons/base/i18n/base.pot +++ b/bin/addons/base/i18n/base.pot @@ -4303,7 +4303,7 @@ msgstr "" #: code:addons/base/res/res_config.py:0 #: code:addons/base/res/res_currency.py:0 #: code:addons/base/res/res_user.py:0 -#: code:addons/base/res/ir_property.py:) +#: code:addons/base/res/ir_property.py:0 #, python-format msgid "Error" msgstr "" diff --git a/bin/addons/base/ir/ir_values.py b/bin/addons/base/ir/ir_values.py index a60fbdddb94..193dc11bbef 100644 --- a/bin/addons/base/ir/ir_values.py +++ b/bin/addons/base/ir/ir_values.py @@ -22,6 +22,7 @@ from osv import osv,fields from osv.orm import except_orm import pickle +from tools.translate import _ class ir_values(osv.osv): _name = 'ir.values' From d644417abb6d962287ebc2d9293a901a38dcf238 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Thu, 4 Nov 2010 11:24:40 +0530 Subject: [PATCH 7/8] [FIX] base: correct warning messages bzr revid: hmo@tinyerp.com-20101104055440-av49qnlqxziq9vro --- bin/addons/base/i18n/base.pot | 2 +- bin/addons/base/module/wizard/base_module_upgrade.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/addons/base/i18n/base.pot b/bin/addons/base/i18n/base.pot index f0ad2bf8207..d96c081d6a6 100644 --- a/bin/addons/base/i18n/base.pot +++ b/bin/addons/base/i18n/base.pot @@ -8746,7 +8746,7 @@ msgstr "" #. module: base #: code:addons/base/module/wizard/base_module_upgrade.py:0 #, python-format -msgid "Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages)" +msgid "Following modules are not installed or unknown: %s" msgstr "" #. module: base diff --git a/bin/addons/base/module/wizard/base_module_upgrade.py b/bin/addons/base/module/wizard/base_module_upgrade.py index b791aeea459..de9df1ec3e0 100644 --- a/bin/addons/base/module/wizard/base_module_upgrade.py +++ b/bin/addons/base/module/wizard/base_module_upgrade.py @@ -93,7 +93,7 @@ class base_module_upgrade(osv.osv_memory): if dep_mod.state in ('unknown','uninstalled'): unmet_packages.append(dep_mod.name) if len(unmet_packages): - raise osv.except_osv(_('Unmet dependency !'), _('Following modules are uninstalled or unknown. \n\n'+'\n'.join(unmet_packages))) + raise osv.except_osv(_('Unmet dependency !'), _('Following modules are not installed or unknown: %s') % ('\n\n' + '\n'.join(unmet_packages))) mod_obj.download(cr, uid, ids, context=context) cr.commit() _, pool = pooler.restart_pool(cr.dbname, update_module=True) From 236e74c3964942f354ae00f5bea0883b4842693e Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Thu, 4 Nov 2010 14:09:16 +0530 Subject: [PATCH 8/8] [FIX] base: remove override create method of res.users object. bzr revid: hmo@tinyerp.com-20101104083916-m93lq4olgle5rrq9 --- bin/addons/base/res/res_user.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bin/addons/base/res/res_user.py b/bin/addons/base/res/res_user.py index 179825d95b4..ca70db47243 100644 --- a/bin/addons/base/res/res_user.py +++ b/bin/addons/base/res/res_user.py @@ -331,12 +331,6 @@ class users(osv.osv): # User can write to a few of her own fields (but not her groups for example) SELF_WRITEABLE_FIELDS = ['menu_tips','view', 'password', 'signature', 'action_id', 'company_id', 'user_email'] - def create(self, cr, uid, vals, context=None): - if (not vals.get('company_ids',[])): - company_ids = self._get_companies(cr, uid, context=context) - if company_ids and len(company_ids): vals['company_ids'] = [(6, 0, company_ids)] - return super(users, self).create(cr, uid, vals, context=context) - def write(self, cr, uid, ids, values, context=None): if not hasattr(ids, '__iter__'): ids = [ids]