Odoo Help


How set STATE=DONE? (Action & Button)

Damian Phang
on 1/27/14, 7:10 PM 2,797 views

How do I go about creating a button that sets the state of purchase order to done?

I have in my purchase.py file

def action_done(self, cr, uid, ids, context=None):
        self.write(cr, uid, ids, {'state': 'done'}, context=context)
        return True

I then added the line action_done in xml. When I click the button, it says no attribute for purchase order. I've already updated the modules, and also rebooted the server. The action is defined in the purchase.py file

you most have in the xml view, for example, in the form view a button <button name="action_done" type="workflow" string="Done" />

Jose Angel Inda Herrera
on 1/28/14, 12:19 PM

This issue has been resolved.

It was notified as a bug : https://bugs.launchpad.net/openobject-addons/+bug/1097633

it was post a year ago. but still no resolve

on 2/18/14, 3:23 AM
Damian Phang
On 1/29/14, 3:37 AM

Let me try this out. In XML view I defined it as "function" and when I call it, it says purchase.order has no such attribute. I'll try it as "workflow" to see if it works

EDIT: Somehow after moving it to a different line in purchase.py the button now works. This is the code I used:

in purchase.py

def action_done(self, cr, uid, ids, context=None):
        self.write(cr, uid, ids, {'state': 'done'}, context=context)
        return True

in form view xml

<button name="action_done" type="object" string="Done" />

Thanks a bunch!

can you please share this solution file i need it also. as in my problem that the purchase order always remain in purchase order state not getting done automatically even invoice paid, and the good in warehouse received

on 2/16/14, 9:45 AM

Hi, you need to modify your own .py file and in debug mode, add the extra line into the xml. If you can't get it done, drop another message here or leave your email I can send you screenshot on how to get it done. Many bugs are fixed in v8 but now I noticed that if you purchase and pay for an item that is $0, it will not complete the purchase order as well.

Damian Phang
on 2/18/14, 8:44 AM

my problem is when the purchase order scheduler then it will be in not done state. because i make the sales order it will generate purchase order. when payment done and warehouse goods received still the purchase order in purchase order state. that's let me confuse which order are not done, which is done.

on 2/18/14, 9:35 AM

my problem come if the purhcase order from warehouse scheduler, even payment done, goods received in warehouse purhcase order remain "purchase order state". i find solution over google non of them give satisfied answer. even in launchpad no solution or update. i'm no knowledge in programing. but i added your command above in purhcase.py via gedit and add the button line in xml file still no done button appear. maybe because i put in wrong line. since i don't know any in programing. my mail: blackneck6666 at gmail dot com

on 2/18/14, 9:36 AM

Cheers and luck

The button is clickable and an action is set, but the purchase order status is still showing as "purchase order" instead of done. I'd post a picture but I don't have enough karma. Any help on this?

Damian Phang
on 1/29/14, 3:02 PM

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/27/14, 7:10 PM
Seen: 2797 times
Last updated: 3/16/15, 8:10 AM