Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ

Hi,

I want to create a company-dependent boolean custom setting field in Odoo, and I plan to relate it to a custom field in the res.company model. I understand how this could be implemented, but I couldn’t find any similar examples in the Odoo 17 codebase. Is this approach considered best practice, or could it potentially cause issues?

Ảnh đại diện
Huỷ bỏ
Tác giả

For the reason I simply want to enable a validation in my model. Are you suggesting that I should create system parameters for each individual company?

Câu trả lời hay nhất

And what do you want to do with it? 

I have similar cases where I have a setting in res.config.settings with a get_values and set_values in the module and then accessed with get_param from other modules... (I mean to access a global setting from other modules)

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất
I'm sorry but I had to rewrite my question to better explain the case. This is an example of what I am talking about:


from odoo import models, fields


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

    custom_setting = fields.Boolean(
        string="Custom Setting",
        related="company_id.custom_setting",
        readonly=False
    )

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

    custom_setting = fields.Char(string="Custom Setting")
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 10 23
5269
5
thg 6 20
5920
0
thg 12 20
5296
2
thg 4 23
6265
3
thg 4 17
11616