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

Hello Odoo Community:

    I would like to see average margin_percentage in the sale list view. I used this code: 

   I am able to see the average value for all sale orders; however, when I grouped orders according to customers, average values become sum values for each group. How could I change it to average again? Thank you so much!

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

You can use the group_operator attribute to decide which value to see when using grouping.

group_operator="avg" gives the average value when grouping.


Here's an example for your reference:
margin_percentage = fields.Float(string="Margin Percentage",
                 group_operator='avg')


Hope it helps

Awatar
Odrzuć
Autor

Thank you so much!

Najlepsza odpowiedź

The code is not visible, 

This is an example of showing Average 


Also odoo reference state the following regarding avg:
displays the corresponding aggregate at the bottom of the column. The aggregation is only computed on currently displayed records. The aggregation operation must match the corresponding field’s group_operator.

If you code was visible, I might be able to help you more

Awatar
Odrzuć
Autor

Thank you for your reply, but I cannot see the example you shown

Powiązane posty Odpowiedzi Widoki Czynność
1
sie 25
653
1
lis 22
2985
2
kwi 19
8104
1
sty 24
15419
1
mar 15
4039