~openerp-commiter/openobject-addons/trunk-extra-addons

« back to all changes in this revision

Viewing changes to sale_margin/invoice_margin.py

merging new development from indian accounting

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
1
2
##############################################################################
2
3
#
3
4
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
33
34
import time
34
35
 
35
36
class account_invoice_line(osv.osv):
36
 
        _name = "account.invoice.line"
37
 
        _inherit = "account.invoice.line"
38
 
        _columns = {
39
 
                'cost_price': fields.float('Cost Price', digits=(16, 2)),
40
 
        }
41
 
        def write(self, cr, uid, ids, vals, context={}):
42
 
                if 'product_id' in vals:
43
 
                        res=self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
44
 
                        vals['cost_price']=res[0]['standard_price']
45
 
                return super(account_invoice_line, self).write(cr, uid, ids, vals, context)
 
37
    _name = "account.invoice.line"
 
38
    _inherit = "account.invoice.line"
 
39
    _columns = {
 
40
        'cost_price': fields.float('Cost Price', digits=(16, 2)),
 
41
    }
 
42
    def write(self, cr, uid, ids, vals, context={}):
 
43
        if vals.get('product_id' , False):
 
44
            res=self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
 
45
            vals['cost_price']=res[0]['standard_price']
 
46
        return super(account_invoice_line, self).write(cr, uid, ids, vals, context)
46
47
 
47
 
        def create(self, cr, uid, vals, context={}):
48
 
                if 'product_id' in vals:
49
 
                        res=self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
50
 
                        vals['cost_price']=res[0]['standard_price']
51
 
                return super(account_invoice_line, self).create(cr, uid, vals, context)
 
48
    def create(self, cr, uid, vals, context={}):
 
49
        if vals.get('product_id',False):
 
50
            res=self.pool.get('product.product').read(cr, uid, [vals['product_id']], ['standard_price'])
 
51
            vals['cost_price']=res[0]['standard_price']
 
52
        return super(account_invoice_line, self).create(cr, uid, vals, context)
52
53
account_invoice_line()
53
54
 
54
55
 
 
56
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
57