hi all , if someone can help , i try to mdofiy the rule to calculate taxes in sale order . i need that the taxes applied only for margin between ( price_unit and purchase_price ) there is a module named product_margin and sale_margin , he add a margin fields in the sale.order.line classes. i am using it , and i was add other class (sale.order.line ) and i try to override the _amount_line functions :
from openerp.osv import fields, osv
class sale_order_line(osv.osv):
_inherit = "sale.order.line"
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')
res = {}
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 ( replaced by line.margin)***, 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
sale_order_line()
but there is no change thanks