47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from . import models
|
|
from . import wizards
|
|
from . import controllers
|
|
|
|
|
|
def _fusion_payroll_post_init(env):
|
|
"""Archive default salary rules auto-added to Canadian structure.
|
|
|
|
When hr_payroll creates a new structure, it automatically generates
|
|
default rules (BASIC, GROSS, NET, etc.). Since this module defines
|
|
its own custom rules, the defaults must be archived to avoid duplicates.
|
|
"""
|
|
structure = env.ref(
|
|
'fusion_payroll.hr_payroll_structure_canada',
|
|
raise_if_not_found=False,
|
|
)
|
|
if not structure:
|
|
return
|
|
|
|
default_codes = [
|
|
'BASIC', 'GROSS', 'NET',
|
|
'ATTACH_SALARY', 'ASSIG_SALARY',
|
|
'CHILD_SUPPORT', 'DEDUCTION', 'REIMBURSEMENT',
|
|
]
|
|
|
|
own_rule_xmlids = [
|
|
'fusion_payroll.hr_rule_basic',
|
|
'fusion_payroll.hr_rule_gross',
|
|
'fusion_payroll.hr_rule_net',
|
|
]
|
|
own_rule_ids = set()
|
|
for xmlid in own_rule_xmlids:
|
|
rule = env.ref(xmlid, raise_if_not_found=False)
|
|
if rule:
|
|
own_rule_ids.add(rule.id)
|
|
|
|
default_rules = env['hr.salary.rule'].search([
|
|
('struct_id', '=', structure.id),
|
|
('code', 'in', default_codes),
|
|
])
|
|
|
|
rules_to_archive = default_rules.filtered(lambda r: r.id not in own_rule_ids)
|
|
if rules_to_archive:
|
|
rules_to_archive.active = False
|