Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
7 Відповіді
13791 Переглядів

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'


Аватар
Відмінити
Найкраща відповідь

I think workflow is deprecated in V10

Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити
Найкраща відповідь

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.

Аватар
Відмінити
Автор

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.

Автор

yes.I have included in __manifest__.py

Related Posts Відповіді Переглядів Дія
2
лип. 25
4859
2
груд. 24
7923
2
лист. 24
28736
2
трав. 24
7606
3
бер. 24
7062