~openbig/bigconsulting/statement_taxes_changes

« back to all changes in this revision

Viewing changes to product_tax_include/object/product.py

  • Committer: husen
  • Date: 2010-08-05 12:52:43 UTC
  • mfrom: (52.2.18 bigconsulting)
  • Revision ID: husen@husen-laptop-20100805125243-24p691l79vcupxd7
code refactoring

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    _inherit = 'product.template'
32
32
 
33
33
    def _price_unit_tax(self, cr, uid, ids, field_name, arg, context=None):
34
 
        """This method calcul the sale price with/without taxes included depending on company configuration"""
 
34
        """
 
35
        This method calcul the sale price with/without taxes included depending on company configuration
 
36
        """
35
37
        if not context: context = {}
36
38
        res = {}
37
39
        tax_obj = self.pool.get('account.tax')
41
43
        cur_obj = self.pool.get('res.currency')
42
44
        cur = user.company_id.partner_id.property_product_pricelist.currency_id
43
45
 
44
 
        for product in self.browse(cr, uid, ids):
 
46
        for product in self.browse(cr, uid, ids, context=context):
45
47
            val = 0.0
46
48
            if prices_tax_include:
47
49
                val = reduce(lambda x, y: x+cur_obj.round(cr, uid, cur, y['amount']),
48
 
                    tax_obj.compute_inv(cr, uid, product.taxes_id,
49
 
                        product.list_price, 1),
50
 
                        val)
 
50
                             tax_obj.compute_inv(cr, uid, product.taxes_id, product.list_price, 1), val)
51
51
                res[product.id] = cur_obj.round(cr, uid, cur, (product.list_price - val))
52
52
            else:
53
53
                val = reduce(lambda x, y: x+cur_obj.round(cr, uid, cur, y['amount']),
54
 
                    tax_obj.compute(cr, uid, product.taxes_id,
55
 
                        product.list_price, 1),
56
 
                        val)
 
54
                             tax_obj.compute(cr, uid, product.taxes_id, product.list_price, 1), val)
57
55
                res[product.id] = cur_obj.round(cr, uid, cur, (product.list_price + val))
58
56
        return res
59
57
 
60
58
    _columns = {
61
 
            'price_unit_tax' : fields.function(_price_unit_tax,
62
 
                                method=True,
63
 
                                string='price inc./exc. tax',
64
 
                                store=False,
65
 
                                type='float',
66
 
                                digits=(16, int(config['price_accuracy'])),
67
 
                                help="Price calculated with taxes included or excluded, depend of the configuration in company configuration"),
 
59
        'price_unit_tax' : fields.function(_price_unit_tax,
 
60
                                           method=True,
 
61
                                           string='price inc./exc. tax',
 
62
                                           store=False,
 
63
                                           type='float',
 
64
                                           digits=(16, int(config['price_accuracy'])),
 
65
                                           help="Price calculated with taxes included or excluded, depend of the configuration in company configuration"),
68
66
    }
69
67
 
70
68
product_template()