Files
suite/hr_payroll_hibou/models/hr_contract.py
Jared Kipe 30f1414df5 [IMP] hr_payroll_hibou: Control the 'wage_type' at the HR Contract Level
This will make it possible to be more abstract with 'work_type' or 'worked days lines' and overtime.
2021-10-06 20:12:22 +00:00

21 lines
790 B
Python

from odoo import fields, models
class HrContract(models.Model):
_inherit = 'hr.contract'
wage_type = fields.Selection([('monthly', 'Period Fixed Wage'), ('hourly', 'Hourly Wage')],
default='monthly', required=True, related=False)
def _get_contract_wage(self, work_type=None):
# Override if you pay differently for different work types
# In 14.0, this utilizes new computed field mechanism,
# but will still get the 'wage' field by default.
self.ensure_one()
return self[self._get_contract_wage_field(work_type=work_type)]
def _get_contract_wage_field(self, work_type=None):
if self.wage_type == 'hourly':
return 'hourly_wage'
return super()._get_contract_wage_field()