Skip to content

[IMP] hr: make work permit fields versioned - #5219

Open
tonymchl wants to merge 1 commit into
master-hr-onboarding-tomicfrom
master-hr-onboarding-version_work_permit_no-tomic
Open

[IMP] hr: make work permit fields versioned#5219
tonymchl wants to merge 1 commit into
master-hr-onboarding-tomicfrom
master-hr-onboarding-version_work_permit_no-tomic

Conversation

@tonymchl

@tonymchl tonymchl commented Aug 5, 2026

Copy link
Copy Markdown

Currently, the work permit information (such as permit_no and its associated fields) is stored directly on the hr.employee model.

This prevents keeping an accurate history of an employee's work permit details over time as their status evolves.

To address this, move permit_no and its related work permit fields (work_permit_expiration_date, work_permit_name, work_permit_scheduled_activity) from hr.employee to hr.version. The fields are now versioned on hr.version and accessed via delegation on hr.employee.

Task: 6448688

@robodoo

robodoo commented Aug 5, 2026

Copy link
Copy Markdown

This PR targets the un-managed branch odoo-dev/odoo:master-hr-onboarding-tomic, it needs to be retargeted before it can be merged.

@YassinWalid YassinWalid left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work. I left some comments/suggestions.

Also, I believe we'll need an upgrade script to migrate the values previously on the employee to be assigned to the new fields on versions.

Comment thread addons/hr/models/hr_employee.py Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't we remove this? (since it is no longer done on the employee, and this function will never be called)

Comment on lines -225 to -231
permit_no = fields.Char('Work Permit No', groups="hr.group_hr_user", tracking=True)
visa_no = fields.Char('Visa No', groups="hr.group_hr_user", tracking=True)
visa_expire = fields.Date('Visa Expiration Date', groups="hr.group_hr_user", tracking=True)
work_permit_expiration_date = fields.Date('Work Permit Expiration Date', groups="hr.group_hr_user", tracking=True)
has_work_permit = fields.Binary(string="Work Permit", groups="hr.group_hr_user")
work_permit_scheduled_activity = fields.Boolean(default=False, groups="hr.group_hr_user")
work_permit_name = fields.Char('work_permit_name', compute='_compute_work_permit_name', groups="hr.group_hr_user")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why didn't you make these fields related to the new version fields, such that they can still be accessed from the employee right away, but corresponding to the correct version

Comment thread addons/hr/models/hr_version.py Outdated
Comment on lines +241 to +246
@api.depends('name', 'permit_no')
def _compute_work_permit_name(self):
for version in self:
name = version.name.replace(' ', '_') + '_' if version.name else ''
permit_no = '_' + version.permit_no if version.permit_no else ''
version.work_permit_name = "%swork_permit%s" % (name, permit_no)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the version name is just a date, so if you put the date and then the permit number, it'll be unreadable. I believe we could still use the employee name, along with the permit number. (this is just my suggestion, do you have a specific reasoning for this?)

@tonymchl
tonymchl force-pushed the master-hr-onboarding-version_work_permit_no-tomic branch from 0768d5a to 0a314b1 Compare August 6, 2026 07:59
Currently, the work permit information (such as `permit_no` and its associated
fields) is stored directly on the `hr.employee` model.

This prevents keeping an accurate history of an employee's work permit details
over time as their status evolves.

To address this, move `permit_no` and its related work permit fields
(`work_permit_expiration_date`, `work_permit_name`, `work_permit_scheduled_activity`)
from `hr.employee` to `hr.version`. The fields are now versioned on `hr.version`
and accessed via delegation on `hr.employee`.

Task: 6448688
@tonymchl
tonymchl force-pushed the master-hr-onboarding-version_work_permit_no-tomic branch from 07c3a2f to 1036472 Compare August 6, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants