Skip to Content
Menu
This question has been flagged
2 Replies
3067 Views

I want to create selection drop down from a model. I want to get current year and it will calculate 5 years later and appearance at drop down. How can do it?

Thanks for your reply

Avatar
Discard

Hi,

Do you need Many2one based on condition?

Best Answer


i  believe that you can't change values of a selection field as values are loaded at form load and can`t be changed.

Avatar
Discard
Author

Can you give me an example ?

if you can add a onchange and domain,do like this

@api.onchange('partner_id')

def apply_domain_customer(self):

vehicles = self.env['fleet.vehicle'].search([('driver_id', '=',

self.partner_id.id)]).ids

return {

'domain': {

'vehicle': [('id', 'in', vehicles)]

}}

you can get date using datetime library in python

datetime.now()

and

from dateutil.relativedelta import relativedelta

new_date = old_date + relativedelta(years=5)

Author

thanks for your answer

Best Answer

Hi, 

You can follow following link for this:

https://youtu.be/GPhgxxwprA4

Hope it helps,

Thanks

Avatar
Discard