1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2010 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as
9
# published by the Free Software Foundation, either version 3 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Affero General Public License for more details.
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
21
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
23
from osv import osv, fields
25
class account_tax(osv.osv):
26
_inherit = 'account.tax'
28
'expense_include': fields.boolean('Tax Included in Expense',
29
help="Check this if this tax is \
30
included in the expense amount."),
33
def compute_all(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):
36
'total': 0.0, # Total without taxes
37
'total_included: 0.0, # Total with taxes
38
'taxes': [] # List of taxes, see compute for the format
41
precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
42
totalin = totalex = round(price_unit * quantity, precision)
46
if (partner.employee and tax.expense_include) or tax.price_include:
50
tin = self.compute_inv(cr, uid, tin, price_unit, quantity, address_id=address_id, product=product, partner=partner)
52
totalex -= r.get('amount', 0.0)
55
totlex_qty=totalex/quantity
58
tex = self._compute(cr, uid, tex, totlex_qty, quantity, address_id=address_id, product=product, partner=partner)
60
totalin += r.get('amount', 0.0)
63
'total_included': totalin,