Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5381 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
kvě 17
11324
0
čvc 22
1659
1
led 22
11394
4
úno 20
4432
1
čvc 19
6648