[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.
This commit is contained in:
Jared Kipe
2020-11-27 14:22:16 -08:00
parent 487daf1201
commit 30f1414df5
10 changed files with 118 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
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()