تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
3416 أدوات العرض

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

الصورة الرمزية
إهمال

Hi,

Do you need Many2one based on condition?

أفضل إجابة


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

الصورة الرمزية
إهمال
الكاتب

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)

الكاتب

thanks for your answer

أفضل إجابة

Hi, 

You can follow following link for this:

https://youtu.be/GPhgxxwprA4

Hope it helps,

Thanks

الصورة الرمزية
إهمال