TypeError:' int'对象在rml中不可迭代

时间:2015-09-08 09:58:54

标签: openerp odoo openerp-7 rml

我希望在每页的数组中显示我在RML中发布的openerp x列的报告。 为此,我做了两个功能。 第一个将给出每x分割的表的大小(= 7,因为我想每页显示7列)。 第二个是显示结果,其中所需的参数是start_position和列数。 这就是我所意识到的:

def get_employee_taille(self, company_id, date_start, date_end, context=None):
    res_list=[]
    res_list2=[]
    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'], context=False):
        print res['employee_id'][1]
        obj = {}
        obj['name'] = res['employee_id'][1]
        res_list.append(obj)
    taille = len (res_list) / 6
    print taille
    return taille  

第二个:

def get_employee_lines(self, company_id, date_start, date_end, start_position, number_of_columns, context=None):
    print ('--------------------MOMO----------------------')
    i = 0
    res_list=[]
    print ('--------------------test me----------------------')
    print company_id
    obj2 = company_id.id
    payslip_line = self.pool.get('hr.payslip')
    print payslip_line
    obj_ids = payslip_line.search(self.cr, self.uid, [('date_from', '=', date_start), ('date_to', '=', date_end), ('company_id', '=', obj2)])
    print obj_ids
    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]
        obj['matricule'] = str (res['employee_id'][0])
        obj['presence'] = str (res['seetek_worked_day'])
        obj['heures_sup'] = str (res['hours_overtime_100'])
        obj['absence'] = str (res['seetek_absence_day'])
        obj['total_brut'] = str (res['total_brut'])
        obj['retenue_source'] = str ( - res['retenue_source'])
        obj['net_payer'] = str (res['net_payer'])
        obj['cnss_sal'] = str (res['total_brut'] * 9.18)
        obj['cnss_pat'] = str (res['total_brut'] * 16.57)
        obj['salaire_imposable'] = str ( -res['total_brut'] * (1-9.18))
        res_list.append(obj)
    print res_list
    print res_list[0:2]
    end_position = start_position + number_of_columns
    return res_list[start_position:end_position]

在我的RML中:

<section>
<para>[[ repeatIn(get_employee_taille(example.company_id,example.date_start,example.date_end),'test') ]]</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, 0, 7), 'o', 'td') ]]</para>
      <para style="P7">[[ o['name'] ]]</para>
    </td>      
  </tr>   
</blockTable>

任何有关实现这一点的建议。

1 个答案:

答案 0 :(得分:0)

您的问题出在repeatIn(get_employee_taille(...),'test') ]] 您正在尝试迭代get_employe_taille这是一个整数。 你应该改变它。