How to Pass Current ID to Wizard via a button form in Odoo 13 Enterprise?

Asked by Leon Nguyen

Hello,

I'm trying to open a form view number 2 with the current parameter has filled in the form view number 1. After clicking the button, it can open the Form view (2) but still not have the current name was filled in before.

I'm using Many2one to get already data for the name.
name = fields.Many2one('hr.employee', string="The Number", required=True)

This is my code in py file:

    def create_field(self):

        return {
            'name': self.name,
            'view_mode': 'form',
            'res_model': 'dieu.chinh',
            'view_id': False,
            'context': {'current_id': self.id},
            'target': 'current',
            'type': 'ir.actions.act_window',
        }

And my code for the button in XML file like this:

<button type="object" string="TĂNG LAO ĐỘNG" name= "create_field" class="oe_highlight"/>

Please help!

Thank you!

Question information

Language:
English Edit question
Status:
Answered
For:
Odoo Web Client Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Farid Ghanchi (gfarid) said :
#1

In wizard you will get this way parent id.
res_ids = self._context.get('active_ids')

thanks

Revision history for this message
Leon Nguyen (leonq8) said :
#2

Hi Farid,

I have no result after using your code? What am I doing wrong?

Can you help with this problem?

Provide an answer of your own, or ask Leon Nguyen for more information if necessary.

To post a message you must log in.