I am working on an app where I need to set a default pricelist, based on whether the res.partner (Contact) is an individual or a company. This needs to be a field in the settings tab, so that the user can select which pricelist to use for company and which one for individuals. I managed to get this field to show up with this model:
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
default_pricelist_company = fields.Many2one(
'product.pricelist',
string="Default Pricelist for Companies",
default_model='res.partner',
config_parameter='my_addon.default_pricelist_company'
)
default_pricelist_individual
= fields.Many2one(
'product.pricelist',
string="Default Pricelist for Individuals",
default_model='res.partner',
config_parameter='my_addon.default_pricelist_individual'
)
However, this causes an error on save, that the field res.partner.pricelist_company does not exist.
I am relatively new to odoo so I am not sure exactly what i am doing wrong or how to properly set up these settings. Any help, or explanation of what i am doing wrong is highly appreciated, thanks!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
2
Trả lời
2024
Lượt xem
Hi,
The default_model argument is unnecessary here, as the settings are stored in the system parameter, not directly on the res.partner model. so default_model should be removed
Hope this will help you
thanks
The problem I was encountering was because my variables started with "default_", changing them resolved the issue in my case.
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
4
thg 5 25
|
2696 | ||
|
2
thg 5 25
|
6125 | ||
|
1
thg 3 25
|
1807 | ||
|
4
thg 3 25
|
4695 | ||
|
3
thg 2 25
|
5769 |
I tried removing the default_model, but then I ran into this error:
File "/home/linuxsub/odoo/odoo/odoo/addons/base/models/res_config.py", line 427, in _get_classified_fields
raise Exception("Field %s without attribute 'default_model'" % field)
Exception: Field res.config.settings.default_pricelist_company without attribute 'default_model'