[VIEW][PYTHON][TRANS] +fixed price field in products categories
[burette/etudesetchantiersidf.git] / product.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 # etudesetchantiersidf module for OpenERP, Custom module for Étude et
5 # Chantiers île-de-France
6 # Copyright (C) 2014-2018 etudesetchantiersidf
7 # (<http://etudesetchantiersiledefrance.unarec.org/>)
8 #
9 # This file is a part of etudesetchantiersidf
10 #
11 # etudesetchantiersidf is free software: you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as published
13 # by the Free Software Foundation, either version 3 of the License, or (at
14 # your option) any later version.
15 #
16 # etudesetchantiersidf is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #
24 ##############################################################################
25
26 from openerp.osv import osv
27 from openerp.osv import orm
28 from openerp.osv import fields
29
30
31 class product_category(orm.Model):
32 _inherit = 'product.category'
33
34 _columns = {
35 'is_fixed_price': fields.boolean('Fixed price', help='Check this box to \
36 prevent price change for products \
37 belong to this category'),
38 }
39
40 class product_product(orm.Model):
41 _inherit = 'product.product'
42
43 def is_fixed_price_get(self, cr, uid, ids, name, args, context=None):
44 """Return if products are fixed price or not"""
45 res = {}
46 for product in self.browse(cr, uid, ids, context=context):
47 categ = product.product_tmpl_id.categ_id
48 res[product.id] = categ.is_fixed_price
49 return res
50
51 _columns = {
52 'is_fixed_price': fields.function(is_fixed_price_get,
53 method=True,
54 string='Fixed price',
55 type='boolean',
56 store=False),
57 }
58
59
60 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: