Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How can I save custom many2many fields inside configuration settings of website Odoo 13?

Odoberať

Get notified when there's activity on this post

This question has been flagged
configurationmany2manywebsiteres.configOdoo13.0
3 Replies
11294 Zobrazenia
Avatar
Rob Bro

I was trying to make two many2many fields inside configuration settings of website. I could make both fields fields but I was not able to save the multiple entered values.  This is the error that occured


 File "/home/RobertD'Souza/Desktop/odoo-13.0/odoo/models.py", line 1688, in _add_missing_default_values     if self._fields[name].type == 'many2many' and value and isinstance(value[0], int):
KeyError: 'web_products'



And this is the code I used


class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
web_product = fields.Many2many('product.template', string="Website Products")
web_category = fields.Many2many('product.public.category', string="Website Categories")

def set_values(self):
res = super(ResConfigSettings, self).set_values()
self.env['ir.config_parameter'].set_param('website_product_visibility.web_product', self.web_product)
self.env['ir.config_parameter'].set_param('website_product_visibility.web_category', self.web_category)
return res

@api.model
def get_values(self):
res = super(ResConfigSettings, self).get_values()
ICPsudo = self.env['ir.config_parameter'].sudo()
web_product = ICPsudo.get_param('website_product_visibility.web_product')
web_category = ICPsudo.get_param('website_product_visibility.web_category')
res.update(
web_products=web_product,
web_categories=web_category
)
return res
1
Avatar
Zrušiť
Avatar
Niyas Raphy (Walnut Software Solutions)
Best Answer

Hi,

You can try this code.

class XYZConfigSettings(models.TransientModel):
_name = 'xyz.config.settings'
_inherit = 'res.config.settings'

product_ids = fields.Many2many('product.product', string="Products")

@api.model
def get_default_values(self, fields):
IrValues = self.env['ir.values'].sudo()
product_ids = IrValues.get_default('xyz.config.settings', 'product_ids')
lines = False
if product_ids:
lines = [(6, 0, product_ids)]
return {
'product_ids': lines,
}

@api.multi
def set_default_values(self):
IrValues = self.env['ir.values'].sudo()
IrValues.set_default('xyz.config.settings', 'product_ids', self.product_ids.ids)

For adding settings and saving values in settings, see: How To Add Settings/Configuration For Module in Odoo

To add many2many Field in the Settings in Odoo12 See this: How To Save Many2many Field Value In Settings Odoo

Thanks


1
Avatar
Zrušiť
Rob Bro
Autor

Thank you for answering Niyas, unfortunately it does not work as most of your code is written in Odoo 10 and I'm doing in Odoo 13. I've tried changing ir.values to ir.default and other necessary changes to fields but still not working.

Niyas Raphy (Walnut Software Solutions)

https://www.youtube.com/watch?v=-n7Ttx1Czdw

Rob Bro
Autor

Thank you so much, this was what I needed.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

You can refer the blog below for storing a many2many field in settings of Odoo 13

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

Regards

2
Avatar
Zrušiť
Avatar
Anusha
Best Answer

Hi,

   Refer this https://www.odoo.com/forum/help-1/question/how-to-get-and-set-a-many2many-field-in-res-config-settings-odoo-12-159437        Make changes accordingly   

1
Avatar
Zrušiť
Rob Bro
Autor

It is working fine with a text field, the problem only arises during the usage of many2many fields.

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

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Store Many2many field in Configuration settings odoo13
configuration store many2many res.config Odoo13.0
Avatar
Avatar
Avatar
Avatar
3
aug 25
7537
How to set Configuration Values from Database for mandatory_billing_fields
configuration databsecursor website website_sale res.config
Avatar
0
mar 15
5194
Odoo 15 - Can't properly update custom many2many field from website
many2many website
Avatar
0
máj 22
3266
Record in many2many is not visible when click save
many2many Odoo13.0
Avatar
Avatar
1
feb 21
4495
Odoo 16 - Programatically setup 'Free Sign Up'
configuration signup website
Avatar
Avatar
1
máj 24
2700
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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