Merge pull request #5270 from expsa/JAZ-3842

[IMP][FIX] attendances, hr_base, *: adjust access rights for accounting manager
This commit is contained in:
abdurrahman-saber 2025-11-07 13:53:22 +02:00 committed by GitHub
commit 878e165955
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 97 additions and 28 deletions

View File

@ -20,4 +20,7 @@ access_hr_attendance_wizard_hr,hr_attendance_wizard_hr,model_hr_attendance_wizar
access_employee_attendance_report_hr,employee_attendance_report_hr,model_employee_attendance_report,hr.group_hr_user,1,1,1,0
access_attendance_attendance_admin,attendance_attendance_admin,model_attendance_attendance,base.group_system,1,1,1,1
access_hr_attendance_transaction_admin,hr.attendance.transaction.admin,model_hr_attendance_transaction,base.group_system,1,1,1,1
access_attendance_special_days_accounting_manager,attendance.special.days.accounting.manager,model_attendance_special_days,hr_base.group_account_manager,1,1,1,1
access_attendance_special_days_accounting_manager,attendance.special.days.accounting.manager,model_attendance_special_days,hr_base.group_account_manager,1,1,0,0
access_hr_attendance_transaction_accounting_manager,hr.attendance.transaction.accounting.manager,model_hr_attendance_transaction,hr_base.group_account_manager,1,1,0,0
access_attendance_attendance_accounting_manager,attendance_attendance_accounting.manager,model_attendance_attendance,hr_base.group_account_manager,1,1,0,0
access_days_off_accounting_manager,days_off.accounting.manager,model_days_off,hr_base.group_account_manager,1,1,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
20 access_employee_attendance_report_hr employee_attendance_report_hr model_employee_attendance_report hr.group_hr_user 1 1 1 0
21 access_attendance_attendance_admin attendance_attendance_admin model_attendance_attendance base.group_system 1 1 1 1
22 access_hr_attendance_transaction_admin hr.attendance.transaction.admin model_hr_attendance_transaction base.group_system 1 1 1 1
23 access_attendance_special_days_accounting_manager attendance.special.days.accounting.manager model_attendance_special_days hr_base.group_account_manager 1 1 1 0 1 0
24 access_hr_attendance_transaction_accounting_manager hr.attendance.transaction.accounting.manager model_hr_attendance_transaction hr_base.group_account_manager 1 1 0 0
25 access_attendance_attendance_accounting_manager attendance_attendance_accounting.manager model_attendance_attendance hr_base.group_account_manager 1 1 0 0
26 access_days_off_accounting_manager days_off.accounting.manager model_days_off hr_base.group_account_manager 1 1 0 0

View File

@ -21,3 +21,4 @@ access_salary_destination_hr,salary_destination_hr,model_salary_destination,hr.g
access_salary_destination_emp,salary_destination_emp,model_salary_destination,base.group_user,1,0,0,0
access_hr_classification,hr_classification,model_hr_classification,base.group_user,1,1,1,1
access_hr_personal_permission_accounting_manager,hr.personal.permission.accounting.manager,model_hr_personal_permission,hr_base.group_account_manager,1,1,0,0

1 id name model_id:id group_id/id perm_read perm_write perm_create perm_unlink
21 access_salary_destination_emp salary_destination_emp model_salary_destination base.group_user 1 0 0 0
22 access_hr_classification hr_classification model_hr_classification base.group_user 1 1 1 1
23 access_hr_personal_permission_accounting_manager hr.personal.permission.accounting.manager model_hr_personal_permission hr_base.group_account_manager 1 1 0 0
24

View File

@ -569,11 +569,8 @@ class HrOfficialMission(models.Model):
self.employee_ids.write({'status': 'approved'})
self.state = 'depart_manager'
if self.mission_type.approve_by == 'direct_manager':
self.approve()
def accounting_manager_refused(self):
for rec in self:
rec.refused()
return self.approve()
return self._reset_to_action()
# Refuse For The Direct Manager Only
def direct_manager_refused(self):
@ -767,6 +764,12 @@ class HrOfficialMission(models.Model):
def refused(self):
self.state = 'refused'
self.reset_emp_work_state()
def _reset_to_action(self):
if self.env.context.get('default_process_type') == 'mission':
return self.env.ref('exp_official_mission.employee_official_mission_action').sudo().read()[0]
else:
return self.env.ref('exp_official_mission.employee_training_action').sudo().read()[0]
def reset_emp_work_state(self):
if self.mission_type.work_state and self.mission_type.duration_type == 'days':

View File

@ -16,4 +16,5 @@ access_hr_mission_type_account_hr_user,access_hr_mission_type_account,model_hr_m
access_hr_mission_type_account_emp,access_hr_mission_type_account,model_hr_mission_type_account,base.group_user,1,0,0,0
access_mission_table,access_mission_table,model_mission_table,base.group_user,1,1,1,1
access_hr_employee_accounting_manager,hr.employee.accounting.manager,hr.model_hr_employee,hr_base.group_account_manager,1,1,0,0
access_hr_employee_accounting_manager,hr.employee.accounting.manager,hr.model_hr_employee,hr_base.group_account_manager,1,1,0,0
access_hr_official_mission_accounting_manager,hr.official.mission.accounting.manager,model_hr_official_mission,hr_base.group_account_manager,1,1,0,0
1 id name model_id:id group_id/id perm_read perm_write perm_create perm_unlink
16 access_hr_mission_type_account_emp access_hr_mission_type_account model_hr_mission_type_account base.group_user 1 0 0 0
17 access_mission_table access_mission_table model_mission_table base.group_user 1 1 1 1
18 access_hr_employee_accounting_manager hr.employee.accounting.manager hr.model_hr_employee hr_base.group_account_manager 1 1 0 0
19 access_hr_official_mission_accounting_manager hr.official.mission.accounting.manager model_hr_official_mission hr_base.group_account_manager 1 1 0 0
20

View File

@ -24,11 +24,18 @@
eval="[(4, ref('hr_base.group_department_manager')),(4, ref('hr_base.group_division_manager')),]"/>
</record>
<record id="hr_official_mission_accounting_manager_rule" model="ir.rule">
<field name="name">Accounting Manager: views missions that needs approval</field>
<field name="model_id" ref="model_hr_official_mission"/>
<field name="domain_force">['|',('state','in',['accounting_manager','accounting_manager_final', 'approve', 'refused']),('employee_ids.employee_id.user_id','in',user.ids)]</field>
<field name="groups" eval="[(4, ref('hr_base.group_account_manager'))]"/>
</record>
<record id="hr_official_mission_hr_rule" model="ir.rule">
<field name="name">Allow HR : views missions of all employees</field>
<field name="model_id" ref="model_hr_official_mission"/>
<field name="domain_force">[(1 ,'=', 1)]</field>
<field name="groups" eval="[(4, ref('hr_base.group_account_manager')),
<field name="groups" eval="[(3, ref('hr_base.group_account_manager')),
(4, ref('hr_base.group_executive_manager')),
(4, ref('hr_base.group_general_manager')),
(4, ref('exp_hr_appraisal.group_appraisal_manager')),

View File

@ -29,7 +29,7 @@
states="send" groups="hr_base.group_division_manager"/>
<button name="accounting_manager" string="Accounting Manager Approve" class="oe_highlight" type="object"
states="accounting_manager" groups="hr_base.group_account_manager"/>
<button name="accounting_manager_refused" string="Refused" class="oe_highlight" type="object"
<button name="refused" string="Refused" class="oe_highlight" type="object"
states="accounting_manager"
groups="hr_base.group_account_manager"/>
<button name="depart_manager" string="Department Manager" class="oe_highlight" type="object"

View File

@ -99,6 +99,8 @@ class HrTicketing(models.Model):
def accounting(self):
self.write({'state': 'review'})
action = self.env.ref('exp_ticket_request.hr_ticket_request_action')
return action.sudo().read()[0]
def confirm(self):
self.write({'state': 'confirm'})

View File

@ -9,6 +9,13 @@
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="hr_ticket_request_accounting_manager_rule" model="ir.rule">
<field name="name">Accounting Manager: views tickets that needs approval</field>
<field name="model_id" ref="model_hr_ticket_request"/>
<field name="domain_force">['|',('state','in',['accounting','accounting_final', 'done', 'refuse']),('employee_id.user_id','=',user.id)]</field>
<field name="groups" eval="[(4, ref('hr_base.group_account_manager'))]"/>
</record>
<record id="hr_ticket_request_manager_rule" model="ir.rule">
<field name="name">Manager: views tickets requests of its subordinates</field>
<field name="model_id" ref="model_hr_ticket_request"/>

View File

@ -36,8 +36,20 @@
class="oe_highlight"
groups="hr_base.group_account_manager"/>
<button name="refuse" states="submit,accounting_final,confirm,review,accounting" string="Refuse" type="object" class="oe_highlight"
groups="hr.group_hr_manager,hr_base.group_government_relations,hr_base.group_account_manager,hr_base.group_division_manager"/>
<button name="refuse" states="submit" string="Refuse" type="object" class="oe_highlight"
groups="hr_base.group_division_manager"/>
<button name="refuse" states="review" string="Refuse" type="object" class="oe_highlight"
groups="hr_base.group_government_relations"/>
<button name="refuse" states="confirm" string="Refuse" type="object" class="oe_highlight"
groups="hr.group_hr_manager"/>
<button name="refuse" states="accounting_final" string="Refuse" type="object" class="oe_highlight"
groups="hr_base.group_account_manager"/>
<button name="refuse" states="accounting" string="Refuse" type="object" class="oe_highlight"
groups="hr_base.group_account_manager"/>
<button name="re_draft" string="Re-Draft" type="object" class="oe_highlight"
states="refuse,done"
@ -92,8 +104,8 @@
help="The Amount of the Ticket is calculated according the type of request or the class of the ticket destination"
attrs="{'readonly':[('state','!=','review')],'required':[('state','=','review')]}"/>
<field name="journal_id"
attrs="{'readonly':[('state','!=','confirm')],
'required':['&amp;',('cost_of_tickets','>', '0' ),('state','=','confirm')]}"/>
attrs="{'readonly':[('state','!=','accounting_final')],
'required':['&amp;',('cost_of_tickets','>', '0' ),('state','=','accounting_final')]}"/>
<field name="move_id" string="Account move" readonly="1"/>
</group>
<group>

View File

@ -78,3 +78,6 @@ access_ir_sequence_group_hr_user,ir_sequence group_hr_user,base.model_ir_sequenc
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
access_hr_employee_accounting_manager,access.hr.employee.accounting.manager,hr.model_hr_employee,hr_base.group_account_manager,1,1,0,0
access_hr_holidays_accounting_manager,access.hr.holidays.accounting.manager,model_hr_holidays,hr_base.group_account_manager,1,1,0,0
1 id name model_id:id group_id/id perm_read perm_write perm_create perm_unlink
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
81 access_hr_employee_accounting_manager access.hr.employee.accounting.manager hr.model_hr_employee hr_base.group_account_manager 1 1 0 0
82 access_hr_holidays_accounting_manager access.hr.holidays.accounting.manager model_hr_holidays hr_base.group_account_manager 1 1 0 0
83

View File

@ -10,3 +10,4 @@ access_contract_extension_emp,access_contract_extension_emp,model_hr_contract_ex
access_hr_re_contract_user,hr.re.contract.user,model_hr_re_contract,hr.group_hr_user,1,1,1,0
access_hr_children_allowance_user,access_hr_children_allowance_user,model_hr_children_allowance,hr.group_hr_user,1,1,1,0
access_hr_vacation_dest_user,access_hr_vacation_dest_user,model_hr_vacation_dest,hr.group_hr_user,1,1,1,0
access_hr_contract_accounting_manager,hr.contract.accounting.manager,model_hr_contract,hr_base.group_account_manager,1,1,0,0

1 id name model_id:id group_id/id perm_read perm_write perm_create perm_unlink
10 access_hr_re_contract_user hr.re.contract.user model_hr_re_contract hr.group_hr_user 1 1 1 0
11 access_hr_children_allowance_user access_hr_children_allowance_user model_hr_children_allowance hr.group_hr_user 1 1 1 0
12 access_hr_vacation_dest_user access_hr_vacation_dest_user model_hr_vacation_dest hr.group_hr_user 1 1 1 0
13 access_hr_contract_accounting_manager hr.contract.accounting.manager model_hr_contract hr_base.group_account_manager 1 1 0 0

View File

@ -110,6 +110,7 @@ class hr_exit_return(models.Model):
def accounting(self):
self.state = 'accounting'
return self._reset_to_action()
def financial_manager(self):
self.state = 'accounting_final'
@ -142,10 +143,15 @@ class hr_exit_return(models.Model):
item.account_move_id = move_id.id
item.state = 'done'
def refuse(self):
self.state = 'refuse'
def _reset_to_action(self):
if not self.env.user.has_group('hr_base.group_account_manager'):
return
return self.env.ref('hr_government_relations.exit_and_return_action').sudo().read()[0]
# overrite unlink function
def unlink(self):
for i in self:

View File

@ -74,6 +74,7 @@ class hr_request_visa(models.Model):
def accounting(self):
self.state = 'accounting'
return self._reset_to_action()
def hr_manager(self):
self.state = 'confirm'
@ -97,19 +98,24 @@ class hr_request_visa(models.Model):
'state': 'draft',
'journal_id': item.account_journal_id.id,
'date': date.today(),
'ref': 'Exit and Return',
'ref': 'Ticket Request',
'line_ids': [(0, 0, debit_line_vals), (0, 0, credit_line_vals)]
})
item.account_move_id = move_id.id
self.state = 'done'
def financial_manager(self):
self.state = 'accounting_final'
def refuse(self):
self.state = 'refuse'
def _reset_to_action(self):
if not self.env.user.has_group('hr_base.group_account_manager'):
return
return self.env.ref('hr_government_relations.request_visa_action').sudo().read()[0]
def unlink(self):
for i in self:
if i.state != 'draft':

View File

@ -58,6 +58,20 @@
<field name="groups" eval="[(4, ref('hr_base.group_department_manager')),(4, ref('hr_base.group_division_manager'))]"/>
</record>
<record id="hr_exit_return_accounting_manager_rule" model="ir.rule">
<field name="name">Accounting Manager: views Exit and Return that needs approval</field>
<field name="model_id" ref="model_hr_exit_return"/>
<field name="domain_force">['|',('state','in',['refuse', 'send','accounting_final', 'done']),('employee_id.user_id','=',user.id)]</field>
<field name="groups" eval="[(4, ref('hr_base.group_account_manager'))]"/>
</record>
<record id="hr_request_visa_accounting_manager_rule" model="ir.rule">
<field name="name">Accounting Manager: views Request Visa that needs approval</field>
<field name="model_id" ref="model_hr_request_visa"/>
<field name="domain_force">['|',('state','in',['refuse', 'send','accounting_final', 'done']),('employee_id.user_id','=',user.id)]</field>
<field name="groups" eval="[(4, ref('hr_base.group_account_manager'))]"/>
</record>
<record id="hr_request_visaall_rule" model="ir.rule">
<field name="name"> Manager: views Request Visa of all employee </field>
<field name="model_id" ref="model_hr_request_visa"/>

View File

@ -95,11 +95,11 @@
<field name="cost" string="Cost"
attrs="{'readonly':[('state','!=','send')],'required':[('state','=','send')]}"/>
<field name="account_journal_id" string="Journal"
attrs="{'readonly':[('state','!=','confirm')],'invisible':[('on_employee_fair','=',True)],
'required':[('state','=','confirm'),('on_employee_fair','=',False)]}"/>
attrs="{'readonly':[('state','!=','accounting_final')],'invisible':[('on_employee_fair','=',True)],
'required':[('state','=','accounting_final'),('on_employee_fair','=',False)]}"/>
<field name="account_debit_id" string="Account"
attrs="{'readonly':[('state','!=','confirm')],'invisible':[('on_employee_fair','=',True)],
'required':[('state','=','confirm'),('on_employee_fair','=',False)]}"/>
attrs="{'readonly':[('state','!=','accounting_final')],'invisible':[('on_employee_fair','=',True)],
'required':[('state','=','accounting_final'),('on_employee_fair','=',False)]}"/>
<field name="account_move_id" string="Account move" readonly="1"
attrs="{'invisible':[('on_employee_fair','=',True)]}"/>
</group>

View File

@ -111,9 +111,9 @@
<group>
<field name="cost" string="Cost" attrs="{'readonly':[('state','!=','send')]}"/>
<field name="account_journal_id" string="Journal"
attrs="{'readonly':[('state','!=','confirm')],'required':['&amp;',('cost','>', '0' ),('state','=','confirm')]}"/>
attrs="{'readonly':[('state','!=','accounting_final')],'required':['&amp;',('cost','>', '0' ),('state','=','accounting_final')]}"/>
<field name="account_debit_id" string="Account"
attrs="{'readonly':[('state','!=','confirm')],'required':['&amp;',('cost','>', '0' ),('state','=','confirm')]}"/>
attrs="{'readonly':[('state','!=','accounting_final')],'required':['&amp;',('cost','>', '0' ),('state','=','accounting_final')]}"/>
<field name="account_move_id" string="Account move" readonly="1"/>
</group>
</group>

View File

@ -16,12 +16,13 @@ class HRHolidays(models.Model):
@api.constrains('leave_request_id')
def ticket_holiday_request(self):
for rec in self:
holiday_req = self.env['hr.exit.return'].search([('employee_id', '=', rec.employee_id.id),
('leave_request_id', '=', rec.leave_request_id.id)])
if rec.leave_request_id:
holiday_req = self.env['hr.exit.return'].search([('employee_id', '=', rec.employee_id.id),
('leave_request_id', '=', rec.leave_request_id.id)])
if len(holiday_req) > 1:
raise exceptions.Warning(
_('This Holiday Request Has Been take Exit Return %s') % rec.leave_request_id.display_name)
if len(holiday_req) > 1:
raise exceptions.Warning(
_('This Holiday Request Has Been take Exit Return %s') % rec.leave_request_id.display_name)
# dynamic domain on leave_request_id & constraint if the employee does not have family
@api.onchange('request_for', 'employee_id')

View File

@ -28,3 +28,5 @@ access_hr_holidays_status_duration,access_hr_holidays_duration,model_holiday_sta
access_public_leave_report_user,access_public_leave_report,model_public_leave_report,base.group_user,1,1,1,0
access_public_holidays_next_year_wizard_user,access_public_holidays_next_year_wizard,model_public_holidays_next_year_wizard,base.group_user,1,1,1,0
access_zfp_hr_custom_buy_vacation,zfp_hr_custom.buy_vacation,model_buy_vacation,base.group_user,1,1,1,1
access_hr_holidays_officials_accounting_manager,access.hr.holidays.officials.accounting.manager,model_hr_holidays_officials,hr_base.group_account_manager,1,1,0,0
access_resource_calendar_accounting_manager,resource.calendar.accounting.manager,model_resource_calendar,hr_base.group_account_manager,1,1,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
28 access_public_leave_report_user access_public_leave_report model_public_leave_report base.group_user 1 1 1 0
29 access_public_holidays_next_year_wizard_user access_public_holidays_next_year_wizard model_public_holidays_next_year_wizard base.group_user 1 1 1 0
30 access_zfp_hr_custom_buy_vacation zfp_hr_custom.buy_vacation model_buy_vacation base.group_user 1 1 1 1
31 access_hr_holidays_officials_accounting_manager access.hr.holidays.officials.accounting.manager model_hr_holidays_officials hr_base.group_account_manager 1 1 0 0
32 access_resource_calendar_accounting_manager resource.calendar.accounting.manager model_resource_calendar hr_base.group_account_manager 1 1 0 0