# -*- coding: utf-8 -*-
##############################################################################
#
# etudesetchantiersidf module for OpenERP, Custom module for Étude et
# Chantiers île-de-France
# Copyright (C) 2014-2019 etudesetchantiersidf
# ()
#
# This file is a part of etudesetchantiersidf
#
# etudesetchantiersidf 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 3 of the License, or (at
# your option) any later version.
#
# etudesetchantiersidf 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, see .
#
##############################################################################
from openerp.osv import osv
from openerp.osv import orm
from openerp.osv import fields
class pos_order_line(orm.Model):
_inherit = 'pos.order.line'
def create(self, cr, uid, vals, context=None):
product_id = vals['product_id']
products_obj = self.pool.get('product.product')
product = products_obj.browse(cr, uid, product_id, context=context)
import pdb
pdb.set_trace()
if product.is_fixed_price:
vals['price_unit'] = product.list_price
res = super(pos_order_line, self).create(cr, uid, vals, context=context)
return res
def onchange_product_id(self, cr, uid, ids, pricelist, product_id, qty=0, partner_id=False, context=None):
res = super(pos_order_line, self).onchange_product_id(cr, uid, ids, pricelist, product_id, qty, partner_id, context=context)
if product_id:
products_obj = self.pool.get('product.product')
product = products_obj.browse(cr, uid, product_id, context=context)
res['value'].update({'is_fixed_price': product.is_fixed_price})
return res
_columns = {
'is_fixed_price': fields.boolean('Fixed price'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: