diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 17:14:58 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 17:14:58 +0700 |
| commit | 1ca3b3df3421961caec3b747a364071c80f5c7da (patch) | |
| tree | 6778a1f0f3f9b4c6e26d6d87ccde16e24da6c9d6 /hr_payroll_community/models/hr_contract.py | |
| parent | b57188be371d36d96caac4b8d65a40745c0e972c (diff) | |
initial commit
Diffstat (limited to 'hr_payroll_community/models/hr_contract.py')
| -rw-r--r-- | hr_payroll_community/models/hr_contract.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/hr_payroll_community/models/hr_contract.py b/hr_payroll_community/models/hr_contract.py new file mode 100644 index 0000000..b0bc43f --- /dev/null +++ b/hr_payroll_community/models/hr_contract.py @@ -0,0 +1,69 @@ +# -*- coding:utf-8 -*- + +from odoo import api, fields, models + + +class HrContract(models.Model): + """ + Employee contract based on the visa, work permits + allows to configure different Salary structure + """ + _inherit = 'hr.contract' + _description = 'Employee Contract' + + struct_id = fields.Many2one('hr.payroll.structure', string='Salary Structure') + schedule_pay = fields.Selection([ + ('monthly', 'Monthly'), + ('quarterly', 'Quarterly'), + ('semi-annually', 'Semi-annually'), + ('annually', 'Annually'), + ('weekly', 'Weekly'), + ('bi-weekly', 'Bi-weekly'), + ('bi-monthly', 'Bi-monthly'), + ], string='Scheduled Pay', index=True, default='monthly', + help="Defines the frequency of the wage payment.") + resource_calendar_id = fields.Many2one(required=True, help="Employee's working schedule.") + hra = fields.Monetary(string='HRA', tracking=True, help="House rent allowance.") + travel_allowance = fields.Monetary(string="Travel Allowance", help="Travel allowance") + da = fields.Monetary(string="DA", help="Dearness allowance") + meal_allowance = fields.Monetary(string="Meal Allowance", help="Meal allowance") + medical_allowance = fields.Monetary(string="Medical Allowance", help="Medical allowance") + other_allowance = fields.Monetary(string="Other Allowance", help="Other allowances") + + def get_all_structures(self): + + """ + @return: the structures linked to the given contracts, ordered by hierachy (parent=False first, + then first level children and so on) and without duplicata + """ + structures = self.mapped('struct_id') + if not structures: + return [] + # YTI TODO return browse records + return list(set(structures._get_parent_structure().ids)) + + def get_attribute(self, code, attribute): + + return self.env['hr.contract.advantage.template'].search([('code', '=', code)], limit=1)[attribute] + + def set_attribute_value(self, code, active): + for contract in self: + + if active: + + value = self.env['hr.contract.advantage.template'].search([('code', '=', code)], limit=1).default_value + contract[code] = value + else: + + contract[code] = 0.0 + + +class HrContractAdvandageTemplate(models.Model): + _name = 'hr.contract.advantage.template' + _description = "Employee's Advantage on Contract" + + name = fields.Char('Name', required=True) + code = fields.Char('Code', required=True) + lower_bound = fields.Float('Lower Bound', help="Lower bound authorized by the employer for this advantage") + upper_bound = fields.Float('Upper Bound', help="Upper bound authorized by the employer for this advantage") + default_value = fields.Float('Default value for this advantage') |
