1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # cyclofficine_pantin module for OpenERP, Custom module for La Cyclofficine
7 # Copyright (C) 2015-2016 cyclofficine_pantin
8 # (<http://cyclocoop.org/index.php/les-ateliers/pantin/>)
10 # This file is a part of cyclofficine_pantin
12 # cyclofficine_pantin is free software: you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as published
14 # by the Free Software Foundation, either version 3 of the License, or (at
15 # your option) any later version.
17 # cyclofficine_pantin is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ##############################################################################
26 from openerp
.osv
import osv
27 from openerp
.osv
import orm
28 from openerp
.osv
import fields
31 class Partner(orm
.Model
):
32 _inherit
= 'res.partner'
34 _order
= 'member_ident,name asc'
36 def _check_member_ident_length(self
, cr
, uid
, ids
, context
=None):
37 # Check if member ident length is equal to sequence padding.
38 sequences
= self
.pool
.get('ir.sequence')
39 id_mb_seq
= sequences
.search(cr
, uid
,
40 [('name', '=', 'Member identifier')],
41 limit
=1, context
=context
)
42 mb_sequences
= sequences
.browse(cr
, uid
, id_mb_seq
, context
=context
)
44 partners
= self
.browse(cr
, uid
, ids
, context
=context
)
45 for mb_seq
in mb_sequences
:
46 padding
= mb_seq
.padding
48 for partner
in partners
:
49 if partner
.member_ident
:
50 mb_ident_length
= len(partner
.member_ident
)
51 if not mb_ident_length
== padding
:
57 (_check_member_ident_length
,
58 'This member indentifier has not a good length.', ['member_ident']),
61 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: