From 258a9bde39111c365c5a2ab10dbc7ce32efa6e0c Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Sat, 14 Jan 2017 12:04:53 +0100 Subject: [PATCH] [FIX] partner_relations: Prevent crash when getting relation type without context passed --- partner_firstname/__openerp__.py | 4 +-- partner_firstname/partner.py | 3 +- .../model/res_partner_relation_all.py | 8 ++--- .../res_partner_relation_type_selection.py | 1 + .../view/res_partner_relation_type.xml | 2 -- partner_relations_in_tab/__openerp__.py | 32 ++----------------- .../view/res_partner_relation_type.xml | 6 ++-- 7 files changed, 15 insertions(+), 41 deletions(-) diff --git a/partner_firstname/__openerp__.py b/partner_firstname/__openerp__.py index c407ab7d3..3a9163d1a 100644 --- a/partner_firstname/__openerp__.py +++ b/partner_firstname/__openerp__.py @@ -17,7 +17,6 @@ # along with this program. If not, see . # ############################################################################## - { 'name': 'Partner first name, last name', 'description': """ @@ -35,8 +34,9 @@ Jonathan Nemry Olivier Laurent """, - 'version': '1.2', + 'version': '7.0.1.2.0', 'author': "Camptocamp,Odoo Community Association (OCA)", + "license": "AGPL-3", 'maintainer': 'Camptocamp, Acsone', 'category': 'Extra Tools', 'website': 'http://www.camptocamp.com, http://www.acsone.eu', diff --git a/partner_firstname/partner.py b/partner_firstname/partner.py index 278848fab..bcb2cd600 100644 --- a/partner_firstname/partner.py +++ b/partner_firstname/partner.py @@ -142,7 +142,6 @@ class ResPartner(orm.Model): readonly=True, fnct_inv=_write_name ), - 'firstname': fields.char("Firstname"), - 'lastname': fields.char("Lastname", required=True), + 'lastname': fields.char("Lastname"), } diff --git a/partner_relations/model/res_partner_relation_all.py b/partner_relations/model/res_partner_relation_all.py index a5ed94bcc..c248b2d26 100644 --- a/partner_relations/model/res_partner_relation_all.py +++ b/partner_relations/model/res_partner_relation_all.py @@ -98,17 +98,17 @@ class ResPartnerRelationAll(Model): } def name_get(self, cr, uid, ids, context=None): - """Create name from both partners and relation.""" - return dict([ + """Name of relation is names of partners involved + type.""" + return [ (this.id, '%s %s %s' % ( this.this_partner_id.name, this.type_selection_id.name_get()[0][1], this.other_partner_id.name, )) - for this in self.browse(cr, uid, ids, context=context)]) + for this in self.browse(cr, uid, ids, context=context)] def write(self, cr, uid, ids, vals, context=None): - """divert non-problematic writes to underlying table""" + """Divert non-problematic writes to underlying table.""" # pylint: disable=W8106 return self.pool['res.partner.relation'].write( cr, uid, diff --git a/partner_relations/model/res_partner_relation_type_selection.py b/partner_relations/model/res_partner_relation_type_selection.py index 5b5e29cb8..18bc2fbf1 100644 --- a/partner_relations/model/res_partner_relation_type_selection.py +++ b/partner_relations/model/res_partner_relation_type_selection.py @@ -133,6 +133,7 @@ class ResPartnerRelationTypeSelection(orm.Model): def name_get(self, cr, uid, ids, context=None): 'translate name using translations from res.partner.relation.type' + context = context or {'lang': 'en_US'} # prevent crash later result = super(ResPartnerRelationTypeSelection, self).name_get( cr, uid, ids, context=context) ir_translation = self.pool['ir.translation'] diff --git a/partner_relations/view/res_partner_relation_type.xml b/partner_relations/view/res_partner_relation_type.xml index d0a3c0746..00b2ff7e9 100644 --- a/partner_relations/view/res_partner_relation_type.xml +++ b/partner_relations/view/res_partner_relation_type.xml @@ -2,7 +2,6 @@ res.partner.relation.type - tree @@ -14,7 +13,6 @@ res.partner.relation.type - form
diff --git a/partner_relations_in_tab/__openerp__.py b/partner_relations_in_tab/__openerp__.py index df2ff20ad..c561be0a5 100644 --- a/partner_relations_in_tab/__openerp__.py +++ b/partner_relations_in_tab/__openerp__.py @@ -1,26 +1,9 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2014 Therp BV (). -# -# 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 . -# -############################################################################## +# © 2014-2017 Therp BV . +# License AGPL-3.0 or later . { "name": "Show partner relations in own tab", - "version": "1.0", + "version": "7.0.1.0.0", "author": "Therp BV,Odoo Community Association (OCA)", "license": "AGPL-3", "complexity": "normal", @@ -37,16 +20,7 @@ relation types are regularly used and should be overseeable at a glace. "data": [ "view/res_partner_relation_type.xml", ], - "js": [ - ], - "css": [ - ], - "qweb": [ - ], "auto_install": False, "installable": True, "application": False, - "external_dependencies": { - 'python': [], - }, } diff --git a/partner_relations_in_tab/view/res_partner_relation_type.xml b/partner_relations_in_tab/view/res_partner_relation_type.xml index 117911258..34270a8d2 100644 --- a/partner_relations_in_tab/view/res_partner_relation_type.xml +++ b/partner_relations_in_tab/view/res_partner_relation_type.xml @@ -3,8 +3,10 @@ res.partner.relation.type - form - +