I added an amount_fodec field in purchase.order to add specific tax of 1% on the amount_untaxed and then add it in the total amount. The problem is that the amount_total does not take into account amount_fodec. Here is my method:
class PurchaseOrder(osv.osv):
_inherit = 'purchase.order'
def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
res = {}
cur_obj=self.pool.get('res.currency')
line_obj = self.pool['purchase.order.line']
for order in self.browse(cr, uid, ids, context=context):
res[order.id] = {
'amount_untaxed': 0.0,
'amount_tax': 0.0,
'amount_fodec':0.0,
'amount_total': 0.0,
}
val = val1 = val2=0.0
cur = order.pricelist_id.currency_id
for line in order.order_line:
val1 += line.price_subtotal
line_price = line_obj._calc_line_base_price(cr, uid, line,
context=context)
line_qty = line_obj._calc_line_quantity(cr, uid, line,
context=context)
for c in self.pool['account.tax'].compute_all(
cr, uid, line.taxes_id, line_price, line_qty,
line.product_id, order.partner_id)['taxes']:
val += c.get('amount', 0.0)
val2=val1/100
res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val)
res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1)
res[order.id]['amount_fodec']=cur_obj.round(cr, uid, cur, val2)
res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax']+res[order.id]['amount_fodec']
return res
any help please