0
votes

Inserting values from two form views into one model.

For example ! Form view (view mode) and popup window(form view) and model(StudentRegistration).

how i can insert field values by both form views as according to my scenario.

For example : Initially student's status is 'not-registered' course . After registration student's status must be changed to 'Registered'. This action i need to perform via clicking 'button' on form view(view mode) to open a new popup window to insert that specific field 'status'.

1

1 Answers

0
votes

just open a new window and provide the id of the record that you want to change the status field for.

@api.multi
def registration(self):
    self.ensure_one()
    # you logic here to registrate
    # now time to open the window to change
    # the status field

    # first you need to look for the form 
    # this form have the button that change the status
    form_id = self.env.ref('module_name.form_status_id')
    return {
        'name': _('Confirm registration'),
        'view_type': 'form',
        'view_mode': 'form',
        # model containing the status
        'res_model': 'model.name',
        # here i'm assuming that you want to change the status field
        # of the same record 
        # but if the status field is in student model for example
        # and the relation is m2o so use the m2o field to
        # pass the id of the record self.student_id.id 
        # hope you get the idea
        'res_id': self.id,
        'view_id': form_id.id,
        'type': 'ir.actions.act_window',
        'target': 'new',
    }