fix like Effective Form with contrat

This commit is contained in:
Bakry 2025-07-29 13:17:11 +03:00
parent 5b17bc2a29
commit 62a28bd9cc
5 changed files with 46 additions and 5 deletions

View File

@ -44,12 +44,12 @@ class EmployeeEffectiveForm(models.Model):
employee_id = self.env['employee.effective.form'].search([('id', '!=', i.id),('employee_id', '=', i.employee_id.id), ('state', '=', 'done')], limit=1)
if employee_id:
raise exceptions.Warning(_('Sorry, Not possible to request a effective Form more than once'))
if i.contract_start:
if i.contract_start and i.effective_form_date:
if i.effective_form_date < i.contract_start:
raise exceptions.Warning(_('Sorry, The First Hiring Date must be after the Contract Start Date'))
if i.employee_id.contract_id.state != 'program_directory':
raise exceptions.Warning(_('Sorry, The Employee Contract Must Be Approved Before Hiring Date'))
#if i.employee_id.contract_id.state != 'program_directory':
#raise exceptions.Warning(_('Sorry, The Employee Contract Must Be Approved Before Hiring Date'))
if i.employee_id.state != 'open':
raise exceptions.Warning(_('Sorry, The Employee Record Must Be Approved Before Hiring Date'))

View File

@ -352,8 +352,8 @@
<field name="user_id" position="attributes">
<attribute name="attrs">{'readonly':[('state','!=','draft')]}
</attribute>
<attribute name="attrs">{'readonly':[('state','!=','draft')]}</attribute>
<attribute name="domain">[('employee_ids', '=', False)]</attribute>
</field>
<!-- <field name="address_home_id" position="attributes">-->

View File

@ -3849,3 +3849,11 @@ msgstr "آخر راتب للتأمينات"
#, python-format
msgid "The Last Salary Gosi After The Age 50 Years."
msgstr "آخر راتب في التأمينات الاجتماعية بعد سن الخمسين"
#. module: hr_contract_custom
#: code:addons/hr_contract_custom/models/hr_contract.py:0
#: model_terms:ir.ui.view,arch_db:hr_contract_custom.hr_contract_form_view
#, python-format
msgid "Effective Form"
msgstr "مباشرة العمل"

View File

@ -667,6 +667,17 @@ class Contract(models.Model):
def program_directory(self):
#self.chick_saudi_percentage()
self.employee_id.contract_id = self.id
hiring_date = self.employee_id.first_hiring_date
effective = self.env['employee.effective.form'].search([('contract_id', '=', self.id)])
if not effective and not hiring_date:
self.env['employee.effective.form'].create({
'employee_id': self.employee_id.id,
'contract_id': self.id,
'department_id': self.department_id.id,
'contract_start': self.date_start,
'effective_form_date': self.date_start,
'state': 'draft'})
self.state = "program_directory"
def unlink(self):
@ -684,6 +695,20 @@ class Contract(models.Model):
{'calendar_id': self.working_hours.id})
# Smart Button to access effective form
def action_view_effective_frm(self):
effective_id = self.env['employee.effective.form'].search([('employee_id', '=', self.employee_id.id)])
return {
'name': _('Employee Effective Form'),
'domain': [('id', '=', effective_id.id)],
'view_mode': 'tree,form',
'res_model': 'employee.effective.form',
'view_id': False,
'type': 'ir.actions.act_window',
}
class VacationDest(models.Model):
_name = 'hr.vacation.dest'

View File

@ -8,6 +8,14 @@
<field name="priority" eval="16"/>
<field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div" position="before">
<!-- Create effective from directly from contract -->
<div class="oe_button_box" name="button_box">
<button class="btn-primary" name="action_view_effective_frm"
string="Effective Form" widget="statinfo" icon="fa-book" type="object"/>
</div>
</xpath>
<header position="replace">
<header>
<button name="program_directory" string="program Director" class="oe_highlight" type="object"