Skip to Content
Menu
This question has been flagged
1 Reply
2334 Views

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?

Avatar
Discard
Best Answer

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.

Avatar
Discard

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

Related Posts Replies Views Activity
0
Nov 23
451
1
Nov 22
1933
2
Aug 22
2319
1
May 22
3124
1
Apr 22
1802