콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2100 화면

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.

아바타
취소

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.

작성자 베스트 답변

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
==========================
아바타
취소