From f17afd9d8964d91b31672d346d742b99411d2746 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Wed, 3 Mar 2010 14:04:35 +0100 Subject: [PATCH 01/15] [REF] Use the logging module instead of the Logger().notifyChannel() function bzr revid: stephane@openerp.com-20100303130435-027rr4aw8k1tz4tj --- bin/netsvc.py | 55 +++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/bin/netsvc.py b/bin/netsvc.py index 9f4cd0c8e39..d8548db5d6a 100644 --- a/bin/netsvc.py +++ b/bin/netsvc.py @@ -24,18 +24,13 @@ # ############################################################################## -import SimpleXMLRPCServer -import SocketServer import logging import logging.handlers -import os -import signal -import socket import sys import threading import time -import xmlrpclib import release +from pprint import pformat import warnings class Service(object): @@ -78,6 +73,7 @@ class LocalService(object): Any instance of this class will behave like the single instance of Service(name) """ + __logger = logging.getLogger('service') def __init__(self, name): self.__name = name try: @@ -85,8 +81,9 @@ class LocalService(object): for method_name, method_definition in self._service._methods.items(): setattr(self, method_name, method_definition) except KeyError, keyError: - Logger().notifyChannel('module', LOG_ERROR, 'This service does not exist: %s' % (str(keyError),) ) + self.__logger.error('This service does not exist: %s' % (str(keyError),) ) raise + def __call__(self, method, *params): return getattr(self, method)(*params) @@ -234,7 +231,7 @@ class Logger(object): try: msg = tools.ustr(msg).strip() - if level in (LOG_ERROR,LOG_CRITICAL) and tools.config.get_misc('debug','env_info',False): + if level in (LOG_ERROR, LOG_CRITICAL) and tools.config.get_misc('debug','env_info',False): msg = common().exp_get_server_environment() + "\n" + msg result = msg.split('\n') @@ -270,10 +267,12 @@ class Agent(object): _timers = {} _logger = Logger() + __logger = logging.getLogger('timer') + def setAlarm(self, fn, dt, db_name, *args, **kwargs): wait = dt - time.time() if wait > 0: - self._logger.notifyChannel('timers', LOG_DEBUG, "Job scheduled in %.3g seconds for %s.%s" % (wait, fn.im_class.__name__, fn.func_name)) + self.__logger.debug("Job scheduled in %.3g seconds for %s.%s" % (wait, fn.im_class.__name__, fn.func_name)) timer = threading.Timer(wait, fn, args, kwargs) timer.start() self._timers.setdefault(db_name, []).append(timer) @@ -300,25 +299,26 @@ import traceback class Server: """ Generic interface for all servers with an event loop etc. Override this to impement http, net-rpc etc. servers. - + Servers here must have threaded behaviour. start() must not block, there is no run(). """ __is_started = False __servers = [] - + + + __logger = logging.getLogger('server') + def __init__(self): if Server.__is_started: raise Exception('All instances of servers must be inited before the startAll()') Server.__servers.append(self) def start(self): - print "called stub Server.start" - pass - + self.__logger.debug("called stub Server.start") + def stop(self): - print "called stub Server.stop" - pass + self.__logger.debug("called stub Server.stop") def stats(self): """ This function should return statistics about the server """ @@ -328,35 +328,25 @@ class Server: def startAll(cls): if cls.__is_started: return - Logger().notifyChannel("services", LOG_INFO, - "Starting %d services" % len(cls.__servers)) + cls.__logger.info("Starting %d services" % len(cls.__servers)) for srv in cls.__servers: srv.start() cls.__is_started = True - + @classmethod def quitAll(cls): if not cls.__is_started: return - Logger().notifyChannel("services", LOG_INFO, - "Stopping %d services" % len(cls.__servers)) + cls.__logger.info("Stopping %d services" % len(cls.__servers)) for srv in cls.__servers: srv.stop() cls.__is_started = False @classmethod def allStats(cls): - res = '' - if cls.__is_started: - res += "Servers started\n" - else: - res += "Servers stopped\n" - for srv in cls.__servers: - try: - res += srv.stats() + "\n" - except: - pass - return res + res = ["Servers %s" % ('stopped', 'started')[cls.__is_started]] + res.extend(srv.stats() for srv in cls.__servers) + return '\n'.join(res) class OpenERPDispatcherException(Exception): def __init__(self, exception, traceback): @@ -365,7 +355,6 @@ class OpenERPDispatcherException(Exception): class OpenERPDispatcher: def log(self, title, msg): - from pprint import pformat Logger().notifyChannel('%s' % title, LOG_DEBUG_RPC, pformat(msg)) def dispatch(self, service_name, method, params): From eda52fba9ff3de61c61a36329f0e64dfd08409a7 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Wed, 3 Mar 2010 14:46:06 +0100 Subject: [PATCH 02/15] [REF] Remove the unused ir_fields_description.py file bzr revid: stephane@openerp.com-20100303134606-dprr4dy6pgqio863 --- bin/addons/base/ir/ir_fields_description.py | 28 --------------------- 1 file changed, 28 deletions(-) delete mode 100644 bin/addons/base/ir/ir_fields_description.py diff --git a/bin/addons/base/ir/ir_fields_description.py b/bin/addons/base/ir/ir_fields_description.py deleted file mode 100644 index 9a3b5424a58..00000000000 --- a/bin/addons/base/ir/ir_fields_description.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). -# -# 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 osv import fields,osv -import ir - - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - From a859e3d091585ed2782af8d7a8a2701f61079921 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 3 Mar 2010 14:58:10 +0100 Subject: [PATCH 03/15] [IMP] confirm date on so bzr revid: fp@tinyerp.com-20100303135810-mhlbcdgsfw5n12ir --- addons/sale/sale.py | 15 ++++++++------- addons/sale/sale_view.xml | 32 +++++++++++++++++++++++--------- addons/sale/sale_workflow.xml | 2 -- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index a9d0935fc76..fefb13cb8d7 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -197,7 +197,8 @@ class sale_order(osv.osv): ('cancel', 'Cancelled') ], 'Order State', readonly=True, help="Gives the state of the quotation or sale order. The exception state is automatically set when a cancel operation occurs in the invoice validation (Invoice Exception) or in the picking list process (Shipping Exception). The 'Waiting Schedule' state is set when the invoice is confirmed but waiting for the scheduler to run on the date 'Ordered Date'.", select=True), 'date_order': fields.date('Ordered Date', required=True, readonly=True, states={'draft': [('readonly', False)]}), - + 'create_date': fields.date('Creation Date', readonly=True), + 'date_confirm': fields.date('confirmation Date', readonly=True), 'user_id': fields.many2one('res.users', 'Salesman', states={'draft': [('readonly', False)]}, select=True), 'partner_id': fields.many2one('res.partner', 'Customer', readonly=True, states={'draft': [('readonly', False)]}, required=True, change_default=True, select=True), 'partner_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, required=True, states={'draft': [('readonly', False)]}), @@ -361,10 +362,10 @@ class sale_order(osv.osv): def button_dummy(self, cr, uid, ids, context={}): return True -#FIXME: the method should return the list of invoices created (invoice_ids) -# and not the id of the last invoice created (res). The problem is that we -# cannot change it directly since the method is called by the sale order -# workflow and I suppose it expects a single id... + #FIXME: the method should return the list of invoices created (invoice_ids) + # and not the id of the last invoice created (res). The problem is that we + # cannot change it directly since the method is called by the sale order + # workflow and I suppose it expects a single id... def _inv_get(self, cr, uid, order, context={}): return {} @@ -522,9 +523,9 @@ class sale_order(osv.osv): 'partner_type': 'customer', 'probability': 1.0,\ 'planned_revenue': o.amount_untaxed}) if (o.order_policy == 'manual'): - self.write(cr, uid, [o.id], {'state': 'manual'}) + self.write(cr, uid, [o.id], {'state': 'manual', 'date_confirm': time.strftime('%Y-%m-%d')}) else: - self.write(cr, uid, [o.id], {'state': 'progress'}) + self.write(cr, uid, [o.id], {'state': 'progress', 'date_confirm': time.strftime('%Y-%m-%d')}) self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line]) def procurement_lines_get(self, cr, uid, ids, *args): diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index e48d59d1f4a..9e8fe820d37 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -204,15 +204,29 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/addons/sale/sale_workflow.xml b/addons/sale/sale_workflow.xml index 6a7e7b6a8ee..213605929ba 100644 --- a/addons/sale/sale_workflow.xml +++ b/addons/sale/sale_workflow.xml @@ -58,7 +58,6 @@ stopall action_cancel() - invoice @@ -85,7 +84,6 @@ stopall action_cancel() - ship From 76c6da87917f369c2fd606e598b808306be4818c Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 3 Mar 2010 14:59:07 +0100 Subject: [PATCH 04/15] merge bzr revid: fp@tinyerp.com-20100303135907-28m82yckqmlb25lb --- addons/sale/sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index fefb13cb8d7..0c0542d6747 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -198,7 +198,7 @@ class sale_order(osv.osv): ], 'Order State', readonly=True, help="Gives the state of the quotation or sale order. The exception state is automatically set when a cancel operation occurs in the invoice validation (Invoice Exception) or in the picking list process (Shipping Exception). The 'Waiting Schedule' state is set when the invoice is confirmed but waiting for the scheduler to run on the date 'Ordered Date'.", select=True), 'date_order': fields.date('Ordered Date', required=True, readonly=True, states={'draft': [('readonly', False)]}), 'create_date': fields.date('Creation Date', readonly=True), - 'date_confirm': fields.date('confirmation Date', readonly=True), + 'date_confirm': fields.date('Confirmation Date', readonly=True), 'user_id': fields.many2one('res.users', 'Salesman', states={'draft': [('readonly', False)]}, select=True), 'partner_id': fields.many2one('res.partner', 'Customer', readonly=True, states={'draft': [('readonly', False)]}, required=True, change_default=True, select=True), 'partner_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, required=True, states={'draft': [('readonly', False)]}), From 948e89992f103d70c3bea8c109c44e7f28caab0e Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 3 Mar 2010 16:36:11 +0100 Subject: [PATCH 05/15] [imp] migrate datas warning in browse_record to logging bzr revid: xmo@tinyerp.com-20100303153611-kfdmr4uoeaf8nia7 --- bin/osv/orm.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index c0caf70087c..4dd222f561c 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -41,6 +41,7 @@ import calendar import copy import datetime +import logging import pickle import random import re @@ -139,6 +140,8 @@ class browse_record(object): self._id = id self._table = table self._table_name = self._table._name + self.__logger = logging.getLogger( + 'osv.browse_record.' + self._table_name) self._context = context self._fields_process = fields_process @@ -210,9 +213,8 @@ class browse_record(object): if not datas: # Where did those ids come from? Perhaps old entries in ir_model_dat? - self.logger.notifyChannel("browse_record", netsvc.LOG_WARNING, - "No datas found for ids %s in %s \n%s" % ( - ids, self, ''.join(traceback.format_exc()))) + self.__logger.warn("No datas found for ids %s in %s", + ids, self) raise KeyError('Field %s not found in %s'%(name,self)) # create browse records for 'remote' objects for data in datas: From ca39947d11c1a94ded13d4bd9b683cec4c6eaab0 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 3 Mar 2010 16:40:41 +0100 Subject: [PATCH 06/15] [fix] for some addons, multiple toplevel menus with the same name are created, generating a single ir.ui.menu entry but multiple ir.model.data for the (ir.ui.menu, @id) specified. Ensure that we remove all ir.model.data matching a given ir.ui.menu, not just a random one or upgrade fails when we try to go from the leftover ir.model.data to the (now missing) ir.ui.menu lp bug: https://launchpad.net/bugs/530835 fixed bzr revid: xmo@tinyerp.com-20100303154041-37hzymi7e5ur9yb6 --- bin/addons/base/ir/ir_model.py | 37 +++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/bin/addons/base/ir/ir_model.py b/bin/addons/base/ir/ir_model.py index 37ded33397b..db03cef116f 100644 --- a/bin/addons/base/ir/ir_model.py +++ b/bin/addons/base/ir/ir_model.py @@ -18,7 +18,8 @@ # along with this program. If not, see . # ############################################################################## - +import logging +from operator import itemgetter from osv import fields,osv import ir, re import netsvc @@ -417,6 +418,7 @@ ir_model_access() class ir_model_data(osv.osv): _name = 'ir.model.data' + __logger = logging.getLogger('addons.base.'+_name) _columns = { 'name': fields.char('XML Identifier', required=True, size=128), 'model': fields.char('Object', required=True, size=64), @@ -599,22 +601,37 @@ class ir_model_data(osv.osv): wf_service.trg_write(uid, model, id, cr) cr.commit() - if not config.get('import_partial', False): - logger = netsvc.Logger() + if not config.get('import_partial'): for (model, res_id) in self.unlink_mark.keys(): if self.pool.get(model): - logger.notifyChannel('init', netsvc.LOG_INFO, 'Deleting %s@%s' % (res_id, model)) + self.__logger.info('Deleting %s@%s', res_id, model) try: self.pool.get(model).unlink(cr, uid, [res_id]) - id = self.unlink_mark[(model, res_id)] if id: - self.unlink(cr, uid, [id]) - cr.execute('DELETE FROM ir_values WHERE value=%s', ('%s,%s' % (model, res_id),)) + ids = self.search(cr, uid, [('res_id','=',res_id), + ('model','=',model)]) + self.__logger.debug('=> Deleting %s: %s', + self._name, ids) + if len(ids) > 1 and \ + self.__logger.isEnabledFor(logging.WARNING): + self.__logger.warn( + 'Got %d %s for (%s, %d): %s', + len(ids), self._name, model, res_id, + map(itemgetter('module','name'), + self.read(cr, uid, ids, + ['name', 'module']))) + self.unlink(cr, uid, ids) + cr.execute( + 'DELETE FROM ir_values WHERE value=%s', + ('%s,%s'%(model, res_id),)) cr.commit() - except Exception, e: + except Exception: cr.rollback() - logger.notifyChannel('init', netsvc.LOG_ERROR, e) - logger.notifyChannel('init', netsvc.LOG_ERROR, 'Could not delete id: %d of model %s\nThere should be some relation that points to this resource\nYou should manually fix this and restart --update=module' % (res_id, model)) + self.__logger.exception( + 'Could not delete id: %d of model %s\nThere ' + 'should be some relation that points to this ' + 'resource\nYou should manually fix this and ' + 'restart with --update=module', res_id, model) return True ir_model_data() From ca854b98ba3ab8717f431620ef6ca2a6951065b6 Mon Sep 17 00:00:00 2001 From: Launchpad Code Hosting Date: Thu, 4 Mar 2010 04:52:14 +0000 Subject: [PATCH 07/15] Launchpad automatic translations update. bzr revid: codehost@crowberry-20100304045214-zrx2me4aqrltx0zo --- bin/addons/base/i18n/hr.po | 4 ++-- bin/addons/base/i18n/ja.po | 6 +++--- bin/addons/base/i18n/uk.po | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/addons/base/i18n/hr.po b/bin/addons/base/i18n/hr.po index c6f03c89808..9537a0c20e8 100644 --- a/bin/addons/base/i18n/hr.po +++ b/bin/addons/base/i18n/hr.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 5.0.4\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-12-18 08:39+0000\n" -"PO-Revision-Date: 2010-03-02 05:28+0000\n" +"PO-Revision-Date: 2010-03-03 12:31+0000\n" "Last-Translator: goranc \n" "Language-Team: openerp-translators\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-03-03 04:45+0000\n" +"X-Launchpad-Export-Date: 2010-03-04 04:52+0000\n" "X-Generator: Launchpad (build Unknown)\n" "Language: hr\n" diff --git a/bin/addons/base/i18n/ja.po b/bin/addons/base/i18n/ja.po index 834624306a4..5536334e978 100644 --- a/bin/addons/base/i18n/ja.po +++ b/bin/addons/base/i18n/ja.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-server\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2009-12-18 08:39+0000\n" -"PO-Revision-Date: 2010-03-02 05:31+0000\n" -"Last-Translator: OpenERP Administrators \n" +"PO-Revision-Date: 2010-03-03 11:42+0000\n" +"Last-Translator: Harry (Open ERP) \n" "Language-Team: Japanese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-03-03 04:45+0000\n" +"X-Launchpad-Export-Date: 2010-03-04 04:52+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: base diff --git a/bin/addons/base/i18n/uk.po b/bin/addons/base/i18n/uk.po index 66bb3b18544..e4b56f5b302 100644 --- a/bin/addons/base/i18n/uk.po +++ b/bin/addons/base/i18n/uk.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 5.0.0\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-12-18 08:39+0000\n" -"PO-Revision-Date: 2010-01-27 05:47+0000\n" +"PO-Revision-Date: 2010-03-03 12:33+0000\n" "Last-Translator: Fabien (Open ERP) \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-01-28 04:34+0000\n" +"X-Launchpad-Export-Date: 2010-03-04 04:52+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: base From b1175ec0876521c9bce745dba9eab678ecd0fb8c Mon Sep 17 00:00:00 2001 From: "noz@tinyerp.com" <> Date: Thu, 4 Mar 2010 11:54:34 +0530 Subject: [PATCH 08/15] [IMP] Added HTML tag support in rng file. bzr revid: noz@tinyerp.com-20100304062434-ctsqkqsdsb6bu6wj --- bin/addons/base/rng/view.rng | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/bin/addons/base/rng/view.rng b/bin/addons/base/rng/view.rng index 766b75bf9c3..4dc74d0294c 100644 --- a/bin/addons/base/rng/view.rng +++ b/bin/addons/base/rng/view.rng @@ -12,7 +12,7 @@ - + @@ -23,6 +23,7 @@ + @@ -46,13 +47,14 @@ - + + @@ -74,6 +76,7 @@ + @@ -86,6 +89,12 @@ + + + + + + @@ -111,6 +120,7 @@ + @@ -125,6 +135,7 @@ + @@ -140,6 +151,7 @@ + @@ -149,6 +161,7 @@ + @@ -158,6 +171,7 @@ + @@ -190,7 +204,7 @@ - + @@ -200,6 +214,7 @@ + @@ -230,10 +245,11 @@ - + + @@ -249,6 +265,7 @@ + @@ -269,6 +286,7 @@ + @@ -349,6 +367,7 @@ + @@ -376,7 +395,7 @@ - + @@ -386,6 +405,7 @@ + @@ -403,6 +423,7 @@ + @@ -415,6 +436,7 @@ + @@ -454,6 +476,7 @@ + @@ -493,6 +516,7 @@ + @@ -528,6 +552,7 @@ + From 22200c4c5f1811d249400fae585d800512cba861 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 4 Mar 2010 07:39:52 +0100 Subject: [PATCH 09/15] [IMP] better views bzr revid: fp@tinyerp.com-20100304063952-dtrqbmwo3r2wz2ki --- addons/crm/crm_lead_view.xml | 2 +- addons/crm/crm_opportunity.py | 2 +- addons/crm/crm_opportunity_view.xml | 2 ++ addons/sale/sale_view.xml | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 9039f00381c..c81f6040a3d 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -29,7 +29,7 @@
- + diff --git a/addons/crm/crm_opportunity.py b/addons/crm/crm_opportunity.py index 84141bdbfc2..f993e79a13f 100644 --- a/addons/crm/crm_opportunity.py +++ b/addons/crm/crm_opportunity.py @@ -26,7 +26,7 @@ AVAILABLE_STATES = [ ('draft','New'), ('open','Open'), ('cancel', 'Lost'), - ('done', 'Won'), + ('done', 'Converted'), ('pending','Pending') ] diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml index 9fa6108e70f..9546906d020 100644 --- a/addons/crm/crm_opportunity_view.xml +++ b/addons/crm/crm_opportunity_view.xml @@ -149,6 +149,8 @@ + +