1 ##############################################################################
3 # OpenERP, Open Source Management Solution
4 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 ##############################################################################
21 from osv import fields,osv
23 from tools import config
25 class account_invoice_line(osv.osv):
26 _name = "account.invoice.line"
27 _inherit = "account.invoice.line"
29 'cost_price': fields.float('Cost Price', digits=(16, 2)),
31 def write(self, cr, uid, ids, vals, context={}):
32 if vals.get('product_id', False):
33 res = self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
34 vals['cost_price'] = res[0]['standard_price']
35 return super(account_invoice_line, self).write(cr, uid, ids, vals, context)
37 def create(self, cr, uid, 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).create(cr, uid, vals, context)
42 account_invoice_line()
44 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: