This question has been flagged
1 Reply
2341 Views

Hello,

I have created on object test.order which is kind of sale order. And other object is test.order.process which is created based on test.order. So whenever I complete the test.order.process , test.order should automatically goes in Done state.

I have tried to implement this. But in my case, what happens is, when I open form view, only then state will be Done. If I see Tree view, state does not change. I need to Open form view always to change the state.

Can anyone help what should I do?

Avatar
Discard
Best Answer

*You can do like this on button Done or Open *

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

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

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

Xml file is like this:

          <header>
                <button string="Done" icon="" states="open" type="object"
                    name="action_open_to_done" class="oe_highlight"/>
                <button string="Cancel" states="open"
                    type="object" name="action_open_to_cancel"
                    class="oe_highlight"/>
                <button string="Reset to Open" states="cancel" type="object"
                    name="action_cancel_to_open" class="oe_highlight"/>
                <field name="state" widget='statusbar'
                    statusbar_visible="open,done,cancel" />
            </header>
Avatar
Discard
Author

I have multiple test.order.process, which can be completed based on requirement. When I load tree view of test.order, related test.order should go in Completed state. the way you said already implemented at my end.