fix overtime to transfer multi accounts base on emp type

This commit is contained in:
Bakry 2025-05-18 16:43:07 +03:00
parent 7eec8f9e7a
commit 2734b1104f
14 changed files with 136 additions and 22 deletions

View File

@ -2285,4 +2285,8 @@ msgstr "تاريخ الخصم من"
msgid "Deduction Date To"
msgstr "تاريخ الخصم إلى"
#. module: attendances
#: model_terms:ir.ui.view,arch_db:attendances.resource_calendar_inherited_form
msgid "Accounting Info"
msgstr "اعداد الحسابات"

View File

@ -42,6 +42,16 @@ class HrAttendanceTransactions(models.Model):
has_sign_in = fields.Boolean(readonly=True)
has_sign_out = fields.Boolean(readonly=True)
to_date = fields.Boolean(string='Today',compute='_attendance_today', store=True)
@api.depends('date','employee_id')
def _attendance_today(self):
today = datetime.now().date()
for item in self:
if item.date==today:
item.to_date = True
else:
item.to_date = False
def get_additional_hours(self):
for rec in self:
@ -52,6 +62,7 @@ class HrAttendanceTransactions(models.Model):
@api.depends('employee_id')
def get_hours(self):
self._attendance_today()
module = self.env['ir.module.module'].sudo()
official_mission_module = module.search([('state', '=', 'installed'), ('name', '=', 'exp_official_mission')])
holidays_module = module.search([('state', '=', 'installed'), ('name', '=', 'hr_holidays_public')])

View File

@ -123,7 +123,8 @@
<filter name="group_branch" string="Branch" domain="[]" context="{'group_by': 'is_branch'}"/>
</group>
<separator/>
<filter string="Attendance Today" name="today_less" domain="[('date','&lt;=',time.strftime('%%Y-%%m-%%d'))]"/>
<!--filter string="Attendance Today" name="today_less" domain="[('date','&lt;=',time.strftime('%%Y-%%m-%%d'))]"/-->
<filter string="Attendance Today" name="today_less" domain="[('to_date', '=', 'True')]"/>
<separator/>
<separator/>
<filter string="My Attendance" name="my_attendance" domain="[('employee_id.user_id', '=', uid)]"/>

View File

@ -145,10 +145,28 @@
<field name="request_after_day" groups="hr.group_hr_manager,hr.group_hr_user"/>
</group>
<group string="Overtime Accounts Settings" >
<!--group string="Overtime Accounts Settings" >
<field name="journal_overtime_id" string="Journal Overtime"/>
<field name="account_overtime_id" string="Account Overtime"/>
</group>
</group-->
<notebook>
<page string="Accounting Info">
<group>
<field name="transfer_by_emp_type" />
<field name="journal_overtime_id" string="Journal Overtime"/>
<field name="account_overtime_id" string="Account Overtime"
attrs="{'invisible' : [('transfer_by_emp_type', '=', True)]}"/>
</group>
<field name="account_ids" attrs="{'invisible' : [('transfer_by_emp_type', '=', False)]}">
<tree editable="bottom">
<field name="emp_type_id"/>
<field name="debit_account_id"/>
</tree>
</field>
</page>
</notebook>
</page>
</notebook>
<notebook attrs="{'invisible':[('is_full_day','=',True)]}">
@ -260,10 +278,27 @@
<field name="request_after_day" groups="hr.group_hr_manager,hr.group_hr_user"/>
</group>
<group string="Overtime Accounts Settings" >
<!--group string="Overtime Accounts Settings" >
<field name="journal_overtime_id" string="Journal Overtime"/>
<field name="account_overtime_id" string="Account Overtime"/>
</group>
</group-->
<notebook>
<page string="Accounting Info">
<group>
<field name="transfer_by_emp_type" />
<field name="journal_overtime_id" string="Journal Overtime"/>
<field name="account_overtime_id" string="Account Overtime"
attrs="{'invisible' : [('transfer_by_emp_type', '=', True)]}"/>
</group>
<field name="account_ids" attrs="{'invisible' : [('transfer_by_emp_type', '=', False)]}">
<tree editable="bottom">
<field name="emp_type_id"/>
<field name="debit_account_id"/>
</tree>
</field>
</page>
</notebook>
</page>
</notebook>

View File

@ -3967,3 +3967,16 @@ msgstr "ساعات شهرية"
#, python-format
msgid "Date To must be on the same day as Date From."
msgstr "يجب أن يكون يوم تاريخ البداية هو نفسه يوم تاريخ النهاية."
#. module: employee_requests
#: code:addons/employee_requests/models/employee_overtime_request.py:0
#, python-format
msgid "You Must Enter The Journal Name Overtim Setting."
msgstr "يجب إدخال إسم دفتر اليومية لإعدادات العمل الإضافي"
#. module: employee_requests
#: code:addons/employee_requests/models/employee_overtime_request.py:0
#, python-format
msgid "Employee %s, has no Overtime Account Setting Base On Employee Type."
msgstr "الموظف %s, ليس لديه إعدادات حساب بند صرف للأجر الإضافي حسب نوع الموظف."

View File

@ -207,29 +207,38 @@ class employee_overtime_request(models.Model):
if self.transfer_type == 'accounting':
for item in self:
for record in item.line_ids_over_time:
emp_type = record.employee_id.employee_type_id
account_debit_id = record.employee_id.contract_id.working_hours.get_debit_overtim_account_id(emp_type)
journal_id = record.employee_id.contract_id.working_hours.journal_overtime_id
if not journal_id:
raise exceptions.Warning(_('You Must Enter The Journal Name Overtim Setting.'))
if not account_debit_id:
raise exceptions.Warning(_('Employee %s, has no Overtime Account Setting Base On Employee Type.'
) % record.employee_id.name)
debit_line_vals = {
'name': record.employee_id.name,
'debit': record.price_hour,
'account_id': item.account_id.id,
'account_id': account_debit_id.id,
'partner_id': record.employee_id.user_id.partner_id.id
}
credit_line_vals = {
'name': record.employee_id.name,
'credit': record.price_hour,
'account_id': item.journal_id.default_account_id.id,
'account_id': journal_id.default_account_id.id,
'partner_id': record.employee_id.user_id.partner_id.id
}
if not record.move_id:
move = record.env['account.move'].create({
'state': 'draft',
'journal_id': item.journal_id.id,
'journal_id': journal_id.id,
'date': item.request_date,
'ref': record.employee_id.name,
'line_ids': [(0, 0, debit_line_vals), (0, 0, credit_line_vals)],
'res_model': 'employee.overtime.request',
'res_id': self.id
})
record.account_id = account_debit_id.id
record.journal_id = journal_id.id
record.move_id = move.id
self.state = "validated"
if self.transfer_type == 'payroll':
@ -422,13 +431,13 @@ class HrEmployeeOverTime(models.Model):
employee_id.remove(line.employee_id.id)
return {'domain': {'employee_id': [('id', 'in', employee_id)]}}
@api.model
'''@api.model
def default_get(self, fields):
res = super(HrEmployeeOverTime, self).default_get(fields)
if self._context.get('account_id') and self._context.get('journal_id'):
res['account_id'] = self._context.get('account_id')
res['journal_id'] = self._context.get('journal_id')
return res
return res'''
@api.depends('employee_id.contract_id', 'over_time_workdays_hours', 'over_time_vacation_hours', 'employee_id',
'calculate_from_total')

View File

@ -92,9 +92,12 @@ class EmployeeOtherRequest(models.Model):
if not item.employee_dependant:
raise exceptions.Warning(_('Please The dependents were not Included'))
if item.employee_id.contract_id.contract_status == 'single':
raise exceptions.Warning(_('You can not Add Fimaly record Because Employee is Single'))
#if item.employee_id.contract_id.contract_status == 'single':
#raise exceptions.Warning(_('You can not Add Fimaly record Because Employee is Single'))
else:
for rec in item.employee_dependant:
if not rec.attachment:
raise exceptions.Warning(_('Please Insert dependents Attachments Files Below!'))
item.state = "submit"
if item.request_type == 'qualification':

View File

@ -91,11 +91,13 @@
</p>
<br/>
<h4 style="text-align: center;">
<strong>وتقبلوا تحياتنا،،،</strong>
<span>مدير إدارة الموارد البشرية</span>
</h4>
<br/>
<h4 style="text-align: center;">
<strong>إدارة الموارد البشرية</strong>
<span>Director of Human Resource</span>
<br/>
<br/>
<span t-esc="env.user.sudo().company_id.hr_manager_id.name"/>
</h4>
<br/>

View File

@ -85,15 +85,15 @@
<field name="reason" string="Reason" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="exception" groups="hr_base.group_executive_manager,hr.group_hr_user" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="journal_id" string="Journal"
<!--field name="journal_id" string="Journal"
attrs="{'invisible':[('transfer_type','!=','accounting')], 'readonly':[('state','!=','executive_office')], 'required': [('state', '=', 'executive_office'),('transfer_type','=','accounting')]}" force_save="1"/>
<field name="account_id" string="Account"
attrs="{'invisible':[('transfer_type','!=','accounting')], 'readonly':[('state','!=','executive_office')], 'required': [('state', '=', 'executive_office'),('transfer_type','=','accounting')]}" force_save="1"/>
attrs="{'invisible':[('transfer_type','!=','accounting')], 'readonly':[('state','!=','executive_office')], 'required': [('state', '=', 'executive_office'),('transfer_type','=','accounting')]}" force_save="1"/-->
</group>
</group>
<separator string="Employees Over Time"/>
<field name="line_ids_over_time" context="{'account_id': account_id, 'journal_id': journal_id}" force_save="1"
<field name="line_ids_over_time" force_save="1"
attrs="{'readonly':[('state','not in',('submit','draft'))], 'required': [('state', '=', 'hr_aaproval')]}">
<tree string="Employee Over Time" editable="bottom">
<field name="employee_id"/>

View File

@ -7,7 +7,7 @@
<field name="inherit_id" ref="exp_official_mission.employee_official_mission_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='destination']" position="after">
<field name="include_in_experience" attrs="{'readonly':[('state','not in',('direct_manager','depart_manager'))]}"/>
<field name="include_in_experience" attrs="{'readonly':[('state','not in',('direct_manager','depart_manager'))]}" invisible='1'/>
</xpath>
<xpath expr="//field/tree/field[@name='account_move_id']" position="after">
<field name="include_in_experience" attrs="{'column_invisible':[('parent.include_in_experience','!=',True)],'readonly':[('parent.state','not in',('direct_manager','depart_manager'))]}"/>

View File

@ -4795,5 +4795,19 @@ msgstr "تسجيل الدخول الافتراضي"
msgid "Login"
msgstr "تسجيل الدخول"
#. module: hr_base
#: model:ir.model.fields,field_description:hr_base.field_resource_calendar__transfer_by_emp_type
msgid "Transfer By Emp Type"
msgstr "ترحيل حسب نوع الموظف"
#. module: hr_base
#: model:ir.model.fields,field_description:hr_base.field_hr.overtim.accounts__emp_type_id
msgid "Employee Type"
msgstr "نوع الموظف"
#. module: hr_base
#: model:ir.model.fields,field_description:hr_base.field_hr.overtim.accounts__debit_account_id
msgid "Debit Account"
msgstr "بند الصرف"

View File

@ -847,6 +847,24 @@ class HrAttendances(models.Model):
journal_overtime_id = fields.Many2one('account.journal')
account_overtime_id = fields.Many2one('account.account')
transfer_by_emp_type = fields.Boolean('Transfer By Emp Type')
account_ids = fields.One2many('hr.overtim.accounts', 'overtim_id')
#get account IDs base on Overtim Employees Type account config
def get_debit_overtim_account_id(self, emp_type):
if not self.transfer_by_emp_type : return self.account_overtime_id
account_mapping = self.account_ids.filtered(lambda a: a.emp_type_id.id == emp_type.id)
return account_mapping[0].debit_account_id if account_mapping else False
class HrOvertimAccounts(models.Model):
_name = 'hr.overtim.accounts'
_description = 'Overtim Account Mapping'
overtim_id = fields.Many2one('resource.calendar', string="Overtim Type", required=True, ondelete="cascade")
emp_type_id = fields.Many2one('hr.contract.type', string="Employee Type", required=True)
debit_account_id = fields.Many2one('account.account', string="Debit Account", required=True)
class HrQualificationName(models.Model):
_name = "hr.qualification.name"
_description = "HR Qualification Name"

View File

@ -76,3 +76,5 @@ access_work_location_hr,Access.emplpyee_work_location_hr,model_work_location,hr.
access_work_location_hr_group_user,Access.employee_work_location_group_user,model_work_location,base.group_user,1,1,1,1
access_ir_sequence_group_hr_user,ir_sequence group_hr_user,base.model_ir_sequence,hr.group_hr_user,1,1,1,1
access_company_document_type_hr_group_user,Access.company_document_type_group_user,model_company_document_type,hr.group_hr_user,1,1,1,1
access_hr_overtim_accounts_hr_user,access_hr_overtim_accounts,model_hr_overtim_accounts,hr.group_hr_user,1,1,1,1
access_hr_overtim_accounts_emp,access_hr_overtim_accounts,model_hr_overtim_accounts,base.group_user,1,0,0,0

1 id name model_id:id group_id/id perm_read perm_write perm_create perm_unlink
76 access_work_location_hr_group_user Access.employee_work_location_group_user model_work_location base.group_user 1 1 1 1
77 access_ir_sequence_group_hr_user ir_sequence group_hr_user base.model_ir_sequence hr.group_hr_user 1 1 1 1
78 access_company_document_type_hr_group_user Access.company_document_type_group_user model_company_document_type hr.group_hr_user 1 1 1 1
79 access_hr_overtim_accounts_hr_user access_hr_overtim_accounts model_hr_overtim_accounts hr.group_hr_user 1 1 1 1
80 access_hr_overtim_accounts_emp access_hr_overtim_accounts model_hr_overtim_accounts base.group_user 1 0 0 0

View File

@ -21,7 +21,7 @@
<field name="arch" type="xml">
<search string="Search Leave">
<field name="name"/>
<filter domain="[('state','in',('confirm','validate1'))]" string="To Approve" name="approve"/>
<!--filter domain="[('state','in',('confirm','validate1'))]" string="To Approve" name="approve"/>
<filter string="Approved Leaves" domain="[('state', '=', 'validate')]" name="validated"/>
<separator/>
<filter name="active_types" string="Active Types" domain="[('holiday_status_id.active', '=', True)]" help="Filters only on allocations and requests that belong to an leave type that is 'active' (active field is True)"/>
@ -41,7 +41,9 @@
<filter string="My Requests" name="my_leaves" domain="[('user_id', '=', uid)]"/>
<separator/>
<filter name="leaves" string="Leaves" domain="[('type', '=', 'remove')]"/>
<filter name="allocations" string="Allocations" domain="[('type', '=', 'add')]"/>
<filter name="allocations" string="Allocations" domain="[('type', '=', 'add')]"/-->
<filter string="My Requests" name="my_leaves" domain="[('user_id', '=', uid)]"/>
<separator/>
<field name="employee_id"/>
<field name="department_id"/>
<field name="holiday_status_id"/>