← Back to team overview

openerp-community team mailing list archive

lp:~openerp-community/openerp-mexico-localization/6.1-hrpayroll into lp:openerp-mexico-localization/6.1

 

Eduardo Vizcaino Granados has proposed merging lp:~openerp-community/openerp-mexico-localization/6.1-hrpayroll into lp:openerp-mexico-localization/6.1.

Requested reviews:
  Nhomar Hernandez (Vauxoo) (nhomar): aprove

For more details, see:
https://code.launchpad.net/~openerp-community/openerp-mexico-localization/6.1-hrpayroll/+merge/134393

Bases minimas para l10n payroll
conceptos
-- 
https://code.launchpad.net/~openerp-community/openerp-mexico-localization/6.1-hrpayroll/+merge/134393
Your team OpenERP Community is subscribed to branch lp:~openerp-community/openerp-mexico-localization/6.1-hrpayroll.
=== added directory 'l10n_mx_hr_payroll'
=== added file 'l10n_mx_hr_payroll/__init__.py'
--- l10n_mx_hr_payroll/__init__.py	1970-01-01 00:00:00 +0000
+++ l10n_mx_hr_payroll/__init__.py	2012-11-15 02:41:21 +0000
@@ -0,0 +1,27 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+import hr_payroll
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+

=== added file 'l10n_mx_hr_payroll/__openerp__.py'
--- l10n_mx_hr_payroll/__openerp__.py	1970-01-01 00:00:00 +0000
+++ l10n_mx_hr_payroll/__openerp__.py	2012-11-15 02:41:21 +0000
@@ -0,0 +1,56 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+    "name" : "l10n MX hr_payroll",
+    "version": "0.1",
+    "author": "OpenEVIGRA - Eduardo Vizcaino Granados",
+    "category": "Human Resources",
+    'complexity': "easy",
+    "website": "http://soluciones-programadas.com";,
+
+    "depends": [
+        'hr',
+        'hr_payroll',
+    ],
+    "data": [        
+        'hr_payroll_view.xml',
+    ],
+    'update_xml': [
+        'hr_payroll_data.xml',
+        
+    ],    
+    "description": """l10n MX hr_payroll
+=======================================
+Este modulo agrega las reglas de salario para generar la nomina mexicana
+
+Powered by SOLUCIONES-PROGRAMADAS.COM
+contacto@xxxxxxxxxxxxxxxxxxxxxxxxxx
+evigra@xxxxxxxxxxx
+Cel 045 (312) 135 - 8030
+Tel 01  (312) 308 - 6380
+""",  
+    "auto_install": False,
+    "installable": True,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
+

=== added file 'l10n_mx_hr_payroll/hr_payroll.py'
--- l10n_mx_hr_payroll/hr_payroll.py	1970-01-01 00:00:00 +0000
+++ l10n_mx_hr_payroll/hr_payroll.py	2012-11-15 02:41:21 +0000
@@ -0,0 +1,314 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#    sudo easy_install python-dateutil
+##############################################################################
+
+from osv import osv,fields
+from datetime import *
+import time, sys, subprocess,os
+from dateutil.relativedelta import *
+from dateutil.easter import *
+from dateutil.rrule import *
+from dateutil.parser import *
+
+import netsvc
+import tools
+from tools.translate import _
+import decimal_precision as dp
+
+from tools.safe_eval import safe_eval as eval
+
+
+
+
+
+
+class hr_payslip(osv.osv):
+    _inherit = 'hr.payslip'
+    def get_worked_day_lines(self, cr, uid, contract_ids, date_from, date_to, context=None):
+        """
+        @param contract_ids: list of contract id
+        @return: returns a list of dict containing the input that should be applied for the given contract between date_from and date_to
+        """
+        def was_on_leave(employee_id, datetime_day, context=None):
+            res = False
+            day = datetime_day.strftime("%Y-%m-%d")
+            
+            holiday_ids = self.pool.get('hr.holidays').search(cr, uid, [('state','=','validate'),('employee_id','=',employee_id),('type','=','remove'),('date_from','<=',day),('date_to','>=',day)])
+            print "holiday_ids=",holiday_ids
+            if holiday_ids:
+                print "DAY_FUNCION=",day
+                res = self.pool.get('hr.holidays').browse(cr, uid, holiday_ids, context=context)[0].holiday_status_id.name
+                print "res=", res
+            return res
+
+        res = []
+        for contract in self.pool.get('hr.contract').browse(cr, uid, contract_ids, context=context):
+            print "ENTRA LALO" 
+            if not contract.working_hours:
+                #fill only if the contract as a working schedule linked
+                continue
+            attendances = {
+                 'name': _("Normal Working Days paid at 100%"),
+                 'sequence': 1,
+                 'code': 'WORK100',
+                 'number_of_days': 0.0,
+                 'number_of_hours': 0.0,
+                 'contract_id': contract.id,
+            }
+            leaves = {}
+            day_from = datetime.strptime(date_from,"%Y-%m-%d")
+            day_to = datetime.strptime(date_to,"%Y-%m-%d")
+            nb_of_days = (day_to - day_from).days + 1
+            
+            print "nb_of_days=",nb_of_days
+            for day in range(0, nb_of_days):
+                print ">>>>>>>>>>>><"
+                print "day=", day
+                working_hours_on_day = self.pool.get('resource.calendar').working_hours_on_day(cr, uid, contract.working_hours, day_from + timedelta(days=day), context)
+                print "working_hours_on_day=",working_hours_on_day
+                if working_hours_on_day:
+                    #the employee had to work
+                    leave_type = was_on_leave(contract.employee_id.id, day_from + timedelta(days=day), context=context)
+                    print "leave_type=",leave_type
+                    if leave_type:
+                        #if he was on leave, fill the leaves dict
+                        if leave_type in leaves:
+                            
+                            leaves[leave_type]['number_of_days'] += 1.0
+                            leaves[leave_type]['number_of_hours'] += working_hours_on_day
+                            print "DENTRO   2 leaves=", leaves
+                        else:
+                            leaves[leave_type] = {
+                                'name': leave_type,
+                                'sequence': 5,
+                                'code': leave_type,
+                                'number_of_days': 1.0,
+                                'number_of_hours': working_hours_on_day,
+                                'contract_id': contract.id,
+                            }
+                            print "FUERA   2 leaves=", leaves
+                    else:
+                        print "FUERA"
+                        #add the input vals to tmp (increment if existing)
+                        attendances['number_of_days'] += 1.0
+                        attendances['number_of_hours'] += working_hours_on_day
+            leaves = [value for key,value in leaves.items()]
+            res += [attendances] + leaves
+        return res
+    
+    def onchange_employee_id(self, cr, uid, ids, date_from, date_to, employee_id=False, contract_id=False, context=None):
+        print "onchange_employee_id LALO"
+        empolyee_obj = self.pool.get('hr.employee')
+        contract_obj = self.pool.get('hr.contract')
+        worked_days_obj = self.pool.get('hr.payslip.worked_days')
+        input_obj = self.pool.get('hr.payslip.input')
+
+        if context is None:
+            context = {}
+        #delete old worked days lines
+        old_worked_days_ids = ids and worked_days_obj.search(cr, uid, [('payslip_id', '=', ids[0])], context=context) or False
+        if old_worked_days_ids:
+            worked_days_obj.unlink(cr, uid, old_worked_days_ids, context=context)
+
+        #delete old input lines
+        old_input_ids = ids and input_obj.search(cr, uid, [('payslip_id', '=', ids[0])], context=context) or False
+        if old_input_ids:
+            input_obj.unlink(cr, uid, old_input_ids, context=context)
+
+
+        #defaults
+        res = {'value':{
+                      'line_ids':[],
+                      'input_line_ids': [],
+                      'worked_days_line_ids': [],
+                      #'details_by_salary_head':[], TODO put me back
+                      'name':'',
+                      'contract_id': False,
+                      'struct_id': False,
+                      }
+            }
+        if (not employee_id) or (not date_from) or (not date_to):
+            return res
+        ttyme = datetime.fromtimestamp(time.mktime(time.strptime(date_from, "%Y-%m-%d")))
+        employee_id = empolyee_obj.browse(cr, uid, employee_id, context=context)
+        res['value'].update({
+                    'name': _('Salary Slip of %s for %s') % (employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))),
+                    'company_id': employee_id.company_id.id
+        })
+
+        if not context.get('contract', False):
+            #fill with the first contract of the employee
+            contract_ids = self.get_contract(cr, uid, employee_id, date_from, date_to, context=context)
+            res['value'].update({
+                        'struct_id': contract_ids and contract_obj.read(cr, uid, contract_ids[0], ['struct_id'], context=context)['struct_id'][0] or False,
+                        'contract_id': contract_ids and contract_ids[0] or False,
+            })
+        else:
+            if contract_id:
+                #set the list of contract for which the input have to be filled
+                contract_ids = [contract_id]
+                #fill the structure with the one on the selected contract
+                contract_record = contract_obj.browse(cr, uid, contract_id, context=context)
+                res['value'].update({
+                            'struct_id': contract_record.struct_id.id,
+                            'contract_id': contract_id
+                })
+            else:
+                #if we don't give the contract, then the input to fill should be for all current contracts of the employee
+                contract_ids = self.get_contract(cr, uid, employee_id, date_from, date_to, context=context)
+                if not contract_ids:
+                    return res
+
+        #computation of the salary input
+        worked_days_line_ids = self.get_worked_day_lines(cr, uid, contract_ids, date_from, date_to, context=context)
+        print "###############################################################3"
+        print "worked_days_line_ids=",worked_days_line_ids
+        input_line_ids = self.get_inputs(cr, uid, contract_ids, date_from, date_to, context=context)
+        res['value'].update({
+                    'worked_days_line_ids': worked_days_line_ids,
+                    'input_line_ids': input_line_ids,
+        })
+        return res
+    
+    def get_inputs(self, cr, uid, contract_ids, date_from, date_to, context=None):
+        #print datetime.date.today()
+        #print datetime.date.today()-datetime.timedelta(days=7)
+
+
+        res = []
+        contract_obj = self.pool.get('hr.contract')
+        loan_obj = self.pool.get('hr.contract.loan')
+        rule_obj = self.pool.get('hr.salary.rule')
+
+        structure_ids = contract_obj.get_all_structures(cr, uid, contract_ids, context=context)
+        rule_ids = self.pool.get('hr.payroll.structure').get_all_rules(cr, uid, structure_ids, context=context)
+        sorted_rule_ids = [id for id, sequence in sorted(rule_ids, key=lambda x:x[1])]
+        for contract in contract_obj.browse(cr, uid, contract_ids, context=context):
+        
+            loan_ids=contract.loan_ids
+            inicio=datetime(int(str(contract.date_start)[:4]),int(str(contract.date_start)[5:7]),int(str(contract.date_start)[8:10]))
+            days=datetime.today() -inicio 
+            days=datetime.today().date() -inicio.date() 
+            str_days=str(days)            
+            antiguedad = float(int(str_days.replace(str_days[-14:],"")))/365
+            vals_contract={"years_old":antiguedad}
+            contract_obj.write(cr, uid, contract.id, vals_contract)
+            
+            #print "ACTUAL=",  date.today() 
+            #print "FECHA=",  date.today() - contract.date_start
+                
+            for rule in rule_obj.browse(cr, uid, sorted_rule_ids, context=context):
+                if rule.input_ids:
+                    for input in rule.input_ids:
+                        monto=0
+                        for loans in loan_ids:
+                            loan_id=loans.id            
+                            loan =loan_obj.browse(cr, uid, loan_id)
+                            initial= loan.loan_initial
+                            final= loan.loan_final
+                            code= loan.code
+                    
+                            if code==input.code:
+                                monto=final
+                                
+                        inputs = {
+                            'name': input.name,
+                            'code': input.code,
+                            'amount': monto,
+                            'contract_id': contract.id,
+                        }
+                        res += [inputs]
+        return res
+
+hr_payslip()
+class hr_contract(osv.osv):
+    _inherit = 'hr.contract'
+    _columns = {
+        'years_old':fields.float('Years Old'),
+        'christmas_box': fields.integer('Dias de Aguinaldo'),
+        'loan_ids': fields.one2many('hr.contract.loan','contract_id','Loans')           
+    }
+    _defaults = {
+        'christmas_box': 15,
+    }   
+    """     
+    def save(self, cr, uid, vals, ids, context=False):
+        if (type(ids) is list and len(ids)>0) or ids==False:                                            
+            if(ids==0 or ids==False):
+                ids=[]               
+                
+                res         = super(hr_contract, self).create(cr, uid, vals, context=context)                     
+                ids.append(res)
+                
+                data_before = self.browse(cr, uid, ids)[0]
+                before_name = data_before.name
+                data        = self.browse(cr, uid, ids)[0]
+            else:        
+                data_before = self.browse(cr, uid, ids)[0]
+                before_name = data_before.name                
+                res         = super(hr_contract, self).write(cr, uid, ids, vals)  
+                data        = self.browse(cr, uid, ids)[0]  
+        print "VALS=", vals
+        return res   
+    def create(self, cr, uid, vals, context=False):
+        ids=False
+        res=self.save(cr, uid, vals, ids)   
+        return res
+    def write(self, cr, uid, ids, vals, context=None, update=True):
+        res=self.save(cr, uid, vals, ids)
+        return res  
+    """    
+hr_contract()    
+
+class hr_contract_loan(osv.osv):
+    _name = 'hr.contract.loan'
+    _columns = {
+        'contract_id': fields.many2one('hr.contract', 'Contract',),
+        'name': fields.char('Concept', size=75, required=True, readonly=False),
+        'code': fields.char('Code', size=20, required=True, readonly=False),
+        'description': fields.char('Description', size=250, required=False, readonly=False),
+        'loan_initial':fields.float('Loan Initial'),
+        'loan_final':fields.float('Loan Final'),
+    }
+    def save(self, cr, uid, vals, ids, context=False):
+        if (type(ids) is list and len(ids)>0) or ids==False:                                            
+            if(ids==0 or ids==False):
+                ids=[]               
+                
+                res         = super(hr_contract_loan, self).create(cr, uid, vals, context=context)                     
+                ids.append(res)
+                
+                data_before = self.browse(cr, uid, ids)[0]
+                before_name = data_before.name
+                data        = self.browse(cr, uid, ids)[0]
+            else:        
+                data_before = self.browse(cr, uid, ids)[0]
+                before_name = data_before.name                
+                res         = super(hr_contract_loan, self).write(cr, uid, ids, vals)  
+                data        = self.browse(cr, uid, ids)[0]  
+        return res   
+    def create(self, cr, uid, vals, context=False):
+        ids=False
+        res=self.save(cr, uid, vals, ids)   
+        return res
+    def write(self, cr, uid, ids, vals, context=None, update=True):
+        res=self.save(cr, uid, vals, ids)
+        return res
+hr_contract_loan()    

=== added file 'l10n_mx_hr_payroll/hr_payroll_data.xml'
--- l10n_mx_hr_payroll/hr_payroll_data.xml	1970-01-01 00:00:00 +0000
+++ l10n_mx_hr_payroll/hr_payroll_data.xml	2012-11-15 02:41:21 +0000
@@ -0,0 +1,508 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+        <record id="nomina" model="hr.payroll.structure">
+            <field name="name">Nomina</field>
+            <field name="code">NOM</field>
+        </record>                    
+    
+        <!-- CATEGORIAS -->
+        <record id="CAT_SGVDF" model="hr.salary.rule.category">
+            <field name="name">Salario General Vigente al DF</field>
+            <field name="code">SGVDF</field>
+        </record>                    
+        <record id="CAT_SDI" model="hr.salary.rule.category">
+            <field name="name">Salario Diario Integrado</field>
+            <field name="code">SDI</field>
+        </record>            
+        <record id="CAT_ISPT" model="hr.salary.rule.category">
+            <field name="name">ISPT</field>
+            <field name="code">ISPT</field>
+        </record>                    
+        <record id="CAT_SEA" model="hr.salary.rule.category">
+            <field name="name">SEA</field>
+            <field name="code">SEA</field>
+        </record>                    
+        <record id="CAT_SESP" model="hr.salary.rule.category">
+            <field name="name">SESP</field>
+            <field name="code">SESP</field>
+        </record>                    
+        <record id="CAT_IMSS_T" model="hr.salary.rule.category">
+            <field name="name">IMSS Trabajador</field>
+            <field name="code">IMSS_T</field>
+        </record>              
+        <record id="CAT_IMSS_E" model="hr.salary.rule.category">
+            <field name="name">IMSS Empresa</field>
+            <field name="code">IMSS_E</field>
+        </record>              
+        <record id="CAT_IMSS_Emp" model="hr.salary.rule.category">
+            <field name="name">IMSS Empresa</field>
+            <field name="code">IMSS_Emp</field>
+        </record>              
+        
+        <!-- FIN CATEGORIAS -->
+        
+        
+        
+        
+        
+        
+        <!-- REGLAS SALARIALES -->
+        <record id="REG0" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_SGVDF"/> 
+            <field name="name">Salario General Vigente al DF</field>
+            <field name="sequence">10</field>
+            <field name="code">SGVDF</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="amount_python_compute">result = 62.33</field>
+        </record>        
+        <record id="REG1" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_SDI"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Salario Diario Integrado</field>
+            <field name="sequence">11</field>
+            <field name="code">SDI</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute"><![CDATA[
+antiguedad = contract.years_old
+if antiguedad<2:
+    vac=6    
+    factor=(vac*.25+contract.christmas_box)/365+1
+elif antiguedad<3:
+    vac=8    
+    factor=(vac*.25+contract.christmas_box)/365+1
+elif antiguedad<4:
+    vac=10    
+    factor=(vac*.25+contract.christmas_box)/365+1
+elif antiguedad<5:
+    vac=12    
+    factor=(vac*.25+contract.christmas_box)/365+1
+elif antiguedad<10:
+    vac=14    
+    factor=(vac*.25+contract.christmas_box)/365+1
+elif antiguedad<15:
+    vac=16    
+    factor=(vac*.25+contract.christmas_box)/365+1
+elif antiguedad<20:
+    vac=18    
+    factor=(vac*.25+contract.christmas_box)/365+1
+elif antiguedad<25:
+    vac=20    
+    factor=(vac*.25+contract.christmas_box)/365+1
+elif antiguedad<30:
+    vac=22    
+    factor=(vac*.25+contract.christmas_box)/365+1
+elif antiguedad<35:
+    vac=24    
+    factor=(vac*.25+contract.christmas_box)/365+1  
+result = factor * contract.wage            
+            ]]></field>
+        </record>        
+        
+        <record id="REG2" model="hr.salary.rule">
+            <field name="category_id" ref="hr_payroll.BASIC"/> 
+            <field name="name">Sueldo</field>
+            <field name="sequence">51</field>
+            <field name="code">S</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = contract.wage * worked_days.WORK100.number_of_days</field>
+        </record>
+        <record id="nuev" model="hr.rule.input">
+            <field name="name">Prestamo Infonavit</field>
+            <field name="code">CINFO</field>
+            <field name="input_id" ref="REG2"/>
+        </record>        
+        <record id="REG3" model="hr.salary.rule">
+            <field name="category_id" ref="hr_payroll.BASIC"/> 
+            <field name="name">Septimo Dia</field>
+            <field name="sequence">52</field>
+            <field name="code">SD</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result =        contract.wage * worked_days.WORK100.number_of_days / 6</field>
+        </record>
+        <record id="REG4" model="hr.salary.rule">
+            <field name="category_id" ref="hr_payroll.BASIC"/> 
+            <field name="name">Bono de Asistencia</field>
+            <field name="sequence">53</field>
+            <field name="code">BA</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = 0.10 * contract.wage  * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>
+        <record id="REG5" model="hr.salary.rule">
+            <field name="category_id" ref="hr_payroll.BASIC"/> 
+            <field name="name">Bono de Puntualidad</field>
+            <field name="sequence">54</field>
+            <field name="code">BP</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = 0.10 * contract.wage  * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>
+        <record id="REG6" model="hr.salary.rule">
+            <field name="category_id" ref="hr_payroll.BASIC"/> 
+            <field name="name">Despensa</field>
+            <field name="sequence">55</field>
+            <field name="code">D</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SGVDF *  0.4  * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>
+        <record id="REG7" model="hr.salary.rule">
+            <field name="category_id" ref="hr_payroll.ALW"/> 
+            <field name="name">PERCEPCIONES</field>
+            <field name="sequence">100</field>
+            <field name="code">PERCEPCIONES</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.BASIC</field>
+        </record>
+        <record id="REG8" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_ISPT"/> 
+            
+            <field name="name">ISPT</field>
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="sequence">101</field>
+            <field name="code">ISPT</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute"><![CDATA[
+LI_aux = 0.01
+LS_aux = 114.24
+if categories.ALW>LI_aux and categories.ALW<LS_aux:
+    LI = LI_aux
+    CF = 0
+    Ex = 0.0192   
+    
+LI_aux = LS_aux + 0.01
+LS_aux = 969.50
+if categories.ALW>LI_aux and categories.ALW<LS_aux:
+    LI = LI_aux
+    CF = 2.17
+    Ex = 0.064
+    
+LI_aux = LS_aux + 0.01
+LS_aux = 1703.80
+if categories.ALW>LI_aux and categories.ALW<LS_aux:
+    LI = LI_aux
+    CF = 56.91
+    Ex = 0.1088
+    
+LI_aux = LS_aux + 0.01
+LS_aux = 1980.58
+if categories.ALW>LI_aux and categories.ALW<LS_aux:
+    LI = LI_aux
+    CF = 136.85
+    Ex = 0.16
+    
+LI_aux = LS_aux + 0.01
+LS_aux = 2371.32
+if categories.ALW>LI_aux and categories.ALW<LS_aux:
+    LI = LI_aux
+    CF = 181.06
+    Ex = 0.1792
+    
+LI_aux = LS_aux + 0.01
+LS_aux = 4782.61
+if categories.ALW>LI_aux and categories.ALW<LS_aux:
+    LI = LI_aux
+    CF = 251.16
+    Ex = 0.2136
+    
+LI_aux = LS_aux + 0.01
+LS_aux = 7538.09
+if categories.ALW>LI_aux and categories.ALW<LS_aux:
+    LI = LI_aux
+    CF = 766.15
+    Ex = 0.2352
+    
+LI_aux = LS_aux + 0.01
+if categories.ALW>LI_aux:
+    LI = LI_aux
+    CF = 1414.28
+    Ex = 0.30       
+result = ((categories.ALW - LI) * Ex + CF)
+            ]]></field>
+        </record>        
+        <record id="REG9" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_SEA"/> 
+            <field name="name">Subsidio al Empleo acreditado</field>
+            <field name="sequence">102</field>
+            <field name="code">SEA</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute"><![CDATA[
+if categories.ALW>0.01 and categories.ALW<407.33:
+    result = 93.73 
+if categories.ALW>407.34 and categories.ALW<610.96:
+    result = 93.66 
+if categories.ALW>610.97 and categories.ALW<799.68:
+    result = 93.66 
+if categories.ALW>799.69 and categories.ALW<814.66: 
+    result = 90.44 
+if categories.ALW>814.67 and categories.ALW<1023.75: 
+    result = 88.06 
+if categories.ALW>1023.76 and categories.ALW<1086.16: 
+    result = 81.55 
+if categories.ALW>1086.20 and categories.ALW<1228.57: 
+    result = 74.83 
+if categories.ALW>1228.58 and categories.ALW<1433.32: 
+    result = 67.83 
+if categories.ALW>1433.33 and categories.ALW<1638.07: 
+    result = 58.38 
+if categories.ALW>1638.08 and categories.ALW<1699.88: 
+    result = 50.12 
+if categories.ALW>1699.89: 
+   result = 0
+result=result*-1            
+            ]]></field>
+        </record>        
+        <record id="REG10" model="hr.salary.rule">
+            <field name="category_id" ref="hr_payroll.DED"/> 
+            <field name="name">Subsidio al empleo (sp) </field>
+            <field name="sequence">103</field>
+            <field name="code">SESP</field>            
+            <field name="condition_select">python</field>
+            <field name="condition_python">result =- categories.ISPT > categories.SEA</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result =categories.SEA + categories.ISPT</field>
+        </record>              
+            
+        <record id="REG11" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_SESP"/> 
+            <field name="name">ISPT antes de Sub al Empleo</field>
+            <field name="sequence">104</field>
+            <field name="code">ISPT_SE</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result =categories.ISPT</field>
+        </record>             
+        
+        <record id="REG12" model="hr.salary.rule">
+            <field name="category_id" ref="hr_payroll.DED"/> 
+            <field name="name">ISPT (sp)</field>
+            <field name="sequence">105</field>
+            <field name="code">ISPT_SP</field>
+            <field name="condition_select">python</field>
+            <field name="condition_python">result = categories.SEA> - categories.ISPT </field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result =categories.SEA + categories.ISPT_SE</field>
+        </record>    
+        <record id="REG13" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_T"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Prestaciones en especie</field>
+            <field name="sequence">106</field>
+            <field name="code">PE_T</field>
+            <field name="condition_select">python</field>
+            <field name="condition_python">result =  categories.SDI>3 * categories.SGVDF </field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result =((categories.SDI * worked_days.WORK100.number_of_days * 7 /6)-(3 * categories.SGVDF))*0.004</field>
+        </record>          
+             
+        <record id="REG14" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_T"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Prestaciones en especie (Pensionados y beneficiarios)</field>
+            <field name="sequence">107</field>
+            <field name="code">PEPB_T</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.00375 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>            
+
+        <record id="REG15" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_T"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Prestaciones en dinero</field>
+            <field name="sequence">108</field>
+            <field name="code">PD_T</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.0025 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>          
+
+        <record id="REG16" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_T"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Seguro de invalides y vida</field>
+            <field name="sequence">109</field>
+            <field name="code">SIV_T</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.00625 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>        
+        
+        <record id="REG17" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_T"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Cesantia en edad avanzada y vejes</field>
+            <field name="sequence">110</field>
+            <field name="code">CEAV_T</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.01125 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>         
+        
+        
+        <record id="REG18" model="hr.salary.rule">
+            <field name="category_id" ref="hr_payroll.DED"/> 
+            <field name="name">IMSS</field>
+            <field name="sequence">111</field>
+            <field name="code">IMSS_T</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.IMSS_T</field>
+        </record>   
+
+        <record id="REG19" model="hr.salary.rule">
+            <field name="category_id" ref="hr_payroll.DED"/> 
+            <field name="name">Prestamo Infonavit</field>
+            <field name="sequence">112</field>
+            <field name="code">CINFO_T</field>
+            <field name="condition_select">python</field>
+            <field name="condition_python">result =  inputs.CINFO.amount >0 </field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = inputs.CINFO.amount</field>
+        </record>          
+
+<!-- ################################ -->        
+        
+        <record id="REG30" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_E"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Prestaciones en especie(Cuota fija)</field>
+            <field name="sequence">130</field>
+            <field name="code">PE_E</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.204 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>          
+        <record id="REG31" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_E"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Prestaciones en especie(Cuota adicional)</field>
+            <field name="sequence">131</field>
+            <field name="code">PE_E</field>
+            <field name="condition_select">python</field>
+            <field name="condition_python">result =  categories.SDI>3 * categories.SGVDF </field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result =((categories.SDI * worked_days.WORK100.number_of_days * 7 /6)-(3 * categories.SGVDF))*0.011</field>
+        </record>          
+        
+             
+        <record id="REG32" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_E"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Prestaciones en especie (Pensionados y beneficiarios)</field>
+            <field name="sequence">132</field>
+            <field name="code">PEPB_E</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.0105 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>            
+
+        <record id="REG33" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_E"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Prestaciones en dinero</field>
+            <field name="sequence">133</field>
+            <field name="code">PD_E</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.007 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>          
+
+        <record id="REG34" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_E"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Seguro de invalides y vida</field>
+            <field name="sequence">134</field>
+            <field name="code">SIV_E</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.0175 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>        
+        <record id="REG35" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_E"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Seguro para el retiro</field>
+            <field name="sequence">135</field>
+            <field name="code">SR_E</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.02 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>         
+        
+        <record id="REG36" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_E"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Cesantia en edad avanzada y vejes</field>
+            <field name="sequence">136</field>
+            <field name="code">CEAV_E</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.0315 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>         
+        <record id="REG37" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_E"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Guarderias y Prestaciones Sociales</field>
+            <field name="sequence">137</field>
+            <field name="code">GPS_E</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.01 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>         
+        <record id="REG38" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_E"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">Infonavit</field>
+            <field name="sequence">138</field>
+            <field name="code">I_E</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.SDI * 0.05 * worked_days.WORK100.number_of_days * 7 /6</field>
+        </record>         
+        
+        
+        <record id="REG39" model="hr.salary.rule">
+            <field name="category_id" ref="CAT_IMSS_Emp"/> 
+            <field name="appears_on_payslip" eval="False"/>
+            <field name="name">IMSS Empresa</field>
+            <field name="sequence">139</field>
+            <field name="code">IMSS_E</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute">result = categories.IMSS_E</field>
+        </record>   
+        
+                
+        
+        <!--
+        <record id="REG7" model="hr.salary.rule">
+            <field name="category_id" ref="hr_payroll.ALW"/> 
+            <field name="name">Subsidio al Empleo acreditado</field>
+            <field name="secuence">102</field>
+            <field name="code">SEA</field>
+            <field name="condition_select">none</field>
+            <field name="amount_select">code</field>
+            <field name="amount_python_compute"><![CDATA[
+            
+            ]]></field>
+        </record>        
+        -->
+        
+        <!-- REGLAS SALARIALES -->        
+        
+     </data>
+</openerp>
+
+
+
+
+

=== added file 'l10n_mx_hr_payroll/hr_payroll_view.xml'
--- l10n_mx_hr_payroll/hr_payroll_view.xml	1970-01-01 00:00:00 +0000
+++ l10n_mx_hr_payroll/hr_payroll_view.xml	2012-11-15 02:41:21 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+        <record id="view_hr_contract_form" model="ir.ui.view">
+            <field name="name">hr.contract</field>
+            <field name="model">hr.contract</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
+            <field name="arch" type="xml">
+
+                <xpath expr="/form/group/field[@name='type_id']" position="after">
+                    <field name="christmas_box"/>
+                    <field name="years_old"/>
+                </xpath> 
+
+                <xpath expr="/form/notebook/page[@string='Work Permit']" position="after">
+                    <page string="Loans"> 
+                        <field name="loan_ids" nolabel="1" colspan="4"/>     
+                    </page>
+                </xpath>             
+
+            </field>
+        </record>
+     </data>
+</openerp>


Follow ups