1
# -*- coding: utf-8 -*-
2
'''Define model res.partner.relation.type'''
3
##############################################################################
5
# OpenERP, Open Source Management Solution
6
# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU Affero General Public License as
10
# published by the Free Software Foundation, either version 3 of the
11
# License, or (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU Affero General Public License for more details.
18
# You should have received a copy of the GNU Affero General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
22
from openerp.osv.orm import Model
23
from openerp.osv import fields
26
class ResPartnerRelationType(Model):
27
'''Model that defines relation types that might exist between partners'''
28
_name = 'res.partner.relation.type'
29
_description = 'Parter relation type'
32
def _get_partner_types(self, cr, uid, context=None):
33
return (('c', 'Company'), ('p', 'Person'),)
37
'Name', size=128, required=True, translate=True),
38
'name_inverse': fields.char(
39
'Inverse name', size=128, required=True, translate=True),
40
'contact_type_left': fields.selection(
41
_get_partner_types, 'Left partner type'),
42
'contact_type_right': fields.selection(
43
_get_partner_types, 'Right partner type'),
44
'partner_category_left': fields.many2one(
45
'res.partner.category', 'Left partner category'),
46
'partner_category_right': fields.many2one(
47
'res.partner.category', 'Right partner category'),
51
class ResPartnerRelationTypeInverse(Model):
52
'''Model to describe inverse of model res.partner.relation.type'''
53
_name = 'res.partner.relation.type.inverse'
54
_description = 'Parter relation type'
58
self, cr, uid, name='', args=None, operator='ilike',
59
context=None, limit=100):
60
type_model = self.pool['res.partner.relation.type']
61
type_ids = type_model.search(
63
(args or []) + [('name_inverse', operator, name)],
66
type_records = type_model.read(
67
cr, uid, type_ids, ['name_inverse'], context=context)
68
return [(r['id'], r['name_inverse']) for r in type_records]