From 26b3501ca99fbf6670fc040b10951a89ae2bd7d2 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 10 Jun 2016 11:19:47 +0200 Subject: [PATCH] [FIX] l10n_fr_hr_payroll: use `child_of` Previous commit 8f7129216 searches recursively for children of a rule category. Use `child_of` instead which is way more efficient. opw-673222 --- addons/l10n_fr_hr_payroll/report/fiche_paye.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/addons/l10n_fr_hr_payroll/report/fiche_paye.py b/addons/l10n_fr_hr_payroll/report/fiche_paye.py index 98159c8129f..057373e44e4 100644 --- a/addons/l10n_fr_hr_payroll/report/fiche_paye.py +++ b/addons/l10n_fr_hr_payroll/report/fiche_paye.py @@ -48,24 +48,15 @@ class fiche_paye_parser(report_sxw.rml_parse): res = payslip_line.browse(self.cr, self.uid, ids) return res - def _get_children_categories(self, cate_ids): - rule_cate_obj = self.pool.get('hr.salary.rule.category') - new_cate_ids = rule_cate_obj.search(self.cr, self.uid, [('parent_id', 'in', cate_ids)]) - if new_cate_ids: - return cate_ids + self._get_children_categories(new_cate_ids) - else: - return cate_ids - def get_total_by_rule_category(self, obj, code): payslip_line = self.pool.get('hr.payslip.line') rule_cate_obj = self.pool.get('hr.salary.rule.category') cate_ids = rule_cate_obj.search(self.cr, self.uid, [('code', '=', code)]) - cate_ids = self._get_children_categories(cate_ids) category_total = 0 if cate_ids: - line_ids = payslip_line.search(self.cr, self.uid, [('slip_id', '=', obj.id), ('category_id', 'in', cate_ids)]) + line_ids = payslip_line.search(self.cr, self.uid, [('slip_id', '=', obj.id), ('category_id', 'child_of', cate_ids)]) for line in payslip_line.browse(self.cr, self.uid, line_ids): category_total += line.total