You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

42 lines
1.7 KiB

# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Aysha Shalin (odoo@cybrosys.com)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import api, fields, models
class HrEmployee(models.Model):
_inherit = 'hr.employee'
hourly_payslip = fields.Boolean(help='Enable to see the hours spend by the'
' employee in the payslip.',
string='Hourly Payslip')
@api.onchange('hourly_payslip')
def _onchange_hourly_payslip(self):
""" This method will work when the user modifies the Hourly Cost
field. According to the conditions, will add a new python code to
the Basic salary rule. """
if self.hourly_payslip:
rule_id = self.env['hr.salary.rule'].browse(
self.env.ref('hr_payroll_community.hr_rule_basic').id)
rule_id.write({
'amount_python_compute': 'result = employee.hourly_cost*payslip.total_hours'
})