[FIX] hr_expense: tax included computation
When a tax included has a several childs, the source line should not be duplicated for each tax. Without the patch, the actual product price (without taxes) would be (total - tax amount) for the last tax only (and not the sum of each tax). (opw 609104)
This commit is contained in:
parent
a210420582
commit
33e0910841
|
@ -283,7 +283,6 @@ class hr_expense_expense(osv.osv):
|
||||||
if not mres:
|
if not mres:
|
||||||
continue
|
continue
|
||||||
res.append(mres)
|
res.append(mres)
|
||||||
tax_code_found= False
|
|
||||||
|
|
||||||
#Calculate tax according to default tax on product
|
#Calculate tax according to default tax on product
|
||||||
taxes = []
|
taxes = []
|
||||||
|
@ -301,9 +300,9 @@ class hr_expense_expense(osv.osv):
|
||||||
a = product.categ_id.property_account_expense_categ.id
|
a = product.categ_id.property_account_expense_categ.id
|
||||||
a = fpos_obj.map_account(cr, uid, fpos, a)
|
a = fpos_obj.map_account(cr, uid, fpos, a)
|
||||||
taxes = a and self.pool.get('account.account').browse(cr, uid, a, context=context).tax_ids or False
|
taxes = a and self.pool.get('account.account').browse(cr, uid, a, context=context).tax_ids or False
|
||||||
tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
|
|
||||||
if not taxes:
|
if not taxes:
|
||||||
continue
|
continue
|
||||||
|
tax_l = []
|
||||||
#Calculating tax on the line and creating move?
|
#Calculating tax on the line and creating move?
|
||||||
for tax in tax_obj.compute_all(cr, uid, taxes,
|
for tax in tax_obj.compute_all(cr, uid, taxes,
|
||||||
line.unit_amount ,
|
line.unit_amount ,
|
||||||
|
@ -311,15 +310,8 @@ class hr_expense_expense(osv.osv):
|
||||||
exp.user_id.partner_id)['taxes']:
|
exp.user_id.partner_id)['taxes']:
|
||||||
tax_code_id = tax['base_code_id']
|
tax_code_id = tax['base_code_id']
|
||||||
tax_amount = line.total_amount * tax['base_sign']
|
tax_amount = line.total_amount * tax['base_sign']
|
||||||
if tax_code_found:
|
if not tax_code_id:
|
||||||
if not tax_code_id:
|
|
||||||
continue
|
|
||||||
res.append(self.move_line_get_item(cr, uid, line, context))
|
|
||||||
res[-1]['price'] = 0.0
|
|
||||||
res[-1]['account_analytic_id'] = False
|
|
||||||
elif not tax_code_id:
|
|
||||||
continue
|
continue
|
||||||
tax_code_found = True
|
|
||||||
res[-1]['tax_code_id'] = tax_code_id
|
res[-1]['tax_code_id'] = tax_code_id
|
||||||
res[-1]['tax_amount'] = cur_obj.compute(cr, uid, exp.currency_id.id, company_currency, tax_amount, context={'date': exp.date_confirm})
|
res[-1]['tax_amount'] = cur_obj.compute(cr, uid, exp.currency_id.id, company_currency, tax_amount, context={'date': exp.date_confirm})
|
||||||
##
|
##
|
||||||
|
@ -337,7 +329,8 @@ class hr_expense_expense(osv.osv):
|
||||||
'tax_code_id': tax['tax_code_id'],
|
'tax_code_id': tax['tax_code_id'],
|
||||||
'tax_amount': tax['amount'] * tax['base_sign'],
|
'tax_amount': tax['amount'] * tax['base_sign'],
|
||||||
}
|
}
|
||||||
res.append(assoc_tax)
|
tax_l.append(assoc_tax)
|
||||||
|
res += tax_l
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def move_line_get_item(self, cr, uid, line, context=None):
|
def move_line_get_item(self, cr, uid, line, context=None):
|
||||||
|
|
Loading…
Reference in New Issue