fix issues

This commit is contained in:
raman 2025-03-21 10:56:43 +05:30
parent a64fdf9a43
commit cabb3c85a1
5 changed files with 67 additions and 15 deletions

View File

@ -1 +1,2 @@
from . import models,wizards
from . import models
from . import wizards

View File

@ -18,7 +18,7 @@
'version': '0.1',
# 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
'data': [

View File

@ -3,6 +3,8 @@
from odoo import _, api, fields, models
from dateutil.relativedelta import relativedelta
from odoo.exceptions import ValidationError
from datetime import datetime, timedelta
from calendar import monthrange
class HrEmployeeBase(models.AbstractModel):
@ -47,10 +49,41 @@ class HrEmployeeBase(models.AbstractModel):
current_date = fields.Date.today()
# 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'
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
else:
record.current_company_exp = '0 years 0 months 0 days'

View File

@ -119,11 +119,11 @@
parent="menu_hr_payroll_payslips"/>
<!-- **** Reporting **** -->
<menuitem id="menu_report_payroll"
name="Payroll"
action="ir_actions_server_action_open_reporting"
sequence="10"
parent="menu_hr_payroll_report"/>
<!-- <menuitem id="menu_report_payroll"-->
<!-- name="Payroll"-->
<!-- action="ir_actions_server_action_open_reporting"-->
<!-- sequence="10"-->
<!-- parent="menu_hr_payroll_report"/>-->
<menuitem
id="menu_hr_payroll_headcount_action"
@ -132,12 +132,12 @@
sequence="11"
parent="menu_hr_payroll_report"/>
<menuitem
id="menu_hr_work_entry_report"
name="Work Entry Analysis"
action="hr_work_entry_report_action"
sequence="20"
parent="menu_hr_payroll_report"/>
<!-- <menuitem-->
<!-- id="menu_hr_work_entry_report"-->
<!-- name="Work Entry Analysis"-->
<!-- action="hr_work_entry_report_action"-->
<!-- sequence="20"-->
<!-- parent="menu_hr_payroll_report"/>-->
<!-- **** Configuration **** -->

View File

@ -462,6 +462,24 @@ class BiometricDeviceDetails(models.Model):
raise UserError(_(
"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):
"""Function to get all user's details"""
for info in self: