Hi,
I couldn't create function field in Openerp 7.0, Can anyone help me? Error Is AttributeError: 'str' object has no attribute 'func_name' .. except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
Py File:
def _sub_total_expenses(self, cursor, user, ids, name, arg, context=None):
tes = {}
cur_obj = self.pool.get('res.currency')
for order in self.browse(cr,uid,u=ids):
tes[order.id] = {
'freight_charges':0.0,
'delivery_charges': 0.0,
'installation_charges': 0.0,
'training_charges' : 0.0,
'profit' : 0.0,
'subtotal_expenses' : 0.0,
'net_profit_landed_gp': 0.0,
'net_profit_sale_gp' : 0.0,
'amount_untaxed': 0.0,
'amount_tax': 0.0,
'amount_total': 0.0,
}
val = val1 = lanval= 0.0
cur = order.pricelist_id.currency_id
landed_sub_total = lanval + order.freight_charges + order.delivery_charges + order.installation_charges
for line in order.order_line:
val1 += line.price_subtotal
val += self._amount_line_tax(cr, uid, line, context=context)
lanval += line.purchase_price
landed_sub_total = lanval + order.freight_charges + order.delivery_charges + order.installation_charges
tes[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)
tes[order.id]['amount_untaxed'] = cur_obj.round(cr, uid, cur, val1)
tes[order.id]['subtotal_expenses'] = res[order.id]['amount_untaxed'] + landed_sub_total
tes[order.id]['amount_total'] = res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'] + res[order.id]['subtotal_expenses']
return tes
Calling @
'subtotal_expenses': fields.function('_sub_total_expenses', type = 'float', string='Sub Total Expenses'),