~ruchir.shukla/margin-analysis/margin-analysis-migrate-V7

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
from openerp.osv.orm import Model
from openerp.osv import fields
import decimal_precision as dp
import logging

class product_product(Model):
    _inherit = 'product.product'

    def _cost_price(self, cr, uid, ids, field_name, arg, context=None):
        if context is None:
            context = {}
        res = {}
        for product in self.browse(cr, uid, ids):
            res[product.id] = product.standard_price + product.fixed_cost_price
        return res

    _columns = {
        'fixed_cost_price': fields.float(
            'Fixed Cost Price', digits_compute = dp.get_precision('Sale Price')),
        'cost_price': fields.function(_cost_price,
                                      string='Cost Price',
                                      digits_compute=dp.get_precision('Sale Price'),
                                      help="The cost price is the standard price unless you install the product_cost_incl_bom module.")
        }

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: