[IMP]account: remove address_id form compute_all
bzr revid: sbh@tinyerp.com-20120329124138-isbvzt8z4drn7fwn
This commit is contained in:
parent
4094f53f77
commit
d9359aacfb
|
@ -2060,7 +2060,7 @@ 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, force_excluded=False):
|
||||
def compute_all(self, cr, uid, taxes, price_unit, quantity, 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
|
||||
|
@ -2080,7 +2080,7 @@ class account_tax(osv.osv):
|
|||
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)
|
||||
tin = self.compute_inv(cr, uid, tin, price_unit, quantity, product=product, partner=partner)
|
||||
for r in tin:
|
||||
totalex -= r.get('amount', 0.0)
|
||||
totlex_qty = 0.0
|
||||
|
@ -2088,7 +2088,7 @@ class account_tax(osv.osv):
|
|||
totlex_qty = totalex/quantity
|
||||
except:
|
||||
pass
|
||||
tex = self._compute(cr, uid, tex, totlex_qty, quantity, address_id=address_id, product=product, partner=partner)
|
||||
tex = self._compute(cr, uid, tex, totlex_qty, quantity,product=product, partner=partner)
|
||||
for r in tex:
|
||||
totalin += r.get('amount', 0.0)
|
||||
return {
|
||||
|
@ -2097,13 +2097,13 @@ class account_tax(osv.osv):
|
|||
'taxes': tin + tex
|
||||
}
|
||||
|
||||
def compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):
|
||||
def compute(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None):
|
||||
logger = netsvc.Logger()
|
||||
logger.notifyChannel("warning", netsvc.LOG_WARNING,
|
||||
"Deprecated, use compute_all(...)['taxes'] instead of compute(...) to manage prices with tax included")
|
||||
return self._compute(cr, uid, taxes, price_unit, quantity, address_id, product, partner)
|
||||
|
||||
def _compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):
|
||||
def _compute(self, cr, uid, taxes, price_unit, quantity,product=None, partner=None):
|
||||
"""
|
||||
Compute tax values for given PRICE_UNIT, QUANTITY and a buyer/seller ADDRESS_ID.
|
||||
|
||||
|
@ -2112,7 +2112,7 @@ class account_tax(osv.osv):
|
|||
tax = {'name':'', 'amount':0.0, 'account_collected_id':1, 'account_paid_id':2}
|
||||
one tax for each tax id in IDS and their children
|
||||
"""
|
||||
res = self._unit_compute(cr, uid, taxes, price_unit, address_id, product, partner, quantity)
|
||||
res = self._unit_compute(cr, uid, taxes, price_unit, product, partner, quantity)
|
||||
total = 0.0
|
||||
precision_pool = self.pool.get('decimal.precision')
|
||||
for r in res:
|
||||
|
@ -2123,8 +2123,8 @@ class account_tax(osv.osv):
|
|||
total += r['amount']
|
||||
return res
|
||||
|
||||
def _unit_compute_inv(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None):
|
||||
taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner)
|
||||
def _unit_compute_inv(self, cr, uid, taxes, price_unit, product=None, partner=None):
|
||||
taxes = self._applicable(cr, uid, taxes, price_unit, product, partner)
|
||||
obj_partener_address = self.pool.get('res.partner')
|
||||
res = []
|
||||
taxes.reverse()
|
||||
|
@ -2150,8 +2150,7 @@ class account_tax(osv.osv):
|
|||
amount = tax.amount
|
||||
|
||||
elif tax.type=='code':
|
||||
address = address_id and obj_partener_address.browse(cr, uid, address_id) or None
|
||||
localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner}
|
||||
localdict = {'price_unit':cur_price_unit, 'product':product, 'partner':partner}
|
||||
exec tax.python_compute_inv in localdict
|
||||
amount = localdict['result']
|
||||
elif tax.type=='balance':
|
||||
|
@ -2185,7 +2184,7 @@ class account_tax(osv.osv):
|
|||
del res[-1]
|
||||
amount = price_unit
|
||||
|
||||
parent_tax = self._unit_compute_inv(cr, uid, tax.child_ids, amount, address_id, product, partner)
|
||||
parent_tax = self._unit_compute_inv(cr, uid, tax.child_ids, amount, product, partner)
|
||||
res.extend(parent_tax)
|
||||
|
||||
total = 0.0
|
||||
|
@ -2197,7 +2196,7 @@ class account_tax(osv.osv):
|
|||
r['todo'] = 0
|
||||
return res
|
||||
|
||||
def compute_inv(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):
|
||||
def compute_inv(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None):
|
||||
"""
|
||||
Compute tax values for given PRICE_UNIT, QUANTITY and a buyer/seller ADDRESS_ID.
|
||||
Price Unit is a VAT included price
|
||||
|
@ -2207,7 +2206,7 @@ class account_tax(osv.osv):
|
|||
tax = {'name':'', 'amount':0.0, 'account_collected_id':1, 'account_paid_id':2}
|
||||
one tax for each tax id in IDS and their children
|
||||
"""
|
||||
res = self._unit_compute_inv(cr, uid, taxes, price_unit, address_id, product, partner=None)
|
||||
res = self._unit_compute_inv(cr, uid, taxes, price_unit, product, partner=None)
|
||||
total = 0.0
|
||||
obj_precision = self.pool.get('decimal.precision')
|
||||
for r in res:
|
||||
|
|
|
@ -70,12 +70,12 @@ class mrp_repair(osv.osv):
|
|||
for line in repair.operations:
|
||||
#manage prices with tax included use compute_all instead of compute
|
||||
if line.to_invoice:
|
||||
tax_calculate = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, repair.partner_invoice_id.id, line.product_id, repair.partner_id)
|
||||
tax_calculate = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, line.product_id, repair.partner_id)
|
||||
for c in tax_calculate['taxes']:
|
||||
val += c['amount']
|
||||
for line in repair.fees_lines:
|
||||
if line.to_invoice:
|
||||
tax_calculate = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, repair.partner_invoice_id.id, line.product_id, repair.partner_id)
|
||||
tax_calculate = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, line.product_id, repair.partner_id)
|
||||
for c in tax_calculate['taxes']:
|
||||
val += c['amount']
|
||||
res[repair.id] = cur_obj.round(cr, uid, cur, val)
|
||||
|
|
|
@ -49,7 +49,7 @@ class purchase_order(osv.osv):
|
|||
cur = order.pricelist_id.currency_id
|
||||
for line in order.order_line:
|
||||
val1 += line.price_subtotal
|
||||
for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_id.id, line.product_id.id, order.partner_id)['taxes']:
|
||||
for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, line.product_id.id, order.partner_id)['taxes']:
|
||||
val += c.get('amount', 0.0)
|
||||
res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val)
|
||||
res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1)
|
||||
|
|
|
@ -65,7 +65,7 @@ class sale_order(osv.osv):
|
|||
|
||||
def _amount_line_tax(self, cr, uid, line, context=None):
|
||||
val = 0.0
|
||||
for c in self.pool.get('account.tax').compute_all(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.product_uom_qty, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id)['taxes']:
|
||||
for c in self.pool.get('account.tax').compute_all(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.product_uom_qty, line.product_id, line.order_id.partner_id)['taxes']:
|
||||
val += c.get('amount', 0.0)
|
||||
return val
|
||||
|
||||
|
@ -920,7 +920,7 @@ class sale_order_line(osv.osv):
|
|||
context = {}
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
|
||||
taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id)
|
||||
taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.product_id, line.order_id.partner_id)
|
||||
cur = line.order_id.pricelist_id.currency_id
|
||||
res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
|
||||
return res
|
||||
|
|
Loading…
Reference in New Issue