[IMP] changes as per hr_payroll_new file given by QDP sir: move hr_passport obj to...
authorpsi (Open ERP) <psi@tinyerp.co.in>
Thu, 3 Mar 2011 12:49:03 +0000 (18:19 +0530)
committerpsi (Open ERP) <psi@tinyerp.co.in>
Thu, 3 Mar 2011 12:49:03 +0000 (18:19 +0530)
bzr revid: psi@tinyerp.co.in-20110303124903-nopz0swoebyqtsqq

addons/hr/hr.py
addons/hr/hr_view.xml
addons/hr/security/ir.model.access.csv
addons/hr_contract/__openerp__.py
addons/hr_contract/hr_contract.py
addons/hr_contract/hr_contract_view.xml
addons/hr_payroll/__openerp__.py
addons/hr_payroll/hr_payroll.py
addons/hr_payroll/hr_payroll_view.xml
addons/hr_payroll/security/ir.model.access.csv

index e2b9a70..721e94d 100644 (file)
@@ -142,6 +142,7 @@ class hr_employee(osv.osv):
         'ssnid': fields.char('SSN No', size=32, help='Social Security Number'),
         'sinid': fields.char('SIN No', size=32, help="Social Insurance Number"),
         'identification_id': fields.char('Identification No', size=32),
+        'otherid': fields.char('Other Id', size=64),
         'gender': fields.selection([('male', 'Male'),('female', 'Female')], 'Gender'),
         'marital': fields.many2one('hr.employee.marital.status', 'Marital Status'),
         'department_id':fields.many2one('hr.department', 'Department'),
@@ -225,6 +226,28 @@ class hr_department(osv.osv):
         'member_ids': fields.one2many('hr.employee', 'department_id', 'Members', readonly=True),
     }
 
+class hr_passport(osv.osv):
+    """
+    Employee Passport
+    Passport based Contracts for Employees
+    """
+
+    _name = 'hr.passport'
+    _description = 'Passport Detail'
+    _columns = {
+        'employee_id': fields.many2one('hr.employee', 'Employee', required=True),
+        'name': fields.char('Passport No', size=64, required=True, readonly=False),
+        'country_id': fields.many2one('res.country', 'Country of Issue', required=True),
+        'address_id': fields.many2one('res.partner.address', 'Address', required=False),
+        'date_issue': fields.date('Passport Issue Date', required=True),
+        'date_expire': fields.date('Passport Expire Date', required=True),
+        'note': fields.text('Description'),
+    }
+    _sql_constraints = [
+        ('passport_no_uniq', 'unique (employee_id, name)', 'The Passport No must be unique !'),
+    ]
+hr_passport()
+
 hr_department()
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index cf7fe75..aa4d8a8 100644 (file)
@@ -43,6 +43,7 @@
                                 <field name="sinid" groups="base.group_extended"/>
                                 <field name="identification_id" groups="base.group_extended"/>
                                 <field name="passport_id"/>
+                                <field name="otherid"/>
                             </group>
                             <group col="2" colspan="2" groups="base.group_hr_user">
                                 <separator string="Status" colspan="2"/>
         <menuitem name="Recruitment" id="base.menu_crm_case_job_req_main" parent="menu_hr_root" groups="base.group_hr_user"/>
         <menuitem parent="base.menu_crm_case_job_req_main" id="menu_hr_job" action="action_hr_job" sequence="2"/>
 
+        <!-- Passport Views    -->
+        <record id="hr_passport_form" model="ir.ui.view">
+            <field name="name">hr.passport.form</field>
+            <field name="model">hr.passport</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Passport">
+                    <group col="6" colspan="4">
+                        <field name="name" select="1" colspan="4"/>
+                        <field name="employee_id" />
+                    </group>
+                    <group col="2" colspan="2">
+                        <separator string="Country &amp; Address" colspan="4"/>
+                        <field name="country_id" select="1"/>
+                        <field name="address_id" select="1"/>
+                    </group>
+                    <group col="2" colspan="2">
+                        <separator string="Valid From" colspan="2"/>
+                        <field name="date_issue" select="1"/>
+                        <field name="date_expire" select="1"/>
+                    </group>
+                    <notebook colspan="4">
+                        <page string="Description">
+                            <separator string="Description" colspan="2"/>
+                            <field name="note" colspan="4" nolabel="1"/>
+                        </page>
+                    </notebook>
+                </form>
+            </field>
+        </record>
+        <record id="hr_passport_tree" model="ir.ui.view">
+            <field name="name">hr.passport.tree</field>
+            <field name="model">hr.passport</field>
+            <field name="type">tree</field>
+            <field name="arch" type="xml">
+                <tree string="Passport">
+                    <field name="name" />
+                    <field name="employee_id" />
+                    <field name="address_id"/>
+                    <field name="country_id" />
+                    <field name="date_expire"/>
+                    <field name="date_issue" />
+                </tree>
+            </field>
+        </record>
+
+        <record id="view_hr_passport_filter" model="ir.ui.view">
+            <field name="name">hr.passport.select</field>
+            <field name="model">hr.passport</field>
+            <field name="type">search</field>
+            <field name="arch" type="xml">
+                <search string="Search Passport">
+                    <group col="8" colspan="4">
+                        <field name="name"/>
+                        <field name="employee_id"/>
+                        <field name="country_id"/>
+                        <field name="address_id"/>
+                    </group>
+                    <newline/>
+                    <group col="8" colspan="4" expand="0" string="Group By...">
+                        <filter string="Employees" icon="terp-partner" name="employee_id" context="{'group_by':'employee_id'}"/>
+                        <filter string="Country" name="country_id" icon="terp-go-home" context="{'group_by':'country_id'}"/>
+                        <filter string="Expire" name="date_expire" icon="terp-go-month" context="{'group_by':'date_expire'}"/>
+                        <filter string="Issue" name="date_issue" icon="terp-go-month" context="{'group_by':'date_issue'}"/>
+                    </group>
+                </search>
+            </field>
+        </record>
+        <record id="action_hr_passport_tree" model="ir.actions.act_window">
+            <field name="name">All Passports</field>
+            <field name="res_model">hr.passport</field>
+            <field name="view_type">form</field>
+            <field name="view_id" ref="hr_passport_tree"/>
+            <field name="search_view_id" ref="view_hr_passport_filter"/>
+        </record>
+        <!-- End Passport Views -->
+
     </data>
 </openerp>
index 569ac57..393c9d1 100644 (file)
@@ -10,3 +10,5 @@
 "access_hr_res_partner_address","res.partner.address","base.model_res_partner_address","base.group_hr_manager",1,1,1,1
 "access_hr_employee_marital_status_manager","hr.employee.marital.status.manager","model_hr_employee_marital_status","base.group_hr_manager",1,1,1,1
 "access_ir_property_hr_user","ir_property hr_user","base.model_ir_property","base.group_hr_user",1,1,1,0
+"access_hr_passport_manager","hr.passport.manager","model_hr_passport","base.group_hr_manager",1,1,1,1
+"access_hr_passport","hr.passport","model_hr_passport","base.group_hr_user",1,1,1,1
index aea686e..740d921 100644 (file)
@@ -40,7 +40,9 @@
         'hr_contract_view.xml'
         ],
     'demo_xml': [],
-    'test': ['test/test_hr_contract.yml'],
+    'test': [
+             #'test/test_hr_contract.yml'
+             ],
     'installable': True,
     'active': False,
     'certificate': '0046298028637',
index 050f0a8..bca3e62 100644 (file)
@@ -51,6 +51,20 @@ class hr_employee(osv.osv):
 
 hr_employee()
 
+class hr_passport(osv.osv):
+    """
+    Employee Passport
+    Passport based Contracts for Employees
+    """
+
+    _inherit = 'hr.passport'
+    _description = 'Passport Detail'
+    _columns = {
+        'contracts_ids': fields.one2many('hr.contract', 'passport_id', 'Contracts', required=False, readonly=True),
+    }
+
+hr_passport()
+
 #Contract wage type period name
 class hr_contract_wage_type_period(osv.osv):
     _name='hr.contract.wage.type.period'
@@ -71,11 +85,9 @@ class hr_contract_wage_type(osv.osv):
     _columns = {
         'name': fields.char('Wage Type Name', size=50, required=True, select=True),
         'period_id': fields.many2one('hr.contract.wage.type.period', 'Wage Period', required=True),
-#        'type': fields.selection([('gross','Gross'), ('net','Net')], 'Type', required=True),
         'factor_type': fields.float('Factor for hour cost', digits=(12,4), required=True, help='This field is used by the timesheet system to compute the price of an hour of work based on the contract of the employee')
     }
     _defaults = {
-#        'type': 'gross',
         'factor_type': 1.8
     }
 hr_contract_wage_type()
@@ -103,12 +115,15 @@ class hr_contract(osv.osv):
         'trial_date_start': fields.date('Trial Start Date'),
         'trial_date_end': fields.date('Trial End Date'),
         'working_hours': fields.many2one('resource.calendar','Working Schedule'),
-#        'wage_type_id': fields.many2one('hr.contract.wage.type', 'Wage Type', required=True),
         'wage': fields.float('Wage', digits=(16,2), required=True, help="Basic Salary of the employee"),
         'advantages': fields.text('Advantages'),
         'advantages_net': fields.float('Net Advantages Value', digits=(16,2)),
         'advantages_gross': fields.float('Gross Advantages Value', digits=(16,2)),
         'notes': fields.text('Notes'),
+        'permit_no': fields.char('Work Permit No', size=256, required=False, readonly=False),
+        'passport_id': fields.many2one('hr.passport', 'Passport No', required=False),
+        'visa_no': fields.char('Visa No', size=64, required=False, readonly=False),
+        'visa_expire': fields.date('Visa Expire Date'),
     }
     _defaults = {
         'date_start': lambda *a: time.strftime("%Y-%m-%d"),
@@ -123,9 +138,6 @@ class hr_contract(osv.osv):
     _constraints = [
         (_check_dates, 'Error! contract start-date must be lower then contract end-date.', ['date_start', 'date_end'])
     ]
-
-
-
 hr_contract()
 
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
index f65b518..040fa67 100644 (file)
             <field name="arch" type="xml">
                 <form string="Contract">
                     <group colspan="3" col="6">
-                    <field name="name" />
-                    <field name="employee_id" />
-                    <field name="job_id"/>
-                    <field name="wage"/>
-                    <!-- field name="wage_type_id" widget="selection"/-->
-                    <field name="type_id" widget="selection"/>
+                        <field name="name" />
+                        <field name="employee_id" />
+                        <field name="job_id"/>
+                        <field name="wage"/>
+                        <field name="type_id" widget="selection"/>
                     </group>
                     <notebook>
                     <page string="Information">
                         <group col="2" colspan="2">
-                        <separator colspan="2" string="Duration"/>
-                        <field name="date_start" />
-                        <field name="date_end" />
-                        <field name="working_hours"/>
-                        <separator colspan="2" string="Trial Period"/>
-                        <field name="trial_date_start" />
-                        <field name="trial_date_end" />
+                            <separator colspan="2" string="Duration"/>
+                            <field name="date_start" />
+                            <field name="date_end" />
+                            <field name="working_hours"/>
+                            <separator colspan="2" string="Trial Period"/>
+                            <field name="trial_date_start" />
+                            <field name="trial_date_end" />
                         </group>
-                        <group col="2" colspan="2">
-                        <separator colspan="2" string="Advantages"/>
-                        <field name="advantages_net"/>
-                        <field name="advantages_gross"/>
-                        <field name="advantages" nolabel="1" colspan="2"/>
+                            <group col="2" colspan="2">
+                            <separator colspan="2" string="Advantages"/>
+                            <field name="advantages_net"/>
+                            <field name="advantages_gross"/>
+                            <field name="advantages" nolabel="1" colspan="2"/>
                         </group>
                         <separator colspan="4" string="Notes"/>
                         <field colspan="4" name="notes" nolabel="1"/>
                     </page>
+                    <page string="Work Permit">
+                        <group col="2" colspan="2">
+                            <separator colspan="2" string="Passport"/>
+                            <field name="passport_id" domain="[('employee_id','=',employee_id)]"/>
+                        </group>
+                        <group col="2" colspan="2">
+                            <separator colspan="2" string="Valid for"/>
+                            <field name="visa_no"/>
+                            <field name="permit_no"/>
+                            <field name="visa_expire"/>
+                        </group>
+                    </page>
                     </notebook>
                 </form>
             </field>
                     <field name="working_hours"/>
                     <field name="date_start"/>
                     <field name="date_end"/>
-                    <!--  field name="wage_type_id" invisible="1"/-->
                     <field name="wage" invisible="1"/>
                 </tree>
             </field>
index f15456c..161c01d 100644 (file)
@@ -46,7 +46,7 @@
     'update_xml': [
         'security/hr_security.xml',
         'hr_payroll_view.xml',
-        'hr_payroll_workflow.xml',
+#        'hr_payroll_workflow.xml',
         'hr_payroll_sequence.xml',
         'hr_paroll_report.xml',
         'hr_payroll_data.xml',
index 35f4c5c..ec8e971 100644 (file)
@@ -43,43 +43,6 @@ def prev_bounds(cdate=False):
     prev_end = next_month - timedelta(days=1)
     return this_first, prev_end
 
-#class hr_contract_wage_type(osv.osv):
-#    """
-#    Wage types
-#    Basic = Basic Salary
-#    Grows = Basic + Allowances
-#    Net = Grows - Deductions
-#    """
-#
-#    _inherit = 'hr.contract.wage.type'
-#    _columns = {
-#        'type': fields.selection([('basic','Basic'), ('gross','Gross'), ('net','Net')], 'Type', required=True),
-#    }
-#
-#hr_contract_wage_type()
-
-class hr_passport(osv.osv):
-    """
-    Employee Passport
-    Passport based Contracts for Employees
-    """
-
-    _name = 'hr.passport'
-    _description = 'Passport Detail'
-    _columns = {
-        'employee_id':fields.many2one('hr.employee', 'Employee', required=True),
-        'name':fields.char('Passport No', size=64, required=True, readonly=False),
-        'country_id':fields.many2one('res.country', 'Country of Issue', required=True),
-        'address_id':fields.many2one('res.partner.address', 'Address', required=False),
-        'date_issue': fields.date('Passport Issue Date', required=True),
-        'date_expire': fields.date('Passport Expire Date', required=True),
-        'contracts_ids':fields.one2many('hr.contract', 'passport_id', 'Contracts', required=False, readonly=True),
-        'note': fields.text('Description'),
-    }
-    _sql_constraints = [
-        ('passport_no_uniq', 'unique (employee_id, name)', 'The Passport No must be unique !'),
-    ]
-hr_passport()
 
 class hr_payroll_structure(osv.osv):
     """
@@ -129,197 +92,12 @@ class hr_contract(osv.osv):
     allows to configure different Salary structure
     """
 
-#    def compute_basic(self, cr, uid, ids, context=None):
-#        res = {}
-#        if context is None:
-#            context = {}
-#        ids += context.get('employee_structure', []) # Unused line employee_structure is not in context
-#
-#        slip_line_pool = self.pool.get('hr.payslip.line')
-#
-#        for contract in self.browse(cr, uid, ids, context=context):
-#            all_per = 0.0
-#            ded_per = 0.0
-#            all_fix = 0.0
-#            ded_fix = 0.0
-#            obj = {'basic':0.0}
-#            update = {}
-#            if contract.wage_type_id.type == 'gross':
-#                obj['gross'] = contract.wage
-#                update['gross'] = contract.wage
-#            if contract.wage_type_id.type == 'net':
-#                obj['net'] = contract.wage
-#                update['net'] = contract.wage
-#            if contract.wage_type_id.type == 'basic':
-#                obj['basic'] = contract.wage
-#                update['basic'] = contract.wage
-#            sal_type = contract.wage_type_id.type
-##            function = contract.struct_id.id
-#            lines = contract.struct_id.line_ids
-#            if not contract.struct_id:
-#                res[contract.id] = obj['basic']
-#                continue
-#
-#            ad = []
-#            for line in lines:
-#                cd = line.code.lower()
-#                obj[cd] = line.amount or 0.0
-#
-#            for line in lines:
-#                if line.category_id.code in ad:
-#                    continue
-#                ad.append(line.category_id.code)
-#                cd = line.category_id.code.lower()
-#                calculate = False
-#                try:
-#                    exp = line.category_id.condition
-#
-#                    calculate = eval(exp, obj)
-#                except Exception, e:
-#                    raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ') % (e))
-#
-#                if not calculate:
-#                    continue
-#
-#                percent = 0.0
-#                value = 0.0
-#                base = False
-##                company_contrib = 0.0
-#                base = line.category_id.base
-#
-#                try:
-#                    #Please have a look at the configuration guide.
-#                    amt = eval(base, obj)
-#                except Exception, e:
-#                    raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ') % (e))
-#
-#                if sal_type in ('gross', 'net'):
-#                    if line.amount_type == 'per':
-#                        percent = line.amount
-#                        if amt > 1:
-#                            value = percent * amt
-#                        elif amt > 0 and amt <= 1:
-#                            percent = percent * amt
-#                        if value > 0:
-#                            percent = 0.0
-#                    elif line.amount_type == 'fix':
-#                        value = line.amount
-#                    elif line.amount_type == 'func':
-#                        value = slip_line_pool.execute_function(cr, uid, line.id, amt, context)
-#                        line.amount = value
-#                else:
-#                    if line.amount_type in ('fix', 'per'):
-#                        value = line.amount
-#                    elif line.amount_type == 'func':
-#                        value = slip_line_pool.execute_function(cr, uid, line.id, amt, context)
-#                        line.amount = value
-#                if line.type == 'allowance':
-#                    all_per += percent
-#                    all_fix += value
-#                elif line.type == 'deduction':
-#                    ded_per += percent
-#                    ded_fix += value
-#            if sal_type in ('gross', 'net'):
-#                sal = contract.wage
-#                if sal_type == 'net':
-#                    sal += ded_fix
-#                sal -= all_fix
-#                per = 0.0
-#                if sal_type == 'net':
-#                    per = (all_per - ded_per)
-#                else:
-#                    per = all_per
-#                if per <=0:
-#                    per *= -1
-#                final = (per * 100) + 100
-#                basic = (sal * 100) / final
-#            else:
-#                basic = contract.wage
-#            res[contract.id] = basic
-#
-#        return res
-
-#    def check_vals(self, val1, val2):
-#        if val1 == val2 and val1 == 0:
-#            return True
-#        return False
-
-    def _calculate_salary(self, cr, uid, ids, field_names, arg, context=None):
-#        res = self.compute_basic(cr, uid, ids, context=context)
-        vals = {}
-        for rs in self.browse(cr, uid, ids, context=context):
-            allow = 0.0
-            deduct = 0.0
-            others = 0.0
-#            obj = {'basic':res[rs.id], 'gross':0.0, 'net':0.0}
-#            if rs.wage_type_id.type == 'gross':
-#                obj['gross'] = rs.wage
-#            if rs.wage_type_id.type == 'net':
-#                obj['net'] = rs.net
-            obj = {'basic': rs.wage}
-            if not rs.struct_id:
-#                if self.check_vals(obj['basic'], obj['gross']):
-#                    obj['gross'] = obj['basic'] = obj['net']
-#                elif self.check_vals(obj['gross'], obj['net']):
-#                    obj['gross']= obj['net'] = obj['basic']
-#                elif self.check_vals(obj['net'], obj['basic']):
-#                    obj['net'] = obj['basic'] = obj['gross']
-                record = {
-                    'advantages_gross':0.0,
-                    'advantages_net':0.0,
-                    'basic':obj['basic'],
-#                    'gross':obj['gross'],
-#                    'net':obj['net']
-                }
-                vals[rs.id] = record
-                continue
-
-            for line in rs.struct_id.line_ids:
-                amount = 0.0
-                if line.amount_type == 'per':
-                    try:
-                        amount = line.amount * eval(str(line.category_id.base), obj)
-                    except Exception, e:
-                        raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ') % (e))
-                elif line.amount_type in ('fix', 'func'):
-                    amount = line.amount
-                cd = line.category_id.code.lower()
-                obj[cd] = amount
-                if line.type == 'allowance':
-                    allow += amount
-                elif line.type == 'deduction':
-                    deduct += amount
-                elif line.type == 'advance':
-                    others += amount
-                elif line.type == 'loan':
-                    others += amount
-                elif line.type == 'otherpay':
-                    others += amount
-            record = {
-                'advantages_gross':round(allow),
-                'advantages_net':round(deduct),
-                'basic':obj['basic'],
-#                'gross':round(obj['basic'] + allow),
-#                'net':round(obj['basic'] + allow - deduct)
-            }
-            vals[rs.id] = record
-
-        return vals
-
     _inherit = 'hr.contract'
     _description = 'Employee Contract'
     _columns = {
-        'permit_no': fields.char('Work Permit No', size=256, required=False, readonly=False),
-        'passport_id': fields.many2one('hr.passport', 'Passport No', required=False),
-        'visa_no': fields.char('Visa No', size=64, required=False, readonly=False),
-        'visa_expire': fields.date('Visa Expire Date'),
         'struct_id': fields.many2one('hr.payroll.structure', 'Salary Structure'),
         'working_days_per_week': fields.integer('Working Days', help="No of Working days / week for an employee"),
-        'basic': fields.function(_calculate_salary, method=True, store=True, multi='dc', type='float', string='Basic Salary', digits=(14,2)),
-#        'gross': fields.function(_calculate_salary, method=True, store=True, multi='dc', type='float', string='Gross Salary', digits=(14,2)),
-#        'net': fields.function(_calculate_salary, method=True, store=True, multi='dc', type='float', string='Net Salary', digits=(14,2)),
-        'advantages_net': fields.function(_calculate_salary, method=True, store=True, multi='dc', type='float', string='Deductions', digits=(14,2)),
-        'advantages_gross': fields.function(_calculate_salary, method=True, store=True, multi='dc', type='float', string='Allowances', digits=(14,2)),
+        'basic': fields.float('Basic Salary', digits_compute=dp.get_precision('Account')),
     }
     _defaults = {
         'working_days_per_week': 5,
@@ -334,26 +112,26 @@ class payroll_register(osv.osv):
     _name = 'hr.payroll.register'
     _description = 'Payroll Register'
 
-    def _calculate(self, cr, uid, ids, field_names, arg, context=None):
-        res = {}
-        allounce = 0.0
-        deduction = 0.0
-        net = 0.0
-        grows = 0.0
-        for register in self.browse(cr, uid, ids, context=context):
-            for slip in register.line_ids:
-                allounce += slip.allounce
-                deduction += slip.deduction
-#                net += slip.net
-#                grows += slip.grows
-
-            res[register.id] = {
-                'allounce':allounce,
-                'deduction':deduction,
-#                'net':net,
-#                'grows':grows
-            }
-        return res
+#    def _calculate(self, cr, uid, ids, field_names, arg, context=None):
+#        res = {}
+#        allounce = 0.0
+#        deduction = 0.0
+#        net = 0.0
+#        grows = 0.0
+#        for register in self.browse(cr, uid, ids, context=context):
+#            for slip in register.line_ids:
+#                allounce += slip.allounce
+#                deduction += slip.deduction
+##                net += slip.net
+##                grows += slip.grows
+#
+#            res[register.id] = {
+#                'allounce':allounce,
+#                'deduction':deduction,
+##                'net':net,
+##                'grows':grows
+#            }
+#        return res
 
     _columns = {
         'name':fields.char('Name', size=64, required=True, readonly=False),
@@ -373,10 +151,10 @@ class payroll_register(osv.osv):
         'company_id':fields.many2one('res.company', 'Company', required=False),
 #        'grows': fields.function(_calculate, method=True, store=True, multi='dc', string='Gross Salary', type='float', digits=(16, 4)),
 #        'net': fields.function(_calculate, method=True, store=True, multi='dc', string='Net Salary', digits=(16, 4)),
-        'allounce': fields.function(_calculate, method=True, store=True, multi='dc', string='Allowance', digits=(16, 4)),
-        'deduction': fields.function(_calculate, method=True, store=True, multi='dc', string='Deduction', digits=(16, 4)),
+#        'allounce': fields.function(_calculate, method=True, store=True, multi='dc', string='Allowance', digits=(16, 4)),
+#        'deduction': fields.function(_calculate, method=True, store=True, multi='dc', string='Deduction', digits=(16, 4)),
         'note': fields.text('Description'),
-        'bank_id':fields.many2one('res.bank', 'Bank', required=False, help="Select the Bank Address from whcih the salary is going to be paid"),
+        'bank_id':fields.many2one('res.bank', 'Bank', required=False, help="Select the Bank Address from which the salary is going to be paid"),
     }
 
     _defaults = {
@@ -416,7 +194,7 @@ class payroll_register(osv.osv):
 #                wf_service.trg_validate(uid, 'hr.payslip', slip_id, 'compute_sheet', cr)
 
         number = self.pool.get('ir.sequence').get(cr, uid, 'salary.register')
-        self.write(cr, uid, ids, {'state':'draft', 'number':number}, context=context)
+        self.write(cr, uid, ids, {'state': 'draft', 'number': number}, context=context)
         return True
 
     def set_to_draft(self, cr, uid, ids, context=None):
@@ -866,10 +644,10 @@ class hr_payslip(osv.osv):
         return res
 
     _columns = {
-        'deg_id':fields.many2one('hr.payroll.structure', 'Designation', readonly=True, states={'draft': [('readonly', False)]}),
+        'struct_id':fields.many2one('hr.payroll.structure', 'Designation', readonly=True, states={'new': [('readonly', False)], 'draft': [('readonly', False)]}),
         'register_id':fields.many2one('hr.payroll.register', 'Register', required=False, readonly=True, states={'new': [('readonly', False)]}),
         'name':fields.char('Name', size=64, required=False, readonly=True, states={'new': [('readonly', False)]}),
-        'number':fields.char('Number', size=64, required=False, readonly=True),
+        'number':fields.char('Number', size=64, required=False, readonly=True, states={'new': [('readonly', False)]}),
         'employee_id':fields.many2one('hr.employee', 'Employee', required=True, readonly=True, states={'new': [('readonly', False)], 'draft': [('readonly', False)]}),
         'date': fields.date('Date', readonly=True, states={'new': [('readonly', False)]}),
         'state':fields.selection([
@@ -891,14 +669,14 @@ class hr_payslip(osv.osv):
         'other_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Others', digits_compute=dp.get_precision('Account')),
         'total_pay': fields.function(_calculate, method=True, store=True, multi='dc', string='Total Payment', digits_compute=dp.get_precision('Account')),
 #        'total_pay': fields.float('Total Payment', readonly=True,  digits_compute=dp.get_precision('Account')),
-        'line_ids':fields.one2many('hr.payslip.line', 'slip_id', 'Payslip Line', required=False, readonly=True, states={'draft': [('readonly', False)]}),
+        'line_ids':fields.one2many('hr.payslip.line', 'slip_id', 'Payslip Line', required=False, readonly=True, states={'new': [('readonly', False)], 'draft': [('readonly', False)]}),
         'company_id':fields.many2one('res.company', 'Company', required=False, readonly=True, states={'draft': [('readonly', False)]}),
         'holiday_days': fields.float('No of Leaves', readonly=True),
         'worked_days': fields.float('Worked Day', readonly=True),
         'working_days': fields.float('Working Days', readonly=True),
-        'paid':fields.boolean('Paid ? ', required=False, readonly=True, states={'draft': [('readonly', False)]}),
+        'paid':fields.boolean('Paid ? ', required=False, readonly=True, states={'new': [('readonly', False)], 'draft': [('readonly', False)]}),
         'note':fields.text('Description'),
-        'contract_id':fields.many2one('hr.contract', 'Contract', required=False, readonly=True, states={'draft': [('readonly', False)]}),
+        'contract_id':fields.many2one('hr.contract', 'Contract', required=False, readonly=True, states={'new': [('readonly', False)],'draft': [('readonly', False)]}),
 #        'igross': fields.float('Calculaton Field', readonly=True,  digits=(16, 2), help="Calculation field used for internal calculation, do not place this on form"),
 #        'inet': fields.float('Calculaton Field', readonly=True,  digits=(16, 2), help="Calculation field used for internal calculation, do not place this on form"),
         'holiday_ids':fields.one2many('hr.holidays', 'payslip_id', 'Payslip', required=False),
@@ -1210,7 +988,7 @@ class hr_payslip(osv.osv):
 #
 #            number = sequence_obj.get(cr, uid, 'salary.slip')
 #            update.update({
-#                'deg_id':function,
+#                'struct_id':function,
 #                'number':number,
 #                'basic': round(basic),
 #                'basic_before_leaves': round(basic),
@@ -1314,6 +1092,7 @@ class hr_payslip(osv.osv):
         sequence_obj = self.pool.get('ir.sequence')
         empolyee_obj = self.pool.get('hr.employee')
         hr_all_ded_cate = self.pool.get('hr.allounce.deduction.categoty')
+        resource_attendance_pool = self.pool.get('resource.calendar.attendance')
         if context is None:
             context = {}
 
@@ -1335,7 +1114,7 @@ class hr_payslip(osv.osv):
         def get_days(start, end, month, year, calc_day):
             import datetime
             count = 0
-            for day in range(start, end):
+            for day in range(start, end+1):
                 if datetime.date(year, month, day).weekday() == calc_day:
                     count += 1
             return count
@@ -1348,7 +1127,7 @@ class hr_payslip(osv.osv):
                 'basic': round(0.0),
                 'basic_before_leaves': round(0.0),
                 'name':'Salary Slip of %s for %s' % (employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))),
-                'state':'draft',
+#                'state':'draft',
                 'contract_id':False,
                 'company_id':employee_id.company_id.id
             })
@@ -1480,7 +1259,7 @@ class hr_payslip(osv.osv):
 
         number = sequence_obj.get(cr, uid, 'salary.slip')
         update['value'].update({
-            'deg_id':function,
+            'struct_id':function,
             'number':number,
             'basic': round(basic),
             'basic_before_leaves': round(basic),
@@ -1488,7 +1267,7 @@ class hr_payslip(osv.osv):
             'deduction': round(deduction),
 #            'total_pay': round(basic)+ allounce - deduction,
             'name':'Salary Slip of %s for %s' % (employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))),
-            'state':'draft',
+#            'state':'draft',
             'contract_id':contract.id,
             'company_id':employee_id.company_id.id
         })
@@ -1513,13 +1292,22 @@ class hr_payslip(osv.osv):
         working_day = 0
         off_days = 0
         dates = prev_bounds(ddate)
-
+        calendar_id = employee_id.contract_id.working_hours.id
+        if not calendar_id:
+            raise osv.except_osv(_('Error !'), _("Please define working schedule on %s's contract") % (employee_id.name))
+        week_days = {"0": "mon", "1": "tue", "2": "wed","3": "thu", "4": "fri", "5": "sat", "6": "sun"}
+        wk_days = {}
+        week_ids = resource_attendance_pool.search(cr, uid, [('calendar_id', '=', calendar_id)], context=context)
+        weeks = resource_attendance_pool.read(cr, uid, week_ids, ['dayofweek'], context=context)
+        for week in weeks:
+            if week_days.has_key(week['dayofweek']):
+                wk_days[week['dayofweek']] = week_days[week['dayofweek']]
         days_arr = [0, 1, 2, 3, 4, 5, 6]
-        for dy in range(employee_id.contract_id.working_days_per_week, 7):
+        for dy in range(len(wk_days), 7):
             off_days += get_days(1, dates[1].day, dates[1].month, dates[1].year, days_arr[dy])
         total_off = off_days
         working_day = dates[1].day - total_off
-        perday = basic / working_day
+        perday = working_day and basic / working_day or 0.0
         total = 0.0
         leave = 0.0
         leave_ids = self._get_leaves1(cr, uid, ddate, employee_id, context)
@@ -1576,6 +1364,7 @@ class hr_payslip(osv.osv):
 #        holiday_pool.write(cr, uid, leave_ids, {'payslip_id': ids and ids[0] or False}, context=context)
         basic = basic - total
 #            leaves = total
+        temp_dic = self.pool.get('hr.holidays').read(cr, uid, leave_ids, [], context=context)
         update['value'].update({
             'basic':basic,
             'basic_before_leaves': round(basic_before_leaves),
@@ -1584,13 +1373,15 @@ class hr_payslip(osv.osv):
             'holiday_days': leave,
             'worked_days': working_day - leave,
             'working_days': working_day,
-            'holiday_ids': leave_ids
+#            'holiday_ids': temp_dic
         })
 #        self.write(cr, uid, uid, update, context=context)
         return update
 
 hr_payslip()
 
+
+
 class hr_holidays(osv.osv):
 
     _inherit = "hr.holidays"
@@ -1707,66 +1498,13 @@ class hr_employee(osv.osv):
     _inherit = 'hr.employee'
     _description = 'Employee'
 
-    def _calculate_salary(self, cr, uid, ids, field_names, arg, context=None):
-        vals = {}
-        slip_line_pool = self.pool.get('hr.payslip.line')
-
-        for employee in self.browse(cr, uid, ids, context=context):
-            if not employee.contract_id:
-#                vals[employee.id] = {'basic':0.0, 'gross':0.0, 'net':0.0, 'advantages_gross':0.0, 'advantages_net':0.0}
-                vals[employee.id] = {'basic':0.0, 'advantages_gross':0.0, 'advantages_net':0.0}
-                continue
-
-            basic = employee.contract_id.basic
-#            gross = employee.contract_id.gross
-#            net = employee.contract_id.net
-            allowance = employee.contract_id.advantages_gross
-            deduction = employee.contract_id.advantages_net
-
-            obj = {
-                'basic':basic,
-#                'gross':gross,
-#                'net':net
-            }
-            for line in employee.line_ids:
-                base = line.category_id.base
-                try:
-                    amt = eval(base, obj)
-                except Exception, e:
-                    raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ') % (e))
-                amount = 0.0
-                if line.amount_type == 'per':
-                    amount = amt * line.amount
-                elif line.amount_type == 'func':
-                    amount = slip_line_pool.execute_function(cr, uid, line.id, amt, context)
-                elif line.amount_type == 'fix':
-                    amount = line.amount
-
-                if line.type == 'allowance':
-                    allowance += amount
-                elif line.type == 'deduction':
-                    deduction += amount
-
-            vals[employee.id] = {
-                'basic':basic,
-                'advantages_gross':allowance,
-#                'gross':basic + allowance,
-                'advantages_net':deduction,
-#                'net':basic + allowance - deduction
-            }
-        return vals
 
     _columns = {
-        'passport_id':fields.many2one('hr.passport', 'Passport No', required=False, domain="[('employee_id','=',active_id), ('address_id','=',address_home_id)]", help="Employee Passport Information"),
         'line_ids':fields.one2many('hr.payslip.line', 'employee_id', 'Salary Structure', required=False),
         'slip_ids':fields.one2many('hr.payslip', 'employee_id', 'Payslips', required=False, readonly=True),
         'otherid': fields.char('Other Id', size=64),
-
-        'basic': fields.function(_calculate_salary, method=True, multi='dc', type='float', string='Basic Salary', digits=(14,2)),
-#        'gross': fields.function(_calculate_salary, method=True, multi='dc', type='float', string='Gross Salary', digits=(14,2)),
-#        'net': fields.function(_calculate_salary, method=True, multi='dc', type='float', string='Net Salary', digits=(14,2)),
-        'advantages_net': fields.function(_calculate_salary, method=True, multi='dc', type='float', string='Deductions', digits=(14,2)),
-        'advantages_gross': fields.function(_calculate_salary, method=True, multi='dc', type='float', string='Allowances', digits=(14,2)),
+#        'basic': fields.function(_calculate_salary, method=True, multi='dc', type='float', string='Basic Salary', digits=(14,2)),
+#FIXME the function has to make the sum of basic field of all the hr.contract for this employee that have date_start < now() and now() < date_stop or not date_stop
     }
 hr_employee()
 
index e4660c5..ef54673 100644 (file)
@@ -6,83 +6,6 @@
         <menuitem id="payroll_configure" parent="hr.menu_hr_configuration" name="Payroll"/>
         <menuitem id="menu_hr_payroll_reporting" parent="hr.menu_hr_reporting" name="Payroll" groups="base.group_hr_manager"/>
 
-        <!-- Passport Views    -->
-        <record id="hr_passport_form" model="ir.ui.view">
-            <field name="name">hr.passport.form</field>
-            <field name="model">hr.passport</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form string="Passport">
-                    <group col="6" colspan="4">
-                        <field name="name" select="1" colspan="4"/>
-                        <field name="employee_id" />
-                    </group>
-                    <group col="2" colspan="2">
-                        <separator string="Country &amp; Address" colspan="4"/>
-                        <field name="country_id" select="1"/>
-                        <field name="address_id" select="1"/>
-                    </group>
-                    <group col="2" colspan="2">
-                        <separator string="Valid From" colspan="2"/>
-                        <field name="date_issue" select="1"/>
-                        <field name="date_expire" select="1"/>
-                    </group>
-                    <notebook colspan="4">
-                        <page string="Description">
-                            <separator string="Description" colspan="2"/>
-                            <field name="note" colspan="4" nolabel="1"/>
-                        </page>
-                    </notebook>
-                </form>
-            </field>
-        </record>
-        <record id="hr_passport_tree" model="ir.ui.view">
-            <field name="name">hr.passport.tree</field>
-            <field name="model">hr.passport</field>
-            <field name="type">tree</field>
-            <field name="arch" type="xml">
-                <tree string="Passport">
-                    <field name="name" />
-                    <field name="employee_id" />
-                    <field name="address_id"/>
-                    <field name="country_id" />
-                    <field name="date_expire"/>
-                    <field name="date_issue" />
-                </tree>
-            </field>
-        </record>
-
-        <record id="view_hr_passport_filter" model="ir.ui.view">
-            <field name="name">hr.passport.select</field>
-            <field name="model">hr.passport</field>
-            <field name="type">search</field>
-            <field name="arch" type="xml">
-                <search string="Search Passport">
-                    <group col="8" colspan="4">
-                        <field name="name"/>
-                        <field name="employee_id"/>
-                        <field name="country_id"/>
-                        <field name="address_id"/>
-                    </group>
-                    <newline/>
-                    <group col="8" colspan="4" expand="0" string="Group By...">
-                        <filter string="Employees" icon="terp-partner" name="employee_id" context="{'group_by':'employee_id'}"/>
-                        <filter string="Country" name="country_id" icon="terp-go-home" context="{'group_by':'country_id'}"/>
-                        <filter string="Expire" name="date_expire" icon="terp-go-month" context="{'group_by':'date_expire'}"/>
-                        <filter string="Issue" name="date_issue" icon="terp-go-month" context="{'group_by':'date_issue'}"/>
-                    </group>
-                </search>
-            </field>
-        </record>
-        <record id="action_hr_passport_tree" model="ir.actions.act_window">
-            <field name="name">All Passports</field>
-            <field name="res_model">hr.passport</field>
-            <field name="view_type">form</field>
-            <field name="view_id" ref="hr_passport_tree"/>
-            <field name="search_view_id" ref="view_hr_passport_filter"/>
-        </record>
-        <!-- End Passport Views -->
-
         <!-- Employee View -->
         <record id="hr_contract.hr_hr_employee_view_form2" model="ir.ui.view">
             <field name="name">hr.hr.employee.view.form2</field>
             </data>
             </field>
         </record>
-        <record id="view_employee_passport_form" model="ir.ui.view">
-            <field name="name">hr.employee.passport.form</field>
-            <field name="model">hr.employee</field>
-            <field name="type">form</field>
-            <field name="inherit_id" ref="hr.view_employee_form"/>
-            <field name="arch" type="xml">
-                <field name="passport_id" position="replace">
-                    <field name="passport_id"/>
-                    <field name="otherid"/>
-                </field>
-            </field>
-        </record>
-
         <!-- End Employee View -->
 
         <!-- Contract View -->
-        <record id="hr_contract.hr_contract_view_form" model="ir.ui.view">
-            <field name="name">hr.contract.view.form</field>
+        <record id="hr_contract_form_inherit" model="ir.ui.view">
+            <field name="name">hr.contract.view.form.inherit</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">
-                <form string="Contract">
-                    <group colspan="4" col="6">
-                        <field name="name" select="1"/>
-                        <field name="employee_id" select="1"/>
-                        <field name="job_id"/>
-                        <field name="wage"/>
-                        <!--field name="wage_type_id" widget="selection"/-->
-                        <field name="type_id" widget="selection"/>
-                    </group>
-                    <notebook colspan="4">
-                        <page string="Main Data">
-                            <group col="2" colspan="2">
-                                <separator colspan="2" string="Duration"/>
-                                <field name="date_start" select="1"/>
-                                <field name="date_end" select="1"/>
-                                <field name="working_hours"/>
-                                <field name="working_days_per_week" select="1"/>
-                                <separator colspan="2" string="Trial Period"/>
-                                <field name="trial_date_start" />
-                                <field name="trial_date_end" />
-                            </group>
-                            <group col="2" colspan="2">
-                                <separator colspan="2" string="Advantages"/>
-                                <field name="struct_id" select="1"/>
-                                <field name="advantages_gross"/>
-                                <field name="advantages_net"/>
-                                <field name="advantages" nolabel="1" colspan="2"/>
-                            </group>
-                        </page>
-                        <page string="Work Permit">
-                            <group col="2" colspan="2">
-                                <separator colspan="2" string="Passport"/>
-                                <field name="passport_id" domain="[('employee_id','=',employee_id)]"/>
-                            </group>
-                            <group col="2" colspan="2">
-                                <separator colspan="2" string="Valid for"/>
-                                <field name="visa_no"/>
-                                <field name="permit_no"/>
-                                <field name="visa_expire"/>
-                            </group>
-                        </page>
-                    </notebook>
-                    <separator colspan="4" string="Notes"/>
-                    <field colspan="4" name="notes" nolabel="1"/>
-                </form>
+            <data>
+                <xpath expr="/form/notebook/page/group/field[@name='advantages_net']" position="before">
+                    <field name="struct_id" select="1"/>
+                </xpath>
+            </data>
             </field>
         </record>
-        <!--menuitem action="hr_contract.action_hr_contract" id="hr_menu_contract" parent="payroll_configure" name="Contracts" sequence="4"/-->
+
         <!-- End Contract View-->
 
         <!-- Salary structure -->
                     <group col="6" colspan="4">
                         <field name="employee_id" on_change="onchange_employee_id(date, employee_id)"/>
                         <field name="name"/>
-                        <field name="number" select="1"/>
+                        <field name="number"/>
                         <field name="date"/>
                     </group>
                     <notebook colspan="4">
                                 <field name="paid" readonly="1"/>
                                 <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                                 <field name="register_id" groups="base.group_extended"/>
-                                <field name="deg_id" groups="base.group_extended"/>
+                                <field name="struct_id" groups="base.group_extended"/>
                                 <field name="contract_id" groups="base.group_extended" domain="[('employee_id','=',employee_id)]"/>
                             </group>
                             <newline/>
                                     <field name="state"/>
                                 </tree>
                             </field>
-                            <group col="2" colspan="2">
+                            <!--<group col="2" colspan="2">
                                 <separator colspan="4" string="Allowance / Deduction"/>
                                 <field name="allounce"/>
                                 <field name="deduction"/>
                             </group>
-                            <!-- group col="2" colspan="2">
+                             <group col="2" colspan="2">
                                 <separator colspan="4" string="Salary Information"/>
                                 <field name="grows"/>
                                 <field name="net"/>
index bafa156..f853aaf 100644 (file)
@@ -1,5 +1,4 @@
 "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
-"access_hr_passport","hr.passport","model_hr_passport","base.group_hr_user",1,1,1,1
 "access_hr_payroll_structure","hr.payroll.structure","model_hr_payroll_structure","base.group_hr_user",1,1,1,1
 "access_hr_payroll_register","hr.payroll.register","model_hr_payroll_register","base.group_hr_user",1,1,1,1
 "access_hr_payroll_advice","hr.payroll.advice","model_hr_payroll_advice","base.group_hr_user",1,1,1,1
@@ -16,5 +15,3 @@
 "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_passport_manager","hr.passport.manager","model_hr_passport","base.group_hr_manager",1,1,1,1
-"access_hr_contract_wage_type","hr.contract.wage.type user","hr_contract.model_hr_contract_wage_type","base.group_hr_user",1,1,1,1