This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
forked from mga-team/openerp-sale_simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpartner.py
61 lines (52 loc) · 2.26 KB
/
partner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2008 Sylëam Info Services http://www.syleam.fr
# All rights Reserved.
# 2013 Christophe CHAUVET <[email protected]>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from openerp.osv import orm
from openerp.osv import fields
class res_partner_category(orm.Model):
_inherit = 'res.partner.category'
def _check_valid(self, cr, uid, ids, context=None):
for category in self.browse(cr, uid, ids, context=context):
if category.discount < 0 or category.discount > 100:
return False
return True
_columns = {
'discount': fields.float('Discount Control', required=True,
help="If different to 0, it control max value"
"of discount(%) and block if greather")
}
_defaults = {
'discount': 0.0,
}
_constraints = [
(_check_valid,
'Erreur la valeur doit etre comprise entre 0 et 100',
['discount'])
]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: