具有服务器操作的工作流不适用于Odoo 9.1

时间:2017-09-08 03:02:10

标签: openerp odoo-9

我一直在用this tutorial构建一个Odoo 9.1模块。但是我通过该指令创建的工作流程不起作用(当我点击确认按钮时,没有任何反应,没有错误日志等)

以下是相关代码:

models.py(在Session类中)

state = fields.Selection([
    ('draft', "Draft"),
    ('confirmed', "Confirmed"),
    ('done', "Done"),
])

@api.multi
def action_draft(self):
    self.state = 'draft'

@api.multi
def action_confirm(self):
    self.state = 'confirmed'

@api.multi
def action_done(self):
    self.state = 'done'

academy.xml(会话表单中的标题)

<header>
    <button name="action_draft" type="workflow"
            string="Reset to draft"
            states="confirmed,done"/>
    <button name="action_confirm" type="workflow"
            string="Confirm" states="draft"
            class="oe_highlight"/>
    <button name="action_done" type="workflow"
            string="Mark as done" states="confirmed"
            class="oe_highlight"/>
    <field name="state" widget="statusbar"/>
</header>

session_workflow.xml

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
        <record model="workflow" id="wkf_session">
            <field name="name">OpenAcademy sessions workflow</field>
            <field name="osv">academy.session</field>
            <field name="on_create">True</field>
        </record>

        <record model="ir.actions.server" id="set_session_to_draft">
            <field name="name">Set session to Draft</field>
            <field name="model_id" ref="model_academy_session"/>
            <field name="code">
model.search([('id', 'in', context['active_ids'])]).action_draft()
            </field>
        </record>
        <record model="workflow.activity" id="draft">
            <field name="name">Draft</field>
            <field name="wkf_id" ref="wkf_session"/>
            <field name="flow_start" eval="True"/>
            <field name="kind">dummy</field>
            <field name="action"></field>
            <field name="action_id" ref="set_session_to_draft"/>
        </record>

        <record model="ir.actions.server" id="set_session_to_confirmed">
            <field name="name">Set session to Confirmed</field>
            <field name="model_id" ref="model_academy_session"/>
            <field name="code">
model.search([('id', 'in', context['active_ids'])]).action_confirm()
            </field>
        </record>
        <record model="workflow.activity" id="confirmed">
            <field name="name">Confirmed</field>
            <field name="wkf_id" ref="wkf_session"/>
            <field name="kind">dummy</field>
            <field name="action"></field>
            <field name="action_id" ref="set_session_to_confirmed"/>
        </record>

        <record model="ir.actions.server" id="set_session_to_done">
            <field name="name">Set session to Done</field>
            <field name="model_id" ref="model_academy_session"/>
            <field name="code">
model.search([('id', 'in', context['active_ids'])]).action_done()
            </field>
        </record>
        <record model="workflow.activity" id="done">
            <field name="name">Done</field>
            <field name="wkf_id" ref="wkf_session"/>
            <field name="kind">dummy</field>
            <field name="action"></field>
            <field name="action_id" ref="set_session_to_done"/>
        </record>

        <record model="workflow.transition" id="session_draft_to_confirmed">
            <field name="act_from" ref="draft"/>
            <field name="act_to" ref="confirmed"/>
            <field name="signal">confirm</field>
        </record>
        <record model="workflow.transition" id="session_confirmed_to_draft">
            <field name="act_from" ref="confirmed"/>
            <field name="act_to" ref="draft"/>
            <field name="signal">draft</field>
        </record>
        <record model="workflow.transition" id="session_done_to_draft">
            <field name="act_from" ref="done"/>
            <field name="act_to" ref="draft"/>
            <field name="signal">draft</field>
        </record>
        <record model="workflow.transition" id="session_confirmed_to_done">
            <field name="act_from" ref="confirmed"/>
            <field name="act_to" ref="done"/>
            <field name="signal">done</field>
        </record>
        <record model="workflow.transition" id="session_auto_confirm_half_filled">
            <field name="act_from" ref="draft"/>
            <field name="act_to" ref="confirmed"/>
            <field name="condition">taken_seats &gt; 50</field>
        </record>
    </data>
</openerp>

出了什么问题?

1 个答案:

答案 0 :(得分:2)

根据信号值

更改按钮名称

您的代码:

<field name="signal">draft</field>
<button name="action_draft"...

改变&#34; action_draft&#34;到&#34;草案&#34;

单击该按钮时,它会将按钮名称作为信号发送,因此它们必须相同。