← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/trunk-payroll-rules_engine into lp:~openerp-dev/openobject-addons/trunk-payroll

 

Mustufa Rangwala (Open ERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-payroll-rules_engine into lp:~openerp-dev/openobject-addons/trunk-payroll.

Requested reviews:
  qdp (OpenERP) (qdp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-payroll-rules_engine/+merge/58931

Python code on salary rules improved for conditions and computation. now we can access rules directly by giving rule code no need to give rules[Code name] in dictionary.

Thanks,
mra 
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-payroll-rules_engine/+merge/58931
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-payroll.
=== modified file 'hr_payroll/hr_payroll.py'
--- hr_payroll/hr_payroll.py	2011-04-12 17:01:28 +0000
+++ hr_payroll/hr_payroll.py	2011-04-25 07:23:25 +0000
@@ -482,11 +482,12 @@
         #we keep a dict with the result because a value can be overwritten by another rule with the same code
         result_dict = {}
         blacklist = []
+        obj_rule = self.pool.get('hr.salary.rule')
         payslip = self.pool.get('hr.payslip').browse(cr, uid, payslip_id, context=context)
         worked_days = {}
         for input_line in payslip.input_line_ids:
             worked_days[input_line.code] = input_line
-        localdict = {'rules': {}, 'heads': {}, 'payslip': payslip, 'worked_days': worked_days}
+        localdict = {'heads': {}, 'payslip': payslip, 'worked_days': worked_days}
         #get the ids of the structures on the contracts and their parent id as well
         structure_ids = self.pool.get('hr.contract').get_all_structures(cr, uid, contract_ids, context=context)
         #get the rules of the structure and thier children
@@ -497,17 +498,17 @@
         for contract in self.pool.get('hr.contract').browse(cr, uid, contract_ids, context=context):
             employee = contract.employee_id
             localdict.update({'employee': employee, 'contract': contract})
-            for rule in self.pool.get('hr.salary.rule').browse(cr, uid, sorted_rule_ids, context=context):
+            for rule in obj_rule.browse(cr, uid, sorted_rule_ids, context=context):
                 key = rule.code + '-' + str(contract.id)
                 localdict['result'] = None
                 #check if the rule can be applied
-                if self.pool.get('hr.salary.rule').satisfy_condition(cr, uid, rule.id, localdict, context=context) and rule.id not in blacklist:
+                if obj_rule.satisfy_condition(cr, uid, rule.id, localdict, context=context) and rule.id not in blacklist:
                     #compute the amount of the rule
-                    amount = self.pool.get('hr.salary.rule').compute_rule(cr, uid, rule.id, localdict, context=context)
+                    amount = obj_rule.compute_rule(cr, uid, rule.id, localdict, context=context)
                     #check if there is already a rule computed with that code
-                    previous_amount = rule.code in localdict['rules'] and localdict['rules'][rule.code] or 0.0
+                    previous_amount = rule.code in localdict and localdict[rule.code] or 0.0
                     #set/overwrite the amount computed for this rule in the localdict
-                    localdict['rules'][rule.code] = amount
+                    localdict[rule.code] = amount
                     #sum the amount for its salary head
                     localdict = _sum_salary_head(localdict, rule.category_id, amount - previous_amount)
                     #create/overwrite the rule in the temporary results
@@ -679,7 +680,7 @@
 # payslip: hr.payslip object
 # employee: hr.employee object
 # contract: hr.contract object
-# rules: dictionary containing the previsouly computed rules. Keys are the rule codes.
+# rules: rules code (previously computed)
 # heads: dictionary containing the computed heads (sum of amount of all rules belonging to that head). Keys are the head codes.
 # worked_days: dictionary containing the computed worked days. Keys are the worked days codes.
 
@@ -693,7 +694,7 @@
 # payslip: hr.payslip object
 # employee: hr.employee object
 # contract: hr.contract object
-# rules: dictionary containing the previsouly computed rules. Keys are the rule codes.
+# rules: rules code (previously computed)
 # heads: dictionary containing the computed heads (sum of amount of all rules belonging to that head). Keys are the head codes.
 # worked_days: dictionary containing the computed worked days. Keys are the worked days codes.
 


Follow ups