From 095be21ab17f7f731877d61c99b48b51119ff39a Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 6 Aug 2014 12:47:40 +0200 Subject: [PATCH] [FIX] crm_claim: allow to create claim as portal user It wasn't possible to create claims as a portal user when the portal user had a parent_id --- addons/portal_claim/__init__.py | 1 + addons/portal_claim/portal_claim.py | 39 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 addons/portal_claim/portal_claim.py diff --git a/addons/portal_claim/__init__.py b/addons/portal_claim/__init__.py index 26c654db9dd..dbd07a05428 100644 --- a/addons/portal_claim/__init__.py +++ b/addons/portal_claim/__init__.py @@ -19,3 +19,4 @@ # ############################################################################## +import portal_claim \ No newline at end of file diff --git a/addons/portal_claim/portal_claim.py b/addons/portal_claim/portal_claim.py new file mode 100644 index 00000000000..d7c9c1af6ca --- /dev/null +++ b/addons/portal_claim/portal_claim.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-today 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 License +# along with this program. If not, see . +# +############################################################################## + +from openerp import SUPERUSER_ID +from openerp.addons.base_status.base_stage import base_stage +from openerp.osv import osv + + +class crm_claim(base_stage, osv.osv): + _inherit = "crm.claim" + + def default_get(self, cr, uid, fields, context=None): + res = super(crm_claim, self).default_get(cr, uid, fields, context=context) + if isinstance(res.get('partner_id'), (int, long)): + # Special case for portal users, as they are not allowed to call name_get on res.partner + # We save this call for the web client by returning it in default get + res['partner_id'] = self.pool['res.partner'].name_get( + cr, SUPERUSER_ID, [res['partner_id']], context=context)[0] + return res + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: