Skip to content
Snippets Groups Projects
Commit 2f49ec86 authored by Thomas Lefebvre (thle)'s avatar Thomas Lefebvre (thle)
Browse files

[FIX] hr: add a name for work permit file


Issue:
------
When adding a file to an employee's work permit ("Private Information tab"),
the file name is the "value" of the file.
This is not meaningful for the user who will download the file.

Solution:
---------
Use the `filename` attribute to determine the field of `hr.employee`
to be used to get the file name.
As the original file name doesn't exist in an existing field,
we can use a "generic" file name with a non-stored computed field.

opw-3458842

closes odoo/odoo#133569

Signed-off-by: default avatarSofie Gvaladze (sgv) <sgv@odoo.com>
parent 7ff1dac4
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,7 @@ class HrEmployeePrivate(models.Model):
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", tracking=True)
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')
additional_note = fields.Text(string='Additional Note', groups="hr.group_hr_user", tracking=True)
certificate = fields.Selection([
('graduate', 'Graduate'),
......@@ -157,6 +158,13 @@ class HrEmployeePrivate(models.Model):
avatar = base64.b64encode(employee._avatar_get_placeholder())
employee[avatar_field] = avatar
@api.depends('name', 'permit_no')
def _compute_work_permit_name(self):
for employee in self:
name = employee.name.replace(' ', '_') + '_' if employee.name else ''
permit_no = '_' + employee.permit_no if employee.permit_no else ''
employee.work_permit_name = "%swork_permit%s" % (name, permit_no)
def action_create_user(self):
self.ensure_one()
if self.user_id:
......
......@@ -166,7 +166,8 @@
<field name="permit_no"/>
<field name="visa_expire"/>
<field name="work_permit_expiration_date"/>
<field name="has_work_permit" widget="work_permit_upload"/>
<field name="work_permit_name" invisible="1"/>
<field name="has_work_permit" widget="work_permit_upload" filename="work_permit_name"/>
</group>
<group string="Citizenship">
<field name="country_id" options='{"no_open": True, "no_create": True}'/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment