如何从OpenERP7中的函数调用向导? [英] How to call a wizard from a function in OpenERP7?

查看:70
本文介绍了如何从OpenERP7中的函数调用向导?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用XML创建了下一个向导表单:

I've created the next wizard form in XML:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record model="ir.ui.view" id="confirm_unlink_res_partner_bank_wizard_form">
            <field name="name">confirm.unlink.res.partner.bank.wizard.form</field>
            <field name="model">confirm.unlink.res.partner.bank.wizard</field>
            <field name="arch" type="xml">
                <form string="Confirm removing bank account" version="7.0">
                    <group colspan="8">
                        <group colspan="8">
                            <label string="Do you want to continue?"/>
                        </group>
                        <footer>
                            <button string="Confirm" name="unlink_res_partner_bank" type="object" class="oe_highlight"/>
                            or
                            <button string="Cancel" class="oe_link" special="cancel" />
                        </footer>
                    </group>
                </form>
            </field>
        </record>
    </data>
</openerp>

我要管理的是,如果用户尝试删除模型res.partner.bank的记录(实际上您可以对任何模型进行尝试),请向他们显示一个弹出窗口(我的向导).因此,我做了下一个:

What I want to manage is that if the user tries to remove a record of the model res.partner.bank (actually you can try it with any model), show them a pop-up (my wizard). So for that, I did the next:

class res_partner_bank(orm.Model):
    _inherit = 'res.partner.bank'

    def unlink(self, cr, uid, ids, context=None):
        data_obj = self.pool.get('ir.model.data')
        form_data_id = data_obj.get_object_reference(cr, uid, 'res_partner_extended',
'confirm_unlink_res_partner_bank_wizard_form')
        form_view_id = form_data_id and form_data_id[1] or False
        # raise orm.except_orm(_('Aviso!'), _('Sobreescritura correcta.'))
        return {
            'name': 'Confirm removing bank account',
            'view_type': 'form',
            'view_mode': 'form',
            'view_id': False,
            'views': [(form_view_id, 'form'),],
            'res_model': 'confirm.unlink.res.partner.bank.wizard',
            'type': 'ir.actions.act_window',
            'target': 'new',
            'flags': {'form': {'action_buttons': True},}
        }

res_partner_bank()

但是向导表单没有显示.我检查了变量form_view_id的值,它是正确的.如果我取消注释该异常,则在尝试删除res.partner.bank时会显示该异常,因此unlink函数会被很好地覆盖.

But the wizard form is not showing up. I've checked the value of the variable form_view_id and it's right. If I uncomment the exception, it's being shown when I try to remove a res.partner.bank, so the unlink function is being overriden well.

我可能还缺少其他任何东西.有人可以帮我吗?是否可以从unlink之类的ORM方法调用视图?

There must be anything else I'm missing. Can anyone help me, please? Is it possible to call a view from an ORM method like unlink?

推荐答案

无法从ORM方法返回字典.这就是我无法从取消链接功能返回向导的原因.

It's not possible to return a dictionary from an ORM method. That's the reason for which I'm not able to return my wizard from the unlink function.

这篇关于如何从OpenERP7中的函数调用向导?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆