Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
5209 Prikazi

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
Opusti
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
Opusti
Related Posts Odgovori Prikazi Aktivnost
2
maj 17
11153
0
jul. 22
1545
1
jan. 22
11257
4
feb. 20
4198
1
jul. 19
6517