Skip to Content
Menu
This question has been flagged
7 Replies
13275 Views

I Am Creating Workflow for Approve Account button in odoo 10 i tried a lot but is not working can anyone tell me whats wrong with this code

Here is my code for creating Transition and activity

<record id="wkf_model_setting" model="workflow">           

    <field name="name">Name</field>          

     <field name="osv">model</field>           

    <field name="on_create">True</field>       

</record>

<!--Activity -->                

<record id="act_draft" model="workflow.activity">           

    <field name="wkf_id" ref="wkf_model_setting"/>           

    <field name="flow_start">True</field>           

    <field name="name">draft</field>           

    <field name="kind">function</field>           

    <field name="action">write({'state':'draft'})</field>       

</record>              

<record id="act_approved" model="workflow.activity">           

    <field name="name">approval</field>           

    <field name="wkf_id" ref="wkf_model_setting"/>           

    <field name="kind">function</field>           

    <field name="action">do_approval()</field>       

</record>

<record id="trans_awaiting_approved" model="workflow.transition">          

     <field name="act_from" ref="act_draft"/>           

    <field name="act_to" ref="act_approved"/>           

    <field name="signal">button_approval</field>           

    <field name="group_id" ref="PE_ADMIN"/>      

</record>



and defination for do_approval is like this

@api.multi   

def do_approval(self):
        #TODO: Check if user has rights       

         self.state ='approved'


Avatar
Discard
Best Answer

I think workflow is deprecated in V10

Avatar
Discard
Best Answer

In simple words workflow is "Perform some action in a organized way". To organize tasks or activities we use workflow. In the term of Computer Science workflow is same as the directed graph, where the nodes are called activities and arcs are called transitions. Here activities are some action that could be done on odoo server such as changing the state of some records based on some condition. We can say that the behaviour of the workflow depends on user action (for example clicking on a button).
There is a complete step by step guide of odoo workflow: http://learnopenerp.blogspot.com/2017/12/odoo-workflow.html

Avatar
Discard
Best Answer

Hi,

Workflow still works in Odoo 10 community edition. You may check here for references:

https://www.odoo.com/documentation/10.0/howtos/backend.html#workflows

I have a doubt in your code:

<record id="wkf_model_setting" model="workflow">           
    <field name="name">Name</field>          
     <field name="osv">model</field>           
    <field name="on_create">True</field>       
</record>

Here model is your model name? You should specify your model name there like  for eg: <field name="osv">sale.order</field>.  And also note that, workflow gets instantiated only on creating new records.

Avatar
Discard
Author

It's just an example.<field name="osv">model</field> Here model is model name on which i have created workflow.when i am creating a new record it is not giving me expected output.

Have you included the workflow xml file in __manifest__.py file?

Have you included the workflow xml file in __manifest__.py file? Workflow is working fine in Odoo 10 community edition, I have checked.

Author

yes.I have included in __manifest__.py

Related Posts Replies Views Activity
2
Nov 24
25101
2
May 24
5524
3
Mar 24
4967
0
Mar 24
264
3
Feb 24
11421