Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2086 Lượt xem

Hi guys,

In a contact view I have a list with the gross sales of a company by year.
I want to retrieve the total of the first line to perform a calculation in an invoice field.


Is there a way to do that?

PS: I use Odoo 15 with Studio



Thanks for assitance.

Ảnh đại diện
Huỷ bỏ

Please explain more by giving an example.

Do you want to find the total of the first column or the first row? can you please explain? what do you want to compute? The CA lines total for all years?

Tác giả

Thanks for reply.

I want to compute the first line Total with a % field (commission) and that result is the amount to retrieve in an invoice.

Tác giả

Hi,

Thanks for reply.

Here is a use case:

- A user fills each trimester the gross sales of a company
- At the end of the year he generates an invoice
- This invoice is based on the gross sale and a percentage to charge a customer

For example:
- Total gross sales: 1 000 000€
- Customer percentage: 5%
=> Invoice amount: 50 000€

So is it a way to retrieve the gross sales amount from the list as shown on the screenshot?

If the gross sales amount was a simple field, computed fields would have worked but I don't know how I can get a specific value from a list.

Tác giả Câu trả lời hay nhất

Hi,

I found a solution and share it if anyone had the same problem.

"x_res_partner_line_ids_751ec" is the list component var name
"x_studio_dernier_ca_dynamique" is the field in which I want to display the total of the gross sales
"x_studio_total" is the "Total" colum var name

==========================
for record in self:
ca_lines = len(record.x_res_partner_line_ids_751ec)
# We can get sales revenues only if at least 2 lines are filled (current year + year-1)
if ca_lines >= 2 :
# Select the second line total amount i.e. year -1
record['x_studio_dernier_ca_dynamique'] = record.x_res_partner_line_ids_751ec[1].x_studio_total
else:
record['x_studio_dernier_ca_dynamique'] = 0
==========================
Ảnh đại diện
Huỷ bỏ