In odoo 15, i got the issue after trying to create Many2many field in settings:
psycopg2.errors.UndefinedTable: relation "product_product_res_config_settings_rel" does not exist
My code:
from odoo import api, fields, models
from ast import literal_eval
class SchoolSettings(models.TransientModel):
_inherit = 'res.config.settings'
product_default = fields.Many2many('product.product', string='Default Product')
@api.model
def get_values(self):
res = super(SchoolSettings, self).get_values()
if self.env['ir.config_parameter'].sudo().get_param('school.school_default_teacher'):
product_default = self.env['ir.config_parameter'].sudo().get_param('school.product_default')
res.update(
product_default=[(6, 0, literal_eval(product_default))]
)
return res
def set_values(self):
super(SchoolSettings, self).set_values()
self.env['ir.config_parameter'].set_param('school.product_default', self.product_default.ids)
Xml:
<div class="content-group">
<label string="Default Product" for="product_default"/>
<field name="product_default" widget="many2many_tags"/>
</div>
Please help, thanks.
many2many field in Odoo: https://learnopenerp.blogspot.com/2018/12/add-domain-on-many2many-field-in-odoo.html