Browse Source

[FIX] partner_relations: Prevent crash when getting relation type without context passed

7.0
Ronald Portier 8 years ago
committed by Pedro M. Baeza
parent
commit
258a9bde39
  1. 4
      partner_firstname/__openerp__.py
  2. 3
      partner_firstname/partner.py
  3. 8
      partner_relations/model/res_partner_relation_all.py
  4. 1
      partner_relations/model/res_partner_relation_type_selection.py
  5. 2
      partner_relations/view/res_partner_relation_type.xml
  6. 32
      partner_relations_in_tab/__openerp__.py
  7. 6
      partner_relations_in_tab/view/res_partner_relation_type.xml

4
partner_firstname/__openerp__.py

@ -17,7 +17,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
{ {
'name': 'Partner first name, last name', 'name': 'Partner first name, last name',
'description': """ 'description': """
@ -35,8 +34,9 @@ Jonathan Nemry <jonathan.nemry@acsone.eu>
Olivier Laurent <olivier.laurent@acsone.eu> Olivier Laurent <olivier.laurent@acsone.eu>
""", """,
'version': '1.2',
'version': '7.0.1.2.0',
'author': "Camptocamp,Odoo Community Association (OCA)", 'author': "Camptocamp,Odoo Community Association (OCA)",
"license": "AGPL-3",
'maintainer': 'Camptocamp, Acsone', 'maintainer': 'Camptocamp, Acsone',
'category': 'Extra Tools', 'category': 'Extra Tools',
'website': 'http://www.camptocamp.com, http://www.acsone.eu', 'website': 'http://www.camptocamp.com, http://www.acsone.eu',

3
partner_firstname/partner.py

@ -142,7 +142,6 @@ class ResPartner(orm.Model):
readonly=True, readonly=True,
fnct_inv=_write_name fnct_inv=_write_name
), ),
'firstname': fields.char("Firstname"), 'firstname': fields.char("Firstname"),
'lastname': fields.char("Lastname", required=True),
'lastname': fields.char("Lastname"),
} }

8
partner_relations/model/res_partner_relation_all.py

@ -98,17 +98,17 @@ class ResPartnerRelationAll(Model):
} }
def name_get(self, cr, uid, ids, context=None): 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.id, '%s %s %s' % (
this.this_partner_id.name, this.this_partner_id.name,
this.type_selection_id.name_get()[0][1], this.type_selection_id.name_get()[0][1],
this.other_partner_id.name, 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): 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 # pylint: disable=W8106
return self.pool['res.partner.relation'].write( return self.pool['res.partner.relation'].write(
cr, uid, cr, uid,

1
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): def name_get(self, cr, uid, ids, context=None):
'translate name using translations from res.partner.relation.type' 'translate name using translations from res.partner.relation.type'
context = context or {'lang': 'en_US'} # prevent crash later
result = super(ResPartnerRelationTypeSelection, self).name_get( result = super(ResPartnerRelationTypeSelection, self).name_get(
cr, uid, ids, context=context) cr, uid, ids, context=context)
ir_translation = self.pool['ir.translation'] ir_translation = self.pool['ir.translation']

2
partner_relations/view/res_partner_relation_type.xml

@ -2,7 +2,6 @@
<data> <data>
<record id="tree_res_partner_relation_type" model="ir.ui.view"> <record id="tree_res_partner_relation_type" model="ir.ui.view">
<field name="model">res.partner.relation.type</field> <field name="model">res.partner.relation.type</field>
<field name="type">tree</field>
<field type="xml" name="arch"> <field type="xml" name="arch">
<tree version="7.0" string="Partner relation"> <tree version="7.0" string="Partner relation">
<field name="name" /> <field name="name" />
@ -14,7 +13,6 @@
</record> </record>
<record id="form_res_partner_relation_type" model="ir.ui.view"> <record id="form_res_partner_relation_type" model="ir.ui.view">
<field name="model">res.partner.relation.type</field> <field name="model">res.partner.relation.type</field>
<field name="type">form</field>
<field type="xml" name="arch"> <field type="xml" name="arch">
<form version="7.0" string="Partner relation"> <form version="7.0" string="Partner relation">
<sheet> <sheet>

32
partner_relations_in_tab/__openerp__.py

@ -1,26 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2014-2017 Therp BV <http://therp.nl>.
# License AGPL-3.0 or later <http://www.gnu.org/licenses/agpl.html>.
{ {
"name": "Show partner relations in own tab", "name": "Show partner relations in own tab",
"version": "1.0",
"version": "7.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)", "author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"complexity": "normal", "complexity": "normal",
@ -37,16 +20,7 @@ relation types are regularly used and should be overseeable at a glace.
"data": [ "data": [
"view/res_partner_relation_type.xml", "view/res_partner_relation_type.xml",
], ],
"js": [
],
"css": [
],
"qweb": [
],
"auto_install": False, "auto_install": False,
"installable": True, "installable": True,
"application": False, "application": False,
"external_dependencies": {
'python': [],
},
} }

6
partner_relations_in_tab/view/res_partner_relation_type.xml

@ -3,8 +3,10 @@
<data> <data>
<record id="form_res_partner_relation_type" model="ir.ui.view"> <record id="form_res_partner_relation_type" model="ir.ui.view">
<field name="model">res.partner.relation.type</field> <field name="model">res.partner.relation.type</field>
<field name="type">form</field>
<field name="inherit_id" ref="partner_relations.form_res_partner_relation_type" />
<field
name="inherit_id"
ref="partner_relations.form_res_partner_relation_type"
/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<data> <data>
<field name="partner_category_left" position="after"> <field name="partner_category_left" position="after">

Loading…
Cancel
Save