gpt4 book ai didi

python - 工作流程按钮 Odoo v8

转载 作者:太空宇宙 更新时间:2023-11-03 14:50:49 24 4
gpt4 key购买 nike

我正在模块中执行工作流程,我已在 __openerp__ 文件中声明了工作流程 xml,执行了所有按钮功能,添加了 state 选择字段,并且在我看来还有statusbar,这是按钮功能之一:

def budget_validate(self,cr, uid, ids, context=None):

if context is None:

context = {}

self.write(cr, uid, ids, {'state': 'validate'}, context=context)

return True

就一个,因为无论我点击哪个,错误都是一样的,这是我的字段:

    state = fields.Selection([
('draft', 'Draft'),
('confirm', 'Confirm'),
('validate', 'Validate'),
('last', 'Last'),
('current1', 'Current1'),
('current2', 'Current2'),
('current', 'Current'),
('next', 'Next'),
('adjusted', 'Adjusted'),
('done', 'Done'),
], string="State", readonly=True, copy=False)

我的 View xml:

        <record id="view_order_form" model="ir.ui.view">
<field name="name">account.budget.bsi.form</field>
<field name="model">account.budget.bsi</field>
<field name="arch" type="xml">
<form string="Sales Order">
<header>
<button string="Confirm" name="confirm" states="draft" type="object" class="oe_highlight"/>
<button string="Approve" name="validate" states="confirm" type="object" class="oe_highlight"/>
<button string="Last" name="last" states="confirm" type="object" class="oe_highlight"/>
<button string="Current 1" name="current1" states="last" type="object" class="oe_highlight"/>
<button string="Current 2" name="current2" states="current1" type="object" class="oe_highlight"/>
<button string="Current" name="current" states="current2" type="object" class="oe_highlight"/>
<button string="Next" name="next" states="current" type="object" class="oe_highlight"/>
<button string="Adjusted" name="adjusted" states="next" type="object" class="oe_highlight"/>
<button string="Done" name="done" states="adjusted" type="object" class="oe_highlight"/>
<button name="draft" states="cancel" string="Reset to Draft" type="object" class="oe_highlight"/>
<button string="Cancel Budget" name="cancel" states="confirm,validate" type="object" />
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,last,current1,current2,current,next,adjusted,done,cancel" clickable="True"/>
</header> ...

每次我点击任何按钮,它都会抛出我:

Traceback (most recent call last):
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 546, in _handle_exception
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 583, in dispatch
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 319, in _call_function
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\service\model.py", line 118, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 316, in checked_call
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 812, in __call__
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 412, in response_wrap
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\web\controllers\main.py", line 948, in call_button
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
AttributeError: 'account.budget.bsi' object has no attribute 'validate'

最初,我将这些按钮设置为 type="workflow" 但在这种情况下,这些按钮不会执行任何操作。没有任何错误,但状态不会改变。

那么,有什么想法吗?

最佳答案

这就是我解决这个问题的方法:

@api.one
def budget_validate(self):
self.write({'state': 'validate',})

保留 select 字段不变,并将按钮保留为 xml View 上的对象。

关于python - 工作流程按钮 Odoo v8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45907103/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com