fix issues
This commit is contained in:
parent
38080d56c0
commit
2342ded3ff
|
|
@ -1 +1,2 @@
|
||||||
from . import models,wizards
|
from . import models
|
||||||
|
from . import wizards
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
'version': '0.1',
|
'version': '0.1',
|
||||||
|
|
||||||
# any module necessary for this one to work correctly
|
# any module necessary for this one to work correctly
|
||||||
'depends': ['base','hr','account','mail','hr_skills'],
|
'depends': ['base','hr','account','mail','hr_skills', 'hr_contract'],
|
||||||
|
|
||||||
# always loaded
|
# always loaded
|
||||||
'data': [
|
'data': [
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
from calendar import monthrange
|
||||||
|
|
||||||
|
|
||||||
class HrEmployeeBase(models.AbstractModel):
|
class HrEmployeeBase(models.AbstractModel):
|
||||||
|
|
@ -47,10 +49,41 @@ class HrEmployeeBase(models.AbstractModel):
|
||||||
current_date = fields.Date.today()
|
current_date = fields.Date.today()
|
||||||
|
|
||||||
# Calculate the difference between current date and doj
|
# Calculate the difference between current date and doj
|
||||||
delta = relativedelta(current_date, record.doj)
|
|
||||||
|
def calculate_experience(joined_date, current_date):
|
||||||
|
# Start by calculating the difference in years and months
|
||||||
|
delta_years = current_date.year - joined_date.year
|
||||||
|
delta_months = current_date.month - joined_date.month
|
||||||
|
delta_days = current_date.day - joined_date.day
|
||||||
|
|
||||||
|
# Adjust months and years if necessary
|
||||||
|
if delta_months < 0:
|
||||||
|
delta_years -= 1
|
||||||
|
delta_months += 12
|
||||||
|
|
||||||
|
# Handle day adjustment if necessary (i.e., current day is less than the joined day)
|
||||||
|
if delta_days < 0:
|
||||||
|
# Subtract one month to adjust
|
||||||
|
delta_months -= 1
|
||||||
|
# Get the number of days in the previous month to add to the days
|
||||||
|
if current_date.month == 1:
|
||||||
|
days_in_last_month = monthrange(current_date.year - 1, 12)[1]
|
||||||
|
else:
|
||||||
|
days_in_last_month = monthrange(current_date.year, current_date.month - 1)[1]
|
||||||
|
delta_days += days_in_last_month
|
||||||
|
|
||||||
|
# Final adjustment: if months become negative after adjusting days, fix that
|
||||||
|
if delta_months < 0:
|
||||||
|
delta_years -= 1
|
||||||
|
delta_months += 12
|
||||||
|
|
||||||
|
return delta_years, delta_months, delta_days
|
||||||
|
|
||||||
|
# Calculate the experience
|
||||||
|
years, months, days = calculate_experience(record.doj, current_date)
|
||||||
|
|
||||||
# Format the experience as 'X years Y months Z days'
|
# Format the experience as 'X years Y months Z days'
|
||||||
experience_str = f"{delta.years} years {delta.months} months {delta.days} days"
|
experience_str = f"{years} years {months} months {days} days"
|
||||||
record.current_company_exp = experience_str
|
record.current_company_exp = experience_str
|
||||||
else:
|
else:
|
||||||
record.current_company_exp = '0 years 0 months 0 days'
|
record.current_company_exp = '0 years 0 months 0 days'
|
||||||
|
|
|
||||||
|
|
@ -119,11 +119,11 @@
|
||||||
parent="menu_hr_payroll_payslips"/>
|
parent="menu_hr_payroll_payslips"/>
|
||||||
|
|
||||||
<!-- **** Reporting **** -->
|
<!-- **** Reporting **** -->
|
||||||
<menuitem id="menu_report_payroll"
|
<!-- <menuitem id="menu_report_payroll"-->
|
||||||
name="Payroll"
|
<!-- name="Payroll"-->
|
||||||
action="ir_actions_server_action_open_reporting"
|
<!-- action="ir_actions_server_action_open_reporting"-->
|
||||||
sequence="10"
|
<!-- sequence="10"-->
|
||||||
parent="menu_hr_payroll_report"/>
|
<!-- parent="menu_hr_payroll_report"/>-->
|
||||||
|
|
||||||
<menuitem
|
<menuitem
|
||||||
id="menu_hr_payroll_headcount_action"
|
id="menu_hr_payroll_headcount_action"
|
||||||
|
|
@ -132,12 +132,12 @@
|
||||||
sequence="11"
|
sequence="11"
|
||||||
parent="menu_hr_payroll_report"/>
|
parent="menu_hr_payroll_report"/>
|
||||||
|
|
||||||
<menuitem
|
<!-- <menuitem-->
|
||||||
id="menu_hr_work_entry_report"
|
<!-- id="menu_hr_work_entry_report"-->
|
||||||
name="Work Entry Analysis"
|
<!-- name="Work Entry Analysis"-->
|
||||||
action="hr_work_entry_report_action"
|
<!-- action="hr_work_entry_report_action"-->
|
||||||
sequence="20"
|
<!-- sequence="20"-->
|
||||||
parent="menu_hr_payroll_report"/>
|
<!-- parent="menu_hr_payroll_report"/>-->
|
||||||
|
|
||||||
<!-- **** Configuration **** -->
|
<!-- **** Configuration **** -->
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -462,6 +462,24 @@ class BiometricDeviceDetails(models.Model):
|
||||||
raise UserError(_(
|
raise UserError(_(
|
||||||
"Please Check the Connection"))
|
"Please Check the Connection"))
|
||||||
|
|
||||||
|
def button_door_unlock(self):
|
||||||
|
for info in self:
|
||||||
|
machine_ip = info.device_ip
|
||||||
|
zk_port = info.port_number
|
||||||
|
try:
|
||||||
|
# Connecting with the device with the ip and port provided
|
||||||
|
zk = ZK(machine_ip, port=zk_port, timeout=15,
|
||||||
|
password=self.device_password,
|
||||||
|
force_udp=False, ommit_ping=False)
|
||||||
|
except NameError:
|
||||||
|
raise UserError(
|
||||||
|
_("Pyzk module not Found. Please install it"
|
||||||
|
"with 'pip3 install pyzk'."))
|
||||||
|
conn = self.device_connect(zk)
|
||||||
|
if conn:
|
||||||
|
conn.unlock()
|
||||||
|
|
||||||
|
|
||||||
def get_all_users(self):
|
def get_all_users(self):
|
||||||
"""Function to get all user's details"""
|
"""Function to get all user's details"""
|
||||||
for info in self:
|
for info in self:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue