Odoo Help

Welcome!

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

0

How to trigger workflow state based on field selection

By
Erhuvwu Akpobaro
on 1/27/15, 7:09 AM 789 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 ?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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