I am trying to add more values to the base field vehicle_type in the fleet.vehicle.model model of the Fleet App. Currently only Car and Bike are a available and I'd like to add Truck and a few more options using a server action (this is the easiest way no?).
I am underequipped from a coding perspective in python but I have researched it and I am pretty sure I need to use selection_add as such for example:
vehicle_type = fields.selection(selection_add=[('truck', 'Truck')])
I just don't know how to completely package the entire statement with class, _inherit, etc. etc. so that it works.
Can anyone please advise?
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ờ
Server Actions can't be used to alter base fields like vehicle_type.
You would need to write a module.
You might consider using Odoo Studio to make your own custom field though, since you are likely to be equipped to be able to do this easier than the alternative. See an older video (still applicable) at https://www.youtube.com/watch?v=o7xVFypSbLk to learn how to do this.
Developer documentation is at https://www.odoo.com/documentation/15.0/developer.html and there is a link at the bottom "Building a Module" that you should spend time reviewing.
Some review of the existing code would also be needed before using selection_add since there are places where the selection option is used for other purposes, see https://github.com/odoo/odoo/blob/15.0/addons/fleet/models/fleet_vehicle.py#L253

All this to say it is not trivial to add the additional option, so we would recommend your own custom field instead.
Hello Ray - thank you very much for this feedback. I have begun wondering if that were the more sensible way to go about this and it sounds like it is. Getting under the hood to modify this seems like a LOT of work for not much return for our needs.
I really appreciate you reverting on this.
Cheers
Jamie
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 | |
|---|---|---|---|---|
|
|
0
thg 11 23
|
1906 | ||
|
Create order_line from code
Đã xử lý
|
|
1
thg 11 22
|
4596 | |
|
|
2
thg 8 22
|
4779 | ||
|
How to round sum of if code
Đã xử lý
|
|
1
thg 5 22
|
5233 | |
|
|
1
thg 4 22
|
3706 |