I have created a new model called res.partner.link.category. I have also created a button in the model res.partner, which opens a form to create a new record of res.partner.link.category (I have defined this form too). Everything is fine, but I need one of the fields of the form to have a specific value (to be accurate, the field is partner_id and I want it to value 5 ~when I manage this, I will turn this value to something more logical~). I tried with context, but, by the moment, no results. Here my code:
def create_rplc(self, cr, uid, ids, context=None):
if context is None:
context = {}
context['partner_id'] = 5
data_obj = self.pool.get('ir.model.data')
data_id = data_obj._get_id(cr, uid, 'res_partner_extended', 'res_partner_link_category_create_form_view')
view_id = False
if data_id:
view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
return {
'name': 'Creation',
'view_type': 'form',
'view_mode': 'form',
'views': [(view_id, 'form'),],
'res_model': 'res.partner.link.category',
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
'flags': {'form': {'action_buttons': True}},
'context': context,
}
How can I manage this?