[IMP] sale: hooks for the base price and the quantity
To make it easier to override without rewritting the full method Closes #1470
This commit is contained in:
parent
8c77c711ee
commit
cbe85f42d0
|
@ -47,7 +47,12 @@ class sale_order(osv.osv):
|
||||||
|
|
||||||
def _amount_line_tax(self, cr, uid, line, context=None):
|
def _amount_line_tax(self, cr, uid, line, context=None):
|
||||||
val = 0.0
|
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.product_id, line.order_id.partner_id)['taxes']:
|
line_obj = self.pool['sale.order.line']
|
||||||
|
price = line_obj._calc_line_base_price(cr, uid, line, context=context)
|
||||||
|
qty = line_obj._calc_line_quantity(cr, uid, line, context=context)
|
||||||
|
for c in self.pool['account.tax'].compute_all(
|
||||||
|
cr, uid, line.tax_id, price, qty, line.product_id,
|
||||||
|
line.order_id.partner_id)['taxes']:
|
||||||
val += c.get('amount', 0.0)
|
val += c.get('amount', 0.0)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
@ -852,6 +857,12 @@ class sale_order_line(osv.osv):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _calc_line_base_price(self, cr, uid, line, context=None):
|
||||||
|
return line.price_unit * (1 - (line.discount or 0.0) / 100.0)
|
||||||
|
|
||||||
|
def _calc_line_quantity(self, cr, uid, line, context=None):
|
||||||
|
return line.product_uom_qty
|
||||||
|
|
||||||
def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
|
def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
|
||||||
tax_obj = self.pool.get('account.tax')
|
tax_obj = self.pool.get('account.tax')
|
||||||
cur_obj = self.pool.get('res.currency')
|
cur_obj = self.pool.get('res.currency')
|
||||||
|
@ -859,8 +870,11 @@ class sale_order_line(osv.osv):
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
for line in self.browse(cr, uid, ids, context=context):
|
for line in self.browse(cr, uid, ids, context=context):
|
||||||
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
|
price = self._calc_line_base_price(cr, uid, line, context=context)
|
||||||
taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.product_id, line.order_id.partner_id)
|
qty = self._calc_line_quantity(cr, uid, line, context=context)
|
||||||
|
taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, qty,
|
||||||
|
line.product_id,
|
||||||
|
line.order_id.partner_id)
|
||||||
cur = line.order_id.pricelist_id.currency_id
|
cur = line.order_id.pricelist_id.currency_id
|
||||||
res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
|
res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
|
||||||
return res
|
return res
|
||||||
|
|
Loading…
Reference in New Issue