From 5bb14725d4534fe0e4f66ab4d9fdca0afd73b74e Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 13 Dec 2010 11:51:04 +0100 Subject: [PATCH 1/6] [IMP] osv: the object pool is not a service anymore bzr revid: chs@openerp.com-20101213105104-jpctooc6j7yc8i8i --- bin/osv/osv.py | 73 +++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/bin/osv/osv.py b/bin/osv/osv.py index e7b84351a23..c66ee896425 100644 --- a/bin/osv/osv.py +++ b/bin/osv/osv.py @@ -27,8 +27,6 @@ import orm import netsvc import pooler import copy -import sys -import traceback import logging from psycopg2 import IntegrityError, errorcodes from tools.func import wraps @@ -46,7 +44,12 @@ class except_osv(Exception): self.args = (exc_type, name) -class osv_pool(netsvc.Service): +class object_proxy(netsvc.Service): + def __init__(self): + self.logger = logging.getLogger('web-services') + netsvc.Service.__init__(self, 'object_proxy', audience='') + self.exportMethod(self.exec_workflow) + self.exportMethod(self.execute) def check(f): @wraps(f) @@ -151,41 +154,12 @@ class osv_pool(netsvc.Service): self.abortResponse(1, _('Integrity Error'), 'warning', msg) else: self.abortResponse(1, _('Integrity Error'), 'warning', inst[0]) - except Exception, e: + except Exception: self.logger.exception("Uncaught exception") raise return wrapper - - def __init__(self): - self._ready = False - self.obj_pool = {} - self.module_object_list = {} - self.created = [] - self._sql_error = {} - self._store_function = {} - self._init = True - self._init_parent = {} - self.logger = logging.getLogger("web-services") - netsvc.Service.__init__(self, 'object_proxy', audience='') - self.exportMethod(self.obj_list) - self.exportMethod(self.exec_workflow) - self.exportMethod(self.execute) - - def init_set(self, cr, mode): - different = mode != self._init - if different: - if mode: - self._init_parent = {} - if not mode: - for o in self._init_parent: - self.get(o)._parent_store_compute(cr) - self._init = mode - - self._ready = True - return different - def execute_cr(self, cr, uid, obj, method, *args, **kw): object = pooler.get_pool(cr.dbname).get(obj) if not object: @@ -194,13 +168,12 @@ class osv_pool(netsvc.Service): @check def execute(self, db, uid, obj, method, *args, **kw): - db, pool = pooler.get_db_and_pool(db) - cr = db.cursor() + cr = pooler.get_db(db).cursor() try: try: if method.startswith('_'): raise except_osv('Access Denied', 'Private methods (such as %s) cannot be called remotely.' % (method,)) - res = pool.execute_cr(cr, uid, obj, method, *args, **kw) + res = self.execute_cr(cr, uid, obj, method, *args, **kw) if res is None: self.logger.warning('The method %s of the object %s can not return `None` !', method, obj) cr.commit() @@ -229,6 +202,34 @@ class osv_pool(netsvc.Service): cr.close() return res +object_proxy() + +class osv_pool(object): + def __init__(self): + self._ready = False + self.obj_pool = {} + self.module_object_list = {} + self.created = [] + self._sql_error = {} + self._store_function = {} + self._init = True + self._init_parent = {} + self.logger = logging.getLogger("pool") + + def init_set(self, cr, mode): + different = mode != self._init + if different: + if mode: + self._init_parent = {} + if not mode: + for o in self._init_parent: + self.get(o)._parent_store_compute(cr) + self._init = mode + + self._ready = True + return different + + def obj_list(self): return self.obj_pool.keys() From e55bd7051cdfcc53b81f73e0797722510c9ccc01 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Mon, 13 Dec 2010 19:07:54 +0530 Subject: [PATCH 2/6] [FIX] openerp-buildfail-1-3691: remove tab char in line#72 and local variable count is assigned to but never used into fetchmail/fetchmail.py bzr revid: hmo@tinyerp.com-20101213133754-8ucpt5in5qod8gjd --- addons/fetchmail/fetchmail.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 8bebe514402..7592061ec36 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -72,7 +72,7 @@ class email_server(osv.osv): } def check_duplicate(self, cr, uid, ids): - # RFC *-* Why this limitation? why not in SQL constraint? + # RFC *-* Why this limitation? why not in SQL constraint? vals = self.read(cr, uid, ids, ['user', 'password'])[0] cr.execute("select count(id) from email_server where user=%s and password=%s", (vals['user'], vals['password'])) res = cr.fetchone() @@ -113,7 +113,6 @@ class email_server(osv.osv): for server in self.browse(cr, uid, ids, context): logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) context.update({'server_id': server.id, 'server_type': server.type}) - count = 0 try: if server.type == 'imap': imap_server = None From 7bcccbafe585701724e4bc118ab9b9495145d08c Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 13 Dec 2010 17:18:02 +0100 Subject: [PATCH 3/6] [FIX] addons: avoid deleting resources after stand-alone base module update When updating a database, base module is first loaded on its own, and this may cause useless deletion of resource, because the aut-cleanup process. This process looks for records that are in the base namespace and have not been processed, and deletes them because they are presumed removed from the newer version. This does not properly work now that several modules install records (menus, groups) in the base namespace. This is fixed by skipping the auto-cleanup process during the stand-alone loading of base, which is fine because it will be processed properly after the rest of the modules are loaded/updated. (No specific LP bug reference, but many translation bugs stem partially from this) bzr revid: odo@openerp.com-20101213161802-ulsece9bb3q1y1fx --- bin/addons/__init__.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 2413b21ce4e..feb635055f5 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -599,8 +599,19 @@ class MigrationManager(object): log = logging.getLogger('init') -def load_module_graph(cr, graph, status=None, perform_checks=True, **kwargs): - +def load_module_graph(cr, graph, status=None, perform_checks=True, skip_cleanup=False, **kwargs): + """Migrates+Updates or Installs all module nodes from ``graph`` + :param graph: graph of module nodes to load + :param status: status dictionary for keeping track of progress + :param perform_checks: whether module descriptors should be checked for validity (prints warnings + for same cases, and even raise osv_except if certificate is invalid) + :param skip_cleanup: whether the auto-cleanup of records should be executed (unlinks any object that + appears to be from one of the updated modules, but have not been loaded during + last loading (i.e. records that seem to have been removed from the module). + This is best left disabled when loading stand-alone modules that could contain + records from dependent modules (i.e. other modules have put records in their + namespace) + """ def process_sql_file(cr, fp): queries = fp.read().split(';') for query in queries: @@ -762,7 +773,9 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, **kwargs): for model in cr.dictfetchall(): pool.get('ir.model').instanciate(cr, 1, model['model'], {}) - pool.get('ir.model.data')._process_end(cr, 1, package_todo) + if not skip_cleanup: + # Cleanup orphan records + pool.get('ir.model.data')._process_end(cr, 1, package_todo) cr.commit() return has_updates @@ -806,7 +819,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): 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)')) - has_updates = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report) + has_updates = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report, skip_cleanup=True) if update_module: modobj = pool.get('ir.module.module') From 94cfc0e203401fe48c4f6f83d1d82c076ea02089 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 13 Dec 2010 17:43:29 +0100 Subject: [PATCH 4/6] [ADD] web_uservoice module bzr revid: chs@openerp.com-20101213164329-7nzi2hoc4n7c0m9p --- addons/web_uservoice/LICENSE | 15 ++++ addons/web_uservoice/__init__.py | 19 +++++ addons/web_uservoice/__openerp__.py | 34 +++++++++ addons/web_uservoice/web/__init__.py | 22 ++++++ addons/web_uservoice/web/controllers.py | 68 +++++++++++++++++ addons/web_uservoice/web/editors.py | 75 +++++++++++++++++++ .../web/static/css/uservoice.css | 7 ++ 7 files changed, 240 insertions(+) create mode 100644 addons/web_uservoice/LICENSE create mode 100644 addons/web_uservoice/__init__.py create mode 100644 addons/web_uservoice/__openerp__.py create mode 100644 addons/web_uservoice/web/__init__.py create mode 100644 addons/web_uservoice/web/controllers.py create mode 100644 addons/web_uservoice/web/editors.py create mode 100644 addons/web_uservoice/web/static/css/uservoice.css diff --git a/addons/web_uservoice/LICENSE b/addons/web_uservoice/LICENSE new file mode 100644 index 00000000000..27a1a4cf453 --- /dev/null +++ b/addons/web_uservoice/LICENSE @@ -0,0 +1,15 @@ +OpenERP, Open Source Management Solution +Copyright © 2010 OpenERP SA (). + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public Lice +along with this program. If not, see . diff --git a/addons/web_uservoice/__init__.py b/addons/web_uservoice/__init__.py new file mode 100644 index 00000000000..723a87ab410 --- /dev/null +++ b/addons/web_uservoice/__init__.py @@ -0,0 +1,19 @@ +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010 OpenERP s.a. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## diff --git a/addons/web_uservoice/__openerp__.py b/addons/web_uservoice/__openerp__.py new file mode 100644 index 00000000000..974da96ef0d --- /dev/null +++ b/addons/web_uservoice/__openerp__.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010 OpenERP s.a. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'Add uservoice button in header', + 'version': '1.0', + 'category': 'Generic Modules/Others', + 'description': "", + 'author': 'OpenERP s.a.', + 'website': 'http://openerp.com', + 'depends': ['base'], + 'data': [], + 'installable': True, + 'active': False, + 'web': True, + 'certificate': '0040452504963885', +} diff --git a/addons/web_uservoice/web/__init__.py b/addons/web_uservoice/web/__init__.py new file mode 100644 index 00000000000..c651b91f353 --- /dev/null +++ b/addons/web_uservoice/web/__init__.py @@ -0,0 +1,22 @@ +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010 OpenERP s.a. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import editors +import controllers + diff --git a/addons/web_uservoice/web/controllers.py b/addons/web_uservoice/web/controllers.py new file mode 100644 index 00000000000..af3730b07b0 --- /dev/null +++ b/addons/web_uservoice/web/controllers.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010 OpenERP s.a. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.controllers import SecuredController +from openerp.utils import rpc +from openobject.tools import expose +import cherrypy + +class Root(SecuredController): + + _cp_path = "/openerp" + + @expose(mark_only=True) + def menu(self, active=None, next=None): + try: + menu_id = int(active) + except (TypeError, ValueError): + menu_id = False + + menus = rpc.RPCProxy("ir.ui.menu") + ids = menus.search([('parent_id', '=', False)]) + if next or active: + if not menu_id and ids: + menu_id = ids[0] + + menu = '' + if menu_id: + ctx = dict(lang='NO_LANG') # force loading original string even if the english have been translated... + menu = menus.read([menu_id], ['name'], ctx)[0]['name'] or '' + + general_forum = 77459 + forum = { + 'accounting': 87921, + 'administration': 87935, + 'human resources': 87923, + 'knowledge': 87927, + 'manufacturing': 87915, + 'marketing': 87925, + 'point of sale': 87929, + 'project': 87919, + 'purchases': 87911, + 'sales': 87907, + 'tools': 87933, + 'warehouse': 87913, + }.get(menu.lower().strip(), general_forum) + + cherrypy.request.uservoice_forum = forum + return super(Root, self).menu(active, next) + + diff --git a/addons/web_uservoice/web/editors.py b/addons/web_uservoice/web/editors.py new file mode 100644 index 00000000000..36086d5d8b6 --- /dev/null +++ b/addons/web_uservoice/web/editors.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010 OpenERP s.a. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import openobject.templating + +class BaseTemplateEditor(openobject.templating.TemplateEditor): + templates = ['/openobject/controllers/templates/base.mako'] + + def edit(self, template, template_text): + output = super(BaseTemplateEditor, self).edit(template, template_text) + + end_head = output.index('') + + output = output[:end_head] + """ + + """ + output[end_head:] + + + end_body = output.index('') + + # testing forum: 84397 + output = output[:end_body] + """ + + """ + output[end_body:] + + return output + + +class HeaderTemplateEditor(openobject.templating.TemplateEditor): + templates = ['/openerp/controllers/templates/header.mako'] + + def edit(self, template, template_text): + output = super(HeaderTemplateEditor, self).edit(template, template_text) + + PAT = '
    ' + + ul = output.index(PAT) + output = output[:ul] + """ + + """ + output[ul:] + + return output + diff --git a/addons/web_uservoice/web/static/css/uservoice.css b/addons/web_uservoice/web/static/css/uservoice.css new file mode 100644 index 00000000000..9ca2af55678 --- /dev/null +++ b/addons/web_uservoice/web/static/css/uservoice.css @@ -0,0 +1,7 @@ +#corner p.feedback a { + /*color: #9a0404;*/ +} +#corner p.feedback img { + vertical-align: middle; + margin-right: 0.5em; +} From 0846b6491e09f04b63f730f270a0f5d207f3b3b1 Mon Sep 17 00:00:00 2001 From: "jvo(OpenERP)" <> Date: Tue, 14 Dec 2010 10:34:44 +0530 Subject: [PATCH 5/6] [IMP] account: optimized code for __compute method lp bug: https://launchpad.net/bugs/568537 fixed bzr revid: psi@tinyerp.co.in-20101214050444-05jjxgm7xdf8tz17 --- addons/account/account.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 5726a5a793c..bedff44b7e8 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -289,20 +289,20 @@ class account_account(osv.osv): sums = {} while brs: current = brs[0] - can_compute = True - for child in current.child_id: - if child.id not in sums: - can_compute = False - try: - brs.insert(0, brs.pop(brs.index(child))) - except ValueError: - brs.insert(0, child) - if can_compute: - brs.pop(0) - for fn in field_names: - sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0) - if current.child_id: - sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id) +# can_compute = True +# for child in current.child_id: +# if child.id not in sums: +# can_compute = False +# try: +# brs.insert(0, brs.pop(brs.index(child))) +# except ValueError: +# brs.insert(0, child) +# if can_compute: + brs.pop(0) + for fn in field_names: + sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0) + if current.child_id: + sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id) res = {} null_result = dict((fn, 0.0) for fn in field_names) for id in ids: From e1ace70d1c47ad685b90720d1f82332fccc8bd5d Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Tue, 14 Dec 2010 11:45:38 +0530 Subject: [PATCH 6/6] [FIX] Hr_timesheet: hr_timesheet - hr_timesheet_data.xml should not contain demo data lp bug: https://launchpad.net/bugs/689935 fixed bzr revid: mra@mra-laptop-20101214061538-786p5kx602gh2ght --- addons/hr_timesheet/hr_timesheet_data.xml | 16 ---------------- addons/hr_timesheet/hr_timesheet_demo.xml | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/addons/hr_timesheet/hr_timesheet_data.xml b/addons/hr_timesheet/hr_timesheet_data.xml index a19b2c67291..420dcb5a114 100644 --- a/addons/hr_timesheet/hr_timesheet_data.xml +++ b/addons/hr_timesheet/hr_timesheet_data.xml @@ -7,21 +7,5 @@ general - - 75.0 - 30.0 - - - Service on Timesheet - - service - - - - - - - - diff --git a/addons/hr_timesheet/hr_timesheet_demo.xml b/addons/hr_timesheet/hr_timesheet_demo.xml index e7ba5c91342..caaaef12f01 100644 --- a/addons/hr_timesheet/hr_timesheet_demo.xml +++ b/addons/hr_timesheet/hr_timesheet_demo.xml @@ -2,6 +2,21 @@ + + 75.0 + 30.0 + + + Service on Timesheet + + service + + + + + + +