如何通过代码在Odoo15中显示确认弹出,如果确认(为真)或未确认(为假),如何获得结果,并根据此结果继续我的python代码。我希望能够在任何时候通过python函数显示这个对话框。我不想使用向导,因为向导只能通过返回来调用它。我不希望xml中的按钮确认=‘’,我希望通过python代码调用对话框,如果确认或不继续我的python代码,将得到结果。
向导阻止代码,因为它返回向导,所以我尝试了Js2py模块,其中我从python调用javascript函数,但是由于js2py在javascrript中给出了请求(‘’)函数的错误,所以不可能发生。
发布于 2022-11-07 12:08:40
示例py用于向导
class TestModelWizard(models.TransientModel):
_name = 'salesperson.bulkassign'
name = fields.Char(related = 'users.name')
users = fields.Many2one("res.users")
def action_apply(self):
#perform your confirm action here向导示例XML
<record model="ir.ui.view" id="wizard_with_step_form">
<field name="name">wizard_with_step.form</field>
<field name="model">salesperson.bulkassign</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Wizard with step" version="7.0">
<group >
<field name="users" widget="one2many_list" nolabel="1" >
<tree editable="bottom" create="false" delete="false" no_create_edit="1" edit="false">
<field name="name" readonly="1"/>
</tree>
</field>
</group>
<footer >
<button name="action_apply" string="Action Confirm" type="object"/>
</footer>
</form>
</field>
</record>示例py,您将在其中调用向导
def action_open_wizard(self):
users = self.env["res.users"].search([])
dic = []
for i in users:
if i.has_group('sales_team.group_sale_salesman'):
i.check_box = False
dic.append(i.id)
#if your condition for calling wizard
return {
'name': _('Salesperson Bulk Assign Lead'),
'type': 'ir.actions.act_window',
'res_model': 'salesperson.bulkassign',
'view_mode': 'form',
'res_id': self.id,
'context':{"default_users":dic,"default_crm":self.env.context.get('active_ids')} # you can pass the values here in the wizard,
'target': 'new'
}
else:
#what ever you want to do if not want to call Wizardhttps://stackoverflow.com/questions/74343612
复制相似问题