[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:
Pedro M. Baeza 2014-07-31 09:38:03 +02:00 committed by Martin Trigaux
parent 8c77c711ee
commit cbe85f42d0
1 changed files with 17 additions and 3 deletions

View File

@ -47,7 +47,12 @@ 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.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)
return val
@ -852,6 +857,12 @@ class sale_order_line(osv.osv):
return True
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):
tax_obj = self.pool.get('account.tax')
cur_obj = self.pool.get('res.currency')
@ -859,8 +870,11 @@ class sale_order_line(osv.osv):
if context is None:
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.product_id, line.order_id.partner_id)
price = self._calc_line_base_price(cr, uid, line, context=context)
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
res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
return res