Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
1105 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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!

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
1
wrz 24
1835
2
lip 24
1945
1
kwi 24
5017
0
sty 24
1530
0
paź 23
1504