1
votes

I'm using Odoo 8 and for some reason a field which actually exists isn't found. In my XML file the following code

            <field name="amount_tax" position="after">
                <field name="delivery_cost"
                    options="{'currency_field': 'currency_id'}"
                    readonly="1" widget="monetary"/>
            </field>

Gives the error that "delivery_cost" isn't found, though in sale.py it exists

  _columns = {
    'xx_delivery_date': fields.date(string='Delivery date'),
    'xx_payment_method': fields.many2one('xx.payment.method',
                                         string='Payment method'),
    'xx_warranty_period': fields.many2one('xx.warranty.period',
                                          string='Warranty period'),
    'xx_delivery_method': fields.many2one('xx.delivery.method',
                                          string='Delivery method'),
    'delivery_cost': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Delivery cost',
        store={
            'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line', 'xx_delivery_method'], 10),
        },
        multi='sums', help="The delivery cost.", track_visibility='always'),
    'amount_untaxed': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Untaxed Amount',
        store={
            'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
            'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
        },
        multi='sums', help="The amount without tax.", track_visibility='always'),
    'amount_tax': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Taxes',
        store={
            'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
            'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
        },
        multi='sums', help="The tax amount."),
    'amount_total': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Total',
        store={
            'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line', 'xx_delivery_method'], 10),
            'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
        },
        multi='sums', help="The total amount.")

I don't see why the field can't be found and have been looking for quite some time :/

3
Can you give us more information like complete XML definition of the view, _name of the object and the error raised by the server ?Quentin THEURET
Did you added the py in the init.py file and updated the module after restarting openerp service?dccdany
May be there is a typo or an error in your model. Odoo won't load your model if there is an error, but won't raise an error either... Btw, you should use the new api (models.Model) and the new way to declare your fieldsdturcotte

3 Answers

3
votes

Re factor your code block of function field. Don't put it in the column block. create a separate function for function field.It may solve your problem

1
votes

Make sure you restarted the server, and then upgraded the module, after making your model/view changes.

0
votes

if you are use fully odoo 8.0 than after this issue than you remove the comma (,) after field

ex: name = name.Char('Name')

after you can not enter (comma)(,)