From 601804a87ba2af5da9a8d5f2f7d6e12ee19039c7 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sat, 28 Aug 2010 17:18:49 +0300 Subject: [PATCH] crm, product: Tolerate missing shortcut for res_users.create() Those 2 addons try to attach a shortcur to every new user created. However, this data may be missing (eg. during the install of "product, idea" to a clean db). We shouldn't block the creation of users. bzr revid: p_christ@hol.gr-20100828141849-wzibtjq02cscg98v --- addons/crm/crm_meeting.py | 18 +++++++++++++----- addons/product/product.py | 22 +++++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index d8acbff7555..5fc98053046 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -25,6 +25,7 @@ from datetime import datetime, timedelta from osv import fields, osv from tools.translate import _ import time +import logging class crm_lead(crm_case, osv.osv): """ CRM Leads """ @@ -178,13 +179,20 @@ class res_users(osv.osv): _name = 'res.users' _inherit = 'res.users' - def create(self, cr, uid, data, context={}): + def create(self, cr, uid, data, context=None): + if context is None: + context = {} user_id = super(res_users, self).create(cr, uid, data, context) data_obj = self.pool.get('ir.model.data') - data_id = data_obj._get_id(cr, uid, 'crm', 'ir_ui_view_sc_calendar0') - view_id = data_obj.browse(cr, uid, data_id, context=context).res_id - copy_id = self.pool.get('ir.ui.view_sc').copy(cr, uid, view_id, default = { - 'user_id': user_id}, context=context) + try: + data_id = data_obj._get_id(cr, uid, 'crm', 'ir_ui_view_sc_calendar0') + view_id = data_obj.browse(cr, uid, data_id, context=context).res_id + copy_id = self.pool.get('ir.ui.view_sc').copy(cr, uid, view_id, default = { + 'user_id': user_id}, context=context) + except ValueError: + # Tolerate a missing shortcut. See product/product.py for similar code. + logging.getLogger('orm').warning('Skipped Products shortcut for user "%s"', data.get('name','