Files
enterprise-addons/hr_payroll/models/hr_salary_rule_section.py
T

22 lines
719 B
Python

from odoo import api, fields, models
from odoo.exceptions import UserError
class HrSalaryRuleSection(models.Model):
_name = 'hr.salary.rule.section'
_description = 'Salary Input Section'
name = fields.Char()
sequence = fields.Integer()
struct_ids = fields.Many2many('hr.payroll.structure')
@api.ondelete(at_uninstall=False)
def _unlink_if_not_used_in_salary_structure(self):
if self.env['hr.salary.rule'].search_count([
('input_section', 'in', self.ids),
('input_used_in_definition', '=', True)
], limit=1):
raise UserError(self.env._(
"You cannot delete a section currently used in a salary structure."
))