Hello
I want to create 5 fields of selection type: N1, N2, N3, N4 and N5. Each field must have 3 possible selections. "Yes", "No" and "Do not apply"
And I need to calculate in another field the percentage of "Yes" answers out of the total fields.
Is it possible with Odoo Studio?
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- Müşteri İlişkileri Yönetimi
- e-Commerce
- Muhasebe
- Envanter
- PoS
- Project
- MRP
Bu soru işaretlendi
Hi,
The Selection fields can be directly created with the Odoo studio. Drag and drop 'Selection' from the Add > New fields selection and in the field properties popup add the required selection options - 'Yes', 'No', 'Do not apply'.
For the percentage calculation a Decimal(float) field can be used. We have to define a compute function for this float field. For that select the field, cllck on the 'More' option under the Properties tab. In the form view , you can see the options to provide Dependencies and Compute function.
In the dependencies provide the names of the 5 selection fields separated by comma. For example - x_studio_n1, x_studio_n2,x_studio_n3, x_studio_n4,x_studio_n5.
In the Compute field provide the code to calculate our percentage.
Sample Code:
for record in self:
yes_count = 0
if record.x_studio_n1 == 'Yes':
yes_count += 1
if record.x_studio_n2 == 'Yes':
yes_count += 1
if record.x_studio_n3 == 'Yes':
yes_count += 1
if record.x_studio_n4 == 'Yes':
yes_count += 1
if record.x_studio_n5 == 'Yes':
yes_count += 1
record['x_studio_percentage'] = yes_count*100/5Regards
Thank you so much, I prove it and it works perfectly¡
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Üye Ol| İlgili Gönderiler | Cevaplar | Görünümler | Aktivite | |
|---|---|---|---|---|
|
Create a consecutive field
Çözüldü
|
|
1
Kas 21
|
3141 | |
|
|
0
Tem 22
|
2091 | ||
|
|
0
May 22
|
2611 | ||
|
|
1
Nis 25
|
2012 | ||
|
Restrict Studio ,to users
Çözüldü
|
|
1
Ara 24
|
3390 |