首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Odoo中弹出显示确认

问在Odoo中弹出显示确认
EN

Stack Overflow用户
提问于 2022-11-07 08:11:14
回答 1查看 71关注 0票数 0

如何通过代码在Odoo15中显示确认弹出,如果确认(为真)或未确认(为假),如何获得结果,并根据此结果继续我的python代码。我希望能够在任何时候通过python函数显示这个对话框。我不想使用向导,因为向导只能通过返回来调用它。我不希望xml中的按钮确认=‘’,我希望通过python代码调用对话框,如果确认或不继续我的python代码,将得到结果。

向导阻止代码,因为它返回向导,所以我尝试了Js2py模块,其中我从python调用javascript函数,但是由于js2py在javascrript中给出了请求(‘’)函数的错误,所以不可能发生。

EN

回答 1

Stack Overflow用户

发布于 2022-11-07 12:08:40

示例py用于向导

代码语言:javascript
复制
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

代码语言:javascript
复制
<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,您将在其中调用向导

代码语言:javascript
复制
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 Wizard
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74343612

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档