[FIX] account: encoding by line is now working also for tax included (in fact it doesn't consider that value, but it's normal)

bzr revid: qdp-launchpad@openerp.com-20111114103945-blqw5f4egom3dp9m
This commit is contained in:
Quentin (OpenERP) 2011-11-14 11:39:45 +01:00
parent f79e0d1f59
commit f033b7b1b1
2 changed files with 8 additions and 9 deletions

View File

@ -2001,8 +2001,11 @@ class account_tax(osv.osv):
cur_price_unit+=amount2
return res
def compute_all(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):
def compute_all(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None, force_excluded=False):
"""
:param force_excluded: boolean used to say that we don't want to consider the value of field price_include of
tax. It's used in encoding by line where you don't matter if you encoded a tax with that boolean to True or
False
RETURN: {
'total': 0.0, # Total without taxes
'total_included: 0.0, # Total with taxes
@ -2014,10 +2017,10 @@ class account_tax(osv.osv):
tin = []
tex = []
for tax in taxes:
if tax.price_include:
tin.append(tax)
else:
if not tax.price_include or force_excluded:
tex.append(tax)
else:
tin.append(tax)
tin = self.compute_inv(cr, uid, tin, price_unit, quantity, address_id=address_id, product=product, partner=partner)
for r in tin:
totalex -= r.get('amount', 0.0)

View File

@ -1326,7 +1326,7 @@ class account_move_line(osv.osv):
base_sign = 'base_sign'
tax_sign = 'tax_sign'
tmp_cnt = 0
for tax in tax_obj.compute_all(cr, uid, [tax_id], total, 1.00).get('taxes'):
for tax in tax_obj.compute_all(cr, uid, [tax_id], total, 1.00, force_excluded=True).get('taxes'):
#create the base movement
if tmp_cnt == 0:
if tax[base_code]:
@ -1338,8 +1338,6 @@ class account_move_line(osv.osv):
else:
data = {
'move_id': vals['move_id'],
'journal_id': vals['journal_id'],
'period_id': vals['period_id'],
'name': tools.ustr(vals['name'] or '') + ' ' + tools.ustr(tax['name'] or ''),
'date': vals['date'],
'partner_id': vals.get('partner_id',False),
@ -1356,8 +1354,6 @@ class account_move_line(osv.osv):
#create the VAT movement
data = {
'move_id': vals['move_id'],
'journal_id': vals['journal_id'],
'period_id': vals['period_id'],
'name': tools.ustr(vals['name'] or '') + ' ' + tools.ustr(tax['name'] or ''),
'date': vals['date'],
'partner_id': vals.get('partner_id',False),