콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3176 화면

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?

아바타
취소
베스트 답변

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

관련 게시물 답글 화면 활동
0
11월 23
1891
1
11월 22
4568
2
8월 22
4770
1
5월 22
5224
1
4월 22
3702