new module hr_training_payment + training module notes
This commit is contained in:
parent
daa9122131
commit
3f9b54384a
|
|
@ -0,0 +1,3 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (branches)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/odex25_hr.iml" filepath="$PROJECT_DIR$/.idea/odex25_hr.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.8 (branches)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
<option name="format" value="PLAIN" />
|
||||
<option name="myDocStringFormat" value="Plain" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -128,25 +128,15 @@ class HrOfficialMission(models.Model):
|
|||
rec.attachment_count = attachment.search_count([('res_model', '=', self._name), ('res_id', '=', rec.id)])
|
||||
|
||||
def action_get_attachment_view(self):
|
||||
domain = ['&', ('res_model', '=', self._name), ('res_id', 'in', self.ids)]
|
||||
res_id = self.ids and self.ids[0] or False
|
||||
return {
|
||||
'name': _('Attachments'),
|
||||
'domain': domain,
|
||||
'res_model': 'ir.attachment',
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_id': False,
|
||||
'view_mode': 'kanban,tree,form',
|
||||
'view_type': 'form',
|
||||
'help': _('''<p class="oe_view_nocontent_create">
|
||||
|
||||
Attach
|
||||
documents of %s .</p>''' % (self._description)),
|
||||
'limit': 80,
|
||||
'context': "{'default_res_model': '%s','default_res_id': %d}"
|
||||
% (self._name, res_id)
|
||||
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.employee_ids.ids)]
|
||||
res['context'] = {
|
||||
'default_res_model': 'hr.official.mission.employee',
|
||||
'default_res_id': self.id,
|
||||
'create': False,
|
||||
'edit': False,
|
||||
}
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def get_user_id(self):
|
||||
|
|
@ -670,6 +660,8 @@ class OfficialMissionAttach(models.Model):
|
|||
_inherit = 'ir.attachment'
|
||||
|
||||
mission_id = fields.Many2one(comodel_name='hr.official.mission')
|
||||
# employee_mission_id = fields.Many2one(comodel_name='hr.official.mission.employee')
|
||||
|
||||
|
||||
|
||||
class EmployeeCourseName(models.Model):
|
||||
|
|
|
|||
|
|
@ -99,8 +99,7 @@
|
|||
</group>
|
||||
</group>
|
||||
<group string="Mission Purpose">
|
||||
<field name="mission_purpose" nolabel="1"
|
||||
attrs="{'readonly':[('state','!=','draft')]}" required="1"/>
|
||||
<field name="mission_purpose" nolabel="1" required="1"/>
|
||||
<field name="appraisal_check" invisible="1"/>
|
||||
</group>
|
||||
<notebook>
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
<data>
|
||||
|
||||
<menuitem name="Training" id="hr_employee_training_main_menu"
|
||||
parent="hr.menu_hr_root" sequence="3"
|
||||
groups="group_hr_training_user"/>
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from . import models
|
||||
|
|
@ -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",
|
||||
|
||||
],
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
# 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 ""
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import hr_official_mission
|
||||
from . import mission_type
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields, api, exceptions
|
||||
from datetime import datetime, date, timedelta
|
||||
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
|
||||
self.employee_ids.chick_not_overtime()
|
||||
if self.mission_type.work_state == 'training':
|
||||
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.mission_purpose,
|
||||
'line_ids': [(0, 0, product_line)]
|
||||
})
|
||||
|
||||
self.purchase_request_id = purchase_request.id
|
||||
else:
|
||||
|
||||
if self.employee_ids and self.mission_type.related_with_financial:
|
||||
# move amounts to journal entries
|
||||
if self.move_type == 'accounting':
|
||||
if self.mission_type.account_id and self.mission_type.journal_id:
|
||||
for item in self.employee_ids:
|
||||
if item.amount > 0.0:
|
||||
debit_line_vals = {
|
||||
'name': item.employee_id.name + ' in official mission "%s" ' % self.mission_type.name,
|
||||
'debit': item.amount,
|
||||
'account_id': self.mission_type.account_id.id,
|
||||
'partner_id': item.employee_id.user_id.partner_id.id
|
||||
}
|
||||
credit_line_vals = {
|
||||
'name': item.employee_id.name + ' in official mission "%s" ' % self.mission_type.name,
|
||||
'credit': item.amount,
|
||||
'account_id': self.mission_type.journal_id.default_account_id.id,
|
||||
'partner_id': item.employee_id.user_id.partner_id.id
|
||||
}
|
||||
move = self.env['account.move'].create({
|
||||
'state': 'draft',
|
||||
'journal_id': self.mission_type.journal_id.id,
|
||||
'date': date.today(),
|
||||
'ref': 'Official mission for employee "%s" ' % item.employee_id.name,
|
||||
'line_ids': [(0, 0, debit_line_vals), (0, 0, credit_line_vals)]
|
||||
})
|
||||
# fill account move for each employee
|
||||
item.write({'account_move_id': move.id})
|
||||
else:
|
||||
raise exceptions.Warning(
|
||||
_('You do not have account or journal in mission type "%s" ') % self.mission_type.name)
|
||||
|
||||
# move amounts to advantages of employee in contract
|
||||
elif self.move_type == 'payroll':
|
||||
# get start and end date of the current month
|
||||
current_date = date.today()
|
||||
month_start = date(current_date.year, current_date.month, 1)
|
||||
month_end = date(current_date.year, current_date.month, calendar.mdays[current_date.month])
|
||||
for line in self.employee_ids:
|
||||
if line.employee_id.contract_id:
|
||||
|
||||
advantage_arc = line.env['contract.advantage'].create({
|
||||
'benefits_discounts': self.official_mission.id,
|
||||
'date_from': month_start,
|
||||
'date_to': month_end,
|
||||
'amount': line.amount,
|
||||
'official_mission_id': True,
|
||||
'employee_id': line.employee_id.id,
|
||||
'contract_advantage_id': line.employee_id.contract_id.id,
|
||||
'out_rule': True,
|
||||
'state': 'confirm',
|
||||
'comments': self.mission_purpose})
|
||||
line.advantage_id = advantage_arc.id
|
||||
|
||||
print(advantage_arc,"the type is payroll advantage created>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
|
||||
else:
|
||||
raise exceptions.Warning(_(
|
||||
'Employee "%s" has no contract Please create contract to add line to advantages')
|
||||
% line.employee_id.name)
|
||||
|
||||
for item in self:
|
||||
# create ticket request from all employee
|
||||
if item.issuing_ticket == 'yes':
|
||||
for emp in item.employee_ids:
|
||||
ticket = self.env['hr.ticket.request'].create({
|
||||
'employee_id': emp.employee_id.id,
|
||||
'mission_request_id': item.id,
|
||||
'mission_check': True,
|
||||
'request_for': item.ticket_cash_request_for,
|
||||
'request_type': item.ticket_cash_request_type.id,
|
||||
'cost_of_tickets': item.get_ticket_cost(emp.employee_id),
|
||||
'destination': item.destination.id,
|
||||
})
|
||||
item.write({'ticket_request_id': ticket.id})
|
||||
|
||||
# move invoice training cost our trining center
|
||||
if item.Training_cost > 0:
|
||||
invoice_line_vals = {
|
||||
'name': 'Training Cost for Course Name %s Training Center %s' % (
|
||||
item.course_name.name, item.partner_id.name),
|
||||
'price_unit': item.Training_cost,
|
||||
# 'account_id': self.mission_type.journal_id.default_credit_account_id.id,
|
||||
'account_id': item.partner_id.property_account_payable_id.id,
|
||||
# 'partner_id': item.employee_id.user_id.partner_id.id
|
||||
}
|
||||
invoice = self.env['account.move'].create({
|
||||
'state': 'draft',
|
||||
'move_type': 'in_invoice',
|
||||
'journal_id': item.mission_type.journal_id.id,
|
||||
'partner_id': item.partner_id.id,
|
||||
'invoice_date': date.today(),
|
||||
'ref': 'Training Cost for Course Name %s ' % item.course_name.name,
|
||||
'invoice_line_ids': [(0, 0, invoice_line_vals)]
|
||||
})
|
||||
item.write({'Tra_cost_invo_id': invoice.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()
|
||||
|
||||
|
||||
|
|
@ -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")
|
||||
|
||||
|
|
@ -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='mission_purpose']" position="attributes">
|
||||
<attribute name="required">True</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -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')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
Loading…
Reference in New Issue