跳至内容
菜单
此问题已终结
7 回复
13790 查看

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

相关帖文 回复 查看 活动
2
7月 25
4858
2
12月 24
7923
2
11月 24
28736
2
5月 24
7606
3
3月 24
7062