İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
1138 Görünümler

Hi, I use  Odoo Online ( and I need to create a field that transforms the date into the number of the day of the year:
ex. 1 = 1/25/2022 = 25
ex. 2 = 05/14/2022 = 134
ex. 3 = 08/12/2022 = 224
I don't have much experience so please be as simple as possible.

Thank you

Avatar
Vazgeç
En İyi Yanıt

Hi,

In Odoo Online you can make use of the Odoo Studio app to do this. To do that please follow the below steps:-

1) Go to settings and turn on the developer mode by clicking the "Activate the developer mode" button under the Developer Tools
2) Now go to the view in which you need to add the field.
3) Now switch to studio mode by clicking on the "Toggle Studio" button found in the top right corner.
4) Now add and name one date field and an integer field using the studio. (You can refer to Odoo Studio Book for help: https://www.cybrosys.com/odoo/odoo-books/odoo-15-studio/build-an-app/creating-models-and-adding-fields/)
5) Now we need to add compute method for the integer field for that you can refer to Odoo Studio Book: https://www.cybrosys.com/odoo/odoo-books/odoo-15-studio/build-an-app/define-compute-method/
6) In "Dependencies" you need to add the technical name of the date field which you will get from studio view or just by placing the name over the date field(which will be similar to "x_studio_input_date").
7) Now in the "Compute" field you need to enter the following code "for rec in self:
rec['x_studio_date_of_the_year'] = rec.x_studio_input_date.strftime('%j')"
8) Now you can save it and close the studio view.

Now the integer field will show the day of the year when the value in the input date field is changed

Regards

Avatar
Vazgeç
En İyi Yanıt

Sure! You can create a custom field in Odoo which performs the desired transformation. All you need to do is define the formula and let Odoo calculate the field for each entry automatically. It's simple, fast, and requires no prior experience!

Avatar
Vazgeç
Üretici En İyi Yanıt

Thank you very much, I will trThank you very much, I will try 👍🏼

Avatar
Vazgeç
Üretici

Hello @Cybrosys Techno Solutions Pvt.Ltd
I had found another solution, but now I need your hand to make yours work.
I tried but it doesn't work for me. The procedure I have adopted is the following:
- created the Date field (x_studio_date_of_the_year)
- created the Day field (x_studio_input_data) and inserted the following formula:
Dependencies : x_studio_date_of_the_year
Calculation : for record in self: record['x_studio_date_of_the_year'] = record.x_studio_input_data.strftime('%j')
It does not work!
But surely I made a mistake in some steps

Could you kindly give me a hand?

Thanks 1000

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Eyl 24
1986
2
Tem 24
2149
1
Nis 24
5250
0
Oca 24
1676
0
Ağu 25
1648