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

In my pdf files, I would like to show the name of Analytic Accounts.


I use the following code in odoo qweb report


However, it shows up like this:


 


There was no indication of the name of the filed.

I would appreciate any help from an Odoo developer.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi ,

Please refer to the below line of codes. This code is used in the hr_expense report to get the analytic distribution.


<span>
<span t-foreach="line.analytic_distribution" t-as="distribution">
<span t-out="line.env['account.analytic.account'].browse(int(distribution))[0].name">Analytic Account Name</span>:
<span t-out="line.analytic_distribution.get(distribution)">50%</span>
                                            </span>
                                        </span>

<field name="censored_field" invisible="1" />


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

Can this work for two analytic plans as well?

Câu trả lời hay nhất

For anyone still having issues with this problem. This is how I solved it.

 <t t-foreach="line.analytic_distribution" t-as="dist">
                                <t t-set="distributions" t-value="dist.split(',')"/>
                                <t t-foreach="distributions" t-as="distribution">
                                    <span t-if="line.env['account.analytic.account'].browse(int(distribution)).exists()">
                                    <span t-out="line.env['account.analytic.account'].browse(int(distribution)).name">Analytic Account Name</span> <t t-if="not distribution_last">,</t>
                                </span>
                                </t>
                            </t>

currently I am facing no issues when using it like this.


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thank you for your Reply.

It is work in our system

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Take a look at how we do this in the Employee Expense Report:



https://github.com/odoo/odoo/blob/17.0/addons/hr_expense/report/hr_expense_report.xml#L54

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

Hey @ray
Can this work for two analytic plans as well?

Câu trả lời hay nhất

Stuck in the same problem

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 24
1646
1
thg 4 24
1756
1
thg 8 23
2545
2
thg 7 21
4949
1
thg 12 24
1861