fix new GOSI calculation

This commit is contained in:
Bakry 2025-07-07 14:12:41 +03:00
parent 7a645ce875
commit fa6c578e07
5 changed files with 53 additions and 10 deletions

View File

@ -902,10 +902,20 @@ msgid "Date From"
msgstr "تاريخ البداية"
#. module: employee_requests
#: model:ir.model.fields,field_description:employee_requests.field_hr_employee__date_issuance_residence
msgid "Date Issuance Insurances"
#: model_terms:ir.ui.view,arch_db:employee_requests.view_employee_form_leave_inherit_001
msgid "Insurance Date"
msgstr "تاريخ التأمينات الاجتماعية"
#. module: employee_requests
#: model_terms:ir.ui.view,arch_db:employee_requests.view_employee_form_leave_inherit_001
msgid "New Insurance"
msgstr "إشتراك جديد"
#. module: employee_requests
#: model_terms:ir.ui.view,arch_db:employee_requests.view_employee_form_leave_inherit_001
msgid "Insurance Years"
msgstr "سنوات الإشتراك"
#. module: employee_requests
#: model:ir.model.fields,field_description:employee_requests.field_hr_employee__date_of_employment
msgid "Date Of Employment"
@ -928,11 +938,6 @@ msgstr "تاريخ الطلب"
msgid "Date To"
msgstr "تاريخ النهاية"
#. module: employee_requests
#: model_terms:ir.ui.view,arch_db:employee_requests.view_employee_form_leave_inherit_001
msgid "Date of issuance Insurances"
msgstr "تاريخ التأمينات الإجتماعية"
#. module: employee_requests
#: model_terms:ir.ui.view,arch_db:employee_requests.view_employee_form_leave_inherit_001
msgid "Date of issue"

View File

@ -24,7 +24,7 @@ class HrEmployee(models.Model):
# Accommodation and medical insurance page
###Residence
residency_number = fields.Char(string="Insurances Number")
date_issuance_residence = fields.Date()
#date_issuance_residence = fields.Date()
expiration_date_residence = fields.Date()
place_issuance_residence = fields.Char()
first_entry_into_saudi_arabia = fields.Date()

View File

@ -101,11 +101,14 @@
<group>
<separator string="Insurances"
attrs="{'invisible':[('on_company_guarantee','=',False)]}"/>
<field name="new_insurance" attrs="{'readonly':[('state','!=','draft')],
'invisible':[('on_company_guarantee','=',False)]}"/>
<field name="residency_number" string="Insurances Number"
attrs="{'readonly':[('state','!=','draft')],'invisible':[('on_company_guarantee','=',False)]}"/>
<field name="date_issuance_residence" string="Date of issuance Insurances"
widget="date"
<field name="insurance_date"
attrs="{'readonly':[('state','!=','draft')],'invisible':[('on_company_guarantee','=',False)]}"/>
<field name="insurance_years" attrs="{'invisible':[('on_company_guarantee','=',False)]}"/>
<!--field name="expiration_date_residence" string="Expiration date of residence"
widget="date" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="place_issuance_residence" string="Place issuance residence"

View File

@ -4839,3 +4839,23 @@ msgid "Debit Account"
msgstr "بند الصرف"
#. module: hr_base
#: model:ir.model.fields,field_description:hr_base.field_hr_employee__insurance_date
msgid "Insurance Date"
msgstr "تاريخ التأمينات الاجتماعية"
#. module: hr_base
#: model:ir.model.fields,field_description:hr_base.field_hr_employee__new_insurance
msgid "New Insurance"
msgstr "إشتراك جديد"
#. module: hr_base
#: model:ir.model.fields,help:hr_base.field_hr_employee__new_insurance
msgid "New participants who have no prior periods of contribution under the GOSI."
msgstr "المشتركين الجدد الذين ليس لديهم فترات اشتراك سابقة في نظام التأمينات الاجتماعية"
#. module: hr_base
#: model:ir.model.fields,field_description:hr_base.field_hr_employee__insurance_years
msgid "Insurance Years"
msgstr "سنوات الإشتراك"

View File

@ -244,6 +244,20 @@ class HrEmployee(models.Model):
children = fields.Integer(string='Number of Children', groups="base.group_user", tracking=True)
branch_name = fields.Many2one(related='department_id.branch_name', store=True, string="Branch Name")
insurance_date = fields.Date(string="Insurance Date")
new_insurance = fields.Boolean(string="New Insurance",
help='New participants who have no prior periods of contribution under the GOSI.')
insurance_years = fields.Integer(string="Insurance Years", compute='_compute_insurance_years', store=True)
@api.depends('insurance_date')
def _compute_insurance_years(self):
for emp in self:
years = 0
if emp.insurance_date:
insurance_date = datetime.strptime(str(emp.insurance_date), '%Y-%m-%d')
today = date.today()
years = today.year - insurance_date.year - ((today.month, today.day) < (insurance_date.month, insurance_date.day))
emp.sudo().insurance_years = years
'''employee_cars_count = fields.Integer(compute_sudo=True, compute="_compute_employee_cars_count", string="Cars",
groups="base.group_user")
@ -353,6 +367,7 @@ class HrEmployee(models.Model):
def _compute_service_duration(self):
for rec in self:
rec._compute_employee_age()
rec._compute_insurance_years()
rec.service_year = 0
rec.service_month = 0
rec.service_day = 0