How to call a wizard from a function in OpenERP7?

自古美人都是妖i 提交于 2019-12-11 20:17:15

问题


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>

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()

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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/27946554/how-to-call-a-wizard-from-a-function-in-openerp7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!