Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

psycopg2.errors.UndefinedTable: relation "product_product_res_config_settings_rel" does not exist Odoo 15

Subscribe

Get notified when there's activity on this post

This question has been flagged
settingsmany2manyv15
3 Replies
10023 Views
Avatar
fudo

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.

0
Avatar
Discard
Sehrish

many2many field in Odoo: https://learnopenerp.blogspot.com/2018/12/add-domain-on-many2many-field-in-odoo.html

Avatar
fudo
Author Best Answer

I've found the answer based on "Kiran K" answer:


from odoo import api, fields, models
from ast import literal_eval

class SchoolSettings(models.TransientModel):
_inherit = 'res.config.settings'

# many2many will give you multiselect options, when many2one only give you select option
# to use many2many, we must declare the middle table to connect 2 tables together.
# in this example, i create a new table named 'config_product_rel'
# with 2 column connect 2 table that is 'id' for the 'ir_config_parameter' table
# and 'product_id' for 'product_product' table
product_default_many2many = fields.Many2many('product.product', 'config_product_rel', 'id', 'product_id',
'Default Product Many2many')

@api.model
def get_values(self):
res = super(SchoolSettings, self).get_values()

# set values for many2many field
if self.env['ir.config_parameter'].sudo().get_param('school.product_default_many2many'):
product_default_many2many = self.env['ir.config_parameter'].sudo().get_param('school.product_default_many2many')
res['product_default_many2many'] = [(6, 0, literal_eval(product_default_many2many))]

return res


def set_values(self):
# get values for many2many field
self.env['ir.config_parameter'].set_param('school.product_default_many2many', self.product_default_many2many.ids)


Thanks.

0
Avatar
Discard
Avatar
Kiran K
Best Answer

Hi  ​fudo,

Try, 

class ResCompany(models.Model):
_inherit = 'res.company'

def _active_products(self):
return self.env['product.product'].search([]).ids

product_ids = fields.Many2many('product.product', 'company_product_rel', 'company_id', 'product_id',
'Default Product',default=_active_products)


class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'

product_ids = fields.Many2many(related='company_id.product_ids', relation='product.product', readonly=False)

Hope it helps,
Kiran K


3
Avatar
Discard
fudo
Author

thanks you sir, but your answer is way too much for what i asking.

fudo
Author

I've post my answer above based your answer, thanks you for helping me.

Kiran K

https://www.cybrosys.com/blog/how-to-save-many2many-field-in-odoo-13-settings

fudo
Author

thanks you sir.

Avatar
Bryan Sandoval
Best Answer

Lo definí así y funciono.

classProductWizard(models.TransientModel):

    _name = "product.wizard"

    _description = "See all Products and warehause"

    pricelist_ids = fields.Many2many(comodel_name='product.pricelist', string='Pricelist', required=True)

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
many2many restrict selection [odoo15]
many2many v15
Avatar
0
Sep 22
2480
how to use special comand for manymany fields
many2many v15
Avatar
Avatar
1
Jul 22
2794
choose an attachment from ir.attachment
attachment many2many v15
Avatar
0
Feb 23
157
Implicit/canonical naming of many2many relationship table is not possible when source and destination models are the same Solved
many2many relational v15
Avatar
Avatar
1
Jul 22
6321
Upon pressing save in a wizard, populate a many2many field
wizard many2many v15
Avatar
0
Jul 22
2922
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now