Skip to Content
Menu
This question has been flagged
1 Reply
4165 Views

need to create many2many values in base.config.settings but when open already created that field empty,

please guide me how to use many2many field in configuration model


class BaseConfigSettingsInherit(models.TransientModel):
    _inherit = 'base.config.settings'
   
    res_model_email = fields.Many2many('ir.model','partner_email_conf_relat','config_id','model_id',string="Models", help="Here Selected model Internal Log not only send email to Specfied Group users", store=True)

Avatar
Discard
Best Answer

Hello KLN,

try as below code into your inherited object

@api.model
def get_default_<your_fieldname>(self, fields):
        value = self.env['ir.config_parameter'].sudo().get_param('modulename.your_field_name')
        return {
            'your_fieldname': value # list of ids
        }

@api.multi
def set_<your_fieldname>(self):
    self.env['ir.config_parameter'].sudo().set_param('modulename.your_field_name', [(4, record_ids)])
Thanks
Avatar
Discard
Related Posts Replies Views Activity
2
May 17
10098
0
Jul 22
731
1
Jan 22
9930
4
Feb 20
2968
1
Jul 19
5400