我想知道如何通过列数而不是行数来配置分页符。 例如,我想在每个页面5列。 我怎么能意识到这一点?
<blockTable colwidths="150,100,100,100,100,100" style="Table1">
<tr>
<td>
<para style="P8">NOM EMPLOYÉ</para>
</td>
<td>
<para style="P7">[[ repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end), 'o', 'td') ]]</para>
<para style="P7">[[ o['name'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P8">Matricule</para>
</td>
<td>
<para style="P7">[[ repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end), 'p', 'td') ]]</para>
<para style="P7">[[ p['matricule'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P8">HEURES SUPPLEÉMENTAIRES 100%</para>
</td>
<td>
<para style="P7">[[ repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end), 'a', 'td') ]]</para>
<para style="P7">[[ a['hours_overtime_100'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P8">ABSENCE</para>
</td>
<td>
<para style="P7">[[ repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end), 'b', 'td') ]]</para>
<para style="P7">[[ b['seetek_absence_day'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P8">TOTAL BRUT</para>
</td>
<td>
<para style="P7">[[ repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end), 'c', 'td') ]]</para>
<para style="P7">[[ c['total_brut'] ]]</para>
</td>
</tr>
</blockTable>
答案 0 :(得分:0)
你为什么不尝试这样的事情:
<section>
<para>
[[ repeatIn(get_employee_slices(example.company_id,
example.date_start,
example.date_end,
5),
"slice") ]]
</para>
<blockTable colwidths="150,100,100,100,100,100" style="Table1">
<tr>
<td>
<para style="P8">NOM EMPLOYÉ</para>
</td>
<td>
<para style="P7">
[[ repeatIn(get_employee_lines(example.company_id,
example.date_start,
example.date_end,
slice, 5),
'o', 'td') ]]
</para>
<para style="P7">[[ o['name'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P8">Matricule</para>
</td>
<td>
<para style="P7">
[[ repeatIn(get_employee_lines(example.company_id,
example.date_start,
example.date_end,
slice, 5),
'o', 'td') ]]
</para>
<para style="P7">[[ o['matricule'] ]]</para>
</td>
</tr>
<!-- .... -->
</blockTable>
</section>
我添加了额外的循环,它将创建N个不同的表(取决于您拥有的员工数量。我调用了员工切片的不同部分。要实现这一点,您还需要两件事:
get_employee_slices
的方法。此方法应返回从0到N-1的连续数字列表:get_employee_lines
,添加另外两个参数 - number_of_slices
和number_of_columns
。此方法现在应仅返回属于给定切片的员工 - 例如从员工5到员工9。希望这个想法很清楚。我没有测试它,所以可能会有一些错误。
遵循get_employee_slices()
实施的建议:
def get_employee_slices(self, company, date_start, date_end,
columns, context=None):
payslip_pool = self.pool.get('hr.payslip')
ids = payslip_pool.search(self.cr, self.uid,
[('date', '>=', date_start),
('date', '<=', date_end),
('company_id', '=', company.id)])
taille = int(len(ids) / columns) + \
(len(ids) % columns > 0 and 1 or 0)
return range(taille)
答案 1 :(得分:0)
这是我的代码:
def get_employee_slices(self, company_id, date_start, date_end, var, context=None):
res_list=[]
i = 0
obj2 = company_id.id
payslip_line = self.pool.get('hr.payslip')
obj_ids = payslip_line.search(self.cr, self.uid, [('date_from', '=', date_start), ('date_to', '=', date_end), ('company_id', '=', obj2)])
for res in payslip_line.read(self.cr, self.uid, obj_ids, ['id', 'employee_id','seetek_worked_day','hours_overtime_100','seetek_absence_day','total_brut','retenue_source','net_payer'], context=False):
print res['employee_id'][1]
obj = {}
obj['name'] = res['employee_id'][1]
res_list.append(obj)
taille = len (res_list)
while i < taille:
print i
i = i +1
return i
和RML:
<section>
<para>
[[ repeatIn(get_employee_slices(example.company_id,
example.date_start,
example.date_end,
5),
'slice') ]]
</para>
<blockTable colwidths="150,100,100,100,100,100" style="Table1">
<tr>
<td>
<para style="P8">NOM EMPLOYÉ</para>
</td>
<td>
<para style="P7">[[ repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end, slice, 5), 'o', 'td') ]]</para>
<para style="P7">[[ o['name'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P8">Matricule</para>
</td>
<td>
<para style="P7">[[ repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end), 'p', 'td') ]]</para>
<para style="P7">[[ p['matricule'] ]]</para>
</td>
</tr>
答案 2 :(得分:0)
当然,有一个更好的解决方案。而不是首先调用一个给你切片数量的方法,然后调用N次另一种方法返回你的一部分员工,你可以修改你现有的get_employee_lines
,以便给你一个二维的回报。每行中具有所需数量的值的数组。
你修改过的方法应该是这样的:
def get_employee_lines(self, company, date_start, date_end,
columns, context=None):
payslip_pool = self.pool.get('hr.payslip')
payslip_ids = payslip_pool.search(self.cr, self.uid,
[('date', '>=', date_start),
('date', '<=', date_end),
('company_id', '=', company.id)])
records = payslip_line.read(self.cr, self.uid, payslip_ids,
['id', 'employee_id',
'seetek_worked_day',
'hours_overtime_100',
'seetek_absence_day',
'total_brut',
'retenue_source',
'net_payer'],
context=context)
rows_count = int(len(records) / columns) + \
(len(records) % columns > 0 and 1 or 0)
result = [list()] * rows_count
for i in xrange(rows_count):
for j in xrange(columns):
if len(records) <= 0:
break
result[i].append(records.pop())
return result
然后您可以通过以下方式在RML报告中使用它:
<section>
<para>
[[ repeatIn(get_employee_lines(example.company_id,
example.date_start,
example.date_end,
5),
"row") ]]
</para>
<blockTable colwidths="150,100,100,100,100,100" style="Table1">
<tr>
<td>
<para style="P8">NOM EMPLOYÉ</para>
</td>
<td>
<para style="P7">
[[ repeatIn( row ), 'employee', 'td') ]]
</para>
<para style="P7">[[ employee['employee_id'][1] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P8">Matricule</para>
</td>
<td>
<para style="P7">
[[ repeatIn(row, 'employee', 'td') ]]
</para>
<para style="P7">[[ employee['matricule'] ]]</para>
</td>
</tr>
<!-- .... -->
</blockTable>
</section>
同样,它没有经过测试。您可以根据自己的需要对其进行测试并进行调整。