Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Unable to create function field?

By
Vikram
on 8/8/13, 3:02 AM 1,491 views

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'),

1

Maniganda

--Maniganda--
1038
| 5 7 7
Bangalore, India
--Maniganda--
Maniganda
On 8/8/13, 8:28 AM

Hi, Remove the single Quotes for function name in fields.function

'subtotal_expenses': fields.function(_sub_total_expenses, type = 'float', string='Sub Total Expenses'),

Thanks a lot Mani!!!

Vikram
on 8/8/13, 8:42 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 8/8/13, 3:02 AM
Seen: 1491 times
Last updated: 3/16/15, 8:10 AM