1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# sale_margin module for OpenERP, add margin in sale order and invoice
5
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6
# Copyright (C) 2009 EVERLIBRE (<http://www.Everlibre.fr>) Éric VERNICHON
7
# Copyright (C) 2009 SYLEAM (<http://www.Syleam.fr>) Sebastien LANGE
9
# This file is a part of sale_margin
11
# sale_margin is free software: you can redistribute it and/or modify
12
# it under the terms of the GNU General Public License as published by
13
# the Free Software Foundation, either version 3 of the License, or
14
# (at your option) any later version.
16
# sale_margin 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.
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/>.
24
##############################################################################
26
from osv import fields,osv
28
from tools import config
31
class account_invoice_line(osv.osv):
32
_name = "account.invoice.line"
33
_inherit = "account.invoice.line"
35
'cost_price': fields.float('Cost Price', digits=(16, 2)),
37
def write(self, cr, uid, ids, vals, context={}):
38
if vals.get('product_id' , False):
39
res=self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
40
vals['cost_price']=res[0]['standard_price']
41
return super(account_invoice_line, self).write(cr, uid, ids, vals, context)
43
def create(self, cr, uid, vals, context={}):
44
if vals.get('product_id',False):
45
res=self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
46
vals['cost_price']=res[0]['standard_price']
47
return super(account_invoice_line, self).create(cr, uid, vals, context)
48
account_invoice_line()
51
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: