Odoo Help


error: AttributeError: 'sale.order' object has no attribute '_ids'

on 1/29/15, 3:22 AM 9,389 views

I'm trying to Put button inside header to do certain tasks depends on boolean field,
but when try to print the value inside this field this error appears
"AttributeError: 'sale.order' object has no attribute '_ids'"
How can I fix this
my code

class sale_order(models.Model):
    _inherit = 'sale.order'

    category = fields.Boolean(string="Category", default=False)

     def apply_test(self, cr, uid, ids, context=None):
        print "Hello World" 
        print self.category # error

<record model="ir.ui.view" id="view_order_form_inh_promotion">
            <field name="name">sale.order.form.inh.promotion</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <button name="invoice_recreate" position="after">
                    <button name="apply_test" string="Test" type="object"/>


Yannick Vaucher - Camptocamp

--Yannick Vaucher - Camptocamp--

| 5 7 9
Lausanne, Switzerland
--Yannick Vaucher - Camptocamp--
Yannick Vaucher - Camptocamp
On 4/29/15, 3:46 AM

You are trying to use self as in new API 8.0

if you want to access to `self.category` that way, you must be in a new API method.

Somithing like:


    def apply_test(self):

        print self.category

Otherwise if you are in a prior version of Odoo, you must do a browse first.

    sale_order = self.browse(cr, uid, ids[0], context=context)

    print sale_order.category

why here you used api.multi decorator

on 5/3/16, 1:43 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/29/15, 3:22 AM
Seen: 9389 times
Last updated: 11/24/17, 11:02 AM