Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
3451 Zobrazení

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
Zrušit

Hi,

Do you need Many2one based on condition?

Nejlepší odpověď


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
Zrušit
Autor

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)

Autor

thanks for your answer

Nejlepší odpověď

Hi, 

You can follow following link for this:

https://youtu.be/GPhgxxwprA4

Hope it helps,

Thanks

Avatar
Zrušit