Merge pull request #3934 from expsa/bakry_hr

fix Gosi calculation
This commit is contained in:
bakry 2025-07-16 12:20:08 +03:00 committed by GitHub
commit cb81125e5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 70 additions and 26 deletions

View File

@ -101,14 +101,15 @@
<group>
<separator string="Insurances"
attrs="{'invisible':[('on_company_guarantee','=',False)]}"/>
<field name="new_insurance" attrs="{'readonly':[('state','!=','draft')],
<field name="new_gosi" 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="insurance_date"
<field name="gosi_date"
attrs="{'readonly':[('state','!=','draft')],'invisible':[('on_company_guarantee','=',False)]}"/>
<field name="insurance_years" attrs="{'invisible':[('on_company_guarantee','=',False)]}"/>
<field name="gosi_years" attrs="{'invisible':['|',('on_company_guarantee','=',False),
('new_gosi','=',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

@ -4838,24 +4838,51 @@ msgstr "نوع الموظف"
msgid "Debit Account"
msgstr "بند الصرف"
#. module: hr_base
#: model:ir.model.fields,field_description:hr_base.field_hr_employee__gosi_date
msgid "Gosi Date"
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"
#: model:ir.model.fields,field_description:hr_base.field_hr_employee__new_gosi
msgid "New Gosi"
msgstr "إشتراك جديد"
#. module: hr_base
#: model:ir.model.fields,help:hr_base.field_hr_employee__new_insurance
#: model:ir.model.fields,help:hr_base.field_hr_employee__new_gosi
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"
#: model:ir.model.fields,field_description:hr_base.field_hr_employee__gosi_years
msgid "Gosi Years"
msgstr "سنوات الإشتراك"
#. module: hr_base
#: model:ir.model.fields,field_description:hr_base.field_res_company__gosi_active_date
msgid "Gosi Activation Date"
msgstr "تاريخ تفعيل التأمينات الإجتماعية الجديد"
#. module: hr_base
#: model:ir.model.fields,help:hr_base.field_res_company__gosi_active_date
msgid "Activation Date Of The New GOSI Subscription"
msgstr "تاريخ تفعيل الاشتراك الجديد بالتأمينات الاجتماعية للمشتركين الجدد"
#. module: hr_base
#: model:ir.model.fields,help:hr_base.field_hr_employee__gosi_years
msgid "GOSI Years According To The New activation Date Until Today"
msgstr "سنوات التأمينات الاجتماعية حسب تاريخ التفعيل الجديد حتى تاريخ اليوم"
#. module: hr_base
#: code:addons/hr_base/models/hr_base.py:0
#, python-format
msgid "The Gosi Date Must Be Greater Than Or Equal The New Gosi Activation Date"
msgstr "تاريخ اشتراك التأمينات الاجتماعية يجب ان يكون اكبر من او يساوي تاريخ تفعيل التأمينات الاجتماعية الجديد"
#. module: hr_base
#: code:addons/hr_base/models/hr_base.py:0
#, python-format
msgid "The Gosi subscription date Must Be Less Than Today"
msgstr "تاريخ إشتراك التأمينات الإجتماعية يجب أن يكون أقل من تاريخ اليوم"

View File

@ -244,20 +244,32 @@ 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",
gosi_date = fields.Date(string="GOSI Date")
new_gosi = fields.Boolean(string="New GOSI",
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):
gosi_years = fields.Integer(string="GOSI Years", compute='_compute_gosi_years', store=True,
help='GOSI Years According To The New activation Date Until Today')
@api.depends('new_gosi')
def _compute_gosi_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
date_activation = datetime.strptime(str(emp.sudo().company_id.gosi_active_date), '%Y-%m-%d')
if emp.new_gosi==True:
if date_activation:
today = date.today()
years = today.year - date_activation.year - ((today.month, today.day) < (date_activation.month, date_activation.day))
emp.sudo().gosi_years = years
@api.constrains('gosi_date','new_gosi')
def _check_gosi_date(self):
for rec in self:
today = date.today()
date_activation = rec.sudo().company_id.gosi_active_date
if date_activation and rec.gosi_date and rec.new_gosi==True:
if rec.gosi_date < date_activation :
raise ValidationError(_("The Gosi Date Must Be Greater Than Or Equal The New Gosi Activation Date"))
if rec.gosi_date > today :
raise ValidationError(_("The Gosi subscription date Must Be Less Than Today"))
'''employee_cars_count = fields.Integer(compute_sudo=True, compute="_compute_employee_cars_count", string="Cars",
groups="base.group_user")
@ -367,7 +379,7 @@ class HrEmployee(models.Model):
def _compute_service_duration(self):
for rec in self:
rec._compute_employee_age()
rec._compute_insurance_years()
rec._compute_gosi_years()
rec.service_year = 0
rec.service_month = 0
rec.service_day = 0

View File

@ -42,6 +42,9 @@ class ResCompanyExt(models.Model):
financial_manager_id = fields.Many2one('hr.employee', string='Financial Manager')
cyber_security_id = fields.Many2one('hr.employee', string='Cyber Security')
gosi_active_date = fields.Date(string="Gosi Activation Date",default='2024-07-01',
help='Activation Date Of The New GOSI Subscription')
@api.constrains('saudi_percentage')
def saudi_percentage_less_100(self):
for item in self:

View File

@ -103,7 +103,7 @@
</xpath>
<xpath expr="//page" position="after">
<page name="hr_info" string="HR Info">
<page name="hr_info" string="HR Info" groups="hr.group_hr_user">
<group>
<field name="hr_manager_id"/>
<field name="hr_email"/>
@ -112,6 +112,7 @@
<field name="it_manager_id"/>
<field name="cyber_security_id"/>
<field name="admin_manager_id"/>
<field name="gosi_active_date" required="1"/>
</group>
</page>
</xpath>