[PYTHON] fix: -pdb trace
[burette/etudesetchantiersidf.git] / point_of_sale.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-2019 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 pos_order_line(orm.Model):
32 _inherit = 'pos.order.line'
33
34 def create(self, cr, uid, vals, context=None):
35 product_id = vals['product_id']
36 products_obj = self.pool.get('product.product')
37 product = products_obj.browse(cr, uid, product_id, context=context)
38 if product.is_fixed_price:
39 vals['price_unit'] = product.list_price
40 res = super(pos_order_line, self).create(cr, uid, vals, context=context)
41 return res
42
43 def onchange_product_id(self, cr, uid, ids, pricelist, product_id, qty=0, partner_id=False, context=None):
44 res = super(pos_order_line, self).onchange_product_id(cr, uid, ids, pricelist, product_id, qty, partner_id, context=context)
45 if product_id:
46 products_obj = self.pool.get('product.product')
47 product = products_obj.browse(cr, uid, product_id, context=context)
48 res['value'].update({'is_fixed_price': product.is_fixed_price})
49 return res
50
51 _columns = {
52 'is_fixed_price': fields.boolean('Fixed price'),
53 }
54
55 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: