← Back to team overview

openerp-dev-web team mailing list archive

lp:~openerp-dev/openobject-addons/trunk-payroll_details_salary_heads into lp:~openerp-dev/openobject-addons/trunk-payroll

 

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

Requested reviews:
  Mustufa Rangwala (Open ERP) (mra-tinyerp)
  qdp (OpenERP) (qdp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-payroll_details_salary_heads/+merge/57119
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-payroll_details_salary_heads/+merge/57119
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-11 12:10:46 +0000
+++ hr_payroll/hr_payroll.py	2011-04-11 12:14:27 +0000
@@ -187,37 +187,18 @@
     _name = 'hr.payslip'
     _description = 'Pay Slip'
 
-#TODO unused for now, cause the field is commented but we want to put it back
-#    def _get_salary_rules(self, cr, uid, ids, field_names, arg=None, context=None):
-#        structure_obj = self.pool.get('hr.payroll.structure')
-#        contract_obj = self.pool.get('hr.contract')
-#        res = {}
-#        rules = []
-#        contracts = []
-#        structures = []
-#        rule_ids = []
-#        sorted_salary_heads = []
-#        for record in self.browse(cr, uid, ids, context=context):
-#            if record.contract_id:
-#                contracts.append(record.contract_id.id)
-#            else:
-#                contracts = self.get_contract(cr, uid, record.employee_id, record.date, context=context)
-#            for contract in contracts:
-#                structures = contract_obj.get_all_structures(cr, uid, [contract], context)
-#            res[record.id] = {}
-#            for struct in structures:
-#                rule_ids = structure_obj.get_all_rules(cr, uid, [struct], context=None)
-#                for rl in rule_ids:
-#                    if rl[0] not in rules:
-#                        rules.append(rl[0])
-#            cr.execute('''SELECT sr.id FROM hr_salary_rule as sr, hr_salary_head as sh
-#               WHERE sr.category_id = sh.id AND sr.id in %s ORDER BY sh.sequence''',(tuple(rules),))
-#            for x in cr.fetchall():
-#                sorted_salary_heads.append(x[0])
-#            for fn in field_names:
-#               if fn == 'details_by_salary_head':
-#                   res[record.id] = {fn: sorted_salary_heads}
-#        return res
+    def _get_lines_salary_head(self, cr, uid, ids, field_names, arg=None, context=None):
+        result = {}
+        if not ids: return result
+        cr.execute('''SELECT pl.slip_id, pl.id FROM hr_payslip_line AS pl \
+                    LEFT JOIN hr_salary_head AS sh on (pl.category_id = sh.id) \
+                    WHERE pl.slip_id in %s \
+                    GROUP BY pl.slip_id, sh.sequence, pl.sequence, pl.id ORDER BY sh.sequence, pl.sequence''',(tuple(ids),))
+        res = cr.fetchall()
+        for r in res:
+            result.setdefault(r[0], [])
+            result[r[0]].append(r[1])
+        return result
 
     _columns = {
         'struct_id': fields.many2one('hr.payroll.structure', 'Structure', help='Defines the rules that have to be applied to this payslip, accordingly to the contract chosen. If you let empty the field contract, this field isn\'t mandatory anymore and thus the rules applied will be all the rules set on the structure of all contracts of the employee valid for the chosen period'),
@@ -246,9 +227,14 @@
         'paid': fields.boolean('Made Payment Order ? ', required=False, readonly=True, states={'draft': [('readonly', False)]}),
         'note': fields.text('Description'),
         'contract_id': fields.many2one('hr.contract', 'Contract', required=False, readonly=True, states={'draft': [('readonly', False)]}),
+<<<<<<< TREE
         'credit_note': fields.boolean('Credit Note', help="Indicates this payslip has a refund of another"),
        #TODO put me back
        # 'details_by_salary_head': fields.function(_get_salary_rules, method=True, type='one2many', relation='hr.salary.rule', string='Details by Salary Head', multi='details_by_salary_head'),
+=======
+        'details_by_salary_head': fields.function(_get_lines_salary_head, method=True, type='one2many', relation='hr.payslip.line', string='Details by Salary Head'),
+        'credit_note': fields.boolean('Credit Note', help="It indicates that the payslip has been refunded", readonly=True),
+>>>>>>> MERGE-SOURCE
     }
     _defaults = {
         'date_from': lambda *a: time.strftime('%Y-%m-01'),
@@ -524,6 +510,7 @@
                 else:
                     #blacklist this rule and its children
                     blacklist += [id for id, seq in self.pool.get('hr.salary.rule')._recursive_search_of_rules(cr, uid, [rule], context=context)]
+
         return result
 
     def onchange_employee_id(self, cr, uid, ids, date_from, date_to, employee_id=False, contract_id=False, context=None):

=== modified file 'hr_payroll/hr_payroll_view.xml'
--- hr_payroll/hr_payroll_view.xml	2011-04-11 12:10:46 +0000
+++ hr_payroll/hr_payroll_view.xml	2011-04-11 12:14:27 +0000
@@ -237,17 +237,17 @@
                             </field>
                         </page>
 <!-- TODO: put me back -->
-<!--                       <page string="Details By Salary Head">
-                            <field name="details_by_salary_head" nolabel="1">
-                                <tree string="Salary Rules">
+	                    <page string="Details By Salary Head">
+                            <field name="details_by_salary_head" context="{'group_by':'category_id'}" domain="[('appears_on_payslip', '=', True)]" nolabel="1">
+                                <tree string="Payslip Lines">
                                     <field name="category_id"/>
                                     <field name="sequence" groups="base.group_extended"/>
                                     <field name="name"/>
                                     <field name="code"/>
-                                   <field name="total"/>
+                                    <field name="total"/>
                                 </tree>
                             </field>
-                       </page>-->
+                       </page>
 
                        <page string="Worked Days">
                             <field name="input_line_ids" colspan="4" nolabel="1" mode="tree">

=== modified file 'hr_payroll/security/ir.model.access.csv'
--- hr_payroll/security/ir.model.access.csv	2011-04-08 05:48:41 +0000
+++ hr_payroll/security/ir.model.access.csv	2011-04-11 12:14:27 +0000
@@ -8,3 +8,5 @@
 "access_hr_payslip_manager","hr.payslip.manager","model_hr_payslip","base.group_hr_manager",1,1,1,1
 "access_hr_payslip_line_manager","hr.payslip.line.manager","model_hr_payslip_line","base.group_hr_manager",1,1,1,1
 "access_hr_payroll_structure_manager","hr.payroll.structure.manager","model_hr_payroll_structure","base.group_hr_manager",1,1,1,1
+"access_hr_payslip_input ","hr.payslip.input.user","model_hr_payslip_input","base.group_hr_user",1,1,1,1
+"access_hr_salary_rule","hr.salary.rule","model_hr_salary_rule","base.group_hr_user",1,1,1,1


Follow ups