~zaber/openobject-addons/stable_5.0-extra-addons

« back to all changes in this revision

Viewing changes to sale_margin/object/invoice_margin.py

  • Committer: Sebastien LANGE
  • Date: 2009-12-05 15:41:56 UTC
  • Revision ID: sebastien.lange@syleam.fr-20091205154156-8ag8u7qb7h0bd6pz
[IMP] sale_margin : add pourcent margin in sale order line and sale order
the original module is renamed in sale_margin_old

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
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
 
8
#
 
9
#    This file is a part of sale_margin
 
10
#
 
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.
 
15
#
 
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.
 
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 osv import fields,osv
 
27
import pooler
 
28
from tools import config
 
29
import time
 
30
 
 
31
class account_invoice_line(osv.osv):
 
32
    _name = "account.invoice.line"
 
33
    _inherit = "account.invoice.line"
 
34
    _columns = {
 
35
        'cost_price': fields.float('Cost Price', digits=(16, 2)),
 
36
    }
 
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)
 
42
 
 
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()
 
49
 
 
50
 
 
51
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
52