Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

一个workflow的问题



  • 自认为对workflow还是比较熟。(以前做过)但是这次怎么也不成功,请各位老大帮我看看。
    症状是,显示按钮正常(workflow的显示也是正常的),就是点击按钮后,状态不能切换。
    py文件中

    <br /> &#039;state&#039;:fields.selection([<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;new&#039;,&#039;新义工&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;normal&#039;,&#039;正式义工&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&#039;advanced&#039;,&#039;高级义工&#039;)],&#039;义工级别&#039;,readonly=True,select=True),<br />
    


    workflow.xml

    <br />&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br />&lt;openerp&gt;<br />	&lt;data&gt;<br />	&nbsp; &nbsp; &nbsp; &nbsp; &lt;record id=&quot;aflsyg_volunteer_workflow&quot; model=&quot;workflow&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;name&quot;&gt;aflsyg.volunteer.workflow&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;osv&quot;&gt;aflsyg.volunteer&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;on_create&quot;&gt;True&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;record id=&quot;act_volunteer_new&quot; model=&quot;workflow.activity&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; 	&lt;field name=&quot;wkf_id&quot; ref=&quot;aflsyg_volunteer_workflow&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; 	&lt;field name=&quot;flow_start&quot;&gt;True&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; 	&lt;field name=&quot;name&quot;&gt;new&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; 	&lt;field name=&quot;kind&quot;&gt;function&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; 	&lt;field name=&quot;action&quot;&gt;write({&#039;state&#039;:&#039;new&#039;})&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br />&nbsp; &nbsp;  <br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;record id=&quot;act_volunteer_normal&quot; model=&quot;workflow.activity&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; 	&lt;field name=&quot;wkf_id&quot; ref=&quot;aflsyg_volunteer_workflow&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; 	&lt;field name=&quot;name&quot;&gt;normal&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; 	 &lt;field name=&quot;kind&quot;&gt;function&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;field name=&quot;action&quot;&gt;write({&#039;state&#039;:&#039;normal&#039;})&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;record id=&quot;act_volunteer_advanced&quot; model=&quot;workflow.activity&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; 	&lt;field name=&quot;wkf_id&quot; ref=&quot;aflsyg_volunteer_workflow&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; 	&lt;field name=&quot;name&quot;&gt;advance&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; 	 &lt;field name=&quot;kind&quot;&gt;function&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;field name=&quot;action&quot;&gt;write({&#039;state&#039;:&#039;advanced&#039;})&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;field name=&quot;flow_stop&quot;&gt;True&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;record id=&quot;trans_new_normal&quot; model=&quot;workflow.transition&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;act_from&quot; ref=&quot;act_volunteer_new&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;act_to&quot; ref=&quot;act_volunteer_normal&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;signal&quot;&gt;be_normal&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;record id=&quot;trans_normal_advanced&quot; model=&quot;workflow.transition&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;act_from&quot; ref=&quot;act_volunteer_normal&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;act_to&quot; ref=&quot;act_volunteer_advanced&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;field name=&quot;signal&quot;&gt;be_advanced&lt;/field&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/record&gt;&nbsp; &nbsp; &nbsp; &nbsp; &lt;!--&nbsp; --&gt;<br />	&lt;/data&gt;<br />&lt;/openerp&gt;
    


    view.xml中

    <br />	&lt;button name=&quot;be_normal&quot; string=&quot;晋升为正式义工&quot; states=&quot;new&quot; icon=&quot;gtk-convert&quot;/&gt;<br />	&lt;button name=&quot;be_advanced&quot; string=&quot;晋升为高级义工&quot; states=&quot;normal&quot; icon=&quot;gtk-convert&quot;/&gt;<br />	
    


  • 管理员

    把state字段中的readonly属性去掉。(不好意思,楼上的写法没错,selection 字段加readonly属性在这里完全没错)

    楼主最后证实自己的代码完全无误。



  • 去掉 readonly属性还是不行。
    PS
    现在搞定了,不是程序问题。
    只是以前我对state字段,命名重复了。后来虽说删了,还是影响了。
    这次重新建立数据库之后,就搞定了。
    谢谢校长