我想在我的采购订单中添加一个“取消”按钮。此按钮会将我的记录状态更改为“已取消”。
当用户单击此按钮时,脚本会验证所有购买查询和提供商订单(如果有任何订单尚未完成或取消)。
我想添加一个弹出窗口来警告用户有关它们的信息。用户可以取消操作或追查,并取消所有相关的查询和订单。
这是我的向导模型:
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class confirm_wizard(models.TransientModel):
_name = 'tjara.confirm_wizard'
yes_no = fields.Char(default='Do you want to proceed?')
@api.multi
def yes(self):
return True
@api.multi
def no(self):
return False
我的向导视图:
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="confirm_wizard_form">
<field name="name">wizard.form</field>
<field name="model">tjara.confirm_wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Confirm dialog">
<field name="yes_no" readonly="1" />
<footer>
<button class="oe_highlight" name="yes" string="Yes" />
<button class="oe_highlight" name="no" string="No" />
</footer>
</form>
</field>
</record>
</data>
</odoo>
按钮 :
<button string="Canceled" type="object" name="canceled_progressbar" class="oe_highlight" attrs="{'invisible': [('state', '=', 'done')]}"/>
最后是两种方法:
@api.multi
def return_confirmation(self):
return {
'name': 'Are you sure?',
'type': 'ir.actions.act_window',
'res_model': 'tjara.confirm_wizard',
'view_mode': 'form',
'view_type': 'form',
'target': 'new',
}
@api.multi
def canceled_progressbar(self):
if(self.return_confirmation()):
#Do some code
else:
#Do some code
仅当按钮指向 return_confirmation 方法时才会触发该模型。这使我无法追求我的代码。当用户单击按钮时,只会出现一个弹出窗口,然后消失。
我想通过cancel_progressbar调用return_confirmation(弹出窗口),这样我就可以返回值并继续。