Skip to Content
Menu
This question has been flagged
2 Replies
727 Views

Hello Odoo's gurus,


In try to create a custom sum in the report of expenses. To make it simple, I made it with existing values: unit_amount in the expense report.


I have created a new value in Studio (float) in the expense report: x_studio_total_unit


In the depencies of the "x_studio_total_unit", I put:

 x_studio_total_unit


For the calculation, I use a code grabbed and adapted from this forum...

sum = 0

for record in self:

      for rec in record.expense_line:

          if rec.unit_amopunt:

              sum += rec.unit_amount

 record['x_studio_total_unit'] = sum


Of course, it does not work... but its does not crash !

I am on Odoo 15, web version.

Thanks for your support.

Avatar
Discard
Best Answer

In dependencies you will put the 

expense_line_ids

Here you are the code:

for record in self:
sum = 0
for rec in record.expense_line_ids:
if rec.unit_amount:
sum += rec.unit_amount
record['x_studio_total_unit'] = sum


Avatar
Discard
Author Best Answer

You are THE man !

Thanks, its works perfectly.

Avatar
Discard