Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2865 Lượt xem

In Odoo14 I am trying to get value of field module_sale_margin from res.config.settings. but it always return False 


See below code for what I have tried.


sale_margin_module = self.env['ir.config_parameter'].sudo().get_param('sale.module_sale_margin') or False

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

If you check the field in the code, you can see that this field value is not stored inside the ir config parameter model. Currently when we enable and disable this field, the module sale_margin will get installed/uninstalled from the database.

So if you need to know whether this is activated or not, just see the status of the corresponding module.

Code sample:

sale_margin = self.env['ir.module.module'].search([('name' ,'=', 'sale_margin')])

if sale_margin.state == 'installed':

  


Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
2509
2
thg 7 25
7950
2
thg 7 25
4388
2
thg 7 25
4098
2
thg 6 25
2694