How to get and set a Many2many field in res.config.settings
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
Hi,
You can check this https://www.odoo.com/forum/help-1/question/12-0-enable-features-in-the-res-config-settings-149566 link
Hi,
You can refer to the link specified in the other answer. To be a little more specific with the many2many field, 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)
See this Video For Odoo12: How To Save Many2many Field Value In Settings Odoo
Thanks
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrirePublications associées | Réponses | Vues | Activité | |
---|---|---|---|---|
|
4
avr. 23
|
6960 | ||
|
1
juin 21
|
7482 | ||
|
6
mars 24
|
22700 | ||
|
1
août 18
|
5173 | ||
|
0
juin 15
|
4745 |