Merge branch 'dev_odex25_hr' of https://github.com/expsa/odex25-standard-modules into bakry_hr3

This commit is contained in:
Bakry 2025-02-19 13:42:57 +03:00
commit c8dc40d9ad
41 changed files with 1144 additions and 178 deletions

View File

@ -36,8 +36,11 @@
<menuitem
id="menu_view_permission_types"
name="Permission Types"
action="action_permission_types"
parent="hr.hr_menu_configuration"/>
sequence="1"
parent="hr.menu_human_resources_configuration"/>
</data>
</odoo>

View File

@ -56,7 +56,7 @@
<strong>Identification No</strong>
</td>
<td>
<span t-field="o.employee_id.iqama_number"/>
<span t-field="o.employee_id.identification_id"/>
</td>
</tr>
<tr>

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from . import models
from . import wizard

View File

@ -12,8 +12,8 @@
'data': [
'data/data.xml',
'security/official_mission_security.xml',
'security/training_security.xml',
'security/ir.model.access.csv',
'views/hr_official_mission.xml',
'views/hr_official_mission_type_view.xml',
'views/attendance_view.xml',
@ -25,6 +25,8 @@
'views/ticket_view.xml',
'views/course_view.xml',
'views/appraisal_view.xml',
'views/training_menus.xml',
'wizard/employee_selection_wizard.xml',
],
'installable': True,

View File

@ -316,6 +316,10 @@ msgstr "عدد المرفقات"
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_especially_hours_form_view
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_official_mission_form_view
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_training_form_view
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_oficial_mission_line_tree_view
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_training_tree_view
#: model_terms:ir.ui.view,arch_db:exp_official_mission.hr_employees_training_lines_form
#: model_terms:ir.ui.view,arch_db:exp_official_mission.hr_employees_training_lines_tree
msgid "Attachments"
msgstr "المُرفقات"
@ -415,7 +419,7 @@ msgstr "الدولـــة"
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_training_form_view
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_training_tree_view
msgid "Course Name"
msgstr "أسماء الدورات"
msgstr " أسماء الدورات التدريبية"
#. module: exp_official_mission
#: model_terms:ir.ui.view,arch_db:exp_official_mission.official_tran_report_template
@ -661,11 +665,6 @@ msgstr "تصديق المدير المباشر"
msgid "Display Name"
msgstr "الاسم المعروض"
#. module: exp_official_mission
#: code:addons/exp_official_mission/models/hr_official_mission.py:0
#, python-format
msgid "Draft"
msgstr "مبدئي"
#. module: exp_official_mission
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_official_mission_form_view
@ -751,7 +750,7 @@ msgstr "عقد الموظف"
#: model:ir.ui.menu,name:exp_official_mission.employee_training_menu_item
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_training_tree_view
msgid "Employee Training"
msgstr "الدورات التدريبية للموظفين"
msgstr "الدورات التدريبية"
#. module: exp_official_mission
#: model:ir.actions.act_window,name:exp_official_mission.employee_official_mission_action
@ -1793,6 +1792,7 @@ msgstr "نوع طلب التذكرة"
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_especially_line_form_view
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_official_mission_form_view
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_training_form_view
#: model_terms:ir.ui.view,arch_db:exp_official_mission.hr_employees_training_lines_form
msgid "Total Hours"
msgstr "مجموع الساعات"
@ -2300,11 +2300,6 @@ msgid "متطلبات المهمة"
msgstr ""
#. module: exp_official_mission
#: model:ir.model.fields.selection,name:exp_official_mission.selection__hr_official_mission__state__draft
msgid "Draft"
msgstr "مسودة"
#. module: exp_official_mission
#: model:ir.model.fields.selection,name:exp_official_mission.selection__hr_official_mission__state__send
msgid "Waiting Direct Manager"
@ -2454,3 +2449,158 @@ msgstr "طلبـاتي"
msgid "Branch"
msgstr "الفروع"
#. module: exp_official_mission
#: model:ir.ui.menu,name:exp_official_mission.hr_employee_training_main_menu
#, python-format
msgid "Training"
msgstr "التدريب"
#. module: exp_official_mission
#: model:res.groups,name:exp_official_mission.group_hr_training_user
msgid "Training User"
msgstr "مسوؤل التدريب"
#. module: exp_official_mission
#: model:res.groups,name:exp_official_mission.group_hr_training_manager
msgid "Training Manager"
msgstr "مدير التدريب"
#. module: exp_official_mission
#: model:ir.ui.menu,name:exp_official_mission.hr_employee_official_mission_menu
msgid "Employees Training Courses"
msgstr "الدورات التدربية للموظفين"
#. module: exp_official_mission
#: model:ir.ui.menu,name:exp_official_mission.hr_official_mission_config_menu
msgid "Configurations"
msgstr "الاعدادات"
#. module: exp_official_mission
#: model:ir.actions.act_window,name:exp_official_mission.hr_employees_training_lines_action
msgid "Employees Official Mission"
msgstr ""
#. module: exp_official_mission
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_training_form_view
#: model_terms:ir.ui.view,arch_db:exp_official_mission.hr_employees_training_lines_form
#: model_terms:ir.ui.view,arch_db:exp_official_mission.hr_employees_training_lines_tree
msgid "Employee Status"
msgstr "الحالة"
#. module: exp_official_mission
#: code:addons/exp_official_mission/models/hr_official_mission.py:0
#: code:addons/exp_official_mission/models/hr_official_mission.py:0
#: model:ir.model.fields.selection,name:exp_official_mission.selection__hr_official_mission__state__draft
#: model:ir.model.fields.selection,name:exp_official_mission.selection__hr_official_mission_employee__status__draft
#, python-format
msgid "Draft"
msgstr "مسودة"
#. module: exp_official_mission
#: model_terms:ir.ui.view,arch_db:exp_official_mission.hr_employees_training_lines_form
msgid "Approve"
msgstr "تصديق"
#. module: exp_official_mission
#: code:addons/exp_official_mission/models/hr_official_mission.py:0
#: model:ir.model.fields.selection,name:exp_official_mission.selection__hr_official_mission_employee__status__approved
#, python-format
msgid "Approved"
msgstr "تم التصديق"
#. module: exp_official_mission
#: code:addons/exp_official_mission/models/hr_official_mission.py:0
#: model:ir.model.fields.selection,name:exp_official_mission.selection__hr_official_mission_employee__status__done
#: model_terms:ir.ui.view,arch_db:exp_official_mission.hr_employees_training_lines_form
#, python-format
msgid "Done"
msgstr "تم"
#. module: exp_official_mission
#: model_terms:ir.ui.view,arch_db:exp_official_mission.hr_employees_training_lines_form
msgid "Refuse"
msgstr "رفض"
#. module: exp_official_mission
#: model:ir.ui.menu,name:exp_official_mission.hr_employee_training_types_config_menu
msgid "Training Types"
msgstr "انواع التدريب"
#. module: exp_official_mission
#: model:ir.ui.menu,name:exp_official_mission.hr_official_mission_report_menu
msgid "Reports"
msgstr "التقارير"
#. module: exp_official_mission
#: model:ir.ui.menu,name:hr_base_reports.employee_training_report_menu
msgid "Training Report"
msgstr "تقرير التدريب"
#. module: exp_official_mission
#: model:ir.module.category,description:exp_official_mission.module_category_hr_employee_training
msgid "Helps to Manage Employee Training Process..."
msgstr "يساعد في إدارة عملية تدريب الموظفين"
#. module: exp_official_mission
#: model_terms:ir.actions.act_window,help:exp_official_mission.hr_employees_training_lines_action
msgid "Click to add a Employee Training Course."
msgstr "اضغط لإضافة دورة تدريبية للموظف"
#. module: exp_official_mission
#: model_terms:ir.ui.view,arch_db:exp_official_mission.hr_employees_training_lines_form
msgid "Set to Draft"
msgstr "ارجاع الى مسودة"
#. module: exp_official_mission
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_training_form_view
msgid "Add Employees"
msgstr "إضافة موظفين"
#. module: exp_official_mission
#: model:ir.model.fields,field_description:exp_official_mission.field_employee_mission_selection_wizard__employee_ids
msgid "Employees"
msgstr "الموظفين"
#. module: exp_official_mission
#: model_terms:ir.ui.view,arch_db:exp_official_mission.view_employee_mission_selection_wizard_form
msgid "Add"
msgstr "إضافه"
#. module: exp_official_mission
#: model_terms:ir.ui.view,arch_db:exp_official_mission.view_employee_mission_selection_wizard_form
msgid "Cancel"
msgstr "إلغاء"
#. module: exp_official_mission
#: code:addons/exp_official_mission/models/hr_official_mission.py:0
#, python-format
msgid "Add Employees to Mission"
msgstr "إضافة موظفين للدورة التدريبية"
#. module: exp_official_mission
#: code:addons/exp_official_mission/models/hr_official_mission.py:0
#, python-format
msgid "You must Approve all Employees Line First."
msgstr "يجب عمل تصديق لجميع الموظفين اولا"
#. module: exp_official_mission
#: model:ir.model.fields,field_description:exp_official_mission.field_hr_official_mission__trainer_id
msgid "Trainer"
msgstr "المدرب"
#. module: exp_official_mission
#: model:ir.model.fields,field_description:exp_official_mission.field_hr_official_mission__training_details
#: model:ir.model.fields,field_description:exp_official_mission.field_hr_official_mission_employee__training_details
#: model_terms:ir.ui.view,arch_db:exp_official_mission.employee_training_form_view
msgid "Training Details"
msgstr "تفاصيل الدورة التدريبية"

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import calendar
from datetime import datetime, date, timedelta
from odoo.exceptions import ValidationError
from odoo import models, fields, api, exceptions
from odoo.exceptions import UserError
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
@ -91,6 +91,10 @@ class HrOfficialMission(models.Model):
ticket_request_id = fields.Many2one('hr.ticket.request', string="Ticket Request", readonly=True)
department_id2 = fields.Many2one(related='employee_id.department_id', readonly=True,store=True,string='Department')
is_branch = fields.Many2one(related='department_id2.branch_name', store=True, readonly=True)
attachment_count = fields.Integer(string="Attachments", compute="_compute_attachment_count")
training_details = fields.Html('Training Details')
trainer_id = fields.Many2one('res.partner', string="Trainer")
'''@api.constrains('employee_ids')
@ -120,6 +124,52 @@ class HrOfficialMission(models.Model):
#########################################
def _compute_attachment_count(self):
attachment_data = self.env['ir.attachment'].read_group([('res_model', '=', 'hr.official.mission'), ('res_id', 'in', self.ids)], ['res_id'], ['res_id'])
attachment = dict((data['res_id'], data['res_id_count']) for data in attachment_data)
for rec in self:
rec.attachment_count = attachment.get(rec.id, 0)+sum(rec.employee_ids.mapped('attachment_count'))
def action_get_attachment_view(self):
res = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment')
related_ids = self.ids + self.employee_ids.ids
related_models = ['hr.official.mission', 'hr.official.mission.employee']
res['domain'] = [('res_model', 'in', related_models) ,('res_id', 'in', related_ids)]
res['context'] = {
'default_res_model': 'hr.official.mission',
'default_res_id': self.id,
'create': True,
'edit': True,
}
return res
def action_add_employees(self):
self.ensure_one()
ctx = dict(self.env.context)
if not self.id:
ctx.update({
'default_mission_vals': {
'name': self.name,
}
})
else:
ctx['default_official_mission_id'] = self.id
# if self.percentage:
# ctx['default_percentage'] = self.percentage
ctx['default_employee_id'] = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
return {
'name': _('Add Employees to Mission'),
'view_mode': 'form',
'res_model': 'employee.mission.selection.wizard',
'type': 'ir.actions.act_window',
'target': 'new',
'context': ctx,
}
def get_user_id(self):
employee_id = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
if employee_id:
@ -353,6 +403,26 @@ class HrOfficialMission(models.Model):
self.employee_ids.chick_not_overtime()
self.state = "send"
def send_depart_manager(self):
for item in self:
if not item.employee_ids:
raise exceptions.Warning(_('The Request cannot Be completed without Employees'))
item.employee_ids.compute_Training_cost_emp()
# item.chick_employee_ids()
for line in item.employee_ids:
mail_content = "Hello I'm", line.employee_id.name, " request Need to ", item.mission_type.name, "Please approved thanks."
main_content = {
'subject': _('Request To %s Employee %s') % (item.mission_type.name, line.employee_id.name),
'author_id': self.env.user.partner_id.id,
'body_html': mail_content,
'email_to': line.employee_id.department_id.email_manager,
}
self.env['mail.mail'].sudo().create(main_content).send()
self.employee_ids.chick_not_overtime()
self.state = "depart_manager"
def direct_manager(self):
# self.chick_employee_ids()
self.employee_ids.chick_not_overtime()
@ -367,6 +437,10 @@ class HrOfficialMission(models.Model):
def hr_aaproval(self):
# self.chick_employee_ids()
lines_draft_status = any(self.employee_ids.filtered(lambda emp: emp.status == 'draft'))
if lines_draft_status and self.mission_type.work_state=='training':
raise ValidationError(_("You must Approve all Employees Line First."))
self.employee_ids.chick_not_overtime()
self.employee_ids.compute_Training_cost_emp()
self.state = "hr_aaproval"
@ -630,7 +704,7 @@ class EmployeeCourseName(models.Model):
name = fields.Char(translate=True)
code = fields.Char()
job_ids = fields.One2many('hr.job', 'course_ids', string='Jobs', readonly=True)
job_ids = fields.Many2many('hr.job', string='Jobs', readonly=False)
company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.user.company_id)
def unlink(self):
@ -817,6 +891,45 @@ class HrOfficialMissionEmployee(models.Model):
total_hours = fields.Float()
course_name = fields.Many2one(related='official_mission_id.course_name', readonly=True,
store=True)
attachment_count = fields.Integer(string="Attachments", compute="_compute_attachment_count")
status = fields.Selection([('draft', _('Draft')),
('approved', _('Approved')),
('done', _('Done')),
('refused', _('Refused')),
], default="draft", tracking=True)
training_details = fields.Html('Training Details', related="official_mission_id.training_details")
def approve(self):
self.status = "approved"
def refuse(self):
self.status = "refused"
def done(self):
self.status = "done"
def set_to_draft(self):
self.status = "draft"
def _compute_attachment_count(self):
attachment_data = self.env['ir.attachment'].read_group([('res_model', '=', 'hr.official.mission.employee'), ('res_id', 'in', self.ids)], ['res_id'], ['res_id'])
attachment = dict((data['res_id'], data['res_id_count']) for data in attachment_data)
for rec in self:
rec.attachment_count = attachment.get(rec.id, 0)
def action_get_attachment_view(self):
self.ensure_one()
res = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment')
res['domain'] = [('res_model', '=', 'hr.official.mission.employee'), ('res_id', 'in', self.ids)]
res['context'] = {'default_res_model': 'hr.official.mission.employee', 'default_res_id': self.id}
return res
@api.constrains('date_from', 'date_to', 'hour_from', 'hour_to', 'employee_id')
def check_dates(self):
@ -913,8 +1026,10 @@ class HrOfficialMissionEmployee(models.Model):
date_from += delta
def get_permission_domain(self, date_from, date_to):
hour_from = (datetime.min + timedelta(hours=self.hour_from) - timedelta(hours=3)).time()
hour_to = (datetime.min + timedelta(hours=self.hour_to) - timedelta(hours=3)).time()
date_from = str(
datetime.combine(datetime.strptime(str(date_from), DEFAULT_SERVER_DATETIME_FORMAT).date(), hour_from))
date_to = str(datetime.combine(datetime.strptime(str(date_to), DEFAULT_SERVER_DATETIME_FORMAT).date(), hour_to))

View File

@ -9,4 +9,5 @@ access_mission_destination_line,access_mission_destination_line_emp,model_missio
access_mission_destination_line_hr,access_mission_destination_line_hr,model_mission_destination_line,hr.group_hr_user,1,1,1,1
access_employee_course_name_emp,access_employee_course_name_emp,model_employee_course_name,base.group_user,1,0,0,0
access_employee_course_name_hr,access_employee_course_name_hr,model_employee_course_name,hr.group_hr_user,1,1,1,1
access_ticket_class_user,access_ticket_class_user,model_ticket_class,hr.group_hr_user,1,1,1,0
access_ticket_class_user,access_ticket_class_user,model_ticket_class,hr.group_hr_user,1,1,1,0
access_employee_mission_selection_wizard,employee.mission.selection.wizard,model_employee_mission_selection_wizard,base.group_user,1,1,1,1

1 id name model_id:id group_id/id perm_read perm_write perm_create perm_unlink
9 access_mission_destination_line_hr access_mission_destination_line_hr model_mission_destination_line hr.group_hr_user 1 1 1 1
10 access_employee_course_name_emp access_employee_course_name_emp model_employee_course_name base.group_user 1 0 0 0
11 access_employee_course_name_hr access_employee_course_name_hr model_employee_course_name hr.group_hr_user 1 1 1 1
12 access_ticket_class_user access_ticket_class_user model_ticket_class hr.group_hr_user 1 1 1 0
13 access_employee_mission_selection_wizard employee.mission.selection.wizard model_employee_mission_selection_wizard base.group_user 1 1 1 1

View File

@ -6,7 +6,7 @@
<record id="hr_official_mission_emp_rule" model="ir.rule">
<field name="name">Employee: views its missions records</field>
<field name="model_id" ref="model_hr_official_mission"/>
<field name="domain_force">[('employee_id.user_id','=', user.id)]
<field name="domain_force">['|',('employee_id.user_id','=', user.id),('process_type','=', 'training')]
</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
</record>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="module_category_hr_employee_training" model="ir.module.category">
<field name="name">Training</field>
<field name="description">Helps to Manage Employee Training Process...</field>
<field name="parent_id" eval="ref('base.module_category_human_resources')"/>
</record>
<record id="group_hr_training_user" model="res.groups">
<field name="name">Training User</field>
<field name="category_id" ref="module_category_hr_employee_training"/>
<field name="implied_ids" eval="[(4, ref('hr.group_hr_user'))]"/>
</record>
<record id="group_hr_training_manager" model="res.groups">
<field name="name">Training Manager</field>
<field name="category_id" ref="module_category_hr_employee_training"/>
<field name="implied_ids" eval="[(4, ref('group_hr_training_user'))]"/>
</record>
</data>
</odoo>

View File

@ -342,6 +342,7 @@
<field name="hour_to" widget="float_time"/>
<field name="hours" widget="float_time"/>
<field name="state" string="Status" invisible="1"/>
<field name="state" string="Status"/>
</tree>
</field>
</record>

View File

@ -7,6 +7,15 @@
<field name="view_mode">tree,form</field>
</record>
<record model="ir.actions.act_window" id="employee_mission_type_training_settings_action">
<field name="name">Mission Type Settings</field>
<field name="res_model">hr.official.mission.type</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('work_state','=','training')]</field>
</record>
<menuitem name="Mission Type Settings" id="mission_type_settings_menu_item"
parent="hr.hr_menu_configuration"
action="employee_mission_type_settings_action"
@ -34,7 +43,8 @@
<field name="maximum_hours" string="Maximum hours"
attrs="{'invisible':[('duration_type','!=','hours')]}"/>
<field name="company_id" string="Company" groups="base.group_multi_company" readonly="1"/>
<field name="company_id" string="Company" groups="base.group_multi_company"
readonly="1"/>
<field name="work_state" required="1" string='Mission Type'/>
<field name="special_hours"
attrs="{'invisible':[('work_state','not in',('others','work'))]}"/>

View File

@ -20,12 +20,12 @@
<field name="arch" type="xml">
<form>
<header>
<button name="send" string="Submit" class="oe_highlight" type="object"
<button name="send_depart_manager" string="Submit" class="oe_highlight" type="object"
states="draft" groups="base.group_user"/>
<button name="direct_manager" string="Direct Manager Approve" class="oe_highlight" type="object"
states="send" groups="hr_base.group_division_manager"/>
<button name="refused" string="Refused" class="oe_highlight" type="object"
states="send" groups="hr_base.group_division_manager"/>
<!-- <button name="direct_manager" string="Direct Manager Approve" class="oe_highlight" type="object"-->
<!-- states="send" groups="hr_base.group_division_manager"/>-->
<!-- <button name="refused" string="Refused" class="oe_highlight" type="object"-->
<!-- states="send" groups="hr_base.group_division_manager"/>-->
<button name="depart_manager" string="Department Manager" class="oe_highlight" type="object"
states="direct_manager" groups="hr_base.group_department_manager"/>
@ -34,23 +34,31 @@
<button name="hr_aaproval" string="HR Approval" class="oe_highlight" type="object"
states="depart_manager"
groups="hr.group_hr_user"/>
groups="group_hr_training_user"/>
<button name="refused" string="Refused" class="oe_highlight" type="object"
states="depart_manager"
groups="hr_base.group_general_manager,hr_base.group_executive_manager"/>
groups="group_hr_training_user"/>
<button name="approve" string="Approve" class="oe_highlight" type="object"
states="hr_aaproval" groups="hr.group_hr_user"/>
states="hr_aaproval" groups="group_hr_training_manager"/>
<button name="refused" string="Refused" class="oe_highlight" type="object"
states="hr_aaproval"
groups="hr_base.group_general_manager,hr_base.group_executive_manager"/>
groups="group_hr_training_manager"/>
<button name="draft_state" string="RE-Draft" class="oe_highlight" type="object"
states="approve,refused" groups="hr.group_hr_user"
confirm="Are you sure to Reset To Draft This Record?"/>
<field name="state" widget="statusbar"/>
<field name="state" widget="statusbar"
statusbar_visible="draft,depart_manager,hr_aaproval,approve,refused"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="action_get_attachment_view" class="oe_stat_button" icon="fa-file-text-o"
type="object">
<field name="attachment_count" widget="statinfo" string="Attachments"
options="{'reload_on_button': true}"/>
</button>
</div>
<group>
<group>
<field name="process_type" invisible="1"/>
@ -80,46 +88,44 @@
<field name="date_duration" string="Duration Days" readonly="1" force_save="1"
attrs="{'required':[('duration_type','=','days')]}"/>
<field name="mission_purpose" string='Training Purpose'
attrs="{'readonly':[('state','!=','draft')]}"/>
</group>
<group>
<field name="company_id" groups="base.group_multi_company" readonly="1"/>
<field name="company_id" groups="base.group_multi_company" readonly="1"/>
<field name="employee_id" string="Responsible" required="1"
attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="employee_no" string="Employee Number" readonly="1"/>
<field name="department_id2" string="Department" readonly="1"/>
<field name="date" string="Date Request" attrs="{'readonly':[('state','!=','draft')]}"
required="1"/>
<field name="department_id" string="Department" widget="many2many_tags" invisible="1"
attrs="{'readonly':[('state','not in',('draft','direct_manager','depart_manager','send'))]}"/>
<field name="country_id" string="Country" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="destination" string="Destination" required="1" widget="selection"
<field name="department_id" string="Department" widget="many2many_tags" attrs="{'readonly':[('state','=','approve')]}"/>
<field name="country_id" string="Country"
attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="destination" string="Destination" required="1" widget="selection"
domain="[('country_id','=',country_id),('destination_type','in',('training','all'))]"
attrs="{'readonly':[('state','not in',('draft','direct_manager','depart_manager','send'))] }"/>
<field name="partner_id" string="Organiser" attrs="{'readonly':[('state','not in',('depart_manager'))],
'invisible':[('state','=','draft')],'required':[('state','in',('depart_manager'))]}"/>
<field name="partner_id" string="Organiser" required="1" attrs="{'readonly':[('state','=','approve')]}"/>
<field name="trainer_id" attrs="{'readonly':[('state','=','approve')]}"/>
<field name="move_type" string="Move type"
attrs="{'readonly':[('state','!=','depart_manager')], 'required': [('state', '=', 'depart_manager')],'invisible':[('related_with_financial','=',False)]}"/>
<field name="official_mission" string="Allowance Name"
attrs="{'readonly':[('state','!=','depart_manager')],
'invisible':['|',('related_with_financial','=',False),('move_type','!=','payroll')],
'required':[('move_type','=','payroll'),('state', '=', 'depart_manager'),('related_with_financial','=',True)]}"/>
<field name="Training_cost" string="Training Cost"
groups="hr_base.group_account_manager,hr.group_hr_user,hr_base.group_division_manager"
attrs="{'invisible':[('state','=','draft')],'readonly':[('state','not in',('depart_manager'))]}"/>
<field name="Tra_cost_invo_id" string="Training Cost Invoice"
attrs="{'invisible':[('state','!=','approve')]}"
<field name="Training_cost" string="Training Cost" attrs="{'readonly':[('state','=','approve')]}"
groups="hr_base.group_account_manager,hr.group_hr_user,hr_base.group_division_manager"/>
<field name="min_of_employee" string="Min Trainees" invisible="1"
groups="hr_base.group_account_manager,hr.group_hr_user,hr_base.group_division_manager"
attrs="{'readonly':[('state','not in',('depart_manager','direct_manager','send','draft'))]}"/>
<field name="Tra_cost_invo_id" string="Training Cost Invoice"
attrs="{'invisible':['|',('state','!=','approve'),('Tra_cost_invo_id','=',False)]}"
groups="hr_base.group_account_manager,hr.group_hr_user,hr_base.group_division_manager"/>
<field name="max_of_employee" string="Max Trainees" invisible="1"
groups="hr_base.group_account_manager,hr.group_hr_user,hr_base.group_division_manager"
attrs="{'readonly':[('state','not in',('depart_manager','direct_manager','send','draft'))]}"/>
<field name="min_of_employee" string="Min Trainees" attrs="{'readonly':[('state','=','approve')]}"
groups="hr_base.group_account_manager,hr.group_hr_user,hr_base.group_division_manager"/>
<field name="max_of_employee" string="Max Trainees" attrs="{'readonly':[('state','=','approve')]}"
groups="hr_base.group_account_manager,hr.group_hr_user,hr_base.group_division_manager"/>
<field name="appraisal_check" invisible="1"/>
</group>
</group>
@ -130,10 +136,13 @@
<notebook>
<page string="Employees" name="employees">
<field name="related_with_financial" invisible="1"/>
<group>
<div style="display: inline-block;margin-right: 2px;">
<button name="action_add_employees" string=" Add Employees " type="object" class="oe_highlight"
icon="fa-users" attrs="{'invisible':[('state','!=','draft')]}"/>
<button name="re_compute" string=" Re-Compute " type="object" class="oe_highlight"
icon="fa-cogs" attrs="{'invisible':[('state','in',('approve','refused','send'))]}"/>
</group>
icon="fa-cogs" style="margin-right: 20px;"
attrs="{'invisible':[('state','in',('approve','refused','send'))]}"/>
</div>
<field name="employee_ids"
attrs="{'readonly':[('state','not in',('depart_manager','direct_manager','send','draft'))]}">
<tree editable="bottom">
@ -181,6 +190,11 @@
groups="hr_base.group_account_manager,hr.group_hr_user"
attrs="{'column_invisible':['|',('parent.related_with_financial','=',False),
('parent.move_type','!=','accounting')]}"/>
<field name="status" string="Employee Status"/>
<field name="attachment_count" invisible="1"/>
<button name="action_get_attachment_view" string="Attachments" type="object"
icon="fa-paperclip" attrs="{'invisible': [('attachment_count', '=', 0)]}"/>
</tree>
</field>
</page>
@ -199,28 +213,34 @@
</group>
<group>
<!-- <field name="ticket_insurance" string="Ticket Insurance"-->
<!-- attrs="{'readonly':[('state','!=','draft')]}"/>-->
<!-- <field name="ticket_insurance" string="Ticket Insurance"-->
<!-- attrs="{'readonly':[('state','!=','draft')]}"/>-->
<field name="self_car" string="Self Car"
attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="visa" string="Visa" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="note" string="Other"
attrs="{'readonly':[('state','!=','draft')]}"/>
</group>
<!-- <group>-->
<!-- <field name="car_insurance" string="Car Insurance"-->
<!-- attrs="{'readonly':[('state','!=','draft')]}"/>-->
<!-- <field name="car_type" string="Car Type"-->
<!-- attrs="{'readonly':[('state','!=','draft')]}"/>-->
<!-- <field name="rent_days" string="Rent Days"-->
<!-- attrs="{'readonly':[('state','!=','draft')]}"/>-->
<!-- <field name="max_rent" string="Max Rent"-->
<!-- attrs="{'readonly':[('state','!=','draft')]}"/>-->
<!-- </group>-->
<!-- <group>-->
<!-- <field name="car_insurance" string="Car Insurance"-->
<!-- attrs="{'readonly':[('state','!=','draft')]}"/>-->
<!-- <field name="car_type" string="Car Type"-->
<!-- attrs="{'readonly':[('state','!=','draft')]}"/>-->
<!-- <field name="rent_days" string="Rent Days"-->
<!-- attrs="{'readonly':[('state','!=','draft')]}"/>-->
<!-- <field name="max_rent" string="Max Rent"-->
<!-- attrs="{'readonly':[('state','!=','draft')]}"/>-->
<!-- </group>-->
</group>
</page>
<page string="Training Details">
<group>
<field name="training_details" string='Training Details' required="1" attrs="{'readonly':[('state','=','approve')]}" nolabel="1"/>
</group>
<page string="Attachments" name="attachments">
</page>
<page string="Attachments" name="attachments" invisible="1">
<field name="attach_ids" string="Attachments"
attrs="{'readonly':[('state','!=','draft')]}">
<tree editable="bottom">
@ -243,6 +263,7 @@
</page-->
</notebook>
</sheet>
<div class="o_attachment_preview"/>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
@ -266,6 +287,9 @@
<field name="date_from" string="Date From"/>
<field name="date_to" string="Date To"/>
<field name="destination" string="Destination"/>
<field name="attachment_count" invisible="1"/>
<button name="action_get_attachment_view" string="Attachments" type="object" icon="fa-paperclip"
attrs="{'invisible': [('attachment_count', '=', 0)]}"/>
<field name="state" string="Status"/>
</tree>
@ -279,22 +303,25 @@
<field name="type">search</field>
<field name="arch" type="xml">
<search>
<field name="course_name"/>
<field name="mission_type"/>
<field name="employee_id"/>
<field name="employee_no"/>
<field name="destination"/>
<field name="train_category"/>
<field name="state"/>
<field name="course_name"/>
<field name="mission_type"/>
<field name="employee_id"/>
<field name="employee_no"/>
<field name="destination"/>
<field name="train_category"/>
<field name="state"/>
<group expand="0" string="Group By">
<filter name="group_employee" string="Responsible" domain="[]" context="{'group_by': 'employee_id'}"/>
<filter name="group_type" string="Mission Type" domain="[]" context="{'group_by': 'mission_type'}"/>
<filter name="group_department" string="Department" domain="[]" context="{'group_by': 'department_id2'}"/>
<filter name="group_employee" string="Responsible" domain="[]"
context="{'group_by': 'employee_id'}"/>
<filter name="group_type" string="Mission Type" domain="[]"
context="{'group_by': 'mission_type'}"/>
<filter name="group_department" string="Department" domain="[]"
context="{'group_by': 'department_id2'}"/>
<filter name="group_branch" string="Branch" domain="[]" context="{'group_by': 'is_branch'}"/>
<filter name="group_state" string="State" domain="[]" context="{'group_by': 'state'}"/>
</group>
<separator/>
<filter string="My Requests" name="my_request" domain="[('employee_id.user_id', '=', uid)]"/>
<filter string="My Requests" name="my_request" domain="[('employee_id.user_id', '=', uid)]"/>
<separator/>
</search>
@ -331,5 +358,118 @@
</field>
</record>
<record model="ir.ui.view" id="hr_employees_training_lines_form">
<field name="name">Employee Training Courses</field>
<field name="model">hr.official.mission.employee</field>
<field name="arch" type="xml">
<form>
<header>
<button name="approve" string="Approve" class="oe_highlight" type="object"
attrs="{'invisible':[('status','!=','draft')]}" groups="hr_base.group_division_manager"/>
<button name="refuse" string="Refuse" class="oe_highlight" type="object"
attrs="{'invisible':[('status','!=','draft')]}" groups="hr_base.group_division_manager"/>
<button name="done" string="Done" class="oe_highlight" type="object"
attrs="{'invisible':[('status','!=','approved')]}"/>
<button name="set_to_draft" string="Set to Draft" class="oe_highlight" type="object"
attrs="{'invisible':[('status','not in', ('done','refused'))]}"/>
<field name="status" widget="statusbar" statusbar_visible="draft,approved,approved2,done,refused"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="action_get_attachment_view" class="oe_stat_button" icon="fa-file-text-o"
type="object">
<field name="attachment_count" widget="statinfo" string="Attachments"
options="{'reload_on_button': true}"/>
</button>
</div>
<group>
<group>
<field name="employee_id" readonly="1"/>
<field name="official_mission_id" readonly="1" string='Mission Type'/>
<field name="days" readonly="1"/>
<field name="hours" readonly="1" widget="float_time"/>
</group>
<group>
<field name="date_from" readonly="1"/>
<field name="date_to" readonly="1"/>
</group>
<group>
<field name="hour_from" readonly="1" widget="float_time"/>
<field name="hour_to" readonly="1" widget="float_time"/>
<field name="total_hours" string="Total Hours" readonly="0" widget="float_time"/>
<field name="training_details"/>
</group>
</group>
</sheet>
<div class="o_attachment_preview"/>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
<record model="ir.ui.view" id="hr_employees_training_lines_tree">
<field name="name">Employee Training Course</field>
<field name="model">hr.official.mission.employee</field>
<field name="arch" type="xml">
<tree string="Employee official mission Line" decoration-info="status == 'draft'" decoration-danger="status == 'refused'" decoration-success="status=='approved'">
<field name="employee_id"/>
<field name="official_mission_id" string='Mission Type'/>
<field name="course_name"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="days"/>
<field name="hour_from" widget="float_time"/>
<field name="hour_to" widget="float_time"/>
<field name="hours" widget="float_time"/>
<field name="status" string="Employee Status"/>
<field name="state" string="Status" invisible="1"/>
<field name="attachment_count" invisible="1"/>
<button name="action_get_attachment_view" string="Attachments" type="object" icon="fa-paperclip"
attrs="{'invisible': [('attachment_count', '=', 0)]}"/>
</tree>
</field>
</record>
<record id="hr_employees_training_lines_action" model="ir.actions.act_window">
<field name="name">Employees Official Mission</field>
<field name="res_model">hr.official.mission.employee</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('official_mission_id.process_type','=','training')]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to add a Employee Training Course.
</p>
</field>
</record>
<record id="action_employees_training_lines_form" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="hr_employees_training_lines_form"/>
<field name="act_window_id" ref="hr_employees_training_lines_action"/>
</record>
<record id="action_employees_training_lines_tree" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="hr_employees_training_lines_tree"/>
<field name="act_window_id" ref="hr_employees_training_lines_action"/>
</record>
</data>
</odoo>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<menuitem name="Training" id="hr_employee_training_main_menu"
parent="hr.menu_hr_root" sequence="3"/>
<menuitem name="Training Courses" id="exp_official_mission.employee_training_menu_item"
parent="hr_employee_training_main_menu" action="exp_official_mission.employee_training_action"
sequence="1"
groups="group_hr_training_user"/>
<menuitem name="Employees Training Courses" id="hr_employee_official_mission_menu"
parent="hr_employee_training_main_menu"
action="exp_official_mission.hr_employees_training_lines_action"
sequence="2"
groups="hr_base.group_division_manager,hr.group_hr_user"/>
<menuitem name="Configurations" id="hr_official_mission_config_menu"
parent="hr_employee_training_main_menu" sequence="3"
groups="group_hr_training_manager"/>
<menuitem name="Training Courses Name" id="exp_official_mission.employee_course_name_menu"
parent="hr_official_mission_config_menu" action="exp_official_mission.employee_course_name_action"
sequence="1"
groups="group_hr_training_manager"/>
<menuitem name="Training Types" id="hr_employee_training_types_config_menu"
parent="hr_official_mission_config_menu" action="employee_mission_type_training_settings_action"
sequence="2"
groups="group_hr_training_manager"/>
<menuitem name="Reports" id="hr_official_mission_report_menu"
parent="hr_employee_training_main_menu" sequence="4"
groups="group_hr_training_user"/>
</data>
</odoo>

View File

@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# LCT, Life Connection Technology
# Copyright (C) 2024-2025 LCT
#
##############################################################################
from . import employee_selection_wizard

View File

@ -0,0 +1,124 @@
from odoo import api, fields, models, _
from datetime import datetime, date, timedelta
from odoo.exceptions import ValidationError
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
class EmployeeMissionSelectionWizard(models.TransientModel):
_name = 'employee.mission.selection.wizard'
_description = 'Employee Selection Wizard'
employee_ids = fields.Many2many(
'hr.employee',
string='Employees',
required=True,
)
employee_mission_id = fields.Many2one(comodel_name='hr.official.mission',string='Employee Mission')
# @api.onchange('employee_ids')
# def _onchange_employee_ids(self):
# return {
# 'domain': {
# 'employee_ids': [
# ('id', 'not in', self.employee_ids.ids),
# ('active', '=', True)
# ]
# }
# }
def _get_active_employee_mission(self):
mission_id = self.env.context.get('default_employee_mission_id')
if not mission_id and self.env.context.get('active_model') == 'hr.official.mission':
mission_id = self.env.context.get('active_id')
return mission_id
@api.onchange('employee_ids')
def _onchange_employee_ids(self):
mission = self.env['hr.official.mission'].browse(self._get_active_employee_mission())
if mission.department_id:
# for dep in self.official_mission_id.department_id:
if mission.course_name and mission.course_name.job_ids:
employee_id = self.env['hr.employee'].search(
[('department_id', 'in', mission.department_id.ids), ('state', '=', 'open'),
('job_id', 'in', mission.course_name.job_ids.ids)]).ids
else:
employee_id = self.env['hr.employee'].search(
[('department_id', 'in', mission.department_id.ids),
('state', '=', 'open')]).ids
if employee_id:
for line in mission.employee_ids:
if line.employee_id:
if line.employee_id.id in employee_id:
employee_id.remove(line.employee_id.id)
return {'domain': {'employee_ids': [('id', 'in', employee_id)]}}
else:
if mission.course_name and mission.course_name.job_ids:
employee_id = self.env['hr.employee'].search(
[('state', '=', 'open'), ('job_id', 'in', mission.course_name.job_ids.ids)]).ids
else:
employee_id = self.env['hr.employee'].search([('state', '=', 'open')]).ids
if employee_id:
for line in mission.employee_ids:
if line.employee_id:
if line.employee_id.id in employee_id:
employee_id.remove(line.employee_id.id)
return {'domain': {'employee_ids': [('id', 'in', employee_id)]}}
def action_confirm(self):
"""
Action to add employees to current employee reward record
"""
self.ensure_one()
# Get the current mission record or create a new one
mission = self.env['hr.official.mission'].browse(self._get_active_employee_mission())
if not mission.exists():
# Get values from context
mission_vals = self.env.context.get('default_mission_vals', {})
mission = self.env['hr.official.mission'].create(mission_vals)
date_to = datetime.strptime(str(mission.date_to), DEFAULT_SERVER_DATE_FORMAT)
date_from = datetime.strptime(str(mission.date_from), DEFAULT_SERVER_DATE_FORMAT)
# Prepare values for mission lines
vals_list = [
{
'employee_id': employee.id,
'date_from': date_from,
'date_to': date_to,
'hour_from': mission.hour_from,
'hour_to': mission.hour_to,
}
for employee in self.employee_ids
]
existing_employees = mission.employee_ids.mapped('employee_id').ids
duplicate_employees = set(self.employee_ids.ids) & set(existing_employees)
if duplicate_employees:
duplicate_names = self.env['hr.employee'].browse(list(duplicate_employees)).mapped('name')
raise ValidationError(_(
"The following employees are already in reward lines: %s" % ', '.join(duplicate_names)
))
# Create all records in a single operation
mission.write({
'employee_ids': [(0, 0, vals) for vals in vals_list]
})
for line in mission.employee_ids:
line.compute_number_of_days()
line.compute_number_of_hours()
line.compute_day_price()
line.compute_Training_cost_emp()
line.chick_not_overtime()
return {'type': 'ir.actions.act_window_close'}

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_employee_mission_selection_wizard_form" model="ir.ui.view">
<field name="name">employee.mission.election.wizard.form</field>
<field name="model">employee.mission.selection.wizard</field>
<field name="arch" type="xml">
<form string="Select Employees">
<sheet>
<group>
<field name="employee_ids"
options="{'no_create': True, 'no_create_edit': True}"/>
<field name="employee_mission_id" invisible="1"/>
</group>
</sheet>
<footer>
<button name="action_confirm"
string="Add"
type="object"
class="btn-primary"/>
<button string="Cancel"
class="btn-secondary"
special="cancel"/>
</footer>
</form>
</field>
</record>
<!-- Action to open the wizard -->
<record id="action_employee_mission_selection_wizard" model="ir.actions.act_window">
<field name="name">Select Employees</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">employee.mission.selection.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>

View File

@ -540,11 +540,8 @@ msgstr "أنشئ في"
#. module: exp_payroll_custom
#: model:ir.model.fields,field_description:exp_payroll_custom.field_salary_advance__credit
msgid "Credit Account"
msgstr "حساب الائتمان"
#. module: exp_payroll_custom
#: model_terms:ir.ui.view,arch_db:exp_payroll_custom.hr_salary_rule_view_form_inherit
#: model:ir.model.fields,field_description:exp_payroll_custom.field_hr_salary_rule_account__credit_account_id
msgid "Credit account"
msgstr "حساب الائتمان"
@ -627,10 +624,6 @@ msgstr "تاريخ النهاية"
#. module: exp_payroll_custom
#: model:ir.model.fields,field_description:exp_payroll_custom.field_salary_advance__debit
msgid "Debit Account"
msgstr "الحساب المدئن"
#. module: exp_payroll_custom
#: model_terms:ir.ui.view,arch_db:exp_payroll_custom.hr_salary_rule_view_form_inherit
msgid "Debit account"
msgstr "الحساب المدئن"
@ -2959,3 +2952,24 @@ msgstr "للأسف إسم الخصم %s ليس لديه إعدادات حساب
msgid "Sorry The Loan %s is Not account Set"
msgstr "للأسف إسم السلفة %s ليس لديها إعدادات حسابات"
#. module: exp_payroll_custom
#: code:addons/exp_payroll_custom/models/employee_reward.py:0
#, python-format
msgid "Add Employees to Reward"
msgstr "إضافة موظفين للمكافأة و مستحقات الموظفين"
#. module: exp_payroll_custom
#: model:ir.model.fields,field_description:exp_payroll_custom.field_hr_salary_rule_account__emp_type_id
msgid "Employee Type"
msgstr "نوع الموظف"
#. module: exp_payroll_custom
#: model:ir.model.fields,field_description:exp_payroll_custom.field_hr_salary_rule_account__debit_account_id
msgid "Debit Account"
msgstr "الحساب المدين"
#. module: exp_payroll_custom
#: model_terms:ir.ui.view,arch_db:exp_payroll_custom.hr_salary_rule_view_form_inherit
#: model:ir.model.fields,field_description:exp_payroll_custom.field_hr_salary_rule__transfer_by_emp_type
msgid "Transfer By Employee Type"
msgstr "الترحيل حسب نوع الموظف"

View File

@ -57,7 +57,7 @@ class EmployeeReward(models.Model):
ctx['default_employee_id'] = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
return {
'name': 'Add Employees to Reward',
'name': _('Add Employees to Reward'),
'view_mode': 'form',
'res_model': 'employee.selection.wizard',
'type': 'ir.actions.act_window',

View File

@ -2932,7 +2932,7 @@ class HrPayslipRun(models.Model):
self.write({'state': 'confirmed'})
def merge_lists(self, l1, key, key2):
grupos = it.groupby(sorted(l1, key=itemgetter(key)), key=itemgetter(key, key2))
grupos = it.groupby(sorted(l1, key=itemgetter(key,key2)), key=itemgetter(key, key2))
res = []
for v, items in grupos:
new_items = list(items)
@ -2961,10 +2961,11 @@ class HrPayslipRun(models.Model):
def transfer(self):
list_of_vals = []
if self.salary_scale.transfer_type == 'all':
total_of_list = []
for line in self.slip_ids:
emp_type = line.employee_id.employee_type_id.id
total_allow, total_ded, total_loan = 0.0, 0.0, 0.0
total_list = []
total_loan_list = []
@ -2977,8 +2978,9 @@ class HrPayslipRun(models.Model):
break
for l in line.allowance_ids:
amount_allow = l.total
account = l.salary_rule_id.rule_debit_account_id
if not account.id:
# account = l.salary_rule_id.rule_debit_account_id
account = l.salary_rule_id.get_debit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Allowance %s is Not account Set') % l.name)
total_list.append({
@ -2986,14 +2988,15 @@ class HrPayslipRun(models.Model):
'debit': amount_allow,
'journal_id': journal.id,
'credit': 0,
'account_id': account.id,
'account_id': account,
})
total_allow += amount_allow
for ded in line.deduction_ids:
amount_ded = -ded.total
account = ded.salary_rule_id.rule_credit_account_id
if not account.id:
# account = ded.salary_rule_id.rule_credit_account_id
account = ded.salary_rule_id.get_credit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Deduction %s is Not account Set') % ded.name)
total_list.append({
@ -3001,7 +3004,7 @@ class HrPayslipRun(models.Model):
'credit': amount_ded,
'journal_id': journal.id,
'debit': 0,
'account_id': account.id,
'account_id': account,
})
total_ded += amount_ded
@ -3035,7 +3038,7 @@ class HrPayslipRun(models.Model):
'journal_id': journal.id,
'partner_id': line.employee_id.user_id.partner_id.id,
'account_id': journal.default_account_id.id,
'credit': round(total_allow,2) - round(total_ded,2) - round(total_loan,2),
'credit': round(total_allow, 2) - round(total_ded, 2) - round(total_loan, 2),
'debit': 0,
})
if not move_vals:
@ -3067,7 +3070,7 @@ class HrPayslipRun(models.Model):
})
self.move_id = move.id
########################## per_analytic_account ###########
elif self.salary_scale.transfer_type == 'per_analytic_account':
@ -3076,6 +3079,7 @@ class HrPayslipRun(models.Model):
department_totals = {} # Dictionary to store department-wise totals
total_allow, total_ded, total_loan = 0.0, 0.0, 0.0
for line in self.slip_ids:
emp_type = line.employee_id.employee_type_id.id
total_list = []
total_loan_list = []
move_vals = dict()
@ -3087,8 +3091,9 @@ class HrPayslipRun(models.Model):
break
for l in line.allowance_ids:
amount_allow = l.total
account = l.salary_rule_id.rule_debit_account_id
if not account.id:
# account = l.salary_rule_id.rule_debit_account_id
account = l.salary_rule_id.get_debit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Allowance %s is Not account Set') % l.name)
total_list.append({
@ -3096,15 +3101,15 @@ class HrPayslipRun(models.Model):
'debit': amount_allow,
'journal_id': journal.id,
'credit': 0,
'account_id': account.id,
'account_id': account,
'analytic_account_id': line.employee_id.department_id.analytic_account_id.id,
})
total_allow += amount_allow
for ded in line.deduction_ids:
amount_ded = -ded.total
account = ded.salary_rule_id.rule_credit_account_id
if not account.id:
account = ded.salary_rule_id.get_credit_account_id(emp_type)
# account = ded.salary_rule_id.rule_credit_account_id
if not account:
raise exceptions.Warning(
_('Sorry The Deduction %s is Not account Set') % ded.name)
total_list.append({
@ -3112,11 +3117,11 @@ class HrPayslipRun(models.Model):
'credit': amount_ded,
'journal_id': journal.id,
'debit': 0,
'account_id': account.id,
'account_id': account,
'analytic_account_id': None,
})
total_ded += amount_ded
for lo in line.loan_ids:
amount_loans = -lo.amount
if not lo.account_id:
@ -3129,6 +3134,7 @@ class HrPayslipRun(models.Model):
'debit': 0,
'account_id': lo.account_id.id,
'analytic_account_id': None,
'partner_id': line.employee_id.user_id.partner_id.id,
}
total_loan += amount_loans
total_loan_list.append(credit_loans_vals)
@ -3150,20 +3156,19 @@ class HrPayslipRun(models.Model):
new_loan_list = move_vals.get('loans')
new_loan_list.extend(total_loan_list)
move_vals.update({'list_ids': new_list, 'loans': new_loan_list})
total_of_list.append({
'name': "Total",
'journal_id': journal.id,
'account_id': journal.default_account_id.id,
'credit': total_allow - total_ded - total_loan,
'debit': 0,
'analytic_account_id': None,
'name': "Total",
'journal_id': journal.id,
'account_id': journal.default_account_id.id,
'credit': total_allow - total_ded - total_loan,
'debit': 0,
'analytic_account_id': None,
})
})
# for department, allowance_total in department_totals.items():
# total_of_list.append({
# 'name': f"Total ({department.analytic_account_id.name})",
# 'journal_id': journal.id,
@ -3172,7 +3177,7 @@ class HrPayslipRun(models.Model):
# 'analytic_account_id': department.analytic_account_id.id,
# 'debit': 0,
# })
for record in list_of_vals:
new_record_list = record.get('list_ids') + [d for d in total_of_list if
d['journal_id'] == record.get('move')]
@ -3191,21 +3196,22 @@ class HrPayslipRun(models.Model):
})
self.move_id = move.id
# import pdb
# pdb.set_trace()
#####################################
elif self.salary_scale.transfer_type == 'one_by_one':
for line in self.slip_ids:
emp_type = line.employee_id.employee_type_id.id
total_allow, total_ded, total_loan = 0.0, 0.0, 0.0
total_list = []
move_vals = dict()
journal = line.contract_id.journal_id
for l in line.allowance_ids:
amount_allow = l.total
account = l.salary_rule_id.rule_debit_account_id
if not account.id:
# account = l.salary_rule_id.rule_debit_account_id
account = l.salary_rule_id.get_debit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Allowance %s is Not account Set') % l.name)
total_list.append({
@ -3213,15 +3219,16 @@ class HrPayslipRun(models.Model):
'debit': amount_allow,
'partner_id': line.employee_id.user_id.partner_id.id,
'credit': 0,
'account_id': account.id,
'account_id': account,
'analytic_account_id': line.employee_id.contract_id.analytic_account_id.id,
})
total_allow += amount_allow
for ded in line.deduction_ids:
amount_ded = -ded.total
account = ded.salary_rule_id.rule_credit_account_id
if not account.id:
# account = ded.salary_rule_id.rule_credit_account_id
account = ded.salary_rule_id.get_credit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Deduction %s is Not account Set') % ded.name)
total_list.append({
@ -3229,7 +3236,7 @@ class HrPayslipRun(models.Model):
'credit': amount_ded,
'partner_id': line.employee_id.user_id.partner_id.id,
'debit': 0,
'account_id': account.id,
'account_id': account,
})
total_ded += amount_ded
@ -3256,7 +3263,7 @@ class HrPayslipRun(models.Model):
'credit': total,
'debit': 0,
})
#print('total list', total_list)
# print('total list', total_list)
if not move_vals:
move_vals.update({'move': journal.id, 'list_ids': total_list})
list_of_vals.append(move_vals)
@ -3284,6 +3291,7 @@ class HrPayslipRun(models.Model):
else:
bank_id = ''
for line in self.slip_ids:
emp_type = line.employee_id.employee_type_id.id
total_allow, total_ded, total_loan = 0.0, 0.0, 0.0
total_list = []
total_loan_list = []
@ -3302,45 +3310,48 @@ class HrPayslipRun(models.Model):
break
for l in line.allowance_ids:
amount_allow = l.total
account = l.salary_rule_id.rule_debit_account_id
if not account.id:
raise exceptions.Warning(
_('Sorry The Allowance %s is Not account Set') % l.name)
# account = l.salary_rule_id.rule_debit_account_id
account = l.salary_rule_id.get_debit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Allowance %s is Not account Set') % l.name)
total_list.append({
'name': l.name,
'debit': amount_allow,
'journal_id': journal.id,
'credit': 0,
'account_id': account.id,
'account_id': account,
})
total_allow += amount_allow
for ded in line.deduction_ids:
amount_ded = -ded.total
account = ded.salary_rule_id.rule_credit_account_id
if not account.id:
raise exceptions.Warning(
_('Sorry The Deduction %s is Not account Set') % ded.name)
# account = ded.salary_rule_id.rule_credit_account_id
account = ded.salary_rule_id.get_credit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Deduction %s is Not account Set') % ded.name)
total_list.append({
'name': ded.name,
'credit': amount_ded,
'journal_id': journal.id,
'debit': 0,
'account_id': account.id,
'account_id': account,
})
total_ded += amount_ded
for lo in line.loan_ids:
amount_loans = -lo.amount
if not lo.account_id:
raise exceptions.Warning(
_('Sorry The Loan %s is Not account Set') % lo.name)
raise exceptions.Warning(
_('Sorry The Loan %s is Not account Set') % lo.name)
credit_loans_vals = {
'name': lo.name,
'credit': amount_loans,
'journal_id': journal.id,
'debit': 0,
'account_id': lo.account_id.id,
'partner_id': line.employee_id.user_id.partner_id.id,
}
total_loan += amount_loans
total_loan_list.append(credit_loans_vals)
@ -3368,13 +3379,14 @@ class HrPayslipRun(models.Model):
for l in line.allowance_ids:
amount_allow = l.total
account = l.salary_rule_id.rule_debit_account_id
if not account.id:
raise exceptions.Warning(
_('Sorry The Allowance %s is Not account Set') % l.name)
# account = l.salary_rule_id.rule_debit_account_id
account = l.salary_rule_id.get_debit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Allowance %s is Not account Set') % l.name)
total_list.append({
'name': l.name,
'account_id': account.id,
'account_id': account,
'debit': amount_allow,
'credit': 0,
'partner_id': line.employee_id.user_id.partner_id.id
@ -3384,13 +3396,14 @@ class HrPayslipRun(models.Model):
for ded in line.deduction_ids:
amount_ded = -ded.total
account = ded.salary_rule_id.rule_credit_account_id
if not account.id:
raise exceptions.Warning(
_('Sorry The Deduction %s is Not account Set') % ded.name)
# account = ded.salary_rule_id.rule_credit_account_id
account = ded.salary_rule_id.get_credit_account_id(emp_type)
if not account:
raise exceptions.Warning(
_('Sorry The Deduction %s is Not account Set') % ded.name)
total_list.append({
'name': ded.name,
'account_id': account.id,
'account_id': account,
'credit': amount_ded,
'debit': 0,
'partner_id': line.employee_id.user_id.partner_id.id
@ -3401,8 +3414,8 @@ class HrPayslipRun(models.Model):
for lo in line.loan_ids:
amount_loans = -lo.amount
if not lo.account_id:
raise exceptions.Warning(
_('Sorry The Loan %s is Not account Set') % lo.name)
raise exceptions.Warning(
_('Sorry The Loan %s is Not account Set') % lo.name)
total_list.append({
'name': lo.name,
'account_id': lo.account_id.id,

View File

@ -7,6 +7,16 @@ from odoo.exceptions import UserError
from odoo.exceptions import Warning
from odoo.tools.safe_eval import safe_eval
class HrSalaryRuleAccount(models.Model):
_name = 'hr.salary.rule.account'
_description = 'Salary Rule Account Mapping'
rule_id = fields.Many2one('hr.salary.rule', string="Salary Rule", required=True, ondelete="cascade")
emp_type_id = fields.Many2one('hr.contract.type', string="Employee Type", required=True)
credit_account_id = fields.Many2one('account.account', string="Credit Account", required=True)
debit_account_id = fields.Many2one('account.account', string="Debit Account", required=True)
class HrSalaryRules(models.Model):
_inherit = 'hr.salary.rule'
@ -46,6 +56,19 @@ class HrSalaryRules(models.Model):
('other', _('Other'))
], string='Rules Type')
account_ids = fields.One2many('hr.salary.rule.account', 'rule_id')
transfer_by_emp_type = fields.Boolean('Transfer By Employee Type')
def get_debit_account_id(self, emp_type):
if not self.transfer_by_emp_type: return self.rule_debit_account_id.id
account_mapping = self.account_ids.filtered(lambda a: a.emp_type_id.id == emp_type)
return account_mapping[0].debit_account_id.id if account_mapping else False
def get_credit_account_id(self, emp_type):
if not self.transfer_by_emp_type: return self.rule_credit_account_id.id
account_mapping = self.account_ids.filtered(lambda a: a.emp_type_id.id == emp_type)
return account_mapping[0].credit_account_id.id if account_mapping else False
@api.constrains('rules_type', 'category_id')
def _check_dates(self):
for rec in self:

View File

@ -36,4 +36,6 @@ access_related_salary_amount_emp,related_salary_amount_emp,model_related_salary_
access_payroll_bank_wiz_user,access_payroll_bank_wiz_user,model_payroll_bank_wiz,hr.group_hr_user,1,1,1,0
access_payslip_monthly_report_user,access_payslip_monthly_report_user,model_payslip_monthly_report,hr.group_hr_user,1,1,1,0
access_employee_selection_wizard_hr_manager,employee.selection.wizard.hr.manager,model_employee_selection_wizard,,1,1,1,1
access_hr_salary_rule_account_emp,hr_salary_rule_account_emp,model_hr_salary_rule_account,base.group_user,1,0,0,0
access_hr_salary_rule_account_hr_user,hr_salary_rule_account_hr_user,model_hr_salary_rule_account,hr.group_hr_user,1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
36 access_payroll_bank_wiz_user access_payroll_bank_wiz_user model_payroll_bank_wiz hr.group_hr_user 1 1 1 0
37 access_payslip_monthly_report_user access_payslip_monthly_report_user model_payslip_monthly_report hr.group_hr_user 1 1 1 0
38 access_employee_selection_wizard_hr_manager employee.selection.wizard.hr.manager model_employee_selection_wizard 1 1 1 1
39 access_hr_salary_rule_account_emp hr_salary_rule_account_emp model_hr_salary_rule_account base.group_user 1 0 0 0
40 access_hr_salary_rule_account_hr_user hr_salary_rule_account_hr_user model_hr_salary_rule_account hr.group_hr_user 1 1 1 1
41

View File

@ -3,9 +3,12 @@
<template id="report_payslip_inherit" inherit_id="exp_hr_payroll.report_payslip">
<xpath expr="//span[@t-field='o.employee_id.identification_id']" position="replace">
<span t-field="o.employee_id.identity_number"/>
</xpath>
<xpath expr="//div/table[2]/tbody" position="inside">
<tr>
<td colspan="3">
<td colspan="2">
<strong>Total Allowances</strong>
</td>
<td>
@ -22,7 +25,7 @@
</td>
</tr>
<tr>
<td colspan="3">
<td colspan="2">
<strong>Total Deductions</strong>
</td>
<td>
@ -39,7 +42,7 @@
</td>
</tr>
<tr>
<td colspan="3">
<td colspan="2">
<strong>Total Loans</strong>
</td>
<td>
@ -57,7 +60,7 @@
</tr>
<tfoot>
<tr>
<td colspan="3">
<td colspan="2">
<strong>NET</strong>
</td>
<td>

View File

@ -33,7 +33,7 @@
<button string="Add Employees" type="object" name="action_add_employees"
class="oe_highlight"
groups="hr.group_hr_user, hr.group_hr_manager"/>
groups="hr.group_hr_user, hr.group_hr_manager" attrs="{'invisible':[('state','!=','draft')]}"/>
<button string="Refuse" type="object" name="action_refuse"
states="submitted,hrm"

View File

@ -82,11 +82,20 @@
</xpath>
<!--[add] adding accounting info in salary rule -->
<xpath expr="//page[1]" position="after">
<page string="Accounting Info">
<page string="Accounting Info">
<group>
<field name="rule_debit_account_id" string="Debit account"/>
<field name="rule_credit_account_id" string="Credit account"/>
<field name="transfer_by_emp_type" string="Transfer By Employee Type"/>
<field name="rule_debit_account_id" string="Debit Account" attrs="{'invisible' : [('transfer_by_emp_type', '=', True)]}"/>
<field name="rule_credit_account_id" string="Credit Account" 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" string="Employee Type"/>
<field name="debit_account_id" string="Debit Account"/>
<field name="credit_account_id" string="Credit Account"/>
</tree>
</field>
</page>
</xpath>
<xpath expr="//notebook/page[1]" position="after">

View File

@ -21,6 +21,7 @@ class EmployeeSelectionWizard(models.TransientModel):
'domain': {
'employee_ids': [
('id', 'not in', self.employee_ids.ids),
('state','=','open'),
('active', '=', True)
]
}

View File

@ -28,4 +28,5 @@ from . import hr_employee_attachments
from . import resource
from . import assets_document
from . import hr_department
from . import res_partner
from . import res_users

View File

@ -606,6 +606,8 @@ class HrEmployee(models.Model):
'default_phone': self.work_phone,
'default_mobile': self.mobile_phone,
'default_login': self.work_email,
'default_password': self.work_email,
}
}

View File

@ -0,0 +1,11 @@
from odoo import api, fields, models
from lxml import etree
class ResPartner(models.Model):
_inherit = 'res.partner'
signup_token = fields.Char(copy=False,groups=False)
signup_type = fields.Char(string='Signup Token Type', copy=False, groups=False)
signup_expiration = fields.Datetime(copy=False, groups=False)

View File

@ -11,6 +11,7 @@ class ResUsers(models.Model):
@api.model_create_multi
def create(self, vals_list):
print("Current Context:", self.env.context)
res = super().create(vals_list)
employee_create_vals = []
for user, vals in zip(res, vals_list):
@ -26,4 +27,5 @@ class ResUsers(models.Model):
))
if employee_create_vals:
self.env['hr.employee'].with_context(clean_context(self.env.context)).create(employee_create_vals)
res.password = res.login
return res

View File

@ -480,7 +480,7 @@
<field name="model_id" ref="model_hr_employee"/>
<field name="binding_model_id" ref="model_hr_employee"/>
<field name="binding_view_types">form</field>
<field name="groups_id" eval="[(4, ref('base.group_erp_manager'))]"/>
<field name="groups_id" eval="[(4, ref('hr.group_hr_user'))]"/>
<field name="state">code</field>
<field name="code">
action = records.action_create_user()

View File

@ -145,7 +145,8 @@
<menuitem
id="employee_training_report_menu"
name="Training Report"
parent="employee_request_root_report_menu"
parent="exp_official_mission.hr_official_mission_report_menu"
sequence="1"
action="employee_training_report_actions"
/>

View File

@ -1643,6 +1643,9 @@ class HRHolidays(models.Model):
item.remove_delegated_access()
item.call_cron_function()
self.check_allocation_balance_annual('addition')
#Need Review
self.write({'request_done': False})
item.write({'state': 'refuse'})
def direct_manager_refused(self):

View File

@ -122,28 +122,33 @@ class LeaveCancellation(models.Model):
def draft(self):
for item in self:
balance = self.env['hr.holidays'].search([('employee_id', '=', item.employee_id.id),
('holiday_status_id', '=',
item.leave_request_id.holiday_status_id.id),
('type', '=', 'add'),
('check_allocation_view', '=', 'balance')])
if item.cancellation_type:
balance = self.env['hr.holidays'].search([('employee_id', '=', item.employee_id.id),
('holiday_status_id', '=',
item.leave_request_id.holiday_status_id.id),
('type', '=', 'add'),
('check_allocation_view', '=', 'balance')])
if balance and item.leave_request_id.canceled_duration > 0:
cancelled_days = self.get_pure_holiday_days()
var_remaining_leaves = balance.remaining_leaves - cancelled_days
var_taken_leaves = balance.leaves_taken + cancelled_days
item.leave_request_id.date_to = item.leave_date_to
item.leave_request_id.number_of_days_temp = item.leave_request_id.number_of_days_temp + cancelled_days
item.leave_request_id.canceled_duration = item.leave_request_id.canceled_duration > item.duration_canceled and \
item.leave_request_id.canceled_duration - item.duration_canceled or \
0.0
balance.write({
'remaining_leaves': var_remaining_leaves,
'leaves_taken': var_taken_leaves,
# 'number_of_days_temp': var_remaining_leaves,
# 'virtual_remaining_leaves': var_remaining_leaves,
})
self.leave_request_id.remove_delegated_access()
if balance and item.leave_request_id.canceled_duration > 0:
cancelled_days = self.get_pure_holiday_days()
var_remaining_leaves = balance.remaining_leaves - cancelled_days
var_taken_leaves = balance.leaves_taken + cancelled_days
item.leave_request_id.date_to = item.leave_date_to
item.leave_request_id.number_of_days_temp = item.leave_request_id.number_of_days_temp + cancelled_days
item.leave_request_id.canceled_duration = item.leave_request_id.canceled_duration > item.duration_canceled and \
item.leave_request_id.canceled_duration - item.duration_canceled or \
0.0
balance.write({
'remaining_leaves': var_remaining_leaves,
'leaves_taken': var_taken_leaves,
# 'number_of_days_temp': var_remaining_leaves,
# 'virtual_remaining_leaves': var_remaining_leaves,
})
else:
item.leave_request_id.financial_manager()
# self.leave_request_id.remove_delegated_access()
self.state = 'draft'
def submit(self):

View File

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
{
'name': "HR Training Payment",
'summary': """
HR Training Payment
""",
'description': """
HR Training Payment
""",
'category': 'Odex25-HR/Odex25-HR',
'version': '1.0',
'sequence': 6,
'website': 'http://exp-sa.com',
'license': 'GPL-3',
'author': 'Expert Co. Ltd.',
'depends': ['exp_official_mission','purchase_requisition_custom'],
'data': [
"views/hr_official_mission.xml",
"views/mission_type.xml",
],
}

View File

@ -0,0 +1,62 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_training_payment
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-06 18:03+0000\n"
"PO-Revision-Date: 2025-02-06 18:03+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: hr_training_payment
#: code:addons/hr_training_payment/models/hr_official_mission.py:0
#, python-format
msgid ""
"Employee \"%s\" has no contract Please create contract to add line to "
"advantages"
msgstr ""
#. module: hr_training_payment
#: model:ir.model,name:hr_training_payment.model_hr_official_mission
msgid "Official mission"
msgstr ""
#. module: hr_training_payment
#: model:ir.model.fields,field_description:hr_training_payment.field_hr_official_mission_type__pr_product_id
msgid "PR Product"
msgstr "منتج طلب الشراء"
#. module: hr_training_payment
#: model:ir.model.fields,field_description:hr_training_payment.field_hr_official_mission__purchase_request_id
msgid "Purchase Request"
msgstr "طلب الشراء"
#. module: hr_training_payment
#: code:addons/hr_training_payment/models/hr_official_mission.py:0
#, python-format
msgid "You do not have account or journal in mission type \"%s\" "
msgstr ""
#. module: hr_training_payment
#: model:ir.model,name:hr_training_payment.model_hr_official_mission_type
msgid "hr.official.mission.type"
msgstr ""
#. module: hr_training_payment
#: code:addons/hr_training_payment/models/hr_official_mission.py:0
#, python-format
msgid "You must Enter Purchase Product in Training Type Configuration"
msgstr "يجب ادخال منتج طلب الشراء في إعداد نوع المهام"
#. module: hr_training_payment
#: code:addons/hr_training_payment/models/hr_official_mission.py:0
#, python-format
msgid "Training Cost Must be Bigger than Zero"
msgstr "تكلفة مركز التدريب يجب ان تكون اكبر من صفر"

View File

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from . import hr_official_mission
from . import mission_type

View File

@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, exceptions,_
from datetime import datetime, date, timedelta
from odoo.exceptions import ValidationError
import calendar
class HrOfficialMission(models.Model):
_inherit = 'hr.official.mission'
purchase_request_id = fields.Many2one(comodel_name='purchase.request', string="Purchase Request")
def approve(self):
# check if there is dealing with financial
if self.mission_type.work_state == 'training':
if self.Training_cost > 0.0:
self.employee_ids.chick_not_overtime()
if not self.mission_type.pr_product_id.id:
raise ValidationError(_("You must Enter Purchase Product in Training Type Configuration"))
product_line = {
'product_id': self.mission_type.pr_product_id.id,
'qty': 1,
'expected_price': self.Training_cost,
}
purchase_request = self.env['purchase.request'].create({
'state': 'draft',
'department_id': self.department_id2.id,
'date': date.today(),
'employee_id': self.employee_id.id,
'partner_id': self.partner_id.id,
'product_category_ids': [(4, self.mission_type.pr_product_id.categ_id.id)],
'purchase_purpose': self.training_details,
'line_ids': [(0, 0, product_line)]
})
self.purchase_request_id = purchase_request.id
self.state = "approve"
if self.mission_type.work_state and self.mission_type.duration_type == 'days':
for emp in self.employee_ids:
if emp.date_to >= fields.Date.today() >= emp.date_from:
emp.employee_id.write(
{'work_state': self.mission_type.work_state, 'active_mission_id': emp.id})
self.call_cron_function()
else:
raise exceptions.Warning(_('Training Cost Must be Bigger than Zero'))
else:
res = super(HrOfficialMission, self).approve()
return res
def draft_state(self):
res = super(HrOfficialMission, self).draft_state()
if self.purchase_request_id:
self.purchase_request_id.sudo().unlink()
return res

View File

@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class HrOfficialMissionType(models.Model):
_inherit = 'hr.official.mission.type'
pr_product_id = fields.Many2one(comodel_name='product.product', string="PR Product")

View File

@ -0,0 +1,23 @@
<?xml version="1.0" ?>
<odoo>
<data>
<record id="hr_official_mission_view_form" model="ir.ui.view">
<field name="name">hr.official.mission.view.form</field>
<field name="model">hr.official.mission</field>
<field name="inherit_id" ref="exp_official_mission.employee_training_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="purchase_request_id" attrs="{'invisible':[('purchase_request_id','=',False)]}" readonly="1"/>
</xpath>
<xpath expr="//field[@name='training_details']" position="attributes">
<attribute name="required">True</attribute>
</xpath>
</field>
</record>
</data>
</odoo>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" ?>
<odoo>
<data>
<record id="hr_official_mission_type_view_form" model="ir.ui.view">
<field name="name">hr.official.mission.type.view.form</field>
<field name="model">hr.official.mission.type</field>
<field name="inherit_id" ref="exp_official_mission.employee_official_mission_type_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='work_state']" position="after">
<field name="pr_product_id" attrs="{'invisible':[('work_state','!=','training')],'required':[('work_state','=','training')]}"/>
</xpath>
</field>
</record>
</data>
</odoo>