Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
2172 Visualizzazioni

I have a model with a One2Many or Many2Many-Field and I would like to open a form to search/select related records on button click. In my model I created an action which opens the search form but how do I store the results in my Many2many-Field?


# field to store the record selection in
document_ids = fields.Many2many('document', ......

def action_select_document_ids(self):
return {
'name': _('Select documents'),
'view_type': 'tree',
'view_mode': 'tree',
'res_model': 'document',
'view_id': False,
'context': { },
'type': 'ir.actions.act_window',
'target': 'new'
}

Thanks
Avatar
Abbandona
Risposta migliore

Hi,


You can modify your action to include a callback to handle the selected records. Here's an example:def action_select_document_ids(self):

        return {

            'name': _('Select documents'),

            'view_mode': 'tree, form',

            'res_model': 'document',

            'view_id': False,

            'context': { },

            'type': 'ir.actions.act_window',

            'target': 'new',

            'domain': [('id', 'in', self.document_ids.ids)] ,

        }




Hope it helps

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
lug 20
3293
0
giu 19
3313
5
gen 24
8376
1
nov 16
8218
1
feb 24
1961