0
votes

I want to convert the record from CRM Leads to another model (Admission). I have created a button type=object to call the function:

 def convert_to_admission(self, arg):
    return {
        'name': 'custom_admission_form',
        'view_type': 'form',
        'view_mode': 'tree',
        'views': [(view_id, 'form')],
        'res_model': 'op.admission',
        'view_id': view_id,
        'type': 'ir.actions.act_window',
        'res_id': self.id,
        'target': 'new',
        'context': {
            'default_street': value['street'],
            'default_street2': value['street2'],
            'default_mobile': value['phone'],
            'default_birth_date': value['dob'],
            'default_city': value['city'],
            'default_state_id': value['state'],
            'default_country_id': value['country'],
            'default_first_name': value['first_name'],
            'default_last_name': value['last_name'],
            'default_email': value['email'],
            'default_gender': value['gender'],
            'default_prev_institute_id': 'baktuk',
            'default_family_income': value['family_income'],
        },
    }

I can see the view form pop up with automatically filled record (first_name & last name); is it's possible to make it preselect the selection fields like country_id,gender, etc.?

2

2 Answers

1
votes

To store in selection field grab value of database entry:

See the below example:-

eft_status = fields.Selection([
    ('pending', 'Pending'),
    ('done', 'Done')], string="EFT Status", default='pending')

In this tuple ('pending', 'Pending') > first one is the value which is stored in database and second one is the string which you can show in dropdown list of field.

So, most probably you can to select value is to grab something like this:-

'default_eft_status': 'pending'

This will select Pending Selection value from eft_status.

Feel free to ask if you can't understand.

0
votes

well, as long as you said that some fields are updated correctly. you need to make sure that value['country'] is a number value and the value['gender'] holds a string value listed as in the field definition. you could check these value using print() function or enable debug mode.