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

Hi. I am working with Odoo Enterprise 16.4e+

Currently I have Manpower table in QWeb report showing workers with their position.

What I want to do is showing amount of each position in different table as depicted below. Is it possible to get the count?

Any help will be appreciated. Thanks!


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

Hi,

You can use a query to get the count and pass it to the report and show it in the qweb report.
The Query will be something like this:
SELECT COUNT(position), name FROM Customers GROUP BY positon;


Hope it helps


Ảnh đại diện
Huỷ bỏ
Tác giả

Hi. Thanks for the query but where to put that and how to show it in the qweb?

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

Hi,
What you are looking for is technically it is doable .

As saas 16.4 , doesn't support custom module or python codes, you can create a template as follows:

* Add new table to existing report or build it as a new report
* Fetch all job positions from the hr.job model
* To get count of employees in this position you can utilize the employee_ids field in the hr.job model




Thanks

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

<templates>
<t t-set="jobs" t-value="request.env['hr.job'].search([])"/>
<t t-name="job_table">
<table class="table table-condensed">
<thead>
<tr>
<th>Job</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<t t-foreach="jobs" t-as="job">
<tr>
<td><t t-esc="job.name"/></td>
<td><t t-esc="len(job.employee_ids)"/></td>
</tr>
</t>
</tbody>
</table>
</t>
</templates>

Tác giả

Hi Niyas. Thankyou for the answer but it shows all positions while the report I am working on is only showing some selected employee with their job position

depending on how employees are filtered/selected in other section of the report, you need to filter here also

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 25
3977
2
thg 7 20
3773
1
thg 4 25
1355
2
thg 3 25
1548
4
thg 11 24
7230