Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1762 Lượt xem

Hello all,


I would like to display a confirmation popup when saving, creating, or modifying a field. Cancel popup will cancel modifications.

Doable with inherit of methods write, create,..


But, the difficulty is that I want to allow the user to choose the fields that trigger the popup call.

How to proceed dynamically?


Thank you in advance !


Jérôme

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Hello Creyox Technologies,

Thanks, nice approach.

However, write method doesn't open my action to show the wizard, and I think she can't.

Any alternatives ? 

class Esignature(models.Model):
    _inherit = 'res.partner'

    @api.multi
    def write(self, vals):
        rc = super(Esignature, self).write(vals)

        # Resarch in modified vals in field need confirmation
        for val in vals:
            field_rc = self.env['ir.model.fields'].search([('model', '=', self.model.model), ('name', '=', val), ('need_confirm', '=', True)])
            if field_rc:  # Confirmation needed, show confirmation wizard
                return {
                    'name': 'Open Wizard',
                    'type': 'ir.actions.act_window',
                    'res_model': 'a4.password.request',
                    'view_mode': 'form',
                    'target': 'new',
                }

        return rc



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello,

You can put a boolean field inside the ir.fields models to identify whether this field is a popup call field or not.
If you get a modified field in the popup call field then you can trigger the popup.

Thanks,
info@creyox.com

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 10 16
4094
3
thg 4 18
5058
2
thg 4 23
23170
4
thg 6 25
1890
1
thg 6 25
734