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
==========================
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?
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.
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.