Odoo Help

0

How to trigger workflow state based on field selection

By
Erhuvwu Akpobaro
on 1/27/15, 7:09 AM 842 views

Hello guys , 

I was wondering if its possible to change a workflow state for an example from open to draft based on a selection from the field below :

'contract_usage': fields.selection([('Rental', 'Rental'), ('Standard', 'Standard')], 'Type of Contract', size=10),

so far done this so far :

    def activate_draft(self, cr, uid, ids, context=None):
      
           workflow_obj = self.pool.get('account.analytic.account')
        val = workflow_obj.browse(cr,uid,ids, context=context)
        if(val.contract_usage == "Rental"):
                 self.write(cr, uid , ids, {'state':'new'})
                return True
                
        else:
                self.write(cr, uid , ids, {'state':'open'})
                return True

do i need to put something in the xml to actually activate the function ?

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.

Register

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)

Stats

Asked: 1/27/15, 7:09 AM
Seen: 842 times
Last updated: 3/16/15, 8:10 AM