Merge branch 'new/13.0/l10n_us_hr_payroll' into '13.0-test'

new/13.0/l10n_us_hr_payroll into 13.0-test

See merge request hibou-io/hibou-odoo/suite!467
This commit is contained in:
Hibou Bot
2020-09-29 21:40:22 +00:00
3 changed files with 57 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
import odoo
def migrate(cr, version):
"""
Post-migration no contracts will have any structure types.
Unfortunately, we have no way of knowing if they used USA in the past
so we have to just assume they did (knowing of course that l10n_us_hr_payroll was installed)...
"""
env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})
structure_type = env.ref('l10n_us_hr_payroll.structure_type_employee')
cr.execute("UPDATE hr_contract "
"SET structure_type_id = %s "
"WHERE structure_type_id is null AND state in ('draft', 'open')", (structure_type.id, ))
"""
Additionally, it is known that post-migration databases will have bad
work entry record states (and you will spend time trying to fix them
before you could run a payroll batch).
"""
default_work_entry_type = env.ref('hr_work_entry.work_entry_type_attendance', raise_if_not_found=False)
if default_work_entry_type:
cr.execute("UPDATE hr_work_entry "
"SET work_entry_type_id = %s "
"WHERE work_entry_type_id is null", (default_work_entry_type.id, ))
cr.execute("UPDATE hr_work_entry "
"SET state = 'draft' "
"WHERE state = 'conflict'")

View File

@@ -0,0 +1,26 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
import odoo
def migrate(cr, version):
"""
Salary Rules can be archived by Odoo S.A. during migration.
This leaves them archived after the migration, and even un-archiving them
is not enough because they will then be pointed to a "migrated" structure.
"""
env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})
xml_refs = env['ir.model.data'].search([
('module', '=', 'l10n_us_hr_payroll'),
('model', '=', 'hr.salary.rule'),
])
# I don't know why Odoo makes these non-updatable...
xml_refs.write({'noupdate': False})
rule_ids = xml_refs.mapped('res_id')
rules = env['hr.salary.rule'].browse(rule_ids)
rules.write({'active': True})
# Cannot add new selection type without fixing missing
cr.execute('UPDATE hr_payroll_structure SET schedule_pay = \'monthly\' WHERE schedule_pay is null;')
cr.execute('UPDATE hr_payroll_structure_type SET default_schedule_pay = \'monthly\' WHERE default_schedule_pay is null;')

View File

@@ -6,7 +6,7 @@ from .us_payroll_config import FUTA_TYPE_NORMAL, \
FUTA_TYPE_EXEMPT
class HrPayrollStructure(models.Model):
class HrPayrollStructureType(models.Model):
_inherit = 'hr.payroll.structure.type'
default_schedule_pay = fields.Selection(selection_add=[('semi-monthly', 'Semi-monthly')])