parent
5a016ca293
commit
54540f9ae8
|
@ -1230,7 +1230,7 @@ class account_tax(osv.osv):
|
|||
'sequence': fields.integer('Sequence', required=True, help="The sequence field is used to order the taxes lines from the lowest sequences to the higher ones. The order is important if you have a tax that have several tax childs. In this case, the evaluation order is important."),
|
||||
'amount': fields.float('Amount', required=True, digits=(14,4)),
|
||||
'active': fields.boolean('Active'),
|
||||
'type': fields.selection( [('percent','Percent'), ('fixed','Fixed'), ('none','None'), ('code','Python Code')], 'Tax Type', required=True,
|
||||
'type': fields.selection( [('percent','Percent'), ('fixed','Fixed'), ('none','None'), ('code','Python Code'),('balance','Balance')], 'Tax Type', required=True,
|
||||
help="The computation method for the tax amount."),
|
||||
'applicable_type': fields.selection( [('true','True'), ('code','Python Code')], 'Applicable Type', required=True,
|
||||
help="If not applicable (computed through a Python code), the tax do not appears on the invoice."),
|
||||
|
@ -1346,6 +1346,10 @@ class account_tax(osv.osv):
|
|||
exec tax.python_compute in localdict
|
||||
amount = localdict['result']
|
||||
data['amount'] = amount
|
||||
elif tax.type=='balance':
|
||||
data['amount'] = cur_price_unit - reduce(lambda x,y: y.get('amount',0.0)+x, res, 0.0)
|
||||
data['balance'] = cur_price_unit
|
||||
|
||||
amount2 = data['amount']
|
||||
if len(tax.child_ids):
|
||||
if tax.child_depend:
|
||||
|
@ -1369,8 +1373,6 @@ class account_tax(osv.osv):
|
|||
latest[name+'_code_id'] = False
|
||||
if tax.include_base_amount:
|
||||
cur_price_unit+=amount2
|
||||
for r in res:
|
||||
print 'result', r['amount'], r['price_unit']
|
||||
return res
|
||||
|
||||
def compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):
|
||||
|
@ -1384,8 +1386,14 @@ class account_tax(osv.osv):
|
|||
one tax for each tax id in IDS and their childs
|
||||
"""
|
||||
res = self._unit_compute(cr, uid, taxes, price_unit, address_id, product, partner)
|
||||
total = 0.0
|
||||
for r in res:
|
||||
r['amount'] *= quantity
|
||||
if r.get('balance',False):
|
||||
r['amount'] = round(r['balance'] * quantity, 2) - total
|
||||
else:
|
||||
r['amount'] = round(r['amount'] * quantity, 2)
|
||||
total += r['amount']
|
||||
|
||||
return res
|
||||
|
||||
def _unit_compute_inv(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None):
|
||||
|
@ -1415,6 +1423,10 @@ class account_tax(osv.osv):
|
|||
localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner}
|
||||
exec tax.python_compute_inv in localdict
|
||||
amount = localdict['result']
|
||||
elif tax.type=='balance':
|
||||
data['amount'] = cur_price_unit - reduce(lambda x,y: y.get('amount',0.0)+x, res, 0.0)
|
||||
data['balance'] = cur_price_unit
|
||||
|
||||
|
||||
if tax.include_base_amount:
|
||||
cur_price_unit -= amount
|
||||
|
@ -1467,8 +1479,13 @@ class account_tax(osv.osv):
|
|||
one tax for each tax id in IDS and their childs
|
||||
"""
|
||||
res = self._unit_compute_inv(cr, uid, taxes, price_unit, address_id, product, partner=None)
|
||||
total = 0.0
|
||||
for r in res:
|
||||
r['amount'] *= quantity
|
||||
if r.get('balance',False):
|
||||
r['amount'] = round(r['balance'] * quantity, 2) - total
|
||||
else:
|
||||
r['amount'] = round(r['amount'] * quantity, 2)
|
||||
total += r['amount']
|
||||
return res
|
||||
account_tax()
|
||||
|
||||
|
|
Loading…
Reference in New Issue