Compare commits

..

88 Commits

Author SHA1 Message Date
pranaysaidurga 1696e0ded1 recruitment multi company issues 2026-07-03 12:17:14 +05:30
seshikanth ea58c69ed8 #fix:PERformancemanagement 2026-07-03 10:54:28 +05:30
pranaysaidurga 5e617d3ff8 payroll changes 2026-07-01 17:22:14 +05:30
seshikanth 625bd67064 #fix:HRMSdashboard 2026-06-30 16:17:45 +05:30
seshikanth 3de90ee7ce #fix:Payrollstatement 2026-06-30 12:24:02 +05:30
seshikanth 257e05cc34 #fix:payrolland leave 2026-06-29 12:48:07 +05:30
Bhagya-K 80e90ca88a Merge remote-tracking branch 'origin/feature/share_module' into feature/share_module 2026-06-29 11:50:43 +05:30
Bhagya-K a1320afd5b DEV: Probation Tracking 2026-06-29 11:50:02 +05:30
pranaysaidurga cf0b469b21 recruitment mail issue fix 2026-06-26 17:52:45 +05:30
pranaysaidurga 1b34ae2c5c recruitment bug fixes 2026-06-26 17:26:33 +05:30
pranaysaidurga 08569e0ae0 recruitment fixes 2026-06-25 17:05:21 +05:30
pranaysaidurga 77827a188f payroll fixes 2026-06-25 13:22:45 +05:30
pranaysaidurga aecdbab7c2 helpdesk issue 2026-06-25 13:13:45 +05:30
seshikanth f40d78f5dc #fix:Discplinary few HRMS bugs 2026-06-24 15:33:37 +05:30
seshikanth 3ff97c7c8a #fix: Employee Performance Management Module and few HRMS bugs 2026-06-24 15:23:48 +05:30
seshikanth adc4733e15 #fix: Employee Performance Management Module and few HRMS bugs 2026-06-24 12:20:06 +05:30
Bhagya-K a8570dea30 DEV: Probation Tracking 2026-06-22 15:04:56 +05:30
Bhagya-K 7f8a627a8c DEV: Probation Tracking 2026-06-22 15:02:55 +05:30
Bhagya-K 19669a7a3a Merge remote-tracking branch 'origin/feature/share_module' into feature/share_module 2026-06-22 15:01:22 +05:30
Bhagya-K d448713449 DEV: Probation Tracking 2026-06-22 15:01:12 +05:30
pranaysaidurga a9a9f08ff9 recritment bug fixes 2026-06-19 14:05:09 +05:30
pranaysaidurga 7960d1926b recruitment bug fixes 2026-06-17 15:51:56 +05:30
Bhagya-K e2c8a25c7b DEV: Probation Tracking 2026-06-16 17:05:42 +05:30
Bhagya-K 9ce8c135d0 Merge remote-tracking branch 'origin/feature/share_module' into feature/share_module 2026-06-15 10:59:53 +05:30
Bhagya-K 8877a4ebc4 DEV: Sequence genartion for Employee Code 2026-06-15 10:59:42 +05:30
pranaysaidurga 12ec001b38 business travel expenses 2026-06-12 15:00:28 +05:30
pranaysaidurga 064bd90c58 ALL updates regrading the hrms, ats and pmt 2026-06-12 12:17:49 +05:30
raman 29af1ebf29 Merge pull request 'docker files added' (#3) from feature/odoo18_docker into feature/share_module
Reviewed-on: https://gitea.ftprotech.in/administrator/odoo18/pulls/3
2026-06-10 17:35:22 +05:30
Deepak 41f493840b docker files added 2026-06-10 16:53:14 +05:30
Bhagya-K 54541998c5 Merge remote-tracking branch 'origin/feature/share_module' into feature/share_module 2026-06-10 12:00:05 +05:30
Bhagya-K 68e62956b7 resolved installation issue of grace period module 2026-06-10 11:59:42 +05:30
seshikanth 14e725be4f #fix: Employee Performance Management Module 2026-06-09 13:31:02 +05:30
Bhagya-K adfe801d8e Roster management and grace period changes 2026-06-08 17:01:09 +05:30
Bhagya-K 5c6341d8b7 Merge remote-tracking branch 'origin/feature/share_module' into feature/share_module
# Conflicts:
#	addons_extensions/grace_period/models/__init__.py
2026-06-08 16:33:01 +05:30
Bhagya-K 71f416e8e8 grace Period 2026-06-08 16:30:00 +05:30
pranaysaidurga b5f643fb18 attendance, leaves, weekly timesheets enhancements 2026-06-05 16:42:23 +05:30
karuna 3092032fee enhancements of PMT 2026-06-05 15:16:49 +05:30
karuna f118600ab6 enhancements of PMT 2026-06-04 15:36:32 +05:30
karuna 05bdddc472 enhancements of PMT 2026-06-04 11:06:43 +05:30
pranaysaidurga 582225e11e employee issue 2026-06-04 10:51:17 +05:30
pranaysaidurga 478c1708fb Auto doc get default recruitment 2026-06-04 10:43:54 +05:30
pranaysaidurga 945aedc0b4 Recruitement Dashboards 2026-06-03 14:23:00 +05:30
pranaysaidurga eb17d717dd Project Changes 2026-06-03 10:55:50 +05:30
pranaysaidurga 604d556501 Recruitment changes 2026-06-03 10:48:17 +05:30
karuna 90211776a1 small enhancements 2026-05-28 12:20:45 +05:30
karuna 923304f759 project enhancements 2026-05-26 15:03:48 +05:30
pranaysaidurga 96493be796 Leaves Timesheets Management 2026-05-25 16:38:40 +05:30
pranaysaidurga 5460f6c207 Employee it declaration 2026-05-25 16:10:45 +05:30
pranaysaidurga 4db7e5ade2 Document parser upload 2026-05-20 18:59:16 +05:30
pranaysaidurga f2788e025d bench management system changes 2026-05-19 16:10:05 +05:30
pranaysaidurga 0e51ac85e9 user_ids in project tasks bug 2026-05-19 13:48:45 +05:30
pranaysaidurga 19e5f1db80 Project, recruitment, payroll, bench management changes and updates 2026-05-19 13:36:24 +05:30
karuna c2e33753bb project modifications 2026-05-19 12:08:41 +05:30
pranaysaidurga f6bfd46f2c my tasks issue fix 2026-05-14 12:23:28 +05:30
pranaysaidurga c9746456b8 equipment extended 2026-05-13 11:28:50 +05:30
pranaysaidurga b0ec5ee508 Menu Control Center Functionality change 2026-05-12 11:37:01 +05:30
pranaysaidurga e2d6a8c417 user own estimations 2026-05-07 14:14:41 +05:30
pranaysaidurga 9c33507a45 multi company changes 2026-05-06 18:17:04 +05:30
pranaysaidurga a9a6c683d7 new timeline feature and bug fixes 2026-05-06 17:26:15 +05:30
pranaysaidurga 723dcbe225 portfolio company rules 2026-05-06 11:51:28 +05:30
pranaysaidurga 4139e5fa33 company_id constrain fix 2026-05-06 10:56:13 +05:30
pranaysaidurga ce93d9601c project updates and changes 2026-05-05 11:55:32 +05:30
pranaysaidurga 1b21175e75 accounting kit 2026-05-04 10:56:10 +05:30
pranaysaidurga 74526cc1a2 project task issue fix and changes 2026-04-27 16:14:25 +05:30
pranaysaidurga 6a32ac3f37 project task creation issue 2026-04-27 15:27:27 +05:30
pranaysaidurga fa3833bac3 Project Employee view 2026-04-27 12:37:57 +05:30
pranay 73a27d8921 master selector fix 2026-04-14 11:45:11 +05:30
pranay 26923e20b9 bug fix 2026-04-13 18:21:55 +05:30
karuna ff806505e2 PMT bug fix 2026-04-13 17:56:48 +05:30
karuna b5b276f552 Module Master Selector 2026-03-10 10:45:00 +05:30
Pranay 5d6c2c09aa list view scrolling issue 2026-02-05 12:23:55 +05:30
Pranay 4b85cc0f59 Recruitment changes, Menu Contral Center xml change, attachment preview changes 2026-02-04 11:57:31 +05:30
Pranay ad5967d420 ica web responsive theme 2025-12-24 17:50:22 +05:30
Pranay 53f90a7834 packages list 2025-12-24 17:29:23 +05:30
Pranay 87824199d0 project management system Commit 2025-12-24 12:50:57 +05:30
karuna 92543295d6 adding page visibility based on stages 2025-12-15 18:07:11 +05:30
Pranay 7b6d108ace one2many search widget and project task module updates 2025-12-15 11:25:18 +05:30
Pranay 6f77059f85 PMT, UNIVERSAL ATTACHMENT PREVIEW, MENU CONTROL CENTER INTEGRATION 2025-12-10 10:09:23 +05:30
Pranay c93d208990 Document Preview 2025-12-03 10:19:21 +05:30
Pranay bfd7890cbc Documents preview, binary field widget, menu control center changes 2025-12-03 10:16:19 +05:30
karuna d362ef87aa kudos changes commit 2025-12-03 10:11:32 +05:30
Pranay 20d22c1f04 Project timesheet updates 2025-11-25 16:45:09 +05:30
pranay 44e5ee7e2f ALL MODULE CHANGES 2025-11-20 10:11:59 +05:30
pranay 0fa84c6d43 PMS Updates 2025-11-20 10:06:10 +05:30
karuna 4ce02e58fa Rewards Module for PMS 2025-11-13 12:43:31 +05:30
pranay 66077d1819 Project Task Extended Changes 2025-11-13 12:36:54 +05:30
karuna 2dbdb58127 internal team model update 2025-11-10 10:14:09 +05:30
pranay 5f267e96da PROJECT MODULE AND THEME ADDED IN SHARED MODULES 2025-11-04 11:57:04 +05:30
3125 changed files with 1432737 additions and 1292270 deletions

54
Dockerfile Normal file
View File

@ -0,0 +1,54 @@
FROM python:3.12-bookworm
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# System dependencies
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
g++ \
git \
curl \
npm \
libpq-dev \
libldap2-dev \
libsasl2-dev \
libxml2-dev \
libxslt1-dev \
libjpeg62-turbo-dev \
zlib1g-dev \
libffi-dev \
libssl-dev \
liblcms2-dev \
wkhtmltopdf \
&& rm -rf /var/lib/apt/lists/*
# Less compiler used by Odoo
RUN npm install -g less less-plugin-clean-css
# Create odoo user
RUN useradd -m -d /opt/odoo -U -r -s /bin/bash odoo
WORKDIR /opt/odoo/odoo18
# Copy project
COPY . .
# Upgrade pip tools
RUN pip install --upgrade pip setuptools wheel
# Install requirements
RUN pip install --no-cache-dir -r requirements.txt
# PostgreSQL driver
RUN pip install psycopg2-binary
# Permissions
RUN chown -R odoo:odoo /opt/odoo
USER odoo
EXPOSE 8069
CMD ["python3", "odoo-bin", "-c", "odoo.conf"]

View File

@ -6,7 +6,7 @@
'version': '1.0', 'version': '1.0',
'category': 'Accounting/Localizations/Point of Sale', 'category': 'Accounting/Localizations/Point of Sale',
'description': """ 'description': """
This add-on brings the technical requirements of the French regulation CGI art. 286, I. 3° bis that stipulates certain criteria concerning the inalterability, security, storage and archiving of data related to sales to private individuals (B2C). This add-on brings the technical requirements of the French regulation CGI art. 286, I. 3° bis that stipulates certain criteria concerning the inalterability,security, storage and archiving of data related to sales to private individuals (B2C).
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Install it if you use the Point of Sale app to sell to individuals. Install it if you use the Point of Sale app to sell to individuals.

View File

@ -24,7 +24,7 @@
}, },
'installable': True, 'installable': True,
'data': [ 'data': [
# security.xml first, data.xml need the group to exist (checking it) #security.xml first, data.xml need the group to exist (checking it)
'security/website_security.xml', 'security/website_security.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'data/image_library.xml', 'data/image_library.xml',

View File

@ -0,0 +1 @@
from . import models

View File

@ -0,0 +1,24 @@
{
'name': 'Bench Management',
'version': '1.0',
'category': 'Human Resources',
'summary': 'Bench Management System',
'author': 'Team Srivyn',
'depends': [
'hr',
'project',
'hr_timesheet',
'project_task_timesheet_extended',
'hr_employee_extended'
],
'data': [
'security/ir.model.access.csv',
'data/sync_team_lines.xml',
'views/project.xml',
'views/bench_management_view.xml',
],
'installable': True,
'application': True,
'auto_install': False,
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<function model="project.project" name="_sync_all_team_lines_from_members"/>
</odoo>

View File

@ -0,0 +1,2 @@
from . import project
from . import bench_management

View File

@ -0,0 +1,174 @@
from odoo import models, fields, tools, api
class BenchManagementLine(models.Model):
_name = "bench.management.line"
_description = "Employee Availability (Bench)"
_auto = False
_rec_name = 'employee_id'
employee_id = fields.Many2one("hr.employee", readonly=True)
job_id = fields.Many2one("hr.job", readonly=True)
company_id = fields.Many2one("res.company", related="employee_id.company_id")
project_line_ids = fields.Many2many(
'project.team.line',
compute='_compute_bench_details',
string='Project Assignments',
readonly=True,
)
limited_project_line_ids = fields.Many2many(
compute='_compute_bench_details',
comodel_name='project.team.line',
string='Kanban Projects',
readonly=True,
)
project_names_tooltip = fields.Text(
string="Project Names",
compute='_compute_bench_details',
readonly=True,
)
project_count = fields.Integer(
string="Project Count",
compute='_compute_bench_details',
readonly=True,
)
active_project_count = fields.Integer(
string="Active Projects",
compute='_compute_bench_details',
readonly=True,
)
future_project_count = fields.Integer(
string="Upcoming Projects",
compute='_compute_bench_details',
readonly=True,
)
completed_project_count = fields.Integer(
string="Completed Projects",
compute='_compute_bench_details',
readonly=True,
)
status = fields.Selection([
("bench", "Bench"),
("partial", "Partial"),
("full", "Full"),
], readonly=True)
def _get_line_availability_status(self, line, today):
return line.status or 'not_started'
def _compute_bench_details(self):
project_team_line = self.env['project.team.line'].sudo()
today = fields.Date.context_today(self)
for rec in self:
project_lines = project_team_line.search(
[('employee_id', '=', rec.employee_id.id)],
order='start_date desc, id desc'
)
active_lines = project_lines.filtered(
lambda line: rec._get_line_availability_status(line, today) == 'in_progress'
)
future_lines = project_lines.filtered(
lambda line: rec._get_line_availability_status(line, today) == 'not_started'
)
completed_lines = project_lines.filtered(
lambda line: rec._get_line_availability_status(line, today) == 'done'
)
project_records = project_lines.mapped('project_id')
if active_lines:
bench_status = 'full'
elif future_lines:
bench_status = 'partial'
else:
bench_status = 'bench'
rec.project_line_ids = project_lines
rec.limited_project_line_ids = project_lines[:3]
rec.project_count = len(project_records)
rec.active_project_count = len(active_lines)
rec.future_project_count = len(future_lines)
rec.completed_project_count = len(completed_lines)
rec.project_names_tooltip = '\n'.join(
f"{line.project_id.display_name or 'No Project'} - {dict(line._fields['status'].selection).get(rec._get_line_availability_status(line, today), 'N/A')}"
for line in project_lines
) or ''
def init(self):
tools.drop_view_if_exists(self.env.cr, self._table)
self.env.cr.execute("""
CREATE OR REPLACE VIEW bench_management_line AS (
SELECT
he.id AS id,
he.id AS employee_id,
he.job_id AS job_id,
CASE
WHEN EXISTS (
SELECT 1
FROM project_team_line tpl
WHERE tpl.employee_id = he.id
AND tpl.status = 'in_progress'
) THEN 'full'
WHEN EXISTS (
SELECT 1
FROM project_team_line tpl
WHERE tpl.employee_id = he.id
AND tpl.status = 'not_started'
) THEN 'partial'
ELSE 'bench'
END AS status
FROM hr_employee he
)
""")
class ProjectTeamLine(models.Model):
_inherit = 'project.team.line'
line_status_color = fields.Integer(
compute='_compute_line_status_color',
string='Status Color',
readonly=True,
)
@api.depends('status')
def _compute_line_status_color(self):
color_map = {
'not_started': 8,
'in_progress': 2,
'done': 10,
}
for line in self:
line.line_status_color = color_map.get(line.status, 0)
def name_get(self):
result = []
for rec in self:
name = rec.project_id.display_name or 'No Project'
result.append((rec.id, name))
return result
def _sync_project_members(self):
if self.env.context.get('skip_project_team_member_sync'):
return True
self.mapped('project_id')._sync_members_from_team_lines()
return True
@api.model_create_multi
def create(self, vals_list):
records = super().create(vals_list)
records._sync_project_members()
return records
def write(self, vals):
projects = self.mapped('project_id')
res = super().write(vals)
(projects | self.mapped('project_id'))._sync_members_from_team_lines()
return res
def unlink(self):
projects = self.mapped('project_id')
res = super().unlink()
projects._sync_members_from_team_lines()
return res

View File

@ -0,0 +1,223 @@
from odoo import Command, api, fields, models, _
from odoo.exceptions import ValidationError
class ProjectProject(models.Model):
_inherit = 'project.project'
team_line_ids = fields.One2many(
'project.team.line',
'project_id',
string="Team Details"
)
can_manage_team_lines = fields.Boolean(
compute='_compute_can_manage_team_lines',
string='Can Manage Team Lines'
)
@api.depends('user_id', 'project_lead')
def _compute_can_manage_team_lines(self):
current_user = self.env.user
for project in self:
project.can_manage_team_lines = bool(
self.env.is_superuser()
or project.user_id == current_user
or ('project_lead' in project._fields and project.project_lead == current_user) or (current_user.has_group("project.group_project_manager"))
)
@api.onchange('team_line_ids')
def _onchange_team_line_ids(self):
for project in self:
users = project.team_line_ids.mapped('user_id')
project.members_ids = [(6, 0, users.ids)]
def _sync_members_from_team_lines(self):
if self.env.context.get('skip_project_team_member_sync'):
return
for project in self:
users = project.team_line_ids.mapped('user_id')
if set(project.members_ids.ids) != set(users.ids):
project.with_context(skip_project_team_member_sync=True).sudo().write({
'members_ids': [Command.set(users.ids)],
})
def _sync_team_lines_from_members(self):
if self.env.context.get('skip_project_team_member_sync'):
return
TeamLine = self.env['project.team.line'].sudo().with_context(skip_project_team_member_sync=True)
for project in self.sudo():
member_ids = set(project.members_ids.ids)
kept_user_ids = set()
lines_to_remove = self.env['project.team.line'].sudo()
for line in project.team_line_ids.sorted('id'):
user_id = line.user_id.id
if not user_id or user_id not in member_ids or user_id in kept_user_ids:
lines_to_remove |= line
else:
kept_user_ids.add(user_id)
if lines_to_remove:
lines_to_remove.with_context(skip_project_team_member_sync=True).unlink()
for user_id in member_ids - kept_user_ids:
TeamLine.create({
'project_id': project.id,
'user_id': user_id,
})
@api.model
def _sync_all_team_lines_from_members(self):
self.search([])._sync_team_lines_from_members()
return True
@api.model_create_multi
def create(self, vals_list):
projects = super().create(vals_list)
for project, vals in zip(projects, vals_list):
if 'team_line_ids' in vals:
project._sync_members_from_team_lines()
elif 'members_ids' in vals:
project._sync_team_lines_from_members()
return projects
def write(self, vals):
res = super().write(vals)
if 'team_line_ids' in vals:
self._sync_members_from_team_lines()
elif 'members_ids' in vals:
self._sync_team_lines_from_members()
return res
class ProjectTeamLine(models.Model):
_name = 'project.team.line'
_description = 'Project Team Line'
_rec_name = 'project_id'
project_id = fields.Many2one('project.project', ondelete='cascade')
user_id = fields.Many2one('res.users')
employee_id = fields.Many2one(
'hr.employee',
compute="_compute_employee",
store=True
)
job_id = fields.Many2one(
'hr.job',
related='employee_id.job_id',
store=True
)
start_date = fields.Date()
end_date = fields.Date()
status = fields.Selection([
('not_started', 'Not Started'),
('in_progress', 'In Progress'),
('done', 'Completed')
], compute='_compute_status', inverse='_inverse_status', store=True, readonly=False)
can_edit_assignment = fields.Boolean(
compute='_compute_can_edit_assignment',
string='Can Edit Assignment'
)
# ------------------------
# COMPUTE EMPLOYEE
# ------------------------
@api.depends('user_id')
def _compute_employee(self):
for rec in self:
rec.employee_id = self.env['hr.employee'].search([
('user_id', '=', rec.user_id.id)
], limit=1)
@api.depends('start_date', 'end_date')
def _compute_status(self):
today = fields.Date.context_today(self)
for rec in self:
if rec.end_date and rec.end_date < today:
rec.status = 'done'
elif rec.start_date and rec.start_date > today:
rec.status = 'not_started'
else:
rec.status = 'in_progress'
@api.depends('project_id.user_id', 'project_id.project_lead')
def _compute_can_edit_assignment(self):
current_user = self.env.user
for rec in self:
project = rec.project_id
rec.can_edit_assignment = bool(
self.env.is_superuser()
or (project and project.user_id == current_user)
or (project and 'project_lead' in project._fields and project.project_lead == current_user) or (current_user.has_group("project.group_project_manager"))
)
def _inverse_status(self):
# Allow manual edits to the stored computed field.
# When start/end dates change later, compute will refresh it again.
return True
def _check_manager_access(self):
if self.env.is_superuser():
return
unauthorized = self.filtered(lambda rec: not rec.can_edit_assignment)
if unauthorized:
raise ValidationError(_("Only the related project manager can update team assignment dates or status."))
# ------------------------
# SYNC BENCH
# ------------------------
def _sync_bench(self):
# Bench data is read live from SQL view / computed fields,
# so there is no separate sync model to refresh here.
return True
# ------------------------
# CREATE
# ------------------------
@api.model_create_multi
def create(self, vals_list):
if not self.env.is_superuser():
for vals in vals_list:
project_id = vals.get('project_id')
if project_id:
project = self.env['project.project'].browse(project_id)
if not (
project.user_id == self.env.user
or ('project_lead' in project._fields and project.project_lead == self.env.user)
):
raise ValidationError(_("Only the related project manager can add team assignments."))
records = super().create(vals_list)
records._sync_bench()
records.mapped('project_id')._sync_members_from_team_lines()
return records
# ------------------------
# WRITE
# ------------------------
def write(self, vals):
if any(key in vals for key in ('status', 'start_date', 'end_date', 'user_id', 'project_id')):
self._check_manager_access()
projects = self.mapped('project_id')
res = super().write(vals)
self._sync_bench()
if any(key in vals for key in ('user_id', 'project_id')):
(projects | self.mapped('project_id'))._sync_members_from_team_lines()
return res
# ------------------------
# UNLINK
# ------------------------
def unlink(self):
projects = self.mapped('project_id')
self._check_manager_access()
res = super().unlink()
self._sync_bench()
projects._sync_members_from_team_lines()
return res

View File

@ -0,0 +1,3 @@
id,name,model_id:id,group_id,perm_read,perm_write,perm_create,perm_unlink
access_project_team_line,project.team.line,model_project_team_line,,1,1,1,1
access_bench_management_line,bench.management.line,model_bench_management_line,,1,1,1,1
1 id name model_id:id group_id perm_read perm_write perm_create perm_unlink
2 access_project_team_line project.team.line model_project_team_line 1 1 1 1
3 access_bench_management_line bench.management.line model_bench_management_line 1 1 1 1

View File

@ -0,0 +1,245 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_bench_management_tree" model="ir.ui.view">
<field name="name">bench.management.line.list</field>
<field name="model">bench.management.line</field>
<field name="arch" type="xml">
<list create="0" string="Bench Management">
<field name="employee_id"/>
<field name="job_id"/>
<field name="status"/>
<field name="limited_project_line_ids" widget="many2many_tags" options="{'color_field': 'line_status_color'}"/>
<field name="active_project_count"/>
<field name="future_project_count"/>
<field name="completed_project_count"/>
</list>
</field>
</record>
<record id="view_bench_management_search" model="ir.ui.view">
<field name="name">bench.management.line.search</field>
<field name="model">bench.management.line</field>
<field name="arch" type="xml">
<search string="Bench Management">
<field name="employee_id"/>
<field name="job_id"/>
<field name="status"/>
<filter name="filter_bench" string="Bench" domain="[('status', '=', 'bench')]"/>
<filter name="filter_partial" string="Partially Available" domain="[('status', '=', 'partial')]"/>
<filter name="filter_full" string="Fully Allocated" domain="[('status', '=', 'full')]"/>
<group expand="0" string="Group By">
<filter name="group_by_status" string="Status" context="{'group_by': 'status'}"/>
<filter name="group_by_job" string="Job Position" context="{'group_by': 'job_id'}"/>
</group>
</search>
</field>
</record>
<record id="view_bench_management_form" model="ir.ui.view">
<field name="name">bench.management.line.form</field>
<field name="model">bench.management.line</field>
<field name="arch" type="xml">
<form create="0" string="Bench Management">
<sheet>
<group>
<field name="employee_id"/>
<field name="job_id"/>
<field name="status"/>
</group>
<group string="Project Information">
<field name="project_line_ids" nolabel="1" readonly="0">
<list create="0" delete="0" editable="bottom">
<field name="project_id" readonly="1"/>
<field name="can_edit_assignment" column_invisible="1"/>
<field name="status" readonly="not can_edit_assignment"/>
<field name="start_date" readonly="not can_edit_assignment"/>
<field name="end_date" readonly="not can_edit_assignment"/>
<field name="job_id" optional="hide" readonly="1"/>
</list>
</field>
</group>
</sheet>
</form>
</field>
</record>
<record id="view_bench_management_kanban" model="ir.ui.view">
<field name="name">bench.management.line.kanban</field>
<field name="model">bench.management.line</field>
<field name="arch" type="xml">
<kanban create="0" class="o_kanban_mobile">
<field name="employee_id"/>
<field name="job_id"/>
<field name="status"/>
<field name="limited_project_line_ids"/>
<field name="project_count"/>
<field name="active_project_count"/>
<field name="future_project_count"/>
<field name="completed_project_count"/>
<field name="project_names_tooltip"/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_card oe_kanban_global_click"
style="border-radius:16px;border:1px solid #dbe4ee;background:linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);padding:16px;min-height:260px;box-shadow:0 8px 24px rgba(15, 23, 42, 0.06);">
<!-- Header -->
<div class="d-flex align-items-center mb-3">
<img t-att-src="'/web/image/hr.employee/' + record.employee_id.raw_value + '/avatar_128'"
style="
width:42px;
height:42px;
border-radius:50%;
object-fit:cover;
margin-right:10px;
"/>
<div>
<div style="
font-size:16px;
font-weight:600;
color:#1f2937;
">
<field name="employee_id"/>
</div>
<div style="
font-size:12px;
color:#6b7280;
">
<field name="job_id"/>
</div>
</div>
</div>
<!-- Status -->
<div class="mb-3 d-flex align-items-center justify-content-between">
<t t-if="record.status.raw_value == 'bench'">
<span style="
background:#e2e8f0;
color:#334155;
padding:5px 10px;
border-radius:20px;
font-size:11px;
font-weight:600;
">
Bench
</span>
</t>
<t t-if="record.status.raw_value == 'partial'">
<span style="
background:#fef3c7;
color:#92400e;
padding:5px 10px;
border-radius:20px;
font-size:11px;
font-weight:600;
">
Partially Available
</span>
</t>
<t t-if="record.status.raw_value == 'full'">
<span style="
background:#dcfce7;
color:#166534;
padding:5px 10px;
border-radius:20px;
font-size:11px;
font-weight:600;
">
Fully Allocated
</span>
</t>
<div style="font-size:11px;color:#64748b;">
<t t-out="record.active_project_count.raw_value"/> Active
</div>
</div>
<div class="d-flex gap-2 mb-3" style="gap:8px;">
<div style="flex:1;border:1px solid #e2e8f0;border-radius:12px;padding:8px 10px;background:#ffffff;">
<div style="font-size:10px;color:#64748b;text-transform:uppercase;">Current</div>
<div style="font-size:18px;font-weight:700;color:#0f172a;">
<t t-out="record.active_project_count.raw_value"/>
</div>
</div>
<div style="flex:1;border:1px solid #e2e8f0;border-radius:12px;padding:8px 10px;background:#ffffff;">
<div style="font-size:10px;color:#64748b;text-transform:uppercase;">Upcoming</div>
<div style="font-size:18px;font-weight:700;color:#0f172a;">
<t t-out="record.future_project_count.raw_value"/>
</div>
</div>
<div style="flex:1;border:1px solid #e2e8f0;border-radius:12px;padding:8px 10px;background:#ffffff;">
<div style="font-size:10px;color:#64748b;text-transform:uppercase;">Completed</div>
<div style="font-size:18px;font-weight:700;color:#0f172a;">
<t t-out="record.completed_project_count.raw_value"/>
</div>
</div>
</div>
<!-- Project Info -->
<div t-if="record.project_count.raw_value"
style="border-top:1px solid #f3f4f6;padding-top:12px;">
<div style="
font-size:13px;
font-weight:600;
color:#374151;
margin-bottom:8px;
">
Projects
</div>
<div t-att-title="record.project_names_tooltip.raw_value"
style="max-height:48px;overflow:hidden;">
<field name="limited_project_line_ids"
widget="many2many_tags"
options="{'no_create': True, 'no_create_edit': True, 'no_open': True, 'color_field': 'line_status_color'}"/>
</div>
<t t-if="record.project_count.raw_value &gt; 3">
<div t-att-title="record.project_names_tooltip.raw_value"
style="margin-top:8px;font-size:11px;color:#2563eb;font-weight:600;">
+ <t t-out="record.project_count.raw_value - 3"/> more
</div>
</t>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<record id="action_bench_management" model="ir.actions.act_window">
<field name="name">Bench Management</field>
<field name="res_model">bench.management.line</field>
<field name="view_mode">kanban,list,form</field>
<field name="domain">[('company_id', 'in', allowed_company_ids)]</field>
<field name="search_view_id" ref="view_bench_management_search"/>
</record>
<menuitem id="menu_bench_management"
name="Employee Bench"
parent="hr.menu_hr_root"
groups="hr.group_hr_manager"
action="action_bench_management"
sequence="3"/>
</odoo>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="project_project_inherit_form_view2_inherit" model="ir.ui.view">
<field name="name">project.project.inherit.form.view.inherit</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project_task_timesheet_extended.project_project_inherit_form_view2"/>
<field name="arch" type="xml">
<xpath expr="//form" position="inside">
<field name="can_manage_team_lines" invisible="1"/>
</xpath>
<xpath expr="//page[@name='team']/group[field[@name='members_ids']]" position="after">
<group string="Project Team Details">
<field name="team_line_ids" nolabel="1" readonly="not can_manage_team_lines">
<list editable="bottom">
<field name="user_id" string="Employee Name"/>
<field name="employee_id" string="Employee" readonly="1" column_invisible="1" invisible="1"/>
<field name="job_id" string="Job Position"/>
<field name="project_id" column_invisible="1"/>
<field name="can_edit_assignment" column_invisible="1"/>
<field name="start_date" string="Start Date" readonly="not can_edit_assignment"/>
<field name="end_date" string="End date" readonly="not can_edit_assignment"/>
<field name="status" string="Status" readonly="not can_edit_assignment"/>
</list>
</field>
</group>
</xpath>
</field>
</record>
</odoo>

View File

@ -0,0 +1,2 @@
from . import models
from . import wizard

View File

@ -0,0 +1,38 @@
{
'name': 'Business Travel & Expense Management',
'version': '1.0',
'summary': 'Enterprise Business Travel & Expense Management',
'description': """
Business Travel (Trips) & Expense Management Module.
- Pre-approved Trips
- Trip lifecycle management
- Expense tracking per Trip
- Manager & Finance approvals
- Reimbursement workflow
""",
'category': 'Human Resources',
'author': 'Karuna',
'depends': ['base', 'hr'],
'data': [
'security/travel_groups.xml',
'security/travel_trip_rules.xml',
'security/ir.model.access.csv',
# 'data/users.xml',
'data/trip_sequence.xml',
'wizard/trip_reject_wizard_view.xml',
'views/hr_job_view.xml', # 👈 hr extension BEFORE menus
'views/travel_trip_views.xml',
'views/travel_city_category_views.xml',
'views/travel_group_view.xml',
'views/travel_stay_policy_view.xml', # 👈 ADD HERE
'views/travel_daily_allowance_view.xml',
'views/travel_mode_policy_view.xml',
'views/travel_expense_views.xml',
'views/travel_activity_views.xml',
'views/travel_menu.xml',
],
'images': ['static/description/banner.png'],
'installable': True,
'application': True,
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="seq_travel_trip" model="ir.sequence">
<field name="name">Travel Trip</field>
<field name="code">travel.trip</field>
<field name="prefix">TRIP/%(year)s/</field>
<field name="padding">4</field>
</record>
</odoo>

View File

@ -0,0 +1,9 @@
<!--<odoo>-->
<!-- <record id="user_travel_finance" model="res.users">-->
<!-- <field name="name">Finance User</field>-->
<!-- <field name="login">finance@test.com</field>-->
<!-- <field name="email">finance@test.com</field>-->
<!-- &lt;!&ndash; Attach Travel - Finance group &ndash;&gt;-->
<!-- <field name="groups_id" eval="[(4, ref('business_travel_expense_management.group_travel_finance'))]"/>-->
<!-- </record>-->

View File

@ -0,0 +1,9 @@
from . import travel_trip
from . import travel_expense
from . import travel_activity
from . import travel_city_category
from . import travel_group
from . import hr_job
from . import travel_stay_policy
from . import travel_daily_allowance
from . import travel_mode_policy

View File

@ -0,0 +1,28 @@
from odoo import models, fields, api
class HrJob(models.Model):
_inherit = 'hr.job'
designation_level = fields.Selection([
('a', 'Level A'),
('b', 'Level B'),
('c', 'Level C'),
], string="Designation Level")
travel_group_id = fields.Many2one(
'travel.group',
compute='_compute_travel_group',
store=True,
readonly=True
)
@api.depends('designation_level')
def _compute_travel_group(self):
for rec in self:
if rec.designation_level:
group = self.env['travel.group'].search([
('level_code', '=', rec.designation_level)
], limit=1)
rec.travel_group_id = group.id
else:
rec.travel_group_id = False

View File

@ -0,0 +1,114 @@
from odoo import models, fields, api
class TravelActivity(models.Model):
_name = 'travel.activity'
_description = 'Travel Activity'
_order = 'sequence, id'
# --------------------
# BASIC
# --------------------
sequence = fields.Integer(default=10)
name = fields.Char(string="Activity Title", required=True)
trip_id = fields.Many2one(
'travel.trip',
required=True,
ondelete='cascade'
)
activity_type = fields.Selection([
('travel', 'Travel'),
('stay', 'Stay'),
('meeting', 'Meeting'),
('local', 'Local Travel'),
], required=True)
start_datetime = fields.Datetime("Start Time")
end_datetime = fields.Datetime("End Time")
# --------------------
# COMPUTED GROUP (VERY IMPORTANT)
# --------------------
travel_group_id = fields.Many2one(
'travel.group',
string="Travel Group",
compute="_compute_travel_group",
store=True
)
@api.depends('trip_id')
def _compute_travel_group(self):
for rec in self:
rec.travel_group_id = rec.trip_id.travel_group_id
# --------------------
# TRAVEL MODE (FILTERED BY GROUP)
# --------------------
travel_mode_policy_id = fields.Many2one(
'travel.mode.policy',
string="Travel Mode",
domain="""
[
('travel_group_id', '=', travel_group_id),
('mode_type', '=', activity_type),
('active', '=', True)
]
"""
)
from_location = fields.Char()
to_location = fields.Char()
travel_details = fields.Char()
# --------------------
# OTHER FIELDS
# --------------------
stay_type = fields.Selection([
('hotel', 'Hotel'),
('guest', 'Guest House'),
])
hotel_name = fields.Char()
city = fields.Char()
# city_category_id = fields.Many2one(
# 'travel.city.category',
# string="City Category"
# )
checkin = fields.Datetime()
checkout = fields.Datetime()
meeting_title = fields.Char()
meeting_location = fields.Char()
notes = fields.Text()
local_travel_mode = fields.Selection([
('cab', 'Cab'),
('own', 'Own Vehicle'),
], string="Local Travel Mode")
attachment_ids = fields.Many2many(
'ir.attachment',
'travel_activity_attachment_rel',
'activity_id',
'attachment_id',
string="Documents"
)
expense_ids = fields.One2many(
'travel.expense',
'activity_id',
string="Expenses"
)
total_amount = fields.Float(
string='Activity Total',
compute='_compute_total_amount',
store=True
)
@api.depends('expense_ids.amount')
def _compute_total_amount(self):
for rec in self:
rec.total_amount = sum(rec.expense_ids.mapped('amount'))

View File

@ -0,0 +1,17 @@
from odoo import models, fields
class TravelCityCategory(models.Model):
_name = 'travel.city.category'
_description = 'Travel City Category'
name = fields.Char(
string="City Category",
required=True
)
code = fields.Char(
string="Code",
help="Short code like AP_TG_HYD, AP_TG_OTHER, ROI"
)
active = fields.Boolean(default=True)

View File

@ -0,0 +1,25 @@
from odoo import models, fields
class TravelDailyAllowance(models.Model):
_name = 'travel.daily.allowance'
_description = 'Daily Allowance Policy'
_rec_name = 'travel_group_id'
travel_group_id = fields.Many2one(
'travel.group',
string="Travel Group",
required=True
)
city_category_id = fields.Many2one(
'travel.city.category',
string="City Category",
required=True
)
amount = fields.Float(string="Allowance Amount")
actuals_allowed = fields.Boolean(string="Actuals Allowed")
active = fields.Boolean(default=True)

View File

@ -0,0 +1,112 @@
from odoo import models, fields, api
from odoo.exceptions import UserError
from odoo.exceptions import ValidationError
class TravelExpense(models.Model):
_name = 'travel.expense'
_description = 'Travel Expense'
_order = 'expense_date desc, id desc'
name = fields.Char(string="Expense Description", required=True)
expense_date = fields.Date(default=fields.Date.today)
amount = fields.Monetary(required=True)
activity_id = fields.Many2one(
'travel.activity',
string="Activity",
required=True,
ondelete='cascade'
)
receipt = fields.Binary()
currency_id = fields.Many2one(
'res.currency',
default=lambda self: self.env.company.currency_id
)
state = fields.Selection([
('draft', 'Draft'),
('submitted', 'Submitted'),
('approved', 'Approved'),
('rejected', 'Rejected'),
], default='draft')
# ---------------- Actions ----------------
@api.depends('expense_ids.amount')
def _compute_total_amount(self):
for rec in self:
rec.total_amount = sum(rec.expense_ids.mapped('amount'))
@api.onchange('expense_ids')
def _onchange_expense_ids(self):
self.total_amount = sum(self.expense_ids.mapped('amount'))
def action_submit(self):
for rec in self:
if rec.state != 'draft':
raise UserError("Only Draft expenses can be submitted.")
rec.state = 'submitted'
rec.message_post(body="🟡 Expense submitted.")
def action_approve(self):
for rec in self:
if rec.state != 'submitted':
raise UserError("Only Submitted expenses can be approved.")
manager_user = rec.activity_id.trip_id.manager_id.sudo().user_id
if manager_user != self.env.user:
raise UserError("Only the reporting manager can approve.")
rec.state = 'approved'
rec.message_post(body="🟢 Expense approved.")
def action_mark_reimbursed(self):
for rec in self:
if rec.state != 'approved':
raise UserError("Only Approved expenses can be reimbursed.")
if not self.env.user.has_group(
'business_travel_expense_management.group_travel_finance'
):
raise UserError("Only Finance can reimburse.")
rec.state = 'reimbursed'
rec.message_post(body="💰 Expense reimbursed.")
@api.constrains('amount', 'activity_id')
def _check_stay_policy(self):
for record in self:
activity = record.activity_id
if not activity or activity.activity_type != 'stay':
continue
trip = activity.trip_id
group = trip.travel_group_id
city_category = trip.city_category_id # 👈 NOW FROM TRIP
if not group:
raise ValidationError("Trip must have a Travel Group.")
if not city_category:
raise ValidationError("Trip must have a City Category selected.")
policy = self.env['travel.stay.policy'].search([
('travel_group_id', '=', group.id),
('city_category_id', '=', city_category.id),
('active', '=', True)
], limit=1)
if not policy:
raise ValidationError(
f"No Stay Policy configured for Group '{group.name}' and City '{city_category.name}'."
)
if record.amount > policy.max_amount:
raise ValidationError(
f"Stay expense exceeds allowed limit of {policy.max_amount}."
)

View File

@ -0,0 +1,25 @@
from odoo import models, fields
class TravelGroup(models.Model):
_name = 'travel.group'
_description = 'Travel Group'
name = fields.Char(string='Travel Group', required=True)
active = fields.Boolean(default=True)
job_ids = fields.One2many(
'hr.job',
'travel_group_id',
string="Designations"
)
level_code = fields.Selection([
('a', 'Level A'),
('b', 'Level B'),
('c', 'Level C'),
], required=True)
allowed_travel_mode_ids = fields.Many2many(
'travel.mode',
string="Allowed Travel Modes"
)

View File

@ -0,0 +1,31 @@
from odoo import models, fields
class TravelModePolicy(models.Model):
_name = 'travel.mode.policy'
_description = 'Travel Mode Policy'
_rec_name = 'travel_mode' # This makes dropdown show Flight/2AC etc
travel_group_id = fields.Many2one(
'travel.group',
string="Travel Group",
required=True,
ondelete='cascade'
)
mode_type = fields.Selection([
('travel', 'Travel'),
('local', 'Local Travel'),
], string="Mode Type", required=True)
travel_mode = fields.Selection([
('flight', 'Flight'),
('2ac', 'II AC'),
('3ac', 'III AC'),
('1st_class', '1st Class'),
('car', 'Car'),
('taxi', 'Taxi'),
('auto', 'Auto'),
], string="Travel Mode", required=True)
active = fields.Boolean(default=True)

View File

@ -0,0 +1,26 @@
from odoo import models, fields
class TravelStayPolicy(models.Model):
_name = 'travel.stay.policy'
_description = 'Travel Stay Policy'
travel_group_id = fields.Many2one(
'travel.group',
string='Travel Group',
required=True
)
city_category_id = fields.Many2one(
'travel.city.category',
string='City Category',
required=True
)
min_amount = fields.Float(string='Min Amount')
max_amount = fields.Float(string='Max Amount')
is_actuals = fields.Boolean(
string='Actuals Allowed',
help='If checked, actual hotel cost is allowed'
)
active = fields.Boolean(default=True)

View File

@ -0,0 +1,179 @@
from odoo import models, fields, api
from odoo.exceptions import UserError
class TravelTrip(models.Model):
_name = 'travel.trip'
_description = 'Business Travel Trip'
_inherit = ['mail.thread', 'mail.activity.mixin']
_order = 'id desc'
name = fields.Char(
string='Trip Reference',
required=True,
copy=False,
readonly=True,
default='New',
tracking=True
)
employee_id = fields.Many2one(
'hr.employee',
string='Employee',
required=True,
tracking=True
)
department_id = fields.Many2one(
'hr.department',
compute='_compute_emp_details',
store=True,
readonly=True,
tracking=True,
compute_sudo=True, # IMPORTANT
)
manager_id = fields.Many2one(
'hr.employee',
compute='_compute_emp_details',
store=True,
readonly=True,
tracking=True,
compute_sudo=True, # IMPORTANT
)
purpose = fields.Text(tracking=True)
from_location = fields.Char(tracking=True)
to_location = fields.Char(tracking=True)
start_date = fields.Date(tracking=True)
end_date = fields.Date(tracking=True)
estimated_cost = fields.Float(tracking=True)
reject_reason = fields.Text(string="Reject Reason", tracking=True)
state = fields.Selection([
('draft', 'Draft'),
('submitted', 'Submitted'),
('approved', 'Approved'),
('completed', 'Completed'),
('reimbursed', 'Reimbursed'),
], default='draft', tracking=True)
# expense_ids = fields.One2many(
# 'travel.expense',
# 'trip_id',
# string='Expenses'
# )
trave_activity_ids = fields.One2many(
'travel.activity', # child model
'trip_id', # inverse field in travel.activity
string="Activities"
)
total_expense = fields.Float(
string='Activity Total',
compute='_compute_total_expense',
store=True
)
travel_group_id = fields.Many2one(
'travel.group',
string='Travel Group',
related='employee_id.job_id.travel_group_id',
store=True,
readonly=True
)
city_category_id = fields.Many2one(
'travel.city.category',
string="City Category",
required=True
)
@api.depends('trave_activity_ids.total_amount')
def _compute_total_expense(self):
for rec in self:
rec.total_expense = sum(rec.trave_activity_ids.mapped('total_amount'))
# ---------------- COMPUTE ----------------
@api.depends('employee_id')
def _compute_emp_details(self):
for rec in self:
if rec.employee_id:
emp = rec.employee_id.sudo()
rec.department_id = emp.department_id
rec.manager_id = emp.parent_id
else:
rec.department_id = False
rec.manager_id = False
# ---------------- CREATE ----------------
@api.model
def create(self, vals):
if vals.get('name', 'New') == 'New':
vals['name'] = self.env['ir.sequence'].next_by_code('travel.trip') or 'New'
return super().create(vals)
# ---------------- ACTIONS ----------------
def action_submit(self):
for rec in self:
# Submit all DRAFT expenses inside ALL activities
activities = rec.trave_activity_ids
expenses = activities.mapped('expense_ids').filtered(
lambda e: e.state == 'draft'
)
expenses.write({'state': 'submitted'})
rec.state = 'submitted'
def action_approve(self):
for rec in self:
if rec.state != 'submitted':
raise UserError('Only Submitted trips can be approved.')
# Only reporting manager or admin can approve
manager_user = rec.manager_id.sudo().user_id
if not self.env.is_admin() and (not manager_user or manager_user != self.env.user):
raise UserError("Only the reporting manager can approve this trip.")
rec.state = 'approved'
rec.message_post(
body=f"Trip <b>{rec.name}</b> has been approved by {self.env.user.name}.",
subtype_xmlid="mail.mt_comment"
)
def action_mark_completed(self):
for rec in self:
if rec.state != 'approved':
raise UserError('Only Approved trips can be marked as Completed.')
rec.state = 'completed'
rec.message_post(
body=f"Trip <b>{rec.name}</b> has been marked as Completed.",
subtype_xmlid="mail.mt_comment"
)
is_current_user_manager = fields.Boolean(
compute="_compute_is_current_user_manager",
store=False
)
def _compute_is_current_user_manager(self):
for rec in self:
rec.is_current_user_manager = (
rec.manager_id
and rec.manager_id.sudo().user_id
and rec.manager_id.sudo().user_id.id == self.env.user.id
)

View File

@ -0,0 +1,11 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_travel_trip,travel.trip,model_travel_trip,base.group_user,1,1,1,1
access_travel_expense,travel.expense,model_travel_expense,base.group_user,1,1,1,1
access_trip_reject_wizard,trip.reject.wizard,model_trip_reject_wizard,base.group_user,1,1,1,1
access_travel_activity_employee,travel.activity employee,model_travel_activity,base.group_user,1,1,1,1
access_travel_activity_user,travel.activity user,model_travel_activity,base.group_user,1,1,1,1
access_travel_city_category,travel.city.category,model_travel_city_category,base.group_user,1,1,1,1
access_travel_group_user,travel.group user,model_travel_group,base.group_user,1,1,1,1
access_travel_stay_policy,travel.stay.policy,model_travel_stay_policy,base.group_user,1,1,1,1
access_travel_daily_allowance_user,access_travel_daily_allowance_user,model_travel_daily_allowance,base.group_user,1,1,1,1
access_travel_mode_policy_user,access_travel_mode_policy_user,model_travel_mode_policy,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_travel_trip travel.trip model_travel_trip base.group_user 1 1 1 1
3 access_travel_expense travel.expense model_travel_expense base.group_user 1 1 1 1
4 access_trip_reject_wizard trip.reject.wizard model_trip_reject_wizard base.group_user 1 1 1 1
5 access_travel_activity_employee travel.activity employee model_travel_activity base.group_user 1 1 1 1
6 access_travel_activity_user travel.activity user model_travel_activity base.group_user 1 1 1 1
7 access_travel_city_category travel.city.category model_travel_city_category base.group_user 1 1 1 1
8 access_travel_group_user travel.group user model_travel_group base.group_user 1 1 1 1
9 access_travel_stay_policy travel.stay.policy model_travel_stay_policy base.group_user 1 1 1 1
10 access_travel_daily_allowance_user access_travel_daily_allowance_user model_travel_daily_allowance base.group_user 1 1 1 1
11 access_travel_mode_policy_user access_travel_mode_policy_user model_travel_mode_policy base.group_user 1 1 1 1

View File

@ -0,0 +1,18 @@
<odoo>
<record id="group_travel_employee" model="res.groups">
<field name="name">Travel - Employee</field>
<field name="category_id" ref="base.module_category_human_resources"/>
</record>
<record id="group_travel_manager" model="res.groups">
<field name="name">Travel - Manager</field>
<field name="category_id" ref="base.module_category_human_resources"/>
<field name="implied_ids" eval="[(4, ref('group_travel_employee'))]"/>
</record>
<record id="group_travel_finance" model="res.groups">
<field name="name">Travel - Finance</field>
<field name="category_id" ref="base.module_category_human_resources"/>
<field name="implied_ids" eval="[(4, ref('group_travel_manager'))]"/>
</record>
</odoo>

View File

@ -0,0 +1,27 @@
<odoo>
<!-- Employees: only their own trips -->
<record id="travel_trip_rule_employee_own" model="ir.rule">
<field name="name">Travel Trip: Employee Own</field>
<field name="model_id" ref="model_travel_trip"/>
<field name="domain_force">[('employee_id.user_id', '=', user.id)]</field>
<field name="groups" eval="[(4, ref('business_travel_expense_management.group_travel_employee'))]"/>
</record>
<!-- Managers: trips of their team -->
<record id="travel_trip_rule_manager_team" model="ir.rule">
<field name="name">Travel Trip: Manager Team</field>
<field name="model_id" ref="model_travel_trip"/>
<field name="domain_force">[('manager_id.user_id', '=', user.id)]</field>
<field name="groups" eval="[(4, ref('business_travel_expense_management.group_travel_manager'))]"/>
</record>
<!-- System / Admin: everything -->
<record id="travel_trip_rule_admin_all" model="ir.rule">
<field name="name">Travel Trip: Admin All</field>
<field name="model_id" ref="model_travel_trip"/>
<field name="domain_force">[(1,'=',1)]</field>
<field name="groups" eval="[(4, ref('base.group_system'))]"/>
</record>
</odoo>

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -0,0 +1,16 @@
<odoo>
<record id="view_hr_job_form_inherit_travel_group" model="ir.ui.view">
<field name="name">hr.job.form.inherit.travel.group</field>
<field name="model">hr.job</field>
<field name="inherit_id" ref="hr.view_hr_job_form"/>
<field name="arch" type="xml">
<!-- Insert Travel Group below Department -->
<xpath expr="//field[@name='department_id']" position="after">
<field name="designation_level"/>
<field name="travel_group_id" readonly="1"/>
</xpath>
</field>
</record>
</odoo>

View File

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_travel_activity_form" model="ir.ui.view">
<field name="name">travel.activity.form</field>
<field name="model">travel.activity</field>
<field name="arch" type="xml">
<form string="Activity">
<sheet>
<!-- TITLE -->
<div class="oe_title">
<h1>
<field name="name" placeholder="Activity title"/>
</h1>
</div>
<!-- ACTIVITY TYPE -->
<group>
<field name="activity_type"/>
</group>
<!-- TRAVEL DETAILS -->
<group string="Travel Details"
invisible="activity_type != 'travel'">
<group>
<field name="travel_mode_policy_id"/>
<field name="from_location"/>
<field name="to_location"/>
</group>
<group>
<field name="start_datetime"/>
<field name="end_datetime"/>
</group>
<!-- <field name="travel_details" colspan="2"/>-->
</group>
<!-- STAY DETAILS -->
<group string="Accommodation Details"
invisible="activity_type != 'stay'">
<group>
<field name="stay_type"/>
<field name="hotel_name"/>
<field name="city"/>
</group>
<group>
<field name="checkin"/>
<field name="checkout"/>
</group>
</group>
<!-- MEETING DETAILS -->
<group string="Meeting Details"
invisible="activity_type != 'meeting'">
<group>
<field name="meeting_title"/>
<field name="meeting_location"/>
</group>
<group>
<field name="start_datetime"/>
<field name="end_datetime"/>
</group>
<!-- <field name="notes" colspan="2"/>-->
</group>
<!-- LOCAL TRAVEL -->
<group string="Local Commute Details"
invisible="activity_type != 'local'">
<group>
<field name="local_travel_mode"/>
<field name="from_location"/>
<field name="to_location"/>
</group>
<group>
<field name="start_datetime"/>
<field name="end_datetime"/>
</group>
</group>
<!-- DOCUMENTS -->
<separator string="Documents"/>
<field name="attachment_ids">
<list editable="bottom">
<field name="name"/>
<field name="datas"/>
</list>
</field>
<!-- EXPENSES -->
<separator string="Expenses"/>
<field name="expense_ids"
context="{'default_activity_id': id}">
<list editable="bottom">
<field name="name"/>
<field name="expense_date"/>
<field name="amount"/>
<field name="state"/>
</list>
</field>
<!-- TOTAL -->
<group>
<field name="total_amount" readonly="1"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="action_travel_activity" model="ir.actions.act_window">
<field name="name">Activity</field>
<field name="res_model">travel.activity</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_travel_activity_form"/>
</record>
</odoo>

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- List View -->
<record id="view_travel_city_category_tree" model="ir.ui.view">
<field name="name">travel.city.category.tree</field>
<field name="model">travel.city.category</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
<field name="code"/>
<field name="active"/>
</list>
</field>
</record>
<!-- Form View -->
<record id="view_travel_city_category_form" model="ir.ui.view">
<field name="name">travel.city.category.form</field>
<field name="model">travel.city.category</field>
<field name="arch" type="xml">
<form string="City Category">
<sheet>
<group>
<field name="name"/>
<field name="code"/>
<field name="active"/>
</group>
</sheet>
</form>
</field>
</record>
<!-- Action -->
<record id="action_travel_city_category" model="ir.actions.act_window">
<field name="name">City Categories</field>
<field name="res_model">travel.city.category</field>
<field name="view_mode">list,form</field>
</record>
<!-- Menu -->
<!-- <menuitem id="menu_travel_config_root"-->
<!-- name="Travel Configuration"-->
<!-- parent="menu_travel_root"-->
<!-- sequence="50"/>-->
<!-- <menuitem id="menu_travel_city_category"-->
<!-- name="City Categories"-->
<!-- parent="menu_travel_config_root"-->
<!-- action="action_travel_city_category"-->
<!-- sequence="10"/>-->
</odoo>

View File

@ -0,0 +1,44 @@
<odoo>
<!-- TREE VIEW -->
<record id="view_travel_daily_allowance_tree" model="ir.ui.view">
<field name="name">travel.daily.allowance.tree</field>
<field name="model">travel.daily.allowance</field>
<field name="arch" type="xml">
<list>
<field name="travel_group_id"/>
<field name="city_category_id"/>
<field name="amount"/>
<field name="actuals_allowed"/>
<field name="active"/>
</list>
</field>
</record>
<!-- FORM VIEW -->
<record id="view_travel_daily_allowance_form" model="ir.ui.view">
<field name="name">travel.daily.allowance.form</field>
<field name="model">travel.daily.allowance</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="travel_group_id"/>
<field name="city_category_id"/>
<field name="amount"/>
<field name="actuals_allowed"/>
<field name="active"/>
</group>
</sheet>
</form>
</field>
</record>
<!-- ACTION -->
<record id="action_travel_daily_allowance" model="ir.actions.act_window">
<field name="name">Daily Allowance Policies</field>
<field name="res_model">travel.daily.allowance</field>
<field name="view_mode">list,form</field>
</record>
</odoo>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_travel_expense_form" model="ir.ui.view">
<field name="name">travel.expense.form</field>
<field name="model">travel.expense</field>
<field name="arch" type="xml">
<form string="Expense">
<header>
<button name="action_submit"
string="Submit"
type="object"
class="btn-primary"
invisible="state != 'draft'"/>
<button name="action_approve"
string="Approve"
type="object"
class="btn-success"
invisible="state != 'submitted'"/>
<button name="action_mark_reimbursed"
string="Reimburse"
type="object"
class="btn-success"
invisible="state != 'approved'"/>
</header>
<sheet>
<div class="oe_title"
style="display:flex; justify-content:space-between;">
<h1>
<field name="name" placeholder="Expense Description"/>
</h1>
<field name="state"
widget="statusbar"
statusbar_visible="draft,submitted,approved,reimbursed"/>
</div>
<group>
<group>
<field name="activity_id"/>
<field name="expense_date"/>
</group>
<group>
<field name="amount"/>
</group>
</group>
<group string="Documents">
<field name="receipt" widget="binary"/>
</group>
</sheet>
<!-- <chatter>-->
<!-- <field name="message_ids"/>-->
<!-- </chatter>-->
</form>
</field>
</record>
</odoo>

View File

@ -0,0 +1,43 @@
<odoo>
<!-- Tree View -->
<record id="view_travel_group_tree" model="ir.ui.view">
<field name="name">travel.group.tree</field>
<field name="model">travel.group</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
<field name="active"/>
</list>
</field>
</record>
<!-- Form View -->
<record id="view_travel_group_form" model="ir.ui.view">
<field name="name">travel.group.form</field>
<field name="model">travel.group</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
<field name="level_code"/> <!-- ADD THIS -->
<field name="active"/>
</group>
<group string="Designations">
<field name="job_ids" widget="many2many_tags" readonly="1"/>
</group>
</sheet>
</form>
</field>
</record>
<!-- Action -->
<record id="action_travel_group" model="ir.actions.act_window">
<field name="name">Travel Groups</field>
<field name="res_model">travel.group</field>
<field name="view_mode">list,form</field>
</record>
</odoo>

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- ROOT MENU (MUST HAVE ACTION) -->
<menuitem id="menu_travel_root"
name="Business Travel"
action="action_travel_trip"
sequence="50"
web_icon="business_travel_expense_management,static/decription/icon.png"
groups="base.group_user"/>
<!-- TRIPS -->
<menuitem id="menu_travel_trip"
name="Trips"
parent="menu_travel_root"
action="action_travel_trip"
sequence="10"
groups="base.group_user"/>
<!-- CONFIG ROOT -->
<menuitem id="menu_travel_config_root"
name="Travel Configuration"
parent="menu_travel_root"
sequence="50"
groups="base.group_user"/>
<!-- CITY CATEGORY -->
<menuitem id="menu_travel_city_category"
name="City Categories"
parent="menu_travel_config_root"
action="action_travel_city_category"
sequence="10"
groups="base.group_user"/>
<!-- Menu -->
<menuitem id="menu_travel_group"
name="Travel Groups"
parent="menu_travel_config_root"
action="action_travel_group"
sequence="20"
groups="base.group_user"/>
<menuitem id="menu_travel_stay_policy"
name="Stay Policies"
parent="menu_travel_config_root"
action="action_travel_stay_policy"
sequence="30"/>
<menuitem id="menu_travel_daily_allowance"
name="Daily Allowance Policies"
parent="menu_travel_config_root"
action="action_travel_daily_allowance"
sequence="20"/>
<menuitem id="menu_travel_mode_policy"
name="Travel Mode Policies"
parent="menu_travel_config_root"
action="action_travel_mode_policy"
sequence="30"/>
</odoo>

View File

@ -0,0 +1,41 @@
<odoo>
<!-- TREE -->
<record id="view_travel_mode_policy_tree" model="ir.ui.view">
<field name="name">travel.mode.policy.tree</field>
<field name="model">travel.mode.policy</field>
<field name="arch" type="xml">
<list>
<field name="travel_group_id"/>
<field name="mode_type"/>
<field name="travel_mode"/>
<field name="active"/>
</list>
</field>
</record>
<!-- FORM -->
<record id="view_travel_mode_policy_form" model="ir.ui.view">
<field name="name">travel.mode.policy.form</field>
<field name="model">travel.mode.policy</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="travel_group_id"/>
<field name="mode_type"/>
<field name="travel_mode"/>
<field name="active"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="action_travel_mode_policy" model="ir.actions.act_window">
<field name="name">Travel Mode Policies</field>
<field name="res_model">travel.mode.policy</field>
<field name="view_mode">list,form</field>
</record>
</odoo>

View File

@ -0,0 +1,42 @@
<odoo>
<record id="view_travel_stay_policy_tree" model="ir.ui.view">
<field name="name">travel.stay.policy.tree</field>
<field name="model">travel.stay.policy</field>
<field name="arch" type="xml">
<list>
<field name="travel_group_id"/>
<field name="city_category_id"/>
<field name="min_amount"/>
<field name="max_amount"/>
<field name="is_actuals"/>
<field name="active"/>
</list>
</field>
</record>
<record id="view_travel_stay_policy_form" model="ir.ui.view">
<field name="name">travel.stay.policy.form</field>
<field name="model">travel.stay.policy</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="travel_group_id"/>
<field name="city_category_id"/>
<field name="is_actuals"/>
<field name="min_amount"/>
<field name="max_amount"/>
<field name="active"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="action_travel_stay_policy" model="ir.actions.act_window">
<field name="name">Stay Policies</field>
<field name="res_model">travel.stay.policy</field>
<field name="view_mode">list,form</field>
</record>
</odoo>

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Trip Form View -->
<record id="view_travel_trip_form" model="ir.ui.view">
<field name="name">travel.trip.form</field>
<field name="model">travel.trip</field>
<field name="arch" type="xml">
<form string="Trip">
<header>
<!-- Employee -->
<button name="action_submit"
string="Submit Trip"
type="object"
class="btn-primary"
invisible="state != 'draft'"/>
<!-- Manager only -->
<button name="action_approve"
string="Approve"
type="object"
class="btn-success"
invisible="state != 'submitted' or not is_current_user_manager"/>
<button name="%(action_trip_reject_wizard)d"
string="Reject"
type="action"
class="btn-danger"
invisible="state != 'submitted' or not is_current_user_manager"/>
<!-- Employee after approval -->
<button name="action_mark_completed"
string="Mark Completed"
type="object"
class="btn-secondary"
invisible="state != 'approved'"/>
<field name="state" widget="statusbar"
statusbar_visible="draft,submitted,approved,completed,reimbursed,rejected"/>
</header>
<sheet>
<group>
<group>
<field name="name" readonly="1"/>
<field name="employee_id" readonly="state != 'draft'"/>
<xpath expr="//field[@name='employee_id']" position="after">
<field name="travel_group_id" readonly="1"/>
</xpath>
<field name="department_id" readonly="1"/>
<field name="manager_id" readonly="1"/>
</group>
<group>
<field name="from_location" readonly="state != 'draft'"/>
<field name="to_location" readonly="state != 'draft'"/>
<field name="start_date" readonly="state != 'draft'"/>
<field name="end_date" readonly="state != 'draft'"/>
<field name="estimated_cost" readonly="state != 'draft'"/>
<field name="total_expense" string="Actual Cost"/>
<field name="city_category_id"/>
</group>
</group>
<group>
<field name="purpose" readonly="state != 'draft'"/>
</group>
<!-- Show reject reason only when present -->
<group invisible="not reject_reason">
<field name="reject_reason" readonly="1"/>
</group>
<notebook>
<!-- <page string="Expenses">-->
<!-- <field name="expense_ids"-->
<!-- readonly="state != 'draft'"-->
<!-- context="{'form_view_ref': 'business_travel_expense_management.view_travel_expense_form'}">-->
<!-- &lt;!&ndash; Only LIST here &ndash;&gt;-->
<!-- <list>-->
<!-- <field name="name"/>-->
<!-- <field name="category"/>-->
<!-- <field name="transport_detail"/>-->
<!-- <field name="distance_km"/>-->
<!-- <field name="amount"/>-->
<!-- <field name="expense_date"/>-->
<!-- <field name="state"/>-->
<!-- </list>-->
<!-- </field>-->
<page string="Activities">
<field name="trave_activity_ids"
context="{'default_trip_id': id}">
<list>
<field name="sequence" widget="handle"/>
<field name="name" string="Activity"/>
<field name="activity_type"/>
<field name="start_datetime"/>
<field name="end_datetime"/>
<!-- <field name="currency_id" invisible="1"/>-->
<field name="total_amount"
string="Activity Total"
widget="monetary"/>
<!-- options="{'currency_field': 'currency_id'}"/>-->
</list>
</field>
</page>
</notebook>
<!-- <group>-->
<!-- <field name="total_amount"-->
<!-- widget="monetary"-->
<!-- options="{'currency_field': 'currency_id'}"-->
<!-- readonly="1"/>-->
<!-- </group>-->
<chatter>
<field name="message_follower_ids"/>
<!-- <field name="activity_ids"/>-->
<field name="message_ids"/>
</chatter>
</sheet>
</form>
</field>
</record>
<!-- Tree View -->
<record id="view_travel_trip_tree" model="ir.ui.view">
<field name="name">travel.trip.tree</field>
<field name="model">travel.trip</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
<field name="employee_id"/>
<field name="from_location"/>
<field name="to_location"/>
<field name="start_date"/>
<field name="end_date"/>
<field name="estimated_cost"/>
<field name="state"/>
</list>
</field>
</record>
<!-- Action -->
<record id="action_travel_trip" model="ir.actions.act_window">
<field name="name">Trips</field>
<field name="res_model">travel.trip</field>
<field name="view_mode">list,form</field>
</record>
<!-- &lt;!&ndash; Menu &ndash;&gt;-->
<!-- <menuitem id="menu_travel_root"-->
<!-- name="Business Travel"-->
<!-- sequence="50"/>-->
<!-- <menuitem id="menu_travel_trip"-->
<!-- name="Trips"-->
<!-- parent="menu_travel_root"-->
<!-- action="action_travel_trip"-->
<!-- sequence="10"/>-->
</odoo>

View File

@ -0,0 +1 @@
from . import trip_reject_wizard

View File

@ -0,0 +1,19 @@
from odoo import models, fields
from odoo.exceptions import UserError
class TripRejectWizard(models.TransientModel):
_name = 'trip.reject.wizard'
_description = 'Reject Trip Wizard'
reason = fields.Text(string="Reason for Rejection", required=True)
def action_confirm_reject(self):
trip = self.env['travel.trip'].browse(self.env.context.get('active_id'))
if not trip:
raise UserError("No Trip found.")
trip.write({
'state': 'draft',
'reject_reason': self.reason
})

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_trip_reject_wizard" model="ir.ui.view">
<field name="name">trip.reject.wizard.form</field>
<field name="model">trip.reject.wizard</field>
<field name="arch" type="xml">
<form string="Reject Trip">
<group>
<field name="reason"/>
</group>
<footer>
<button string="Confirm Reject"
type="object"
name="action_confirm_reject"
class="btn-danger"/>
<button string="Cancel" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_trip_reject_wizard" model="ir.actions.act_window">
<field name="name">Reject Trip</field>
<field name="res_model">trip.reject.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>

View File

@ -1,10 +1,10 @@
/** @odoo-module **/ /** @odoo-module **/
import { standardWidgetProps } from "@web/views/widgets/standard_widget_props"; import {standardWidgetProps} from "@web/views/widgets/standard_widget_props";
import { Component, onMounted, useRef, useState, onWillStart } from "@odoo/owl"; import {Component, onMounted, useRef, useState, onWillStart, onWillUpdateProps} from "@odoo/owl";
import { registry } from "@web/core/registry"; import {registry} from "@web/core/registry";
import { useService } from "@web/core/utils/hooks"; import {useService} from "@web/core/utils/hooks";
import { loadJS, loadCSS } from "@web/core/assets"; import {loadJS, loadCSS} from "@web/core/assets";
import { rpc } from "@web/core/network/rpc"; import {rpc} from "@web/core/network/rpc";
export class ConsolidatedPayslipGrid extends Component { export class ConsolidatedPayslipGrid extends Component {
static props = { static props = {
@ -34,6 +34,12 @@ export class ConsolidatedPayslipGrid extends Component {
console.error("Grid element not found"); console.error("Grid element not found");
} }
}); });
onWillUpdateProps(async (nextProps) => {
if (nextProps.record.data.state !== this.props.record.data.state) {
await this.loadGrid();
}
});
} }
async loadDependencies() { async loadDependencies() {
@ -122,7 +128,7 @@ export class ConsolidatedPayslipGrid extends Component {
const agg = pq.aggregate; const agg = pq.aggregate;
// Define custom aggregate functions // Define custom aggregate functions
agg.sum_ = function(arr, col) { agg.sum_ = function (arr, col) {
return " " + agg.sum(arr, col).toFixed(2).toString(); return " " + agg.sum(arr, col).toFixed(2).toString();
}; };
@ -139,13 +145,13 @@ export class ConsolidatedPayslipGrid extends Component {
const gridOptions = { const gridOptions = {
selectionModel: { type: 'row' }, selectionModel: {type: 'row'},
width: "100%", width: "100%",
height: "100%", height: "100%",
groupModel: groupModel, groupModel: groupModel,
editable: true, editable: true,
stripeRows:false, stripeRows: false,
editModel: { saveKey: $.ui.keyCode.ENTER }, editModel: {saveKey: $.ui.keyCode.ENTER},
filterModel: {on: true, mode: "AND", header: true, autoSearch: true, type: 'local', minLength: 1}, filterModel: {on: true, mode: "AND", header: true, autoSearch: true, type: 'local', minLength: 1},
dataModel: {data: this.state.rows, location: "local", sorting: "local", paging: "local"}, dataModel: {data: this.state.rows, location: "local", sorting: "local", paging: "local"},
cellSave: function (evt, ui) { cellSave: function (evt, ui) {
@ -157,7 +163,7 @@ export class ConsolidatedPayslipGrid extends Component {
updateData(payload); updateData(payload);
}, },
menuIcon: true, menuIcon: true,
menuUI:{tabs: ['hideCols']}, menuUI: {tabs: ['hideCols']},
colModel: columns, colModel: columns,
postRenderInterval: -1, postRenderInterval: -1,
toolbar: { toolbar: {
@ -167,24 +173,12 @@ export class ConsolidatedPayslipGrid extends Component {
label: 'Refresh', label: 'Refresh',
icon: 'ui-icon-refresh', icon: 'ui-icon-refresh',
listener: () => this.loadGrid() listener: () => this.loadGrid()
},
{
type: 'button',
label: 'Save Changes',
icon: 'ui-icon-disk',
listener: () => this.saveChanges()
},
{
type: 'button',
label: 'Recalculate LOP',
icon: 'ui-icon-calculator',
listener: () => this.recalculateLOP()
}, },
{ {
type: 'select', type: 'select',
label: 'Format: ', label: 'Format: ',
attr: 'id="export_format"', attr: 'id="export_format"',
options: [{ xlsx: 'Excel', csv: 'Csv', htm: 'Html', json: 'Json'}] options: [{xlsx: 'Excel', csv: 'Csv', htm: 'Html', json: 'Json'}]
}, },
{ {
type: 'button', type: 'button',
@ -198,16 +192,17 @@ export class ConsolidatedPayslipGrid extends Component {
format: format, format: format,
render: true render: true
}); });
if(typeof blob === "string"){ if (typeof blob === "string") {
blob = new Blob([blob]); blob = new Blob([blob]);
} }
saveAs(blob, "PaySheet."+ format ); saveAs(blob, "PaySheet." + format);
} }
}, },
] ]
}, },
}; };
function updateData(data){
function updateData(data) {
$.ajax({ $.ajax({
url: "/slip/update", url: "/slip/update",
type: "POST", type: "POST",
@ -225,7 +220,7 @@ export class ConsolidatedPayslipGrid extends Component {
// Apply CSS and initialize grid // Apply CSS and initialize grid
$(this.gridRef.el) $(this.gridRef.el)
.css({ height: '600px', width: '100%' }) .css({height: '600px', width: '100%'})
.pqGrid(gridOptions) .pqGrid(gridOptions)
.pqGrid("refreshDataAndView"); .pqGrid("refreshDataAndView");
} }
@ -295,12 +290,12 @@ export class ConsolidatedPayslipGrid extends Component {
async getColumns() { async getColumns() {
const subCols = await this.getSubgridColumns(); const subCols = await this.getSubgridColumns();
return [ const columns = [
{ {
title: "Employee", title: "Employee",
dataIndx: "employee", dataIndx: "employee",
width: 200, width: 200,
filter: { type: 'textbox', condition: 'contain', listeners: ['keyup'] }, filter: {type: 'textbox', condition: 'contain', listeners: ['keyup']},
editable: false, editable: false,
menuIcon: true, menuIcon: true,
menuInHide: true menuInHide: true
@ -309,7 +304,7 @@ export class ConsolidatedPayslipGrid extends Component {
title: "Employee ID", title: "Employee ID",
dataIndx: "employee_code", dataIndx: "employee_code",
width: 200, width: 200,
filter: { type: 'textbox', condition: 'contain', listeners: ['keyup'] }, filter: {type: 'textbox', condition: 'contain', listeners: ['keyup']},
editable: false, editable: false,
menuInHide: true menuInHide: true
}, },
@ -317,7 +312,7 @@ export class ConsolidatedPayslipGrid extends Component {
title: "Department", title: "Department",
dataIndx: "department", dataIndx: "department",
width: 150, width: 150,
filter: { type: 'textbox', condition: 'contain', listeners: ['keyup'] }, filter: {type: 'textbox', condition: 'contain', listeners: ['keyup']},
editable: false editable: false
}, },
{ {
@ -372,7 +367,7 @@ export class ConsolidatedPayslipGrid extends Component {
width: 80, width: 80,
dataType: "integer", dataType: "integer",
editable: (rowData) => rowData.state === 'draft', editable: (rowData) => rowData.state === 'draft',
summary: { type: "sum_" } summary: {type: "sum_"}
}, },
{ {
title: "Sick Leave Balance", title: "Sick Leave Balance",
@ -380,7 +375,7 @@ export class ConsolidatedPayslipGrid extends Component {
width: 100, width: 100,
dataType: "float", dataType: "float",
editable: false, editable: false,
summary: { type: "sum_" }, summary: {type: "sum_"},
format: "##,##0.00" format: "##,##0.00"
}, },
{ {
@ -389,7 +384,7 @@ export class ConsolidatedPayslipGrid extends Component {
width: 100, width: 100,
dataType: "float", dataType: "float",
editable: false, editable: false,
summary: { type: "sum_" }, summary: {type: "sum_"},
format: "##,##0.00" format: "##,##0.00"
}, },
{ {
@ -398,7 +393,7 @@ export class ConsolidatedPayslipGrid extends Component {
width: 100, width: 100,
dataType: "float", dataType: "float",
editable: false, editable: false,
summary: { type: "sum_" }, summary: {type: "sum_"},
format: "##,##0.00" format: "##,##0.00"
}, },
// { // {
@ -443,7 +438,7 @@ export class ConsolidatedPayslipGrid extends Component {
title: "View", title: "View",
width: 120, width: 120,
editable: false, editable: false,
summary:false, summary: false,
render: function (ui) { render: function (ui) {
return "<button class='row-btn-view' type='button' >View</button>" return "<button class='row-btn-view' type='button' >View</button>"
}, },
@ -451,35 +446,45 @@ export class ConsolidatedPayslipGrid extends Component {
var grid = this, var grid = this,
$cell = grid.getCell(ui); $cell = grid.getCell(ui);
$cell.find(".row-btn-view") $cell.find(".row-btn-view")
.button({ icons: { primary: 'ui-icon-extlink'} }) .button({icons: {primary: 'ui-icon-extlink'}})
.on("click", async function (evt) { .on("click", async function (evt) {
const res = await odoo.__WOWL_DEBUG__.root.orm.call('hr.payslip','action_open_payslips',[ui.rowData.id]) const res = await odoo.__WOWL_DEBUG__.root.orm.call('hr.payslip', 'action_open_payslips', [ui.rowData.id])
// res.views = [[false, "form"]], // res.views = [[false, "form"]],
await odoo.__WOWL_DEBUG__.root.actionService.doAction(res) await odoo.__WOWL_DEBUG__.root.actionService.doAction(res)
}); });
} }
}, },
];
if (this.props.record.data.state !== "paid") {
columns.push(
{ {
title: "Edit", title: "Edit",
width: 120, width: 120,
editable: false, editable: false,
render: function (ui) { render: function (ui) {
if (ui.rowData.state == 'paid') {
return ""
}
return "<button class='row-btn-edit' type='button'>Edit</button>" return "<button class='row-btn-edit' type='button'>Edit</button>"
}, },
postRender: function (ui) { postRender: function (ui) {
var grid = this, var grid = this,
$cell = grid.getCell(ui); $cell = grid.getCell(ui);
$cell.find(".row-btn-edit") $cell.find(".row-btn-edit")
.button({ icons: { primary: 'ui-icon-pencil'} }) .button({icons: {primary: 'ui-icon-pencil'}})
.on("click", async function (evt) { .on("click", async function (evt) {
const res = await odoo.__WOWL_DEBUG__.root.orm.call('hr.payslip','action_edit_payslip_lines',[ui.rowData.id]) const res = await odoo.__WOWL_DEBUG__.root.orm.call('hr.payslip', 'action_edit_payslip_lines', [ui.rowData.id])
res.views = [[false, "form"]], res.views = [[false, "form"]],
await odoo.__WOWL_DEBUG__.root.actionService.doAction(res) await odoo.__WOWL_DEBUG__.root.actionService.doAction(res)
}); });
} }
} }
]; )
}
return columns
} }
async getSubgridColumns() { async getSubgridColumns() {
@ -495,10 +500,10 @@ export class ConsolidatedPayslipGrid extends Component {
try { try {
await this.loadGridData(); await this.loadGridData();
$(this.gridRef.el).pqGrid("refreshDataAndView"); $(this.gridRef.el).pqGrid("refreshDataAndView");
this.notification.add("Data refreshed successfully", { type: 'success' }); this.notification.add("Data refreshed successfully", {type: 'success'});
} catch (error) { } catch (error) {
console.error("Error refreshing grid:", error); console.error("Error refreshing grid:", error);
this.notification.add("Error refreshing data", { type: 'danger' }); this.notification.add("Error refreshing data", {type: 'danger'});
} }
} }
@ -513,10 +518,10 @@ export class ConsolidatedPayslipGrid extends Component {
[this.state.payslipRunId, updatedData] [this.state.payslipRunId, updatedData]
); );
await this.refreshGrid(); await this.refreshGrid();
this.notification.add("Changes saved successfully", { type: 'success' }); this.notification.add("Changes saved successfully", {type: 'success'});
} catch (error) { } catch (error) {
console.error("Error saving data:", error); console.error("Error saving data:", error);
this.notification.add("Error saving changes", { type: 'danger' }); this.notification.add("Error saving changes", {type: 'danger'});
} }
} }
@ -528,10 +533,10 @@ export class ConsolidatedPayslipGrid extends Component {
[this.state.payslipRunId] [this.state.payslipRunId]
); );
await this.refreshGrid(); await this.refreshGrid();
this.notification.add("LOP days recalculated successfully", { type: 'success' }); this.notification.add("LOP days recalculated successfully", {type: 'success'});
} catch (error) { } catch (error) {
console.error("Error recalculating LOP:", error); console.error("Error recalculating LOP:", error);
this.notification.add("Error recalculating LOP", { type: 'danger' }); this.notification.add("Error recalculating LOP", {type: 'danger'});
} }
} }
@ -543,10 +548,10 @@ export class ConsolidatedPayslipGrid extends Component {
[this.state.payslipRunId] [this.state.payslipRunId]
); );
await this.refreshGrid(); await this.refreshGrid();
this.notification.add("All records validated successfully", { type: 'success' }); this.notification.add("All records validated successfully", {type: 'success'});
} catch (error) { } catch (error) {
console.error("Error validating records:", error); console.error("Error validating records:", error);
this.notification.add("Error validating records", { type: 'danger' }); this.notification.add("Error validating records", {type: 'danger'});
} }
} }
} }

View File

@ -115,7 +115,6 @@ class CwfTimesheet(models.Model):
external_group_id = self.env.ref("hr_employee_extended.group_external_user") external_group_id = self.env.ref("hr_employee_extended.group_external_user")
users = self.env["res.users"].search([("groups_id", "=", external_group_id.id)]) users = self.env["res.users"].search([("groups_id", "=", external_group_id.id)])
employees = self.env['hr.employee'].search([('user_id', 'in', users.ids),'|',('doj','=',False),('doj','>=', self.week_start_date)]) employees = self.env['hr.employee'].search([('user_id', 'in', users.ids),'|',('doj','=',False),('doj','>=', self.week_start_date)])
print(employees)
# Loop through each day of the week and create timesheet lines for each employee # Loop through each day of the week and create timesheet lines for each employee
while current_date <= end_date: while current_date <= end_date:
for employee in employees: for employee in employees:

View File

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

View File

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Disciplinary',
'version': '1.0.0',
'category': 'Apps',
'summary': 'Disciplinary',
'description': 'Employee Disciplinary',
'sequence': '10',
'author': '',
'company': 'FTPROTECH',
'website': 'https://www.ftprotech.in',
'depends': ['mail', 'hr', 'base', 'website_hr_recruitment', 'contacts', 'point_of_sale'],
'demo': [],
'data': [
'data/sequence.xml',
'security/ir.model.access.csv',
'views/disciplinary_view.xml',
'views/employee_displance.xml',
'views/mistake_type_views.xml',
'views/incident_sub_type.xml',
'views/disciplinary_complaint_type.xml',
],
'installable': True,
'application': False,
'auto_install': False,
'license': 'LGPL-3',
}

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<record id="incident_report_sequence" model="ir.sequence">
<field name="name">Employee Disciplinary</field>
<field name="code">employee.disciplinary</field>
<field name="prefix">IR</field>
<field name="padding">5</field>
<field name="company_id" eval="False"/>
</record>
<record id="manage_incident_report_sequence" model="ir.sequence">
<field name="name">Manage Incident</field>
<field name="code">manage.incident</field>
<field name="prefix">MI</field>
<field name="padding">5</field>
<field name="company_id" eval="False"/>
</record>
<record id="seq_employee_disciplinary_sequence" model="ir.sequence">
<field name="name">Disciplinary Sequence</field>
<field name="code">hr.employee.sequence</field>
<field name="prefix">ED</field>
<field name="padding">5</field>
<field name="company_id" eval="False"/>
</record>
</data>
</odoo>

View File

@ -0,0 +1,2 @@
from . import disciplinary
from . import employee_displane

View File

@ -0,0 +1,188 @@
from datetime import datetime, date
from odoo import fields, models, api
#
# class NameChangeHrEmployee(models.Model):
# _inherit = "hr.employee"
#
# employee_name_ids1 = fields.One2many('employee.disciplinary', 'disp_name')
# employee_self_service_line_ids = fields.One2many('manage.incident', 'emp_incident', domain=[('state', '=', 'closed')])
#
# def name_get(self):
# result = []
# for record in self:
# if self.env.context.get('new_custom_name', False):
# result.append((record.id, "{} - {}".format(record.name, record.identification_id)))
# else:
# return super(NameChangeHrEmployee, self).name_get()
# return result
class EmployeeDisciplinary(models.Model):
_name = 'employee.disciplinary'
_inherit = ['mail.thread', 'mail.activity.mixin']
_rec_name = 'incident_type'
incident_date = fields.Datetime(string='Incident Date & Time', tracking=True, default=datetime.now(), required=True)
incident_type = fields.Many2one('incident.employee', string='Incident Type', tracking=True, required=True)
incident_sub_type = fields.Many2many('incident.sub.employee', string='Incident Sub Type', tracking=True,
required=True)
incident_details = fields.Char(string='Incident Details', tracking=True, required=True)
seized_items = fields.Char(string='Seized Items', tracking=True)
incident_summary = fields.Text(string='Incident Summary', tracking=True, required=True)
attach = fields.Many2many('ir.attachment', string='Attachments', tracking=True)
emp_many_disp = fields.Many2many('hr.employee', 'new_custom_table', string='Employees Involved in the Incident',
tracking=True, required=True)
date_action = fields.Date(string='Date')
employee = fields.Many2one('manage.incident')
employee_code = fields.Many2one("hr.employee", string="Employee Name", required=True)
employee_name = fields.Char(related="employee_code.identification_id")
disp_name = fields.Many2one('hr.employee')
@api.onchange('incident_type')
def return_incident_sub_type(self):
print(self.incident_type.sub_type)
listed = []
for recs in self.incident_type.sub_type:
listed.append(recs.id)
return {'domain': {'incident_sub_type': [('id', 'in', listed)]}}
@api.constrains('incident_type')
def create_manage_incidents(self):
for rec in self:
print('created')
self.env['manage.incident'].create({
'employee_disciplinary_id': rec.id,
})
@api.constrains('employee')
def holds_hr_employee(self):
for rec in self:
rec.disp_name = rec.employee.employee_code_list1
class IncidentEmployee(models.Model):
_name = 'incident.employee'
name = fields.Char(string='Incident')
sub_type = fields.Many2many('incident.sub.employee', string='Sub type')
class IncidentSubEmployee(models.Model):
_name = 'incident.sub.employee'
name = fields.Char(string='Incident Sub')
class DisciplinaryMistakeType(models.Model):
_name = 'disciplinary.mistake.type'
_description = 'Disciplinary Mistake Type'
name = fields.Char(string="Mistake Type", required=True)
class IncidentSubEmployee(models.Model):
_name = 'incident.sub.employee'
_description = 'Incident Sub Type'
name = fields.Char(string="Incident Sub Type", required=True)
class EmployeeDisciplinaryLines(models.Model):
_name = 'employee.disciplinary.line'
_rec_name = 'hr_emp_many'
emp_many = fields.Many2one('employee.disciplinary', string='Employee Disp')
hr_emp_many = fields.Many2one('hr.employee', string='Employee Number')
hr_emp_many_name = fields.Char(related='hr_emp_many.name', string='Employee Name')
class ManageIncident(models.Model):
_name = 'manage.incident'
_inherit = ['mail.thread', 'mail.activity.mixin']
# employee_name_ids = fields.One2many('employee.disciplinary','employee',string="Employee Name")
employee_disciplinary_id = fields.Many2one("employee.disciplinary", string="Employee Disp")
employee_code_list1 = fields.Many2many("hr.employee", string="Employees Involved in the Incident",
related='employee_disciplinary_id.emp_many_disp', tracking=True)
incident_dat = fields.Datetime(related='employee_disciplinary_id.incident_date', string='Incident Date & Time',
tracking=True)
employee_by_code = fields.Many2one(related='employee_disciplinary_id.employee_code',
string="Reported By Employee Name")
incident_sum = fields.Text(related='employee_disciplinary_id.incident_summary', string='Incident Summary',
tracking=True)
incident_typ = fields.Many2one(related='employee_disciplinary_id.incident_type', string="Incident Type",
tracking=True)
incident_sub_typ = fields.Many2many(related='employee_disciplinary_id.incident_sub_type',
string="Incident Sub Type", tracking=True)
# corrective_action_emp_id = fields.Many2one(related='employee_disciplinary_id.corrective_action_id',
# string="Corrective Action", tracking=True)
state = fields.Selection(([
('pending_inquiry', 'Pending Inquiry'),
('in_progress', 'In Process'),
('closed', 'Closed')
]), string="Status", default='pending_inquiry', tracking=True)
emp_incident = fields.Many2one('hr.employee')
employee_inquiry = fields.One2many('manage.incident.line', 'employee_inquiry_state')
def button_in_progress(self):
self.state = 'in_progress'
# def button_closed(self):
# for rec in self:
# rec.state = 'closed'
def button_closed(self):
for rec in self:
rec.state = 'closed'
update_into_employee = rec.env['hr.employee'].search([('id', '=', rec.employee_code_list1.id)])
records = {
}
if records:
update_into_employee.write(records)
print('triggered 2')
class CorrectiveActions(models.Model):
_name = "corrective.actions"
name = fields.Char(string="Name")
class ManageIncidentLine(models.Model):
_name = 'manage.incident.line'
_inherit = ['mail.thread']
_description = 'Manage Incident Line'
corrective_action_id = fields.Many2one('corrective.actions', string="Corrective Action", tracking=True,
required=True)
internal_panel = fields.Many2many('hr.employee', string="Internal Panel Members", tracking=True,
required=True)
external_panel = fields.Char(string="External Panel Members")
due_date = fields.Date(string="Due Date")
last_action_date = fields.Datetime(string="Last Action Date", compute='_compute_last_action_date',
default=date.today())
recommendation = fields.Char(string="Recommendation", tracking=True, required=True)
venue = fields.Char(string='Venue')
inquiry_summary = fields.Char(string='Inquiry Summary', tracking=True, required=True)
is_guilty = fields.Selection(([
('yes', 'Yes'),
('no', 'No'),
]), string="Is the Employee Guilt of the Incident", default='no', tracking=True)
inquiry_date = fields.Datetime(string="Inquiry Date and Time", required=True)
employee_inquiry_state = fields.Many2one('manage.incident')
@api.depends('inquiry_date')
def _compute_last_action_date(self):
for line in self:
if not line.employee_inquiry_state or line == line.employee_inquiry_state.employee_inquiry[0]:
line.last_action_date = False
else:
previous_line = line.employee_inquiry_state.employee_inquiry.filtered(lambda l: l.inquiry_date < line.inquiry_date)
sorted_previous_line = previous_line.sorted(key=lambda l: l.inquiry_date, reverse=True)
if sorted_previous_line:
line.last_action_date = sorted_previous_line[0].inquiry_date
else:
line.last_action_date = False

View File

@ -0,0 +1,179 @@
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from datetime import date
class HRDisciplinaryAction(models.Model):
_name = 'hr.employee.disciplinary'
_inherit = ['mail.thread', 'mail.activity.mixin']
_description = 'Employee Disciplinary Management'
active = fields.Boolean(default=True)
name = fields.Char('Reference', copy=False, readonly=True, default=lambda x: _('New'))
employee_id = fields.Many2one('hr.employee', string="Employee", required=True)
company_id = fields.Many2one('res.company', string="Company", required=True, default=lambda self: self.env.company)
employee_code = fields.Char(string='Employee Code', related='employee_id.employee_id',tracking=True,required=True)
# unit_id = fields.Many2one('unit.master', string="Unit",tracking=True)
department_id = fields.Many2one('hr.department', string="Department",tracking=True)
designation_id = fields.Many2one('hr.job', string="Designation",tracking=True)
doj = fields.Date(string="Date of Joining",tracking=True)
referred_by_id = fields.Many2one('res.users', string="Referred By",tracking=True)
loss_of_cost = fields.Float(string="Loss of Cost")
# employee_section_id = fields.Many2one('section.master',string='Section')
disciplinary_complaint_line_ids = fields.One2many('hr.disciplinary.complaint.line','disciplinary_id',string = 'Complaint Lines')
disciplinary_action_line_ids = fields.One2many('hr.disciplinary.action.line','disciplinary_id',string = 'Action Lines')
state = fields.Selection([
('new', 'New'),
('submitted', 'Submitted'),
('pending', 'Pending'),
('closed', 'Closed'),
('cancel', 'Cancel')
], default='new',tracking=True,string='State')
complaint_name = fields.Text('Complaint', compute='_compute_complaint_name', store=True)
name_1 = fields.Char('Name')
disciplinary_id = fields.Many2one('hr.employee.disciplinary', string="Disciplinary")
complaint_date = fields.Date('Complaint Date')
language_id = fields.Many2one('res.lang', 'Language')
complaint_type_id = fields.Many2one('disciplinary.complaint.type', string="Complaint Type")
mistake_type_id = fields.Many2one('disciplinary.mistake.type', string="Mistake Type", required=True)
complaint = fields.Char(string='Complaints')
employee_id_2 = fields.Many2one('hr.employee', string='Employee')
related_record_count = fields.Integer(string="Disciplinary Action Records Count", compute="_compute_related_record_count")
# general_cat = fields.Many2one('general.category', string="General Category", tracking=True)
# cat_id = fields.Many2one('hr.category','Category')
occurrences = fields.Integer('Occurrences', store=True)
severe = fields.Char('Severe')
major = fields.Char('Major')
less_major = fields.Char('Less Major')
negligible = fields.Char('Negligible')
normal = fields.Char('Normal')
total_mistakes = fields.Char('Total Mistakes')
memo = fields.Char('Memo')
explanation = fields.Char('Explanation')
show_cause = fields.Char('Show Cause')
charge_sheet = fields.Char('Charge Sheet')
warning = fields.Char('Warning')
enquiry_notice = fields.Char('Enquiry Notice')
recovery_order = fields.Char('Recovery_ Order')
stoppage_of_increment = fields.Char('Stoppage Of Increment')
demotion = fields.Char('Demotion')
total_actions = fields.Char('Total Actions')
normal_action = fields.Char('Normal Actions')
suspension = fields.Char('Suspension')
total_cost = fields.Float('Total Cost')
@api.depends('employee_id')
def _compute_related_record_count(self):
for record in self:
record.related_record_count = self.env['hr.employee.disciplinary'].search_count([('employee_id', '=', record.employee_id.id)])
def action_open_related_records(self):
return {
'name': 'Disciplinary Action Records',
'type': 'ir.actions.act_window',
'res_model': 'hr.employee.disciplinary',
'view_mode': 'list',
'domain': [('employee_id', '=', self.employee_id.id)],
'context': {'default_employee_id': self.employee_id.id},
}
@api.depends('disciplinary_complaint_line_ids.complaint')
def _compute_complaint_name(self):
for record in self:
complaints = record.disciplinary_complaint_line_ids.mapped('complaint')
record.complaint_name = "\n".join(filter(None, complaints))
def action_set_submitted(self):
self.state = 'submitted'
def action_set_pending(self):
self.state = 'pending'
def action_set_closed(self):
self.state = 'closed'
def action_set_cancel(self):
self.state = 'cancel'
def action_reset_to_new(self):
self.state = 'new'
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if not vals.get('name') or vals['name'] == _('New'):
vals['name'] = self.env['ir.sequence'].next_by_code('hr.employee.sequence') or _('New')
return super().create(vals_list)
@api.onchange('employee_id')
def _onchange_employee_id(self):
for rec in self:
if rec.employee_id:
rec.employee_code = rec.employee_id.employee_id or ''
rec.department_id = rec.employee_id.department_id.id
rec.designation_id = rec.employee_id.job_id.id
rec.doj = rec.employee_id.doj
rec.company_id = rec.employee_id.company_id.id
# rec.unit_id = rec.employee_id.unit_name_hr.id if rec.employee_id.unit_name_hr else False
# rec.employee_section_id = rec.employee_id.section_name_hr.id if rec.employee_id.section_name_hr else False
else:
rec.employee_code = False
rec.department_id = False
rec.designation_id = False
rec.doj = False
class DisciplinaryComplaintLine(models.Model):
_name = 'hr.disciplinary.complaint.line'
_description = 'Disciplinary Complaint Line'
name = fields.Char('Name')
disciplinary_id = fields.Many2one('hr.employee.disciplinary',string="Disciplinary")
complaint_date = fields.Date('Complaint Date')
language_id = fields.Many2one('res.lang','Language')
complaint_type_id = fields.Many2one('disciplinary.complaint.type',string="Complaint Type")
mistake_type_id = fields.Many2one('disciplinary.mistake.type',string="Mistake Type")
complaint = fields.Char(string='Complaints')
employee_id = fields.Many2one('hr.employee', string='Employee')
class DisciplinaryActionLine(models.Model):
_name = 'hr.disciplinary.action.line'
_description = 'Disciplinary Action Line'
name = fields.Char('Name')
disciplinary_id = fields.Many2one('hr.employee.disciplinary',string="Disciplinary")
action_taken_date = fields.Date('Action On')
action_type_id = fields.Many2one('disciplinary.action.type',string="Action Type")
action = fields.Char(string='Description')
action_name = fields.Char('ActionName')
related_complaint_id = fields.Many2one('hr.disciplinary.complaint.line', string="Related Complaint",
domain="[('disciplinary_id', '=', disciplinary_id)]")
employee_id = fields.Many2one('hr.employee', string='Employee')
@api.constrains('action_taken_date')
def _check_action_taken_date(self):
for record in self:
if record.action_taken_date and record.action_taken_date > date.today():
raise ValidationError("The Action On date cannot be in the future.")
class DisciplinaryActionType(models.Model):
_name = 'disciplinary.action.type'
_description = 'Action Type'
name = fields.Char('Name', required=True)
class DisciplinaryComplaintType(models.Model):
_name = 'disciplinary.complaint.type'
_description = 'Complaint Type'
name = fields.Char('Name', required=True)
class DisciplinaryMistakeType(models.Model):
_name = 'disciplinary.mistake.type'
_description = 'Mistake Type'
name = fields.Char('Name', required=True)

View File

@ -0,0 +1,22 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_employee_disciplinary,employee_disciplinary,model_employee_disciplinary,,1,1,1,1
access_incident_employee,incident_employee,model_incident_employee,,1,1,1,1
access_incident_sub_employee,incident_sub_employee,model_incident_sub_employee,,1,1,1,1
access_employee_disciplinary_line,employee_disciplinary_line,model_employee_disciplinary_line,,1,1,1,1
access_manage_incident,manage_incident,model_manage_incident,,1,1,1,1
access_manage_incident_line,manage_incident_line,model_manage_incident_line,,1,1,1,1
access_corrective_actions,corrective_actions,model_corrective_actions,,1,1,1,1
access_hr_employee_disciplinary,hr.employee.disciplinary,model_hr_employee_disciplinary,,1,1,1,1
access_hr_disciplinary_complaint_line,hr.disciplinary.complaint.line,model_hr_disciplinary_complaint_line,,1,1,1,1
access_hr_disciplinary_action_line,hr.disciplinary.action.line,model_hr_disciplinary_action_line,,1,1,1,1
access_disciplinary_action_type,disciplinary.action.type,model_disciplinary_action_type,,1,1,1,1
access_disciplinary_complaint_type,disciplinary.complaint.type,model_disciplinary_complaint_type,,1,1,1,1
access_disciplinary_mistake_type,disciplinary.mistake.type,model_disciplinary_mistake_type,,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_employee_disciplinary employee_disciplinary model_employee_disciplinary 1 1 1 1
3 access_incident_employee incident_employee model_incident_employee 1 1 1 1
4 access_incident_sub_employee incident_sub_employee model_incident_sub_employee 1 1 1 1
5 access_employee_disciplinary_line employee_disciplinary_line model_employee_disciplinary_line 1 1 1 1
6 access_manage_incident manage_incident model_manage_incident 1 1 1 1
7 access_manage_incident_line manage_incident_line model_manage_incident_line 1 1 1 1
8 access_corrective_actions corrective_actions model_corrective_actions 1 1 1 1
9 access_hr_employee_disciplinary hr.employee.disciplinary model_hr_employee_disciplinary 1 1 1 1
10 access_hr_disciplinary_complaint_line hr.disciplinary.complaint.line model_hr_disciplinary_complaint_line 1 1 1 1
11 access_hr_disciplinary_action_line hr.disciplinary.action.line model_hr_disciplinary_action_line 1 1 1 1
12 access_disciplinary_action_type disciplinary.action.type model_disciplinary_action_type 1 1 1 1
13 access_disciplinary_complaint_type disciplinary.complaint.type model_disciplinary_complaint_type 1 1 1 1
14 access_disciplinary_mistake_type disciplinary.mistake.type model_disciplinary_mistake_type 1 1 1 1

View File

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_disciplinary_complaint_type_list" model="ir.ui.view">
<field name="name">disciplinary.complaint.type</field>
<field name="model">disciplinary.complaint.type</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
</list>
</field>
</record>
<record id="view_disciplinary_complaint_type_form" model="ir.ui.view">
<field name="name">disciplinary.complaint.type.form</field>
<field name="model">disciplinary.complaint.type</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name" />
</group>
</sheet>
</form>
</field>
</record>
<record id="action_disciplinary_complaint_type" model="ir.actions.act_window">
<field name="name">Employee Disciplinary Complaint Type</field>
<field name="res_model">disciplinary.complaint.type</field>
<field name="view_mode">list,form</field>
</record>
<menuitem
id="menu_view_disciplinary_complaint"
name="Disciplinary Complaints"
action="action_disciplinary_complaint_type"
parent="menu_employee_disciplinary_root"
sequence="19"/>
<record id="view_employee_disciplinary_complaint_line_list" model="ir.ui.view">
<field name="name">hr.disciplinary.action.line</field>
<field name="model">hr.disciplinary.action.line</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
</list>
</field>
</record>
<record id="view_employee_disciplinary_complaint_line_form" model="ir.ui.view">
<field name="name">hr.disciplinary.action.line.form</field>
<field name="model">hr.disciplinary.action.line</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name" />
<field name="disciplinary_id" />
<field name="action_taken_date" />
<field name="action_type_id" />
<field name="action" />
<field name="related_complaint_id" />
<field name="employee_id" />
</group>
</sheet>
</form>
</field>
</record>
<record id="action_employee_disciplinary_complaint_line" model="ir.actions.act_window">
<field name="name">Employee Disciplinary Action</field>
<field name="res_model">hr.disciplinary.action.line</field>
<field name="view_mode">list,form</field>
</record>
<menuitem
id="menu_view_employee__disciplinary_complaint"
name="Employee Disciplinary Complaints"
action="action_employee_disciplinary_complaint_line"
parent="menu_employee_disciplinary_root"
sequence="20"/>
<record id="view_disciplinary_action_type_list" model="ir.ui.view">
<field name="name">disciplinary.action.type</field>
<field name="model">disciplinary.action.type</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
</list>
</field>
</record>
<record id="view_disciplinary_action_type_form" model="ir.ui.view">
<field name="name">disciplinary.action.type.form</field>
<field name="model">disciplinary.action.type</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name" />
</group>
</sheet>
</form>
</field>
</record>
<record id="action_disciplinary_action_type" model="ir.actions.act_window">
<field name="name">Employee Disciplinary Action Type</field>
<field name="res_model">disciplinary.action.type</field>
<field name="view_mode">list,form</field>
</record>
<menuitem
id="menu_view_disciplinary_action_type"
name="Disciplinary Action Type"
action="action_disciplinary_action_type"
parent="menu_employee_disciplinary_root"
sequence="21"/>
</odoo>

View File

@ -0,0 +1,264 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="employee_disciplinary_list" model="ir.ui.view">
<field name="name">Employee Disciplinary list</field>
<field name="model">employee.disciplinary</field>
<field name="arch" type="xml">
<list>
<field name="incident_date"/>
<field name="incident_type"/>
<field name="incident_sub_type" widget="many2many_tags"/>
</list>
</field>
</record>
<record id="employee_disciplinary_form" model="ir.ui.view">
<field name="name">Employee Disciplinary form</field>
<field name="model">employee.disciplinary</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="incident_date"/>
<field name="incident_type" options="{'no_open': True,}"/>
<field name="incident_sub_type" widget="many2many_tags" readonly="0"
options="{'no_open': True}"/>
<label for="employee_code" string="Reported By Employee Code"/>
<div class="address_format">
<field name="employee_code" style="width: 50%" options="{'no_open': True,}"/>
<field name="employee_name" style="width: 50%"/>
</div>
<field name="incident_details"/>
<field name="seized_items"/>
<field name="incident_summary"/>
<field name="attach" widget="many2many_binary" options="{'preview_image': True}"/>
<field name="emp_many_disp" widget="many2many_tags" context="{'new_custom_name': True}"/>
</group>
</sheet>
<chatter/>
</form>
</field>
</record>
<record id="manage_incident_list" model="ir.ui.view">
<field name="name">Manage Incident list</field>
<field name="model">manage.incident</field>
<field name="arch" type="xml">
<list create="0">
<field name="employee_code_list1" widget="many2many_tags" context="{'new_custom_name': True}"/>
<!-- <field name="incident_dat"/>-->
<field name="incident_typ"/>
<field name="incident_sub_typ" widget="many2many_tags"/>
<field name="incident_sum"/>
<field name="state"/>
</list>
</field>
</record>
<record id="manage_incident_form" model="ir.ui.view">
<field name="name">Manage Incident form</field>
<field name="model">manage.incident</field>
<field name="arch" type="xml">
<form create="0">
<header>
<button name="button_in_progress" string="In Progress" class="oe_highlight" type="object"/>
<!-- states="pending_inquiry"/>-->
<!-- attrs="{'invisible' : ('state','!=','pending_inquiry')}"/>-->
<button name="button_closed" string="Closed" class="oe_highlight" type="object"/>
<!-- states="in_progress"/>-->
<!-- attrs="{'invisible' : ('state','!=','in_progress')}"/>-->
<field name="state" widget="statusbar"/>
</header>
<sheet>
<group>
<group>
<field name="employee_code_list1" widget="many2many_tags"
context="{'new_custom_name': True}"/>
<field name="employee_by_code" options="{'no_open': True,}"/>
<!-- <field name="incident_dat"/>-->
</group>
<group>
<field name="incident_typ" options="{'no_open': True,}"/>
<field name="incident_sub_typ" widget="many2many_tags"/>
<field name="incident_sum"/>
</group>
</group>
<field name="employee_inquiry" string="Manage Incident">
<!-- attrs="{'readonly': [('state', '=','closed')]}">-->
<list>
<field name="inquiry_date"/>
<field name="corrective_action_id"/>
<field name="due_date"/>
<field name="last_action_date"/>
</list>
<form>
<group>
<field name="inquiry_date"/>
<field name="venue"/>
<field name="internal_panel" widget="many2many_tags"
context="{'new_custom_name': True}"/>
<field name="external_panel"/>
<field name="inquiry_summary"/>
<field name="is_guilty" widget="radio" options="{'horizontal':true}"/>
<field name="corrective_action_id" options="{'no_open': True,}"/>
<field name="recommendation"/>
<field name="due_date"/>
<field name="last_action_date"/>
</group>
</form>
</field>
</sheet>
<chatter/>
</form>
</field>
</record>
<!-- <record id="career_history_tab_sub_menu" model="ir.ui.view">-->
<!-- <field name="name">Career History Tab Sub Menu</field>-->
<!-- <field name="model">hr.employee</field>-->
<!-- <field name="inherit_id" ref="employee_life_cycle.career_history_tab_menu"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <xpath expr="//page/field[@name='career_history_field']" position="after">-->
<!-- &lt;!&ndash; <group name="career_hist_sub_menu" string="Disciplinary Actions">&ndash;&gt;-->
<!-- &lt;!&ndash; <field name="employee_name_ids1" string="Manage Incident">&ndash;&gt;-->
<!-- &lt;!&ndash; <list editable="0" create="0">&ndash;&gt;-->
<!-- &lt;!&ndash; <field name="incident_date"/>&ndash;&gt;-->
<!-- &lt;!&ndash; <field name="incident_type"/>&ndash;&gt;-->
<!-- &lt;!&ndash; <field name="incident_sub_type"/>&ndash;&gt;-->
<!-- &lt;!&ndash;&lt;!&ndash; <field name="corrective_action_id"/>&ndash;&gt;&ndash;&gt;-->
<!-- &lt;!&ndash; </list>&ndash;&gt;-->
<!-- &lt;!&ndash; </field>&ndash;&gt;-->
<!-- &lt;!&ndash; </group>&ndash;&gt;-->
<!-- <field name="employee_self_service_line_ids" string="Manage Incident" readonly="1">-->
<!-- <list>-->
<!-- <field name="incident_dat"/>-->
<!-- <field name="incident_typ"/>-->
<!-- <field name="incident_sub_typ"/>-->
<!-- </list>-->
<!-- </field>-->
<!-- </xpath>-->
<!-- </field>-->
<!-- </record>-->
<!-- <record id="career_history_tab_sub_menu_self" model="ir.ui.view">-->
<!-- <field name="name">Career History Tab Sub Menu Self Service</field>-->
<!-- <field name="model">hr.employee</field>-->
<!-- <field name="inherit_id" ref="employee_self_service.view_employee_form_self_service"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <xpath expr="//page/field[@name='career_history_field']" position="after">-->
<!-- &lt;!&ndash; <group name="career_hist_sub_menu" string="Disciplinary Actions">&ndash;&gt;-->
<!-- &lt;!&ndash; <field name="employee_name_ids1" string="Manage Incident">&ndash;&gt;-->
<!-- &lt;!&ndash; <list editable="0" create="0">&ndash;&gt;-->
<!-- &lt;!&ndash; <field name="incident_date"/>&ndash;&gt;-->
<!-- &lt;!&ndash; <field name="incident_type"/>&ndash;&gt;-->
<!-- &lt;!&ndash; <field name="incident_sub_type"/>&ndash;&gt;-->
<!-- &lt;!&ndash; &lt;!&ndash; <field name="corrective_action_id"/>&ndash;&gt;&ndash;&gt;-->
<!-- &lt;!&ndash; </list>&ndash;&gt;-->
<!-- &lt;!&ndash; </field>&ndash;&gt;-->
<!-- &lt;!&ndash; </group>&ndash;&gt;-->
<!-- <field name="employee_self_service_line_ids" string="Manage Incident" readonly="1">-->
<!-- <list>-->
<!-- <field name="incident_dat"/>-->
<!-- <field name="incident_typ"/>-->
<!-- <field name="incident_sub_typ"/>-->
<!-- </list>-->
<!-- </field>-->
<!-- </xpath>-->
<!-- </field>-->
<!-- </record>-->
<record id="incident_employee_list" model="ir.ui.view">
<field name="name">incident Employee list</field>
<field name="model">incident.employee</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
<field name="sub_type" widget="many2many_tags"/>
</list>
</field>
</record>
<record id="incident_employee_form" model="ir.ui.view">
<field name="name">incident Employee form</field>
<field name="model">incident.employee</field>
<field name="arch" type="xml">
<form>
<sheet>
<form>
<group>
<field name="name"/>
<field name="sub_type" widget="many2many_tags"/>
</group>
</form>
</sheet>
</form>
</field>
</record>
<record id="employee_disciplinary_action" model="ir.actions.act_window">
<field name="name">Incident Reporting</field>
<field name="res_model">employee.disciplinary</field>
<field name="view_mode">list,form</field>
</record>
<record id="manage_incident_action" model="ir.actions.act_window">
<field name="name">Manage Incident</field>
<field name="res_model">manage.incident</field>
<field name="view_mode">list,form</field>
</record>
<record id="incident_employee_action" model="ir.actions.act_window">
<field name="name">Incident Type</field>
<field name="res_model">incident.employee</field>
<field name="view_mode">list,form</field>
</record>
<record id="action_hr_employee_disciplinary" model="ir.actions.act_window">
<field name="name">Employee Disciplinary</field>
<field name="res_model">hr.employee.disciplinary</field>
<field name="view_mode">list,form</field>
</record>
<menuitem id="employee_disciplinary_menu"
name="Employee Disciplinary Management"
parent="hr.menu_hr_root"
action="employee_disciplinary_action"
sequence="105"/>
<!-- Child Menu (moved inside) -->
<menuitem id="menu_employee_disciplinary_root"
name="Employee Disciplinary Configuration"
parent="employee_disciplinary_menu"
sequence="10"/>
<!-- Sub Menu -->
<menuitem id="menu_employee_disciplinary"
name="Employee Disciplinary"
parent="employee_disciplinary_menu"
action="action_hr_employee_disciplinary"
sequence="01"/>
<!-- <menuitem id="manage_incident_employee"-->
<!-- name="Incident Type"-->
<!-- parent="employee_disciplinary_menu"-->
<!-- action="incident_employee_action"-->
<!-- sequence="3"/>-->
<!-- <menuitem id="manage_incident_sub_menu"-->
<!-- name="Manage Incident"-->
<!-- parent="employee_disciplinary_menu"-->
<!-- action="manage_incident_action"-->
<!-- sequence="2"/>-->
<!-- <menuitem id="employee_disciplinary_sub_menu"-->
<!-- name="Incident Reporting"-->
<!-- parent="employee_disciplinary_menu"-->
<!-- action="employee_disciplinary_action"-->
<!-- sequence="1"/>-->
</odoo>

View File

@ -0,0 +1,169 @@
<odoo>
<!-- Disciplinary Form View -->
<record id="view_hr_employee_disciplinary_form" model="ir.ui.view">
<field name="name">employee.disciplinary.form</field>
<field name="model">hr.employee.disciplinary</field>
<field name="arch" type="xml">
<form string="Employee Disciplinary">
<header>
<button name="action_set_submitted"
type="object"
string="Submit"
class="btn-primary"
invisible="state != 'new'"/>
<button name="action_set_pending"
type="object"
string="Pending"
class="btn-warning"
invisible="state != 'submitted'"/>
<button name="action_set_closed"
type="object"
string="Closed"
class="btn-success"
invisible="state != 'pending'"/>
<button name="action_set_cancel" type="object" string="Cancel"
class="btn-danger" invisible="state not in ['new', 'submitted', 'pending']"/>
<button name="action_reset_to_new" type="object"
string="Reset to New" class="btn-secondary" invisible="state != 'cancel'"/>
<field name="state" widget="statusbar"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="action_open_related_records"
type="object"
icon="fa-gavel"
class="oe_stat_button full-width-button"
string="Disciplinary">
<field name="related_record_count" widget="statinfo"/>
</button>
</div>
<div>
<h3>
<field name="name" readonly="1"/>
</h3>
</div>
<group>
<group>
<field name="employee_code"/>
<field name="employee_id"/>
<field name="designation_id"/>
<field name="doj"/>
<!-- <field name="general_cat"/>-->
<field name="referred_by_id"/>
<!-- <field name="occurrences"/>-->
</group>
<group>
<field name="company_id"/>
<!-- <field name="unit_id"/>-->
<field name="department_id"/>
<!-- <field name="employee_section_id"/>-->
<field name="loss_of_cost"/>
<!-- <field name="cat_id"/>-->
<field name="total_cost"/>
</group>
</group>
<group string="Complaints" colspan="2">
<group colspan="1">
<field name="complaint_date"/>
<field name="language_id"/>
<field name="complaint_type_id"/>
</group>
<group colspan="1">
<field name="mistake_type_id"/>
<field name="complaint"/>
</group>
</group>
<notebook>
<!-- <page name="'complaints" string = "Complaints">-->
<!-- <field name="disciplinary_complaint_line_ids">-->
<!-- <list string="complaints" editable="bottom">-->
<field name="name" column_invisible="1"/>
<field name="complaint_date"/>
<field name="language_id"/>
<field name="complaint_type_id"/>
<field name="mistake_type_id"/>
<field name="complaint"/>
<field name="disciplinary_id" column_invisible="1"/>
<field name="employee_id" column_invisible="1"/>
<!-- </list>-->
<!-- </field>-->
<!-- </page>-->
<page name="'actions" string="Actions">
<field name="disciplinary_action_line_ids">
<list string="Action Lines" editable="bottom">
<field name="name" column_invisible="1"/>
<field name="action_name"/>
<!-- <field name="action_taken_date"/>-->
<field name="action_taken_date"
context="{'max_date': time.strftime('%Y-%m-%d')}"/>
<field name="action_type_id"/>
<field name="action"/>
<field name="disciplinary_id" column_invisible="1"/>
<field name="employee_id" column_invisible="1"/>
</list>
</field>
</page>
</notebook>
</sheet>
<chatter/>
</form>
</field>
</record>
<!-- list View for Employee Disciplinary -->
<record id="view_hr_employee_disciplinary_list" model="ir.ui.view">
<field name="name">hr.employee.disciplinary.list</field>
<field name="model">hr.employee.disciplinary</field>
<field name="arch" type="xml">
<list string="Employee Disciplinary">
<field name="name"/>
<field name="employee_id" string="Employee"/>
<field name="designation_id" string="Designation"/>
<field name="doj" string="Date of Joining"/>
<field name="company_id" string="Company"/>
<!-- <field name="unit_id" string="Unit"/>-->
<field name="department_id" string="Department"/>
<field name="state"
widget="badge"
decoration-primary="state == 'new'"
decoration-warning="state == 'submitted'"
decoration-info="state == 'pending'"
decoration-success="state == 'closed'"
decoration-danger="state == 'cancel'"/>
</list>
</field>
</record>
<record id="view_hr_employee_disciplinary_search" model="ir.ui.view">
<field name="name">hr.employee.disciplinary.search</field>
<field name="model">hr.employee.disciplinary</field>
<field name="arch" type="xml">
<search string="Search Employee Disciplinary">
<field name="employee_id" string="Employee"/>
<field name="employee_code" string="Employee Code"/>
</search>
</field>
</record>
<record id="action_hr_employee_disciplinary" model="ir.actions.act_window">
<field name="name">Employee Disciplinary</field>
<field name="res_model">hr.employee.disciplinary</field>
<field name="view_mode">list,form</field>
<field name="search_view_id" ref="view_hr_employee_disciplinary_search"/>
</record>
<!-- <menuitem id="menu_employee_disciplinary_root" name="Employee Disciplinary" sequence="15" parent="hr.menu_hr_root"/>-->
<!-- <menuitem id="menu_employee_disciplinary" name="Employee Disciplinary"-->
<!-- parent="menu_employee_disciplinary_root"-->
<!-- action="action_hr_employee_disciplinary"-->
<!-- sequence="10"/>-->
</odoo>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<!-- list View -->
<record id="view_incident_sub_employee_list" model="ir.ui.view">
<field name="name">incident.sub.employee.list</field>
<field name="model">incident.sub.employee</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
</list>
</field>
</record>
<!-- Form View -->
<record id="view_incident_sub_employee_form" model="ir.ui.view">
<field name="name">incident.sub.employee.form</field>
<field name="model">incident.sub.employee</field>
<field name="arch" type="xml">
<form string="Incident Sub Type">
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>
<!-- Action -->
<record id="action_incident_sub_employee" model="ir.actions.act_window">
<field name="name">Incident Sub Type</field>
<field name="res_model">incident.sub.employee</field>
<field name="view_mode">list,form</field>
</record>
<!-- Menu -->
<!-- <menuitem id="menu_incident_sub_employee"-->
<!-- name="Incident Sub Type"-->
<!-- parent="employee_disciplinary_menu"-->
<!-- action="action_incident_sub_employee"/>-->
</data>
</odoo>

View File

@ -0,0 +1,42 @@
<odoo>
<!-- Tree View -->
<record id="view_mistake_type_list" model="ir.ui.view">
<field name="name">mistake.type.list</field>
<field name="model">disciplinary.mistake.type</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
</list>
</field>
</record>
<!-- Form View -->
<record id="view_mistake_type_form" model="ir.ui.view">
<field name="name">mistake.type.form</field>
<field name="model">disciplinary.mistake.type</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>
<!-- Action -->
<record id="action_mistake_type" model="ir.actions.act_window">
<field name="name">Mistake Type</field>
<field name="res_model">disciplinary.mistake.type</field>
<field name="view_mode">list,form</field>
</record>
<menuitem
id="menu_mistake_type"
name="Mistake Type"
parent="menu_employee_disciplinary_root"
action="action_mistake_type"
sequence="02"/>
</odoo>

View File

@ -0,0 +1 @@
from . import models

View File

@ -0,0 +1,19 @@
{
"name": "Document Parser",
"summary": "Reusable AI-assisted document text and data extraction",
"version": "1.0.0",
"category": "Tools",
"author": "Pranay",
"website": "https://www.ftprotech.com",
"license": "LGPL-3",
"depends": ["base"],
"data": [
"views/res_config_settings_views.xml",
],
"installable": True,
"application": False,
"auto_install": False,
"external_dependencies": {
"python": ["requests","python-docx"],
},
}

View File

@ -0,0 +1,2 @@
from . import document_parser_service
from . import res_config_settings

View File

@ -0,0 +1,529 @@
import base64
import json
import logging
import mimetypes
import re
from io import BytesIO
import requests
from odoo import _, api, models
from odoo.exceptions import UserError
try:
import pytesseract
except Exception: # pragma: no cover - optional dependency
pytesseract = None
try:
from PIL import Image
except Exception: # pragma: no cover - optional dependency
Image = None
try:
from pdf2image import convert_from_bytes
except Exception: # pragma: no cover - optional dependency
convert_from_bytes = None
try:
from pypdf import PdfReader
except Exception: # pragma: no cover - optional dependency
PdfReader = None
try:
from docx import Document
except Exception: # pragma: no cover - optional dependency
Document = None
_logger = logging.getLogger(__name__)
class DocumentParserService(models.AbstractModel):
_name = "document.parser.service"
_description = "Document Parser Service"
TOGETHER_ENDPOINT = "https://api.together.xyz/v1/chat/completions"
OPENROUTER_ENDPOINT = "https://openrouter.ai/api/v1/chat/completions"
TOGETHER_MODELS = [
"Qwen/Qwen2.5-7B-Instruct-Turbo",
"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
]
OPENROUTER_MODELS = [
"qwen/qwen-2.5-7b-instruct",
"qwen/qwen-2.5-7b-instruct:free",
"deepseek/deepseek-chat:free",
]
@api.model
def parse_document(
self,
file_content,
filename=None,
required_fields=None,
extra_instructions=None,
json_schema=None,
):
if not file_content:
raise UserError(_("No document provided."))
if not filename:
raise UserError(_("Filename is required."))
binary = self._decode_file_content(file_content)
mimetype = self._detect_mimetype(binary, filename)
text_content = self._extract_text(binary, mimetype)
fields_spec = self._normalize_required_fields(required_fields or {})
if not text_content.strip():
return {
"filename": filename,
"mimetype": mimetype,
"text": "",
"result": {},
"provider": False,
"errors": [_("No text could be extracted from the document.")],
"error": _("No text could be extracted from the document."),
}
schema_text = json_schema or self._build_json_schema_text(fields_spec)
ai_result, provider_used, provider_errors = self._send_to_ai(
text_content=text_content[:45000],
schema_text=schema_text,
extra_instructions=extra_instructions,
)
if not ai_result:
ai_result = self._extract_with_heuristics(text_content, fields_spec)
ai_result = ai_result or {}
error_message = False
if not ai_result and provider_errors:
error_message = "; ".join(provider_errors[:3])
return {
"filename": filename,
"mimetype": mimetype,
"text": text_content,
"result": ai_result,
"provider": provider_used,
"errors": provider_errors,
"error": error_message,
}
@api.model
def extract_requested_data(self, file_content, filename, required_fields, extra_instructions=None, json_schema=None):
return self.parse_document(
file_content=file_content,
filename=filename,
required_fields=required_fields,
extra_instructions=extra_instructions,
json_schema=json_schema,
)["result"]
def _decode_file_content(self, file_content):
if isinstance(file_content, bytes):
if file_content.startswith((b"%PDF", b"\xFF\xD8", b"\x89PNG", b"PK")):
return file_content
try:
return base64.b64decode(file_content)
except Exception:
return file_content
if isinstance(file_content, str):
try:
return base64.b64decode(file_content)
except Exception as exc:
raise UserError(_("Invalid base64 document.")) from exc
raise UserError(_("Unsupported file format."))
def _detect_mimetype(self, binary, filename):
if filename:
guessed = mimetypes.guess_type(filename)[0]
if guessed:
return guessed
if binary.startswith(b"%PDF"):
return "application/pdf"
if binary.startswith(b"\xFF\xD8"):
return "image/jpeg"
if binary.startswith(b"\x89PNG"):
return "image/png"
if binary[:2] == b"PK":
return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
return "application/octet-stream"
def _extract_text(self, binary, mimetype):
text_content = ""
try:
if mimetype == "application/pdf":
text_content = self._extract_text_from_pdf(binary)
elif mimetype in {"image/png", "image/jpeg", "image/jpg"}:
text_content = self._extract_text_from_image(binary)
elif mimetype == "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
text_content = self._extract_text_from_docx(binary)
elif mimetype.startswith("text/"):
text_content = binary.decode("utf-8", errors="ignore")
except Exception as exc:
_logger.exception("Document text extraction failed: %s", exc)
return (text_content or "").strip()
def _extract_text_from_pdf(self, binary):
extracted_parts = []
if PdfReader:
try:
reader = PdfReader(BytesIO(binary))
extracted_parts.extend(page.extract_text() or "" for page in reader.pages)
except Exception as exc:
_logger.warning("PdfReader extraction failed: %s", exc)
text_content = "\n".join(part for part in extracted_parts if part).strip()
if text_content:
return text_content
if convert_from_bytes and pytesseract:
try:
images = convert_from_bytes(binary, dpi=300)
return "\n".join(
pytesseract.image_to_string(image)
for image in images
).strip()
except Exception as exc:
_logger.warning("PDF OCR extraction failed: %s", exc)
return ""
def _extract_text_from_image(self, binary):
if not pytesseract or not Image:
return ""
try:
image = Image.open(BytesIO(binary))
return pytesseract.image_to_string(image).strip()
except Exception as exc:
_logger.warning("Image OCR extraction failed: %s", exc)
return ""
def _extract_text_from_docx(self, binary):
if not Document:
return ""
try:
document = Document(BytesIO(binary))
return "\n".join(
paragraph.text for paragraph in document.paragraphs if paragraph.text
).strip()
except Exception as exc:
_logger.warning("DOCX extraction failed: %s", exc)
return ""
def _send_to_ai(self, text_content, schema_text, extra_instructions=None):
prompt = self._build_prompt(text_content, schema_text, extra_instructions)
errors = []
together_key = self._get_param("document_parser.together_ai_key") or self._get_param("document_parser.together_api_key")
openrouter_key = self._get_param("document_parser.openrouter_ai_key") or self._get_param("document_parser.openrouter_api_key")
if together_key:
result, provider_errors = self._call_provider(
provider_name="Together",
endpoint=self.TOGETHER_ENDPOINT,
headers={
"Authorization": f"Bearer {together_key}",
"Content-Type": "application/json",
},
models=self.TOGETHER_MODELS,
prompt=prompt,
)
if result:
return result, "together", errors
errors.extend(provider_errors)
else:
errors.append(_("Together AI key is not configured."))
if openrouter_key:
result, provider_errors = self._call_provider(
provider_name="OpenRouter",
endpoint=self.OPENROUTER_ENDPOINT,
headers={
"Authorization": f"Bearer {openrouter_key}",
"Content-Type": "application/json",
"HTTP-Referer": self._get_param("web.base.url") or "odoo.local",
"X-Title": "Document Parser",
},
models=self.OPENROUTER_MODELS,
prompt=prompt,
)
if result:
return result, "openrouter", errors
errors.extend(provider_errors)
else:
errors.append(_("OpenRouter key is not configured."))
return {}, False, errors
def _build_prompt(self, text_content, schema_text, extra_instructions=None):
return f"""
You are a strict JSON generator.
RULES:
- Output ONLY valid raw JSON.
- No explanation.
- No markdown.
- No backticks.
- No extra text.
- Follow schema strictly.
- If a field is missing in text, return null.
- Scan the entire document carefully before answering.
- Extract ONLY what exists in text.
- FOR ANY DATES CHANGE FORMAT TO %Y-%m-%d
FIELD RULES:
- If "skills" exists, extract only explicit technical skills written in the document.
- Do NOT infer similar skills from role names, responsibilities, or projects.
- Normalize names like "Expert Python" to "Python".
- Exclude soft skills and business phrases.
- Exclude responsibility-style phrases like Cross-Functional Collaboration, Cost Saving, Resource Utilization, Documentation, Reporting, and Team Handling.
- Prefer concrete tools, methods, technologies, platforms, certifications, engineering/process methods, and domain techniques explicitly written in the resume.
- If the resume explicitly mentions items like AutoCAD, Root Cause Analysis, Project Management, Manufacturing Processes, Lean, Six Sigma, or Quality Control, include them.
- Remove duplicates and return each skill only once.
- If "email" exists, return one valid normalized email.
- If "name" exists, prefer the full name at the top and exclude titles, companies, and addresses.
- If "phone" exists, return the most complete phone number found.
- If "experience" exists, return only clearly supported numeric values.
Schema:
{schema_text}
Instructions:
{extra_instructions or "None"}
Document:
{text_content}
"""
def _call_provider(self, provider_name, endpoint, headers, models, prompt):
errors = []
for model in models:
payload = {
"model": model,
"messages": [{"role": "user", "content": prompt}],
"temperature": 0,
"max_tokens": 1500,
}
try:
response = requests.post(endpoint, headers=headers, json=payload, timeout=90)
if response.status_code != 200:
message = _("%(provider)s model %(model)s failed with %(status)s: %(body)s") % {
"provider": provider_name,
"model": model,
"status": response.status_code,
"body": (response.text or "")[:300],
}
_logger.warning(message)
errors.append(message)
continue
body = response.json()
content = self._extract_message_content(body)
parsed = self._safe_json_load(content)
if parsed:
return parsed, errors
message = _("%(provider)s model %(model)s returned invalid JSON.") % {
"provider": provider_name,
"model": model,
}
_logger.warning(message)
errors.append(message)
except Exception as exc:
message = _("%(provider)s model %(model)s error: %(error)s") % {
"provider": provider_name,
"model": model,
"error": str(exc),
}
_logger.warning(message)
errors.append(message)
return {}, errors
def _extract_message_content(self, response_body):
try:
content = response_body["choices"][0]["message"]["content"]
except Exception:
return ""
if isinstance(content, list):
parts = []
for item in content:
if isinstance(item, dict):
if item.get("type") == "text":
parts.append(item.get("text", ""))
elif item.get("text"):
parts.append(item.get("text"))
else:
parts.append(str(item))
return "\n".join(part for part in parts if part)
if isinstance(content, dict):
return content.get("text", "")
return content or ""
def _safe_json_load(self, content):
if not content:
return {}
content = content.strip().replace("```json", "").replace("```", "").strip()
try:
return json.loads(content)
except Exception:
pass
match = re.search(r"\{[\s\S]*\}", content)
if match:
try:
return json.loads(match.group(0))
except Exception:
pass
_logger.warning("JSON parse failed for provider response: %s", content[:500])
return {}
def _extract_with_heuristics(self, text_content, fields):
result = {}
email_match = re.search(r"([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,})", text_content or "", re.I)
phone_match = re.search(r"(\+?\d[\d\-\s()]{7,}\d)", text_content or "")
linkedin_match = re.search(r"(https?://(?:www\.)?linkedin\.com/[^\s]+)", text_content or "", re.I)
name_guess = self._guess_name(text_content or "")
skills_guess = self._guess_skills(text_content or "")
for field_name, field_spec in fields.items():
field_type = field_spec.get("type", "string")
if field_name in {"email", "email_from"}:
result[field_name] = email_match.group(1).lower() if email_match else None
elif field_name in {"phone", "mobile", "partner_phone"}:
result[field_name] = phone_match.group(1).strip() if phone_match else None
elif field_name in {"linkedin_profile", "linkedin"}:
result[field_name] = linkedin_match.group(1).strip() if linkedin_match else None
elif field_name in {"name", "full_name", "partner_name"}:
result[field_name] = name_guess
elif field_name == "skills" and field_type == "list":
result[field_name] = skills_guess
else:
result[field_name] = None
return result
def _guess_name(self, text_content):
for line in [line.strip() for line in (text_content or "").splitlines() if line.strip()][:12]:
cleaned = re.sub(r"[^A-Za-z .'-]", "", line).strip()
if len(cleaned.split()) in {2, 3, 4} and not re.search(r"(resume|cv|email|phone|linkedin|skills|experience)", cleaned, re.I):
return cleaned
return None
def _guess_skills(self, text_content):
section = re.search(r"(skills|technical skills|core competencies)(.*?)(experience|education|projects|certifications|$)", text_content or "", re.I | re.S)
if not section:
return []
parts = re.split(r"[,;\n|•]", section.group(2))
cleaned = []
for part in parts:
value = re.sub(r"\s+", " ", part).strip(" -:\t\r\n")
if value and 1 < len(value) < 50 and not re.search(r"^(skills?|experience|education)$", value, re.I):
cleaned.append(value)
return list(dict.fromkeys(cleaned[:25]))
def _get_param(self, key):
return self.env["ir.config_parameter"].sudo().get_param(key)
@api.model
def validate_explicit_skills(self, resume_text, skills):
if not skills:
return []
prompt = f"""
You are validating resume skills.
Resume:
{resume_text[:30000]}
Extracted Skills:
{json.dumps(skills)}
Keep ONLY skills explicitly claimed by the candidate.
A skill is explicit if:
- It is presented as the candidate's expertise.
- It appears in a skill list or competency list.
Reject skills appearing only in:
- job responsibilities
- project descriptions
- achievements
- employer history
Return ONLY JSON.
Example:
{{
"skills": ["Python", "Django"]
}}
"""
errors = []
together_key = self._get_param(
"document_parser.together_ai_key"
) or self._get_param(
"document_parser.together_api_key"
)
openrouter_key = self._get_param(
"document_parser.openrouter_ai_key"
) or self._get_param(
"document_parser.openrouter_api_key"
)
if together_key:
result, provider_errors = self._call_provider(
provider_name="Together",
endpoint=self.TOGETHER_ENDPOINT,
headers={
"Authorization": f"Bearer {together_key}",
"Content-Type": "application/json",
},
models=self.TOGETHER_MODELS,
prompt=prompt,
)
if result:
return result.get("skills", skills)
errors.extend(provider_errors)
if openrouter_key:
result, provider_errors = self._call_provider(
provider_name="OpenRouter",
endpoint=self.OPENROUTER_ENDPOINT,
headers={
"Authorization": f"Bearer {openrouter_key}",
"Content-Type": "application/json",
"HTTP-Referer": self._get_param("web.base.url") or "odoo.local",
"X-Title": "Document Parser",
},
models=self.OPENROUTER_MODELS,
prompt=prompt,
)
if result:
return result.get("skills", skills)
errors.extend(provider_errors)
return skills
def _normalize_required_fields(self, fields):
if isinstance(fields, dict):
normalized = {}
for field_name, field_value in fields.items():
if isinstance(field_value, dict):
normalized[field_name] = {
"type": field_value.get("type", "string"),
"description": field_value.get("description", field_name.replace("_", " ").title()),
}
else:
normalized[field_name] = {
"type": "string",
"description": str(field_value or field_name.replace("_", " ").title()),
}
return normalized
if isinstance(fields, list):
return {field_name: {"type": "string", "description": field_name.replace("_", " ").title()} for field_name in fields}
return {}
def _build_json_schema_text(self, fields):
return json.dumps(fields, ensure_ascii=True)

View File

@ -0,0 +1,67 @@
import requests
from odoo import _, fields, models
from odoo.exceptions import UserError
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
together_ai_key = fields.Char(
string="Together AI Key",
config_parameter="document_parser.together_ai_key",
)
openrouter_ai_key = fields.Char(
string="OpenRouter AI Key",
config_parameter="document_parser.openrouter_ai_key",
)
def action_test_together_ai_connection(self):
self.ensure_one()
if not self.together_ai_key:
raise UserError(_("Please add the Together AI key first."))
response = requests.get(
"https://api.together.xyz/v1/models",
headers={"Authorization": f"Bearer {self.together_ai_key}"},
timeout=20,
)
if response.ok:
return {
"type": "ir.actions.client",
"tag": "display_notification",
"params": {
"title": _("Together AI Connection"),
"message": _("Connection successful."),
"type": "success",
"sticky": False,
},
}
raise UserError(_("Together AI connection failed: %s") % (response.text or response.reason))
def action_test_openrouter_ai_connection(self):
self.ensure_one()
if not self.openrouter_ai_key:
raise UserError(_("Please add the OpenRouter key first."))
response = requests.get(
"https://openrouter.ai/api/v1/models",
headers={
"Authorization": f"Bearer {self.openrouter_ai_key}",
"HTTP-Referer": self.env["ir.config_parameter"].sudo().get_param("web.base.url", ""),
"X-Title": "Odoo Document Parser",
},
timeout=20,
)
if response.ok:
return {
"type": "ir.actions.client",
"tag": "display_notification",
"params": {
"title": _("OpenRouter Connection"),
"message": _("Connection successful."),
"type": "success",
"sticky": False,
},
}
raise UserError(_("OpenRouter connection failed: %s") % (response.text or response.reason))

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form_document_parser" model="ir.ui.view">
<field name="name">res.config.settings.view.form.document.parser</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="80"/>
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//form" position="inside">
<app string="Document Parser" name="document_parser" groups="base.group_system">
<block title="AI Providers" name="document_parser_ai_provider_block">
<setting string="Together AI Key"
help="Primary provider used first for structured document extraction."
id="document_parser_together_ai_key">
<div class="d-flex align-items-center gap-2">
<field name="together_ai_key" password="True" placeholder="together.ai API key"/>
<button name="action_test_together_ai_connection"
string="Test Connection"
type="object"
class="btn btn-secondary"/>
</div>
</setting>
<setting string="OpenRouter AI Key"
help="Fallback provider used when Together AI is unavailable or quota is exhausted."
id="document_parser_openrouter_ai_key">
<div class="d-flex align-items-center gap-2">
<field name="openrouter_ai_key" password="True" placeholder="openrouter API key"/>
<button name="action_test_openrouter_ai_connection"
string="Test Connection"
type="object"
class="btn btn-secondary"/>
</div>
</setting>
</block>
</app>
</xpath>
</field>
</record>
</odoo>

View File

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

View File

@ -34,7 +34,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','hr_payroll','hr_employee_extended'], 'depends': ['base','hr','hr_payroll','hr_employee_extended','l10n_in_hr_payroll'],
# always loaded # always loaded
'data': [ 'data': [
@ -48,12 +48,15 @@
'report/report_action.xml', 'report/report_action.xml',
'report/it_tax_template.xml', 'report/it_tax_template.xml',
'views/it_tax_menu_and_wizard_view.xml', 'views/it_tax_menu_and_wizard_view.xml',
'views/employee_payslip_download_wizard_views.xml',
'wizards/hr_tds_calculation.xml',
'wizards/children_education_costing.xml', 'wizards/children_education_costing.xml',
'wizards/employee_life_insurance.xml', 'wizards/employee_life_insurance.xml',
'wizards/nsc_declaration.xml', 'wizards/nsc_declaration.xml',
'wizards/self_occupied_property.xml', 'wizards/self_occupied_property.xml',
'wizards/letout_house_property.xml', 'wizards/letout_house_property.xml',
'wizards/nsc_income_loss.xml', 'wizards/nsc_income_loss.xml',
'data/default_investment_types.xml',
# 'views/it_investment_type.xml', # 'views/it_investment_type.xml',
# 'views/it_investment_costing.xml' # 'views/it_investment_costing.xml'
], ],

View File

@ -0,0 +1 @@
from . import main

View File

@ -0,0 +1,63 @@
import io
import zipfile
from odoo import _
from odoo.exceptions import AccessError, UserError
from odoo.http import Controller, content_disposition, request, route
class EmployeePayslipDownloadController(Controller):
@route('/employee_it_declaration/my_payslips/<int:wizard_id>', type='http', auth='user')
def download_my_payslips(self, wizard_id, **kwargs):
wizard = request.env['employee.payslip.download.wizard'].browse(wizard_id)
if not wizard.exists() or wizard.create_uid != request.env.user:
return request.not_found()
try:
payslips = wizard._get_payslips_for_download()
except (AccessError, UserError):
return request.not_found()
if wizard.download_type == 'single':
payslip = payslips[:1]
report, pdf_content = wizard._get_pdf_content(payslip)
headers = [
('Content-Type', 'application/pdf'),
('Content-Length', len(pdf_content)),
('Content-Disposition', content_disposition(wizard._get_pdf_filename(payslip, report))),
]
return request.make_response(pdf_content, headers=headers)
zip_buffer = io.BytesIO()
used_filenames = set()
with zipfile.ZipFile(zip_buffer, 'w', compression=zipfile.ZIP_DEFLATED) as payslip_zip:
for payslip in payslips:
report, pdf_content = wizard._get_pdf_content(payslip)
filename = self._deduplicate_filename(wizard._get_pdf_filename(payslip, report), used_filenames)
payslip_zip.writestr(filename, pdf_content)
zip_content = zip_buffer.getvalue()
headers = [
('Content-Type', 'application/zip'),
('Content-Length', len(zip_content)),
('Content-Disposition', content_disposition(wizard._get_zip_filename())),
]
return request.make_response(zip_content, headers=headers)
@staticmethod
def _deduplicate_filename(filename, used_filenames):
if filename not in used_filenames:
used_filenames.add(filename)
return filename
stem, extension = filename.rsplit('.', 1) if '.' in filename else (filename, '')
counter = 2
while True:
candidate = _('%(stem)s (%(counter)s)', stem=stem, counter=counter)
if extension:
candidate = '%s.%s' % (candidate, extension)
if candidate not in used_filenames:
used_filenames.add(candidate)
return candidate
counter += 1

View File

@ -0,0 +1,579 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="0">
<record id="investment_type_past_employment" model="it.investment.type">
<field name="sequence">5</field>
<field name="investment_type">past_employment</field>
<field name="regime">both</field>
</record>
<record id="investment_type_us80c" model="it.investment.type">
<field name="sequence">10</field>
<field name="investment_type">us_80c</field>
<field name="regime">both</field>
</record>
<record id="investment_type_us80d" model="it.investment.type">
<field name="sequence">20</field>
<field name="investment_type">us_80d</field>
<field name="regime">both</field>
</record>
<record id="investment_type_us10" model="it.investment.type">
<field name="sequence">30</field>
<field name="investment_type">us_10</field>
<field name="regime">both</field>
</record>
<record id="investment_type_us80g" model="it.investment.type">
<field name="sequence">40</field>
<field name="investment_type">us_80g</field>
<field name="regime">both</field>
</record>
<record id="investment_type_chapter_via" model="it.investment.type">
<field name="sequence">50</field>
<field name="investment_type">chapter_via</field>
<field name="regime">both</field>
</record>
<record id="investment_type_us17" model="it.investment.type">
<field name="sequence">60</field>
<field name="investment_type">us_17</field>
<field name="regime">both</field>
</record>
<record id="investment_type_house_rent" model="it.investment.type">
<field name="sequence">70</field>
<field name="investment_type">house_rent</field>
<field name="regime">old</field>
</record>
<record id="investment_type_other_income_loss" model="it.investment.type">
<field name="sequence">80</field>
<field name="investment_type">other_i_or_l</field>
<field name="regime">both</field>
</record>
<record id="investment_type_other_declaration" model="it.investment.type">
<field name="sequence">90</field>
<field name="investment_type">other_declaration</field>
<field name="regime">both</field>
</record>
<!-- Past Employment: required for periods before 2026-2027, configurable on Payroll Periods -->
<record id="past_emp_total_income" model="past_employment.investment.type">
<field name="sequence">10</field>
<field name="name">Previous Employer Total Income (Gross Salary + Any Other Income)</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PETI</field>
<field name="tax_regime">both</field>
</record>
<record id="past_emp_us10_lta_exemption" model="past_employment.investment.type">
<field name="sequence">20</field>
<field name="name">Previous Employer LESS: US10 LTA exemption</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PELTA</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_us10_gratuity_exemption" model="past_employment.investment.type">
<field name="sequence">30</field>
<field name="name">Previous Employer LESS: US10 Gratuity exemption</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PEGRAT</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_us10_leave_encashment_exemption" model="past_employment.investment.type">
<field name="sequence">40</field>
<field name="name">Previous Employer LESS: US10 Leave encashment exemption</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PELEAV</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_us10_others_exemption" model="past_employment.investment.type">
<field name="sequence">50</field>
<field name="name">Previous Employer LESS: US10 Others (HRAUniformWashingetc)</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PEOTH</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_prof_tax" model="past_employment.investment.type">
<field name="sequence">60</field>
<field name="name">Previous Employer Prof.Tax</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PEPROF</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_standard_deduction" model="past_employment.investment.type">
<field name="sequence">70</field>
<field name="name">Previous Employer Standard Deduction Benefit Claimed</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PESTD</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_invest_us80c" model="past_employment.investment.type">
<field name="sequence">80</field>
<field name="name">Previous Employer Invest US 80C</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PEIUSC</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_chapter_via" model="past_employment.investment.type">
<field name="sequence">90</field>
<field name="name">Previous Employer Chapter IVAUS80CCCothers</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PECHAP</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_net_taxable_income" model="past_employment.investment.type">
<field name="sequence">100</field>
<field name="name">Net Taxable Income</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PENET</field>
<field name="compute_method">1</field>
<field name="compute_code">PETI - PELTA - PEGRAT - PELEAV - PEOTH - PEPROF - PESTD - PEIUSC - PECHAP</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_taxable_income_after_exemption" model="past_employment.investment.type">
<field name="sequence">110</field>
<field name="name">Previous Employer Taxable Income After Exemption (Gross - US10 - Chapter VIA US80C) Except Prof.Tax</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PEAFT</field>
<field name="compute_method">1</field>
<field name="compute_code">PETI - PELTA - PEGRAT - PELEAV - PEOTH - PEIUSC - PECHAP</field>
<field name="tax_regime">both</field>
</record>
<record id="past_emp_tax" model="past_employment.investment.type">
<field name="sequence">120</field>
<field name="name">Previous Employer Tax</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PETAX</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_surcharge" model="past_employment.investment.type">
<field name="sequence">130</field>
<field name="name">Previous Employer Surcharge</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PESUR</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_cess" model="past_employment.investment.type">
<field name="sequence">140</field>
<field name="name">Previous Employer Cess</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PECESS</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_tds_deduction" model="past_employment.investment.type">
<field name="sequence">150</field>
<field name="name">Previous Employer TDS Deduction</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PETDS</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_hra_exemptions" model="past_employment.investment.type">
<field name="sequence">160</field>
<field name="name">Previous Employer House Rent Allowance Exemptions</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PEHRA</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_conveyance_exemptions" model="past_employment.investment.type">
<field name="sequence">170</field>
<field name="name">Previous Employer Conveyance Exemptions</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PECON</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_medical_reimbursement_exemptions" model="past_employment.investment.type">
<field name="sequence">180</field>
<field name="name">Previous Employer Medical Reimbursement Exemptions</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PEMED</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_lta_exemption" model="past_employment.investment.type">
<field name="sequence">190</field>
<field name="name">Previous Employer LTA Exemption</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PELT2</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_children_exemption" model="past_employment.investment.type">
<field name="sequence">200</field>
<field name="name">Previous Employer Children Exemption</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PECHLD</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_other_exemption" model="past_employment.investment.type">
<field name="sequence">210</field>
<field name="name">Previous Employer other Exemption</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PEOT2</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_infra_exemption" model="past_employment.investment.type">
<field name="sequence">220</field>
<field name="name">Previous Employer Infra exemption</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PEINF</field>
<field name="tax_regime">old</field>
</record>
<record id="past_emp_gratuity_received" model="past_employment.investment.type">
<field name="sequence">230</field>
<field name="name">Previous Employer Gratuity Received</field>
<field name="investment_type" ref="investment_type_past_employment"/>
<field name="investment_code">PEGR2</field>
<field name="tax_regime">old</field>
</record>
<!-- US 80C: Old regime deductions -->
<record id="us80c_nps_employee" model="us80c.investment.type">
<field name="sequence">10</field>
<field name="name">US 80CCD(1) - Contribution to NPS Scheme (10% of salary)</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80NPS</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_elss" model="us80c.investment.type">
<field name="sequence">20</field>
<field name="name">Mutual Fund - Equity Linked Savings Scheme (ELSS)</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80ELSS</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_pension_funds" model="us80c.investment.type">
<field name="sequence">30</field>
<field name="name">US 80CCC - Pension Funds</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80PEN</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_children_education_fees" model="us80c.investment.type">
<field name="sequence">40</field>
<field name="name">Children Education Fees</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80EDU</field>
<field name="require_action">1</field>
<field name="action_id" ref="action_children_education"/>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_ppf" model="us80c.investment.type">
<field name="sequence">50</field>
<field name="name">Public Provident Fund (PPF)</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80PPF</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_lic_premiums" model="us80c.investment.type">
<field name="sequence">60</field>
<field name="name">LIC - Life Insurance Premiums</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80LIC</field>
<field name="require_action">1</field>
<field name="action_id" ref="action_us80c_insurance_line"/>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_nsc" model="us80c.investment.type">
<field name="sequence">70</field>
<field name="name">National Savings Certificate (NSC)</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80NSC</field>
<field name="require_action">1</field>
<field name="action_id" ref="action_nsc_declaration_line"/>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_ulip" model="us80c.investment.type">
<field name="sequence">80</field>
<field name="name">Unit linked Insurance Plan (ULIP)</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80ULIP</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_five_year_bank_fd" model="us80c.investment.type">
<field name="sequence">90</field>
<field name="name">5-Yr bank fixed deposits (FDs)</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80FD5</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_post_office_time_deposit" model="us80c.investment.type">
<field name="sequence">100</field>
<field name="name">5-Yr post office time deposit (POTD) scheme</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80POT</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_home_loan_principal" model="us80c.investment.type">
<field name="sequence">110</field>
<field name="name">Certificate provided for Home Loan Principal Repayment</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80HLP</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_infrastructure_fund" model="us80c.investment.type">
<field name="sequence">120</field>
<field name="name">Infrastructure Fund</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80INF</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_nabard_rural_bonds" model="us80c.investment.type">
<field name="sequence">130</field>
<field name="name">NABARD rural bonds</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80NRB</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_pf" model="us80c.investment.type">
<field name="sequence">140</field>
<field name="name">Provident Fund (PF)</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80PF</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_scss" model="us80c.investment.type">
<field name="sequence">150</field>
<field name="name">Senior Citizen Savings Scheme 2004 (SCSS)</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80SCS</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_stamp_duty_registration" model="us80c.investment.type">
<field name="sequence">160</field>
<field name="name">Stamp Duty and Registration Charges for a home</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80SDR</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_superannuation" model="us80c.investment.type">
<field name="sequence">170</field>
<field name="name">Superannuation</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80SUP</field>
<field name="limit">150000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_vpf" model="us80c.investment.type">
<field name="sequence">180</field>
<field name="name">Voluntary Provident Fund (VPF)</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80VPF</field>
<field name="tax_regime">old</field>
</record>
<record id="us80c_sukanya_samriddhi" model="us80c.investment.type">
<field name="sequence">190</field>
<field name="name">Sukanya Samriddhi Scheme</field>
<field name="investment_type" ref="investment_type_us80c"/>
<field name="investment_code">C80SSS</field>
<field name="tax_regime">old</field>
</record>
<!-- US 80D: Old regime deductions -->
<record id="us80d_medical_insurance_self" model="us80d.investment.type">
<field name="sequence">10</field>
<field name="name">US 80D - Medical Insurance Premium Self</field>
<field name="investment_type" ref="investment_type_us80d"/>
<field name="for_family">1</field>
<field name="limit">25000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80d_preventive_health_checkup_self" model="us80d.investment.type">
<field name="sequence">20</field>
<field name="name">US 80D - Preventive Health Checkup (Self)</field>
<field name="investment_type" ref="investment_type_us80d"/>
<field name="for_family">1</field>
<field name="limit">5000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80d_medical_insurance_parents_below_60" model="us80d.investment.type">
<field name="sequence">30</field>
<field name="name">US 80D - Medical Insurance Premium Parents below 60 years</field>
<field name="investment_type" ref="investment_type_us80d"/>
<field name="for_parents">1</field>
<field name="limit">25000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80d_medical_insurance_senior_parents" model="us80d.investment.type">
<field name="sequence">40</field>
<field name="name">US 80D - Medical Insurance Premium Parents (Senior Citizen)</field>
<field name="investment_type" ref="investment_type_us80d"/>
<field name="for_senior_parent">1</field>
<field name="limit">50000</field>
<field name="tax_regime">old</field>
</record>
<record id="us80d_medical_expenditure_very_senior" model="us80d.investment.type">
<field name="sequence">50</field>
<field name="name">US 80D - Medical Insurance Expenditure Very Senior Citizen</field>
<field name="investment_type" ref="investment_type_us80d"/>
<field name="for_senior_parent">1</field>
<field name="limit">50000</field>
<field name="tax_regime">old</field>
</record>
<!-- US 10: Old regime exemptions -->
<record id="us10_children_education_allowance" model="us10.investment.type">
<field name="sequence">10</field>
<field name="name">Children Education Allowance Exemptions</field>
<field name="investment_type" ref="investment_type_us10"/>
<field name="limit">72000</field>
<field name="tax_regime">old</field>
</record>
<record id="us10_retrenchment_exemptions" model="us10.investment.type">
<field name="sequence">20</field>
<field name="name">Retrenchment Exemptions</field>
<field name="investment_type" ref="investment_type_us10"/>
<field name="limit">500000</field>
<field name="tax_regime">old</field>
</record>
<record id="us10_leave_travel_allowance" model="us10.investment.type">
<field name="sequence">30</field>
<field name="name">Leave Travel Allowance Exemptions</field>
<field name="investment_type" ref="investment_type_us10"/>
<field name="tax_regime">old</field>
</record>
<record id="us10_medical_reimbursement" model="us10.investment.type">
<field name="sequence">40</field>
<field name="name">Medical Reimbursement Exemptions</field>
<field name="investment_type" ref="investment_type_us10"/>
<field name="tax_regime">old</field>
</record>
<record id="us10_uniform_allowance" model="us10.investment.type">
<field name="sequence">50</field>
<field name="name">Uniform Allowance US10</field>
<field name="investment_type" ref="investment_type_us10"/>
<field name="tax_regime">old</field>
</record>
<!-- US 80G: Old regime donations -->
<record id="us80g_donations" model="us80g.investment.type"><field name="sequence">10</field><field name="name">US 80G - Donations</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_national_defence_fund" model="us80g.investment.type"><field name="sequence">20</field><field name="name">01-National Defence Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_pm_national_relief_fund" model="us80g.investment.type"><field name="sequence">30</field><field name="name">02-PM's National Relief Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_pm_armenia_earthquake_relief_fund" model="us80g.investment.type"><field name="sequence">40</field><field name="name">03-PM's Armenia Earthquake Relief Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_africa_public_contributions_india_fund" model="us80g.investment.type"><field name="sequence">50</field><field name="name">04-Africa (Public Contributions - India) Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_national_foundation_communal_harmony" model="us80g.investment.type"><field name="sequence">60</field><field name="name">05-National Foundation for Communal Harmony</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_university_national_eminence" model="us80g.investment.type"><field name="sequence">70</field><field name="name">06-University/Educational Institution of National Eminence</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_maharashtra_cm_earthquake_relief_fund" model="us80g.investment.type"><field name="sequence">80</field><field name="name">07-Maharashtra CM's Earthquake relief Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_zila_saksharta_samiti" model="us80g.investment.type"><field name="sequence">90</field><field name="name">08-Zila Saksharta Samiti</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_national_blood_transfusion_council" model="us80g.investment.type"><field name="sequence">100</field><field name="name">10-The National Blood Transfusion Council</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_state_medical_relief_fund" model="us80g.investment.type"><field name="sequence">110</field><field name="name">11-State Government medical relief to the poor</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_army_central_welfare_fund" model="us80g.investment.type"><field name="sequence">120</field><field name="name">12-The Army Central Welfare Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_indian_naval_benevolent_fund" model="us80g.investment.type"><field name="sequence">130</field><field name="name">13-The Indian Naval Benevolent Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_air_force_central_welfare_fund" model="us80g.investment.type"><field name="sequence">140</field><field name="name">14-The Air Force Central Welfare Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_andhra_cm_cyclone_relief_fund_1996" model="us80g.investment.type"><field name="sequence">150</field><field name="name">15-Andhra Pradesh CM's Cyclone Relief Fund 1996</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_national_illness_assistance_fund" model="us80g.investment.type"><field name="sequence">160</field><field name="name">16-National Illness Assistance Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_cm_relief_fund_state" model="us80g.investment.type"><field name="sequence">170</field><field name="name">17-The CM's Relief Fund of any State</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_lg_relief_fund_union_territory" model="us80g.investment.type"><field name="sequence">180</field><field name="name">18-Lt. Governor's Relief Fund - Union Territory</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_national_sports_fund_central" model="us80g.investment.type"><field name="sequence">190</field><field name="name">19-National sports Fund - Central Government</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_national_cultural_fund_central" model="us80g.investment.type"><field name="sequence">200</field><field name="name">20-National Cultural Fund - Central Government</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_fund_technology_development_central" model="us80g.investment.type"><field name="sequence">210</field><field name="name">21-Fund for Tech Devt - Central Government</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_welfare_persons_disabilities" model="us80g.investment.type"><field name="sequence">220</field><field name="name">22-Welfare of persons with Disabilities</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_ay_trust_fund" model="us80g.investment.type"><field name="sequence">230</field><field name="name">23-Any Trust, institution or Fund covered under section 80G providing relief to the victims of earthquake in Gujarat, provided such donation is made between 26/01/2001 to 30/09/2001</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_pm_drought_relief_fund" model="us80g.investment.type"><field name="sequence">240</field><field name="name">25-Prime Minister's Drought Relief Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_family_planning" model="us80g.investment.type"><field name="sequence">250</field><field name="name">29-For promoting family planning</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_olympic_association" model="us80g.investment.type"><field name="sequence">260</field><field name="name">30-To any Olympic Association or to any other association or institution established in India and notified by the Central Government for Development of infrastructure of sports and Games, or sponsorship for sports or Games</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_slum_dwellers" model="us80g.investment.type"><field name="sequence">270</field><field name="name">31-For other than promoting family planning</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_charitable_trust_approval" model="us80g.investment.type"><field name="sequence">280</field><field name="name">32-Institutions/Charitable Trust with 80G approval</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_improvement_cities_towns_villages" model="us80g.investment.type"><field name="sequence">290</field><field name="name">33-For improvement of cities, towns or villages</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_corporation_minority" model="us80g.investment.type"><field name="sequence">300</field><field name="name">34-Corporation-Promoting Interests in Minority</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_renovation_notified_places_temples" model="us80g.investment.type"><field name="sequence">310</field><field name="name">35-For renovation-Notified Places like Temples</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_national_childrens_fund" model="us80g.investment.type"><field name="sequence">320</field><field name="name">36-National Children's Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_swachh_bharat_kosh" model="us80g.investment.type"><field name="sequence">330</field><field name="name">37-Swachh Bharat Kosh</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_clean_ganga_fund" model="us80g.investment.type"><field name="sequence">340</field><field name="name">38-Clean Ganga Fund</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<record id="us80g_drug_abuse_control_fund" model="us80g.investment.type"><field name="sequence">350</field><field name="name">39-National Fund for Control of Drug Abuse</field><field name="investment_type" ref="investment_type_us80g"/><field name="tax_regime">old</field></record>
<!-- Chapter VIA: old regime deductions plus allowed new-regime employer NPS -->
<record id="chapter_via_rgess" model="chapter.via.investment.type"><field name="sequence">10</field><field name="name">US 80CCG - Investments in RGESS</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">25000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80ddb_medical_treatment" model="chapter.via.investment.type"><field name="sequence">20</field><field name="name">US 80DDB - Maintenance Including medical treatment</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">125000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80ddb_non_senior" model="chapter.via.investment.type"><field name="sequence">30</field><field name="name">US 80DDB - Medical treatment for non senior citizens</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">40000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80ddbs_senior" model="chapter.via.investment.type"><field name="sequence">40</field><field name="name">US 80DDBS - Medical treatment for senior citizens</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">100000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80e_higher_education" model="chapter.via.investment.type"><field name="sequence">50</field><field name="name">US 80E - Higher education</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="tax_regime">old</field></record>
<record id="chapter_via_80ee_home_loan_interest" model="chapter.via.investment.type"><field name="sequence">60</field><field name="name">US 80EE - Interest Paid On Home Loan</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">50000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80gg_house_rent" model="chapter.via.investment.type"><field name="sequence">70</field><field name="name">US 80GG - House Rent Exemption</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">60000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_us24_home_loan_interest" model="chapter.via.investment.type"><field name="sequence">80</field><field name="name">US 24 - Certificate provided for Interest Paid On Home Loan</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">200000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_us24_first_time_buyer" model="chapter.via.investment.type"><field name="sequence">90</field><field name="name">US 24 - Interest Paid On Home Loan (First time buyer)</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">50000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_us24_letout_property" model="chapter.via.investment.type"><field name="sequence">100</field><field name="name">US 24 - Interest Paid On Home Loan For Let Out Property</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">200000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_us24_before_april_1999" model="chapter.via.investment.type"><field name="sequence">110</field><field name="name">US 24 - Interest Paid On Loan Before 1st April 1999</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">30000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80ccd_employee_contribution" model="chapter.via.investment.type"><field name="sequence">120</field><field name="name">US 80CCD - National Pension Scheme (Employee Contribution)</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">50000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80ccd2_employer_contribution" model="chapter.via.investment.type"><field name="sequence">130</field><field name="name">US 80CCD (2) - National Pension Scheme (Employer Contribution)</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="tax_regime">both</field></record>
<record id="chapter_via_80ccg_outside_nps_employer" model="chapter.via.investment.type"><field name="sequence">140</field><field name="name">US 80CCG Outside National Pension Scheme (Employee Contribution)</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">50000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80ccf_infra_bonds" model="chapter.via.investment.type"><field name="sequence">150</field><field name="name">US 80CCF - Long term Infrastructure bonds</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="tax_regime">old</field></record>
<record id="chapter_via_80qqb_royalty_books" model="chapter.via.investment.type"><field name="sequence">160</field><field name="name">US 80QQB - Royalty on Books</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">300000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80rrb_royalty_patents" model="chapter.via.investment.type"><field name="sequence">170</field><field name="name">US 80RRB - Royalty on patents</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">300000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80tta_saving_interest" model="chapter.via.investment.type"><field name="sequence">180</field><field name="name">US 80TTA - Interest on Saving accounts</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">10000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80u_disability" model="chapter.via.investment.type"><field name="sequence">190</field><field name="name">US 80U - Disability</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">125000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80ttb_senior_interest" model="chapter.via.investment.type"><field name="sequence">200</field><field name="name">US80TTB - For Senior Citizen, exempt Interest from FDs, Post Office</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">50000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80eea_home_loan" model="chapter.via.investment.type"><field name="sequence">210</field><field name="name">US80EEA - Home Loans Taken on Self-Occupied House Property BY 31-Mar-2020</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">150000</field><field name="tax_regime">old</field></record>
<record id="chapter_via_80eeb_electric_vehicle" model="chapter.via.investment.type"><field name="sequence">220</field><field name="name">US80EEB - ELECTRONIC VEHICLE EXEMPTION</field><field name="investment_type" ref="investment_type_chapter_via"/><field name="limit">150000</field><field name="tax_regime">old</field></record>
<!-- US 17: Old regime reimbursements and allowances -->
<record id="us17_academic_allowance" model="us17.investment.type"><field name="sequence">10</field><field name="name">Academic Allowance</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_helper_allowance" model="us17.investment.type"><field name="sequence">20</field><field name="name">Helper Allowance</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_petrol_allowance" model="us17.investment.type"><field name="sequence">30</field><field name="name">Petrol Allowance</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_utility_reimbursement" model="us17.investment.type"><field name="sequence">40</field><field name="name">Utility Reimbursement</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_books_proofs" model="us17.investment.type"><field name="sequence">50</field><field name="name">Books Proofs</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_car_maintenance_reimbursement" model="us17.investment.type"><field name="sequence">60</field><field name="name">Car Maintenance Reimbursement</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_car_maintenance_small_car" model="us17.investment.type"><field name="sequence">70</field><field name="name">Car Maintenance - Small Upto 1600 CC</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_cell_phone_proofs" model="us17.investment.type"><field name="sequence">80</field><field name="name">Cell Phone Proofs</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_conveyance_proofs" model="us17.investment.type"><field name="sequence">90</field><field name="name">Conveyance Proofs</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_driver_salary_reimbursement" model="us17.investment.type"><field name="sequence">100</field><field name="name">Driver Salary Reimbursement</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_driver_salary_reimbursement_small_car" model="us17.investment.type"><field name="sequence">110</field><field name="name">Driver Salary Reimbursement - Small Car Upto 1600 CC</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_driver_proofs" model="us17.investment.type"><field name="sequence">120</field><field name="name">Driver Proofs</field><field name="investment_type" ref="investment_type_us17"/><field name="limit">36000</field><field name="tax_regime">both</field></record>
<record id="us17_driver_petrol_car_maintenance" model="us17.investment.type"><field name="sequence">130</field><field name="name">Driver, Petrol &amp; Car Maintenance Proofs</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">both</field></record>
<record id="us17_petrol_car_maintenance" model="us17.investment.type"><field name="sequence">140</field><field name="name">Petrol &amp; Car Maintenance Proofs</field><field name="investment_type" ref="investment_type_us17"/><field name="limit">84000</field><field name="tax_regime">both</field></record>
<record id="us17_entertainment_proofs" model="us17.investment.type"><field name="sequence">150</field><field name="name">Entertainment Proofs</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_fuel_reimbursement" model="us17.investment.type"><field name="sequence">160</field><field name="name">Fuel Reimbursement</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_general_other_reimbursement" model="us17.investment.type"><field name="sequence">170</field><field name="name">General Other Reimbursement</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_gift_reimbursement" model="us17.investment.type"><field name="sequence">180</field><field name="name">Gift Reimbursement</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_internet_reimbursement" model="us17.investment.type"><field name="sequence">190</field><field name="name">Internet Reimbursement</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_journal_reimbursement" model="us17.investment.type"><field name="sequence">200</field><field name="name">Journal Reimbursement</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_maintenance_reimbursement" model="us17.investment.type"><field name="sequence">210</field><field name="name">Maintenance Reimbursement</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_meal_proofs" model="us17.investment.type"><field name="sequence">220</field><field name="name">Meal Proofs</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_news_paper_proofs" model="us17.investment.type"><field name="sequence">230</field><field name="name">News Paper Proofs</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_parking_proofs" model="us17.investment.type"><field name="sequence">240</field><field name="name">Parking Proofs</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">both</field></record>
<record id="us17_telephone_allowance" model="us17.investment.type"><field name="sequence">250</field><field name="name">Telephone Allowance</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<record id="us17_toll_proofs" model="us17.investment.type"><field name="sequence">260</field><field name="name">Toll Proofs</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">both</field></record>
<record id="us17_uniform_reimbursement" model="us17.investment.type"><field name="sequence">270</field><field name="name">Uniform Reimbursement</field><field name="investment_type" ref="investment_type_us17"/><field name="tax_regime">old</field></record>
<!-- Other income/loss: both-regime taxable income plus old-regime details -->
<record id="other_il_self_occupied_house_property" model="other.il.investment.type"><field name="sequence">10</field><field name="name">Self occupied house property U/S 24</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="require_action">1</field><field name="action_id" ref="action_self_occupied_property"/><field name="tax_regime">old</field></record>
<record id="other_il_bank_interest" model="other.il.investment.type"><field name="sequence">20</field><field name="name">Bank Interest</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="tax_regime">old</field></record>
<record id="other_il_debenture_interest" model="other.il.investment.type"><field name="sequence">30</field><field name="name">Debenture Interest</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="tax_regime">old</field></record>
<record id="other_il_external_income_others" model="other.il.investment.type"><field name="sequence">40</field><field name="name">External Income Others</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="tax_regime">old</field></record>
<record id="other_il_income_let_out_house_property" model="other.il.investment.type"><field name="sequence">50</field><field name="name">Income on Let Out House Property</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="require_action">1</field><field name="action_id" ref="action_letout_house_property"/><field name="tax_regime">both</field></record>
<record id="other_il_loss_let_out_house_property" model="other.il.investment.type"><field name="sequence">60</field><field name="name">Loss on Let Out House Property</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="limit">-200000</field><field name="tax_regime">old</field></record>
<record id="other_il_interest_nsc_80i" model="other.il.investment.type"><field name="sequence">70</field><field name="name">Interest on NSC (80 I)</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="require_action">1</field><field name="action_id" ref="action_nsc_interest_line"/><field name="tax_regime">old</field></record>
<record id="other_il_previous_employer_tax_free_income" model="other.il.investment.type"><field name="sequence">80</field><field name="name">Previous Employer Tax free other income</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="tax_regime">old</field></record>
<record id="other_il_fully_taxable_income" model="other.il.investment.type"><field name="sequence">90</field><field name="name">Fully Taxable Income</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="tax_regime">old</field></record>
<record id="other_il_fully_taxable_other_income" model="other.il.investment.type"><field name="sequence">100</field><field name="name">Fully Taxable Other Income</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="tax_regime">both</field></record>
<record id="other_il_external_inc_var_percentage" model="other.il.investment.type"><field name="sequence">110</field><field name="name">EXTERNAL_INC_VAR_PERCENTAGE</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="tax_regime">old</field></record>
<record id="other_il_previous_employer_other_income" model="other.il.investment.type"><field name="sequence">120</field><field name="name">Previous Employer Other Income</field><field name="investment_type" ref="investment_type_other_income_loss"/><field name="tax_regime">old</field></record>
<!-- Other declarations: old regime supporting values -->
<record id="other_declaration_medical_insurance_manual_input" model="other.declaration.investment.type">
<field name="sequence">10</field>
<field name="name">Medical Insurance Premium Manual Input</field>
<field name="investment_type" ref="investment_type_other_declaration"/>
<field name="tax_regime">old</field>
</record>
<record id="other_declaration_hostel_going_children" model="other.declaration.investment.type">
<field name="sequence">20</field>
<field name="name">Number of Hostel going children</field>
<field name="investment_type" ref="investment_type_other_declaration"/>
<field name="limit">2</field>
<field name="tax_regime">old</field>
</record>
<record id="other_declaration_school_going_children" model="other.declaration.investment.type">
<field name="sequence">30</field>
<field name="name">Number of school going children</field>
<field name="investment_type" ref="investment_type_other_declaration"/>
<field name="limit">2</field>
<field name="tax_regime">old</field>
</record>
</odoo>

View File

@ -1,7 +1,8 @@
from . import payroll_periods from . import payroll_periods
from . import investment_types from . import investment_types
from . import investment_costings
from . import emp_it_declaration from . import emp_it_declaration
from . import investment_costings
from . import slab_master from . import slab_master
from . import it_tax_statement from . import it_tax_statement
from . import it_tax_statement_wiz from . import it_tax_statement_wiz
from . import employee_payslip_download_wiz

View File

@ -1,7 +1,39 @@
from urllib.parse import urlencode
from odoo import models, fields, api, _ from odoo import models, fields, api, _
from odoo.exceptions import ValidationError from odoo.exceptions import UserError
from datetime import datetime, timedelta
import calendar
class ITDeclarationSubmittedLockMixin(models.AbstractModel):
_name = 'it.declaration.submitted.lock.mixin'
_description = 'IT Declaration Submitted Lock Mixin'
def _get_related_it_declarations(self):
if 'it_declaration_id' in self._fields:
return self.mapped('it_declaration_id')
if 'child_education_id' in self._fields:
return self.mapped('child_education_id.it_declaration_id')
if 'parent_id' in self._fields:
return self.mapped('parent_id.it_declaration_id')
return self.env['emp.it.declaration']
def _check_it_declaration_is_editable(self):
if any(declaration.state == 'submitted' for declaration in self._get_related_it_declarations()):
raise UserError(_('Submitted IT declarations are read-only. Return the declaration to draft before editing it.'))
@api.model_create_multi
def create(self, vals_list):
records = super().create(vals_list)
records._check_it_declaration_is_editable()
return records
def write(self, vals):
self._check_it_declaration_is_editable()
return super().write(vals)
def unlink(self):
self._check_it_declaration_is_editable()
return super().unlink()
class EmpITDeclaration(models.Model): class EmpITDeclaration(models.Model):
@ -9,6 +41,11 @@ class EmpITDeclaration(models.Model):
_rec_name = 'employee_id' _rec_name = 'employee_id'
_description = "IT Declaration" _description = "IT Declaration"
_sql_constraints = [
('name_emp_tax_period', 'unique(employee_id, period_id, tax_regime)',
"Avoid creating duplicate records for the same period_id and tax_regime."),
]
# @api.depends('period_id', 'employee_id') # @api.depends('period_id', 'employee_id')
# def _compute_name(self): # def _compute_name(self):
# for sheet in self: # for sheet in self:
@ -24,7 +61,8 @@ class EmpITDeclaration(models.Model):
period_id = fields.Many2one( period_id = fields.Many2one(
'payroll.period', 'payroll.period',
string="Payroll Period", string="Payroll Period",
required=True required=True,
copy=False
) )
display_period_label = fields.Char(string="Period Label", compute='_compute_display_period_label') display_period_label = fields.Char(string="Period Label", compute='_compute_display_period_label')
@ -41,14 +79,47 @@ class EmpITDeclaration(models.Model):
('new', 'New Regime'), ('new', 'New Regime'),
('old', 'Old Regime') ('old', 'Old Regime')
], string="Tax Regime", required=True, default='new') ], string="Tax Regime", required=True, default='new')
state = fields.Selection([
('draft', 'Draft'),
('submitted', 'Submitted'),
], string="Status", default='draft', required=True, copy=False)
return_reason = fields.Text(string="Return Reason", copy=False)
is_payroll_manager = fields.Boolean(compute='_compute_is_payroll_manager')
total_investment = fields.Float(string='Total Investment') total_investment = fields.Float(string='Total Investment')
costing_details_generated = fields.Boolean(default=False) costing_details_generated = fields.Boolean(default=False)
investment_costing_ids = fields.One2many('investment.costings','it_declaration_id') investment_costing_ids = fields.One2many('investment.costings','it_declaration_id')
visible_investment_costing_ids = fields.Many2many(
'investment.costings',
compute='_compute_visible_investment_costing_ids',
string='Visible Investment Costings',
)
house_rent_costing_id = fields.Many2one('investment.costings', compute="_compute_investment_costing") house_rent_costing_id = fields.Many2one('investment.costings', compute="_compute_investment_costing")
is_section_open = fields.Boolean() is_section_open = fields.Boolean()
def _compute_is_payroll_manager(self):
is_manager = self.env.user.has_group('hr_payroll.group_hr_payroll_manager')
for rec in self:
rec.is_payroll_manager = is_manager
def _check_submitted_write_allowed(self, vals):
protected_vals = set(vals) - {'state', 'return_reason'}
submitted_records = self.filtered(lambda rec: rec.state == 'submitted')
if submitted_records and protected_vals:
raise UserError(_('Submitted IT declarations are read-only. Return the declaration to draft before editing it.'))
if submitted_records and set(vals) & {'state', 'return_reason'} and not self.env.user.has_group('hr_payroll.group_hr_payroll_manager'):
raise UserError(_('Only a Payroll Manager can return a submitted IT declaration.'))
def write(self, vals):
self._check_submitted_write_allowed(vals)
return super().write(vals)
def unlink(self):
if any(rec.state == 'submitted' for rec in self):
raise UserError(_('Submitted IT declarations cannot be deleted.'))
return super().unlink()
@api.depends('costing_details_generated','investment_costing_ids') @api.depends('costing_details_generated','investment_costing_ids')
def _compute_investment_costing(self): def _compute_investment_costing(self):
for rec in self: for rec in self:
@ -58,82 +129,250 @@ class EmpITDeclaration(models.Model):
)[:1] )[:1]
else: else:
rec.house_rent_costing_id = False rec.house_rent_costing_id = False
@api.depends(
'investment_costing_ids',
'investment_costing_ids.investment_type_id',
'investment_costing_ids.investment_type_id.active',
'period_id',
'tax_regime',
)
def _compute_visible_investment_costing_ids(self):
for rec in self:
visible_investment_type_ids = rec._get_visible_investment_types().ids
rec.visible_investment_costing_ids = rec.investment_costing_ids.filtered(
lambda costing: costing.investment_type_id
and costing.investment_type_id.id in visible_investment_type_ids
)
past_employment_costings = fields.One2many('past_employment.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['old', 'both'])]) past_employment_costings = fields.One2many('past_employment.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['old', 'both'])])
past_employment_costings_new = fields.One2many('past_employment.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['new', 'both'])]) past_employment_costings_new = fields.One2many('past_employment.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['new', 'both'])])
us80c_costings = fields.One2many('us80c.costing.type','it_declaration_id') us80c_costings = fields.One2many('us80c.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['old', 'both'])])
us80c_costings_new = fields.One2many('us80c.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['new', 'both'])])
us80d_selection_type = fields.Selection([('self_family','Self-family'),('self_family_parent','Self-family and parent'),('self_family_senior_parent','Self-family and senior parent')], default='self_family',required=True) us80d_selection_type = fields.Selection([('self_family','Self-family'),('self_family_parent','Self-family and parent'),('self_family_senior_parent','Self-family and senior parent')], default='self_family',required=True)
us80d_health_checkup = fields.Boolean(string='Preventive Health Checkup') us80d_health_checkup = fields.Boolean(string='Preventive Health Checkup')
us80d_costings = fields.One2many('us80d.costing.type','it_declaration_id',domain=[('investment_type_line_id.for_family','=',True),('investment_type_line_id.for_parents','=',False),('investment_type_line_id.for_senior_parent','=',False)]) us80d_costings = fields.One2many('us80d.costing.type','it_declaration_id',domain=[('investment_type_line_id.for_family','=',True),('investment_type_line_id.for_parents','=',False),('investment_type_line_id.for_senior_parent','=',False),('investment_type_line_id.tax_regime', 'in', ['old', 'both'])])
us80d_costings_parents = fields.One2many('us80d.costing.type','it_declaration_id',domain=['|',('investment_type_line_id.for_family','=',True),('investment_type_line_id.for_parents','=',True),('investment_type_line_id.for_senior_parent','=',False)]) us80d_costings_new = fields.One2many('us80d.costing.type','it_declaration_id',domain=[('investment_type_line_id.for_family','=',True),('investment_type_line_id.for_parents','=',False),('investment_type_line_id.for_senior_parent','=',False),('investment_type_line_id.tax_regime', 'in', ['new', 'both'])])
us80d_costings_senior_parents = fields.One2many('us80d.costing.type','it_declaration_id',domain=['|','|',('investment_type_line_id.for_family','=',True),('investment_type_line_id.for_parents','=',True),('investment_type_line_id.for_senior_parent','=',True)]) us80d_costings_parents = fields.One2many('us80d.costing.type','it_declaration_id',domain=['|',('investment_type_line_id.for_family','=',True),('investment_type_line_id.for_parents','=',True),('investment_type_line_id.for_senior_parent','=',False),('investment_type_line_id.tax_regime', 'in', ['old', 'both'])])
us80d_costings_parents_new = fields.One2many('us80d.costing.type','it_declaration_id',domain=['|',('investment_type_line_id.for_family','=',True),('investment_type_line_id.for_parents','=',True),('investment_type_line_id.for_senior_parent','=',False),('investment_type_line_id.tax_regime', 'in', ['new', 'both'])])
us80d_costings_senior_parents = fields.One2many('us80d.costing.type','it_declaration_id',domain=['|','|',('investment_type_line_id.for_family','=',True),('investment_type_line_id.for_parents','=',True),('investment_type_line_id.for_senior_parent','=',True),('investment_type_line_id.tax_regime', 'in', ['old', 'both'])])
us80d_costings_senior_parents_new = fields.One2many('us80d.costing.type','it_declaration_id',domain=['|','|',('investment_type_line_id.for_family','=',True),('investment_type_line_id.for_parents','=',True),('investment_type_line_id.for_senior_parent','=',True),('investment_type_line_id.tax_regime', 'in', ['new', 'both'])])
us10_costings = fields.One2many('us10.costing.type','it_declaration_id') us10_costings = fields.One2many('us10.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['old', 'both'])])
us80g_costings = fields.One2many('us80g.costing.type','it_declaration_id') us10_costings_new = fields.One2many('us10.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['new', 'both'])])
us80g_costings = fields.One2many('us80g.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['old', 'both'])])
us80g_costings_new = fields.One2many('us80g.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['new', 'both'])])
chapter_via_costings = fields.One2many('chapter.via.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['old', 'both'])]) chapter_via_costings = fields.One2many('chapter.via.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['old', 'both'])])
chapter_via_costings_new = fields.One2many('chapter.via.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['new', 'both'])]) chapter_via_costings_new = fields.One2many('chapter.via.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['new', 'both'])])
us17_costings = fields.One2many('us17.costing.type','it_declaration_id') us17_costings = fields.One2many('us17.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['old', 'both'])])
us17_costings_new = fields.One2many('us17.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['new', 'both'])])
house_rent_costings = fields.One2many('house.rent.declaration','it_declaration_id') house_rent_costings = fields.One2many('house.rent.declaration','it_declaration_id')
other_il_costings = fields.One2many('other.il.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['old', 'both'])]) other_il_costings = fields.One2many('other.il.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['old', 'both'])])
other_il_costings_new = fields.One2many('other.il.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['new', 'both'])]) other_il_costings_new = fields.One2many('other.il.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['new', 'both'])])
other_declaration_costings = fields.One2many('other.declaration.costing.type','it_declaration_id') other_declaration_costings = fields.One2many('other.declaration.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['old', 'both'])])
other_declaration_costings_new = fields.One2many('other.declaration.costing.type','it_declaration_id',domain=[('investment_type_line_id.tax_regime', 'in', ['new', 'both'])])
show_past_employment = fields.Boolean(compute="_compute_show_records")
show_us_80c = fields.Boolean(compute="_compute_show_records")
show_us_80d = fields.Boolean(compute="_compute_show_records")
show_us_10 = fields.Boolean(compute="_compute_show_records")
show_us_80g = fields.Boolean(compute="_compute_show_records")
show_chapter_via = fields.Boolean(compute="_compute_show_records")
show_us_17 = fields.Boolean(compute="_compute_show_records")
show_house_rent = fields.Boolean(compute="_compute_show_records")
show_other_i_or_l = fields.Boolean(compute="_compute_show_records")
show_other_declaration = fields.Boolean(compute="_compute_show_records")
@api.model
def _investment_type_line_fields(self):
return {
'past_employment': 'past_employment_ids',
'us_80c': 'us80c_ids',
'us_80d': 'us80d_ids',
'us_10': 'us10_ids',
'us_80g': 'us80g_ids',
'chapter_via': 'chapter_via_ids',
'us_17': 'us17_ids',
'other_i_or_l': 'other_il_ids',
'other_declaration': 'other_declaration_ids',
}
def _get_available_investment_types(self):
self.ensure_one()
if not self.period_id:
return self.env['it.investment.type']
return self.env['it.investment.type'].sudo().search([
('active', '=', True),
'|',
('period_ids', 'in', self.period_id.id),
('period_ids', '=', False),
])
def _get_visible_investment_types(self):
self.ensure_one()
return self._get_available_investment_types().filtered(
lambda investment_type: self._is_investment_type_visible(investment_type)
)
@api.model
def _investment_type_generation_config(self):
return {
'past_employment': ('past_employment_ids', 'past_employment.costing.type'),
'us_80c': ('us80c_ids', 'us80c.costing.type'),
'us_80d': ('us80d_ids', 'us80d.costing.type'),
'us_10': ('us10_ids', 'us10.costing.type'),
'us_80g': ('us80g_ids', 'us80g.costing.type'),
'chapter_via': ('chapter_via_ids', 'chapter.via.costing.type'),
'us_17': ('us17_ids', 'us17.costing.type'),
'other_i_or_l': ('other_il_ids', 'other.il.costing.type'),
'other_declaration': ('other_declaration_ids', 'other.declaration.costing.type'),
}
def _get_regime_values(self):
self.ensure_one()
return ['old', 'both'] if self.tax_regime == 'old' else ['new', 'both']
def _get_regime_filtered_costings(self, field_name):
self.ensure_one()
return self[field_name].filtered(
lambda line: line.investment_type_line_id
and line.investment_type_line_id.tax_regime in self._get_regime_values()
)
def _ensure_investment_costing_records(self):
for rec in self:
available_investment_types = rec._get_available_investment_types()
generation_config = rec._investment_type_generation_config()
for inv_type in available_investment_types:
investment_costing = rec.investment_costing_ids.filtered(
lambda cost: cost.investment_type_id == inv_type
)[:1]
if not investment_costing:
investment_costing = self.env['investment.costings'].sudo().create({
'investment_type_id': inv_type.id,
'it_declaration_id': rec.id,
})
config = generation_config.get(inv_type.investment_type)
if not config:
continue
line_field, costing_model = config
active_lines = getattr(inv_type, line_field).filtered(lambda line: line.active)
existing_costings = self.env[costing_model].sudo().search([
('it_declaration_id', '=', rec.id),
('costing_type', '=', investment_costing.id),
])
existing_line_ids = set(existing_costings.mapped('investment_type_line_id').ids)
for investment_line in active_lines:
if investment_line.id in existing_line_ids:
continue
self.env[costing_model].sudo().create({
'costing_type': investment_costing.id,
'it_declaration_id': rec.id,
'investment_type_line_id': investment_line.id,
'limit': investment_line.limit,
})
def _update_investment_amounts(self):
for rec in self:
for investment_type in rec.investment_costing_ids:
if investment_type.investment_type_id.investment_type == 'past_employment':
costings = rec.past_employment_costings if rec.tax_regime == 'old' else rec.past_employment_costings_new
investment_type.amount = sum(
cost.declaration_amount
for cost in costings
if not cost.investment_type_line_id.compute_method
)
elif investment_type.investment_type_id.investment_type == 'us_80c':
costings = rec.us80c_costings if rec.tax_regime == 'old' else rec.us80c_costings_new
investment_type.amount = sum(
cost.declaration_amount
for cost in costings
if not cost.investment_type_line_id.compute_method
)
elif investment_type.investment_type_id.investment_type == 'us_80d':
if rec.us80d_selection_type == 'self_family':
costings = rec.us80d_costings if rec.tax_regime == 'old' else rec.us80d_costings_new
elif rec.us80d_selection_type == 'self_family_parent':
costings = rec.us80d_costings_parents if rec.tax_regime == 'old' else rec.us80d_costings_parents_new
else:
costings = rec.us80d_costings_senior_parents if rec.tax_regime == 'old' else rec.us80d_costings_senior_parents_new
investment_type.amount = sum(costings.mapped('declaration_amount') or [0])
elif investment_type.investment_type_id.investment_type == 'us_10':
costings = rec.us10_costings if rec.tax_regime == 'old' else rec.us10_costings_new
investment_type.amount = sum(costings.mapped('declaration_amount') or [0])
elif investment_type.investment_type_id.investment_type == 'us_80g':
costings = rec.us80g_costings if rec.tax_regime == 'old' else rec.us80g_costings_new
investment_type.amount = sum(costings.mapped('declaration_amount') or [0])
elif investment_type.investment_type_id.investment_type == 'chapter_via':
costings = rec.chapter_via_costings if rec.tax_regime == 'old' else rec.chapter_via_costings_new
investment_type.amount = sum(costings.mapped('declaration_amount') or [0])
elif investment_type.investment_type_id.investment_type == 'us_17':
costings = rec.us17_costings if rec.tax_regime == 'old' else rec.us17_costings_new
investment_type.amount = sum(costings.mapped('declaration_amount') or [0])
elif investment_type.investment_type_id.investment_type == 'house_rent':
investment_type.amount = sum(rec.house_rent_costings.mapped('rent_amount') or [0]) if rec.tax_regime == 'old' else 0
elif investment_type.investment_type_id.investment_type == 'other_i_or_l':
costings = rec.other_il_costings if rec.tax_regime == 'old' else rec.other_il_costings_new
investment_type.amount = sum(costings.mapped('declaration_amount') or [0])
elif investment_type.investment_type_id.investment_type == 'other_declaration':
costings = rec.other_declaration_costings if rec.tax_regime == 'old' else rec.other_declaration_costings_new
investment_type.amount = sum(costings.mapped('declaration_amount') or [0])
def _is_investment_type_visible(self, investment_type):
self.ensure_one()
if not investment_type or not investment_type.active:
return False
valid_regimes = ['old', 'both'] if self.tax_regime == 'old' else ['new', 'both']
if investment_type.regime not in valid_regimes:
return False
line_field = self._investment_type_line_fields().get(investment_type.investment_type)
if not line_field:
return True
return bool(getattr(investment_type, line_field).filtered(
lambda line: line.active and line.tax_regime in valid_regimes
))
@api.depends('period_id', 'tax_regime')
def _compute_show_records(self):
field_mapping = {
'past_employment': 'show_past_employment',
'us_80c': 'show_us_80c',
'us_80d': 'show_us_80d',
'us_10': 'show_us_10',
'us_80g': 'show_us_80g',
'chapter_via': 'show_chapter_via',
'us_17': 'show_us_17',
'house_rent': 'show_house_rent',
'other_i_or_l': 'show_other_i_or_l',
'other_declaration': 'show_other_declaration',
}
for rec in self:
visible_investment_types = rec._get_visible_investment_types()
for field_name in field_mapping.values():
rec[field_name] = False
for investment_type_key, field_name in field_mapping.items():
rec[field_name] = bool(visible_investment_types.filtered(
lambda inv: inv.investment_type == investment_type_key
))
def toggle_section_visibility(self): def toggle_section_visibility(self):
for rec in self: for rec in self:
rec.is_section_open = not rec.is_section_open rec.is_section_open = not rec.is_section_open
if rec.is_section_open: if rec.is_section_open:
for investment_type in rec.investment_costing_ids: if rec.costing_details_generated:
if investment_type.investment_type_id.investment_type == 'past_employment': rec._ensure_investment_costing_records()
if rec.tax_regime == 'old': rec._update_investment_amounts()
investment_type.amount = sum(
cost.declaration_amount
for cost in rec.past_employment_costings
if not cost.investment_type_line_id.compute_method
)
else:
investment_type.amount = sum(
cost.declaration_amount
for cost in rec.past_employment_costings_new
if not cost.investment_type_line_id.compute_method
)
elif investment_type.investment_type_id.investment_type == 'us_80c':
investment_type.amount = sum(
cost.declaration_amount
for cost in rec.us80c_costings
if not cost.investment_type_line_id.compute_method
) if rec.tax_regime == 'old' else 0
elif investment_type.investment_type_id.investment_type == 'us_80d':
if rec.us80d_selection_type == 'self_family':
investment_type.amount = sum(rec.us80d_costings.mapped('declaration_amount') or [0]) if rec.tax_regime == 'old' else 0
if rec.us80d_selection_type == 'self_family_parent':
investment_type.amount = sum(rec.us80d_costings_parents.mapped('declaration_amount') or [0]) if rec.tax_regime == 'old' else 0
if rec.us80d_selection_type == 'self_family_senior_parent':
investment_type.amount = sum(rec.us80d_costings_senior_parents.mapped('declaration_amount') or [0]) if rec.tax_regime == 'old' else 0
elif investment_type.investment_type_id.investment_type == 'us_10':
investment_type.amount = sum(rec.us10_costings.mapped('declaration_amount') or [0]) if rec.tax_regime == 'old' else 0
elif investment_type.investment_type_id.investment_type == 'us_80g':
investment_type.amount = sum(rec.us80g_costings.mapped('declaration_amount') or [0]) if rec.tax_regime == 'old' else 0
elif investment_type.investment_type_id.investment_type == 'chapter_via':
if rec.tax_regime == 'old':
investment_type.amount = sum(rec.chapter_via_costings.mapped('declaration_amount') or [0])
else:
investment_type.amount = sum(rec.chapter_via_costings_new.mapped('declaration_amount') or [0])
elif investment_type.investment_type_id.investment_type == 'us_17':
investment_type.amount = sum(rec.us17_costings.mapped('declaration_amount') or [0]) if rec.tax_regime == 'old' else 0
elif investment_type.investment_type_id.investment_type == 'house_rent':
investment_type.amount = sum(rec.house_rent_costings.mapped('rent_amount') or [0]) if rec.tax_regime == 'old' else 0
elif investment_type.investment_type_id.investment_type == 'other_i_or_l':
if rec.tax_regime == 'old':
investment_type.amount = sum(rec.other_il_costings.mapped('declaration_amount') or [0])
else:
investment_type.amount = sum(rec.other_il_costings_new.mapped('declaration_amount') or [0])
elif investment_type.investment_type_id.investment_type == 'other_declaration':
investment_type.amount = sum(rec.other_declaration_costings.mapped('declaration_amount') or [0]) if rec.tax_regime == 'old' else 0
@api.onchange('tax_regime') @api.onchange('tax_regime')
def _onchange_tax_regime(self): def _onchange_tax_regime(self):
if self.costing_details_generated:
self._ensure_investment_costing_records()
self._update_investment_amounts()
if self.tax_regime: if self.tax_regime:
# res = super(empITDeclaration, self).fields_get(allfields, attributes) # res = super(empITDeclaration, self).fields_get(allfields, attributes)
# self.fields_get() # self.fields_get()
@ -173,102 +412,158 @@ class EmpITDeclaration(models.Model):
def generate_declarations(self): def generate_declarations(self):
for rec in self: for rec in self:
investment_types = self.env['it.investment.type'].sudo().search([]) rec._ensure_investment_costing_records()
for inv_type in investment_types: rec._update_investment_amounts()
investment_costing = self.env['investment.costings'].sudo().create({ rec.costing_details_generated = True
'investment_type_id': inv_type.id,
'it_declaration_id': rec.id, def action_submit(self):
for rec in self:
rec._update_investment_amounts()
rec.write({
'state': 'submitted',
'return_reason': False,
}) })
if inv_type.investment_type == 'past_employment': def action_return_to_draft(self):
past_emp_costing_ids = [ for rec in self:
self.env['past_employment.costing.type'].sudo().create({ if not self.env.user.has_group('hr_payroll.group_hr_payroll_manager'):
'costing_type': investment_costing.id, raise UserError(_('Only a Payroll Manager can return a submitted IT declaration.'))
'it_declaration_id': rec.id, if not rec.return_reason:
'investment_type_line_id': investment_line.id, raise UserError(_('Please enter a return reason before returning the declaration to draft.'))
'limit': investment_line.limit rec.state = 'draft'
}).id
for investment_line in inv_type.past_employment_ids
]
if inv_type.investment_type == 'us_80c':
us80c_costing_ids = [ def action_download_submission_pdf(self):
self.env['us80c.costing.type'].sudo().create({ self.ensure_one()
'costing_type': investment_costing.id, if self.state != 'submitted':
'it_declaration_id': rec.id, raise UserError(_('You can download the IT declaration PDF only after it is submitted.'))
'investment_type_line_id': investment_line.id, return self.env.ref('employee_it_declaration.action_report_it_tax_statement').report_action(self)
'limit': investment_line.limit
}).id def _get_regime_label(self):
for investment_line in inv_type.us80c_ids self.ensure_one()
return dict(self._fields['tax_regime'].selection).get(self.tax_regime, self.tax_regime)
def _get_binary_link(self, record, field_name, filename_field=False):
if not record or not record[field_name]:
return False
params = {
'model': record._name,
'id': record.id,
'field': field_name,
'download': 'true',
}
if filename_field:
params['filename_field'] = filename_field
return '/web/content?%s' % urlencode(params)
def _prepare_report_line(self, line):
name = line.investment_type_line_id.name if line.investment_type_line_id else ''
return {
'name': name,
'declaration_amount': line.declaration_amount,
'proof_amount': line.proof_amount,
'limit': line.limit,
'remarks': line.remarks,
'attachment_name': line.proof_name or _('Proof'),
'attachment_url': self._get_binary_link(line, 'proof', 'proof_name'),
}
def _get_report_sections(self):
self.ensure_one()
old_regime = self.tax_regime == 'old'
section_fields = [
(_('Past Employment'), 'past_employment_costings' if old_regime else 'past_employment_costings_new'),
(_('US 80C'), 'us80c_costings' if old_regime else 'us80c_costings_new'),
(_('US 80D'), {
'self_family': 'us80d_costings' if old_regime else 'us80d_costings_new',
'self_family_parent': 'us80d_costings_parents' if old_regime else 'us80d_costings_parents_new',
'self_family_senior_parent': 'us80d_costings_senior_parents' if old_regime else 'us80d_costings_senior_parents_new',
}[self.us80d_selection_type]),
(_('US 10'), 'us10_costings' if old_regime else 'us10_costings_new'),
(_('US 80G'), 'us80g_costings' if old_regime else 'us80g_costings_new'),
(_('Chapter VIA'), 'chapter_via_costings' if old_regime else 'chapter_via_costings_new'),
(_('US 17'), 'us17_costings' if old_regime else 'us17_costings_new'),
(_('Other Income / Loss'), 'other_il_costings' if old_regime else 'other_il_costings_new'),
(_('Other Declarations'), 'other_declaration_costings' if old_regime else 'other_declaration_costings_new'),
] ]
if inv_type.investment_type == 'us_80d': sections = []
us80d_costing_ids = [ for title, field_name in section_fields:
self.env['us80d.costing.type'].sudo().create({ lines = self[field_name].filtered(lambda line: line.declaration_amount or line.proof_amount or line.remarks or line.proof)
'costing_type': investment_costing.id, if lines:
'it_declaration_id': rec.id, sections.append({
'investment_type_line_id': investment_line.id, 'title': title,
'limit': investment_line.limit 'lines': [self._prepare_report_line(line) for line in lines],
}).id })
for investment_line in inv_type.us80d_ids
] if old_regime and self.house_rent_costings:
if inv_type.investment_type == 'us_10': sections.append({
us10_costing_ids = [ 'title': _('House Rent'),
self.env['us10.costing.type'].sudo().create({ 'house_rent': True,
'costing_type': investment_costing.id, 'lines': [{
'it_declaration_id': rec.id, 'hra_exemption_type': dict(line._fields['hra_exemption_type'].selection).get(line.hra_exemption_type, ''),
'investment_type_line_id': investment_line.id, 'rent_amount': line.rent_amount,
'limit': investment_line.limit 'from_date': line.from_date,
}).id 'to_date': line.to_date,
for investment_line in inv_type.us10_ids 'landlord_pan_status': dict(line._fields['landlord_pan_status'].selection).get(line.landlord_pan_status, ''),
] 'landlord_pan_no': line.landlord_pan_no,
if inv_type.investment_type == 'us_80g': 'landlord_name_address': line.landlord_name_address,
us80g_costing_ids = [ 'remarks': line.remarks,
self.env['us80g.costing.type'].sudo().create({ 'attachment_name': line.attachment_filename or _('Proof'),
'costing_type': investment_costing.id, 'attachment_url': self._get_binary_link(line, 'attachment', 'attachment_filename'),
'it_declaration_id': rec.id, } for line in self.house_rent_costings],
'investment_type_line_id': investment_line.id, })
'limit': investment_line.limit return sections
}).id
for investment_line in inv_type.us80g_ids def _get_report_extra_sections(self):
] self.ensure_one()
if inv_type.investment_type == 'chapter_via': extra_sections = []
chapter_via_ids = [ us80c_lines = self.us80c_costings if self.tax_regime == 'old' else self.us80c_costings_new
self.env['chapter.via.costing.type'].sudo().create({ other_il_lines = self.other_il_costings if self.tax_regime == 'old' else self.other_il_costings_new
'costing_type': investment_costing.id,
'it_declaration_id': rec.id, children_records = self.env['children.education'].sudo().search([('it_declaration_id', '=', self.id), ('us80c_id', 'in', us80c_lines.ids)])
'investment_type_line_id': investment_line.id, if children_records:
'limit': investment_line.limit extra_sections.append({
}).id 'title': _('Children Education Details'),
for investment_line in inv_type.chapter_via_ids 'headers': [_('Child'), _('Name'), _('Class / Grade'), _('School / College'), _('Tuition Fee')],
] 'rows': [[child.child_id, child.name, child.chile_class, child.organization, child.tuition_fee] for record in children_records for child in record.children_ids],
if inv_type.investment_type == 'us_17': })
us17_costing_ids = [
self.env['us17.costing.type'].sudo().create({ insurance_records = self.env['us80c.insurance.line'].sudo().search([('it_declaration_id', '=', self.id), ('us80c_id', 'in', us80c_lines.ids)])
'costing_type': investment_costing.id, if insurance_records:
'it_declaration_id': rec.id, extra_sections.append({
'investment_type_line_id': investment_line.id, 'title': _('Life Insurance Details'),
'limit': investment_line.limit 'headers': [_('Company'), _('Insured For'), _('Insured Name'), _('Policy No'), _('Premium'), _('Payment Date'), _('Exempt Amount')],
}).id 'rows': [[line.name_of_insurance_company, line.insured_in_favour_of, line.name_of_insured, line.policy_number, line.premium_amount, line.payment_date, line.exempt_amount] for record in insurance_records for line in record.life_insurance_ids],
for investment_line in inv_type.us17_ids })
]
if inv_type.investment_type == 'other_i_or_l': nsc_records = self.env['nsc.declaration.line'].sudo().search([('it_declaration_id', '=', self.id), ('us80c_id', 'in', us80c_lines.ids)])
other_il_costing_ids = [ if nsc_records:
self.env['other.il.costing.type'].sudo().create({ extra_sections.append({
'costing_type': investment_costing.id, 'title': _('NSC Declaration Details'),
'it_declaration_id': rec.id, 'headers': [_('NSC Number'), _('Amount'), _('Payment Date')],
'investment_type_line_id': investment_line.id, 'rows': [[line.nsc_number, line.nsc_amount, line.nsc_payment_date] for record in nsc_records for line in record.nsc_entry_ids],
'limit': investment_line.limit })
}).id
for investment_line in inv_type.other_il_ids self_occupied_records = self.env['self.occupied.property'].sudo().search([('it_declaration_id', '=', self.id), ('other_il_id', 'in', other_il_lines.ids)])
] if self_occupied_records:
if inv_type.investment_type == 'other_declaration': extra_sections.append({
other_declaration_costing_ids = [ 'title': _('Self Occupied Property Details'),
self.env['other.declaration.costing.type'].sudo().create({ 'headers': [_('Address'), _('Period From'), _('Period To'), _('Interest Paid'), _('Income / Loss'), _('Lender'), _('Lender PAN')],
'costing_type': investment_costing.id, 'rows': [[record.address, record.period_from, record.period_to, record.interest_paid_to, record.income_loss, record.lender_name, record.lender_pan] for record in self_occupied_records],
'it_declaration_id': rec.id, })
'investment_type_line_id': investment_line.id,
'limit': investment_line.limit letout_records = self.env['letout.house.property'].sudo().search([('it_declaration_id', '=', self.id), ('other_il_id', 'in', other_il_lines.ids)])
}).id if letout_records:
for investment_line in inv_type.other_declaration_ids extra_sections.append({
] 'title': _('Let-out House Property Details'),
rec.costing_details_generated = True 'headers': [_('Address'), _('Rent'), _('Property Tax'), _('Water Tax'), _('Interest Paid'), _('Income / Loss'), _('Lender'), _('Lender PAN')],
'rows': [[record.address, record.rent_received, record.property_tax, record.water_tax, record.interest_paid_to, record.income_loss, record.lender_name, record.lender_pan] for record in letout_records],
})
nsc_interest_records = self.env['nsc.interest.line'].sudo().search([('it_declaration_id', '=', self.id), ('other_il_id', 'in', other_il_lines.ids)])
if nsc_interest_records:
extra_sections.append({
'title': _('NSC Interest Details'),
'headers': [_('NSC Number'), _('Amount'), _('Payment Date'), _('Interest Amount')],
'rows': [[line.nsc_number, line.nsc_amount, line.nsc_payment_date, line.nsc_interest_amount] for record in nsc_interest_records for line in record.nsc_entry_ids],
})
return [section for section in extra_sections if section['rows']]

View File

@ -0,0 +1,311 @@
import re
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.tools.safe_eval import safe_eval
from dateutil.relativedelta import relativedelta
import logging
_logger = logging.getLogger(__name__)
class EmployeePayslipDownloadWizard(models.TransientModel):
_name = 'employee.payslip.download.wizard'
_rec_name = 'employee_id'
_description = 'Employee Payslip Download Wizard'
def _default_period(self):
today = fields.Date.today()
return self.env['payroll.period'].search([
('from_date', '<=', today),
('to_date', '>=', today),
], limit=1)
def _default_period_line(self):
previous_month_end = fields.Date.today().replace(day=1) - relativedelta(days=1)
_logger.info("Today: %s", fields.Date.today())
_logger.info("Previous Month End: %s", previous_month_end)
period = self._default_period()
_logger.info("Period: %s", period.name if period else "None")
lines = self.env['payroll.period.line'].search([
('period_id', '=', period.id),
], order='from_date')
for line in lines:
_logger.info(
"Month=%s From=%s To=%s",
line.name,
line.from_date,
line.to_date
)
month = self.env['payroll.period.line'].search([
('period_id', '=', period.id),
('from_date', '<=', previous_month_end),
('to_date', '>=', previous_month_end),
], limit=1)
_logger.info("Selected Month: %s", month.name if month else "None")
return month
# def _default_period_line(self):
# # Last day of the previous month
# previous_month_end = fields.Date.today().replace(day=1) - relativedelta(days=1)
#
# period = self._default_period()
# if not period:
# return False
#
# return self.env['payroll.period.line'].search([
# ('period_id', '=', period.id),
# ('from_date', '<=', previous_month_end),
# ('to_date', '<=', previous_month_end),
# ], limit=1)
employee_id = fields.Many2one(
'hr.employee',
required=True,
default=lambda self: self.env.user.employee_id.id,
)
download_type = fields.Selection(
selection=[
('single', 'Single Payslip'),
('multi', 'Multiple Payslips'),
],
string='Download Option',
required=True,
default='single',
)
period_id = fields.Many2one(
'payroll.period',
string='Payroll Period',
required=True,
default=_default_period,
)
today = fields.Date(
default=fields.Date.today
)
period_line = fields.Many2one(
'payroll.period.line',
string="Month",
default=_default_period_line,
domain="[('period_id','=',period_id), ('to_date','<=', previous_month_end)]",
)
payslip_count = fields.Integer(
string='Available Payslips',
compute='_compute_payslip_count',
)
is_hr_manager = fields.Boolean(compute="_compute_is_hr_manager")
previous_month_end = fields.Date(
default=lambda self: (
fields.Date.today().replace(day=1)
- relativedelta(days=1)
)
)
available_period_ids = fields.Many2many(
'payroll.period',
compute='_compute_available_period_ids'
)
def _compute_is_hr_manager(self):
for rec in self:
rec.is_hr_manager = self.env.user.has_group('hr.group_hr_manager')
@api.onchange('download_type', 'period_id')
def _onchange_download_type_period_id(self):
for rec in self:
rec.period_line = False
@api.depends('download_type', 'period_id', 'period_line')
def _compute_payslip_count(self):
for rec in self:
if not rec.period_id or (rec.download_type == 'single' and not rec.period_line):
rec.payslip_count = 0
else:
rec.payslip_count = len(rec._get_available_payslips())
def _get_current_employee(self):
employee = self.env.user.employee_id
if not employee:
raise UserError(_('No employee is linked to your user. Please contact HR.'))
return employee
def _get_date_range(self):
self.ensure_one()
if self.download_type == 'single':
if not self.period_line:
raise UserError(_('Please select a month to download a single payslip.'))
return self.period_line.from_date, self.period_line.to_date
return self.period_id.from_date, self.period_id.to_date
def _get_available_payslips(self):
self.ensure_one()
employee = self._get_current_employee()
date_from, date_to = self._get_date_range()
if not date_from or not date_to:
return self.env['hr.payslip']
return self.env['hr.payslip'].sudo().search([
('employee_id', '=', employee.id),
('state', 'in', ['done', 'paid']),
('date_from', '>=', date_from),
('date_to', '<=', date_to),
('company_id', 'in', self.env.companies.ids),
], order='date_from asc, date_to asc, id asc')
def _get_payslips_for_download(self):
self.ensure_one()
payslips = self._get_available_payslips()
if not payslips:
raise UserError(_('No confirmed or paid payslip is available for the selected period.'))
if self.download_type == 'single' and len(payslips) > 1:
raise UserError(_('More than one payslip is available for this month. Please contact HR.'))
return payslips
def _get_pdf_content(self, payslip):
report = payslip.struct_id.report_id or self.env.ref('hr_payroll.action_report_payslip')
pdf_content, dummy = self.env['ir.actions.report'].sudo().with_context(
lang=payslip.employee_id.lang or self.env.lang,
)._render_qweb_pdf(report, payslip.id, data={'company_id': payslip.company_id})
return report, pdf_content
def _get_pdf_filename(self, payslip, report=False):
report = report or payslip.struct_id.report_id or self.env.ref('hr_payroll.action_report_payslip')
if report.print_report_name:
filename = safe_eval(report.print_report_name, {'object': payslip})
else:
filename = _('Payslip - %(employee)s - %(period)s', employee=payslip.employee_id.name, period=payslip.name)
return self._sanitize_filename(filename, 'payslip') + '.pdf'
def _get_zip_filename(self):
self.ensure_one()
employee = self._get_current_employee()
filename = _('Payslips - %(employee)s - %(period)s', employee=employee.name, period=self.period_id.name)
return self._sanitize_filename(filename, 'payslips') + '.zip'
@api.model
def _sanitize_filename(self, filename, fallback):
filename = re.sub(r'[\\/:*?"<>|]+', '-', str(filename or '')).strip(' .')
return filename or fallback
def action_download_payslips(self):
self.ensure_one()
self._get_payslips_for_download()
return {
'type': 'ir.actions.act_url',
'url': '/employee_it_declaration/my_payslips/%s' % self.id,
'target': 'self',
}
# @api.onchange('employee_id')
# def _onchange_employee_id(self):
#
# if not self.employee_id:
# return {}
#
# # Replace joining_date with your employee joining field
# joining_date = self.employee_id.doj
# today = fields.Date.today()
#
# if not joining_date:
# joining_date = today
# # today = fields.Date.today()
# current_period = self.env['payroll.period'].search([
# ('from_date', '<=', today),
# ('to_date', '>=', today),
# ], limit=1)
#
# if current_period:
# self.period_id = current_period
#
# return {
# 'domain': {
# 'period_id': [
# ('to_date', '>=', joining_date),
# ('from_date', '<=', today),
# ]
# }
# }
@api.depends('employee_id')
def _compute_available_period_ids(self):
today = fields.Date.today()
for rec in self:
employee = rec.employee_id or self.env.user.employee_id
if not employee:
rec.available_period_ids = False
continue
joining_date = employee.doj or today
periods = self.env['payroll.period'].search([
('to_date', '>=', joining_date),
('from_date', '<=', today),
])
rec.available_period_ids = periods
# @api.onchange('employee_id')
# def _onchange_employee_id(self):
# if not self.employee_id:
# return {}
#
# joining_date = self.employee_id.doj
# today = fields.Date.today()
#
# if not joining_date:
# joining_date = today
#
# # Current Financial Year
# current_period = self.env['payroll.period'].search([
# ('from_date', '<=', today),
# ('to_date', '>=', today),
# ], limit=1)
# if current_period:
# self.period_id = current_period
#
# return {
# 'domain': {
# 'period_id': [
# ('to_date', '>=', joining_date), # DOJ year onwards
# ('from_date', '<=', today), # No future FY
# ]
# }
# }
@api.onchange('period_id')
def _onchange_period_id(self):
self.period_line = False
if not self.period_id:
return {}
previous_month_end = (
fields.Date.today().replace(day=1)
- relativedelta(days=1)
)
month = self.env['payroll.period.line'].search([
('period_id', '=', self.period_id.id),
('from_date', '<=', previous_month_end),
('to_date', '>=', previous_month_end),
], limit=1)
if month:
self.period_line = month
return {
'domain': {
'period_line': [
('period_id', '=', self.period_id.id),
('to_date', '<=', previous_month_end),
]
}
}

View File

@ -7,6 +7,7 @@ import re
class investmentCostings(models.Model): class investmentCostings(models.Model):
_name = 'investment.costings' _name = 'investment.costings'
_inherit = ['it.declaration.submitted.lock.mixin']
_rec_name = 'investment_type_id' _rec_name = 'investment_type_id'
investment_type_id = fields.Many2one('it.investment.type') investment_type_id = fields.Many2one('it.investment.type')
@ -25,6 +26,7 @@ class investmentCostings(models.Model):
class pastEmpcostingType(models.Model): class pastEmpcostingType(models.Model):
_name = 'past_employment.costing.type' _name = 'past_employment.costing.type'
_inherit = ['it.declaration.submitted.lock.mixin']
_rec_name = 'investment_type_line_id' _rec_name = 'investment_type_line_id'
@ -104,6 +106,7 @@ class pastEmpcostingType(models.Model):
class us80cCostingType(models.Model): class us80cCostingType(models.Model):
_name = 'us80c.costing.type' _name = 'us80c.costing.type'
_inherit = ['it.declaration.submitted.lock.mixin']
_rec_name = 'investment_type_line_id' _rec_name = 'investment_type_line_id'
costing_type = fields.Many2one('investment.costings') costing_type = fields.Many2one('investment.costings')
@ -140,6 +143,7 @@ class us80cCostingType(models.Model):
} }
class us80dCostingType(models.Model): class us80dCostingType(models.Model):
_name = 'us80d.costing.type' _name = 'us80d.costing.type'
_inherit = ['it.declaration.submitted.lock.mixin']
_rec_name = 'investment_type_line_id' _rec_name = 'investment_type_line_id'
costing_type = fields.Many2one('investment.costings') costing_type = fields.Many2one('investment.costings')
@ -157,6 +161,7 @@ class us80dCostingType(models.Model):
class us10CostingType(models.Model): class us10CostingType(models.Model):
_name = 'us10.costing.type' _name = 'us10.costing.type'
_inherit = ['it.declaration.submitted.lock.mixin']
_rec_name = 'investment_type_line_id' _rec_name = 'investment_type_line_id'
costing_type = fields.Many2one('investment.costings') costing_type = fields.Many2one('investment.costings')
@ -173,6 +178,7 @@ class us10CostingType(models.Model):
class us80gCostingType(models.Model): class us80gCostingType(models.Model):
_name = 'us80g.costing.type' _name = 'us80g.costing.type'
_inherit = ['it.declaration.submitted.lock.mixin']
_rec_name = 'investment_type_line_id' _rec_name = 'investment_type_line_id'
costing_type = fields.Many2one('investment.costings') costing_type = fields.Many2one('investment.costings')
@ -189,6 +195,7 @@ class us80gCostingType(models.Model):
class chapterViaCostingType(models.Model): class chapterViaCostingType(models.Model):
_name = 'chapter.via.costing.type' _name = 'chapter.via.costing.type'
_inherit = ['it.declaration.submitted.lock.mixin']
_rec_name = 'investment_type_line_id' _rec_name = 'investment_type_line_id'
costing_type = fields.Many2one('investment.costings') costing_type = fields.Many2one('investment.costings')
@ -205,6 +212,7 @@ class chapterViaCostingType(models.Model):
class us17CostingType(models.Model): class us17CostingType(models.Model):
_name = 'us17.costing.type' _name = 'us17.costing.type'
_inherit = ['it.declaration.submitted.lock.mixin']
_rec_name = 'investment_type_line_id' _rec_name = 'investment_type_line_id'
costing_type = fields.Many2one('investment.costings') costing_type = fields.Many2one('investment.costings')
@ -219,6 +227,7 @@ class us17CostingType(models.Model):
class OtherILCostingType(models.Model): class OtherILCostingType(models.Model):
_name = 'other.il.costing.type' _name = 'other.il.costing.type'
_inherit = ['it.declaration.submitted.lock.mixin']
_rec_name = 'investment_type_line_id' _rec_name = 'investment_type_line_id'
costing_type = fields.Many2one('investment.costings') costing_type = fields.Many2one('investment.costings')
@ -256,6 +265,7 @@ class OtherILCostingType(models.Model):
class OtherDeclarationCostingType(models.Model): class OtherDeclarationCostingType(models.Model):
_name = 'other.declaration.costing.type' _name = 'other.declaration.costing.type'
_inherit = ['it.declaration.submitted.lock.mixin']
_rec_name = 'investment_type_line_id' _rec_name = 'investment_type_line_id'
costing_type = fields.Many2one('investment.costings') costing_type = fields.Many2one('investment.costings')
@ -271,6 +281,7 @@ class OtherDeclarationCostingType(models.Model):
class HouseRentDeclaration(models.Model): class HouseRentDeclaration(models.Model):
_name = 'house.rent.declaration' _name = 'house.rent.declaration'
_inherit = ['it.declaration.submitted.lock.mixin']
_description = 'House Rent Declaration' _description = 'House Rent Declaration'
@ -302,8 +313,6 @@ class HouseRentDeclaration(models.Model):
def create(self, vals): def create(self, vals):
# Auto-link applicant_id if context is passed correctly # Auto-link applicant_id if context is passed correctly
if self.env.context.get('default_it_declaration_id'): if self.env.context.get('default_it_declaration_id'):
import pdb
pdb.set_trace()
costing_id = self.env['investment.costings'].sudo().search([('id','=',self.env.context.get('it_declaration_id')),('investment_type_id.investment_type','=','house_rent')],limit=1) costing_id = self.env['investment.costings'].sudo().search([('id','=',self.env.context.get('it_declaration_id')),('investment_type_id.investment_type','=','house_rent')],limit=1)
vals['costing_type'] = costing_id.id vals['costing_type'] = costing_id.id
return super().create(vals) return super().create(vals)

View File

@ -1,9 +1,21 @@
from odoo import models, fields from odoo import models, fields, api
class ItInvestmentType(models.Model): class ItInvestmentType(models.Model):
_name = 'it.investment.type' _name = 'it.investment.type'
_rec_name = 'investment_type'
@api.depends('investment_type')
def _compute_display_name(self):
for rec in self:
if rec.investment_type:
rec.display_name = dict(
self._fields['investment_type'].selection
).get(rec.investment_type)
else:
rec.display_name = (
rec.investment_type.replace('_', ' ').title()
if rec.investment_type else ''
)
sequence = fields.Integer() sequence = fields.Integer()
investment_type = fields.Selection( investment_type = fields.Selection(
@ -11,6 +23,11 @@ class ItInvestmentType(models.Model):
('us_80g', 'US 80G'), ('chapter_via', 'CHAPTER VIA'), ('us_17', 'US 17'), ('house_rent', 'HOUSE RENT'), ('us_80g', 'US 80G'), ('chapter_via', 'CHAPTER VIA'), ('us_17', 'US 17'), ('house_rent', 'HOUSE RENT'),
('other_i_or_l', 'OTHER INCOME/LOSS'), ('other_declaration', 'OTHER DECLARATION')], string="Investment Type", ('other_i_or_l', 'OTHER INCOME/LOSS'), ('other_declaration', 'OTHER DECLARATION')], string="Investment Type",
required=True) required=True)
regime = fields.Selection([
('new', 'New Regime'),
('old', 'Old Regime'),
('both', 'Both')
], string='Regime', required=True, default='both')
active = fields.Boolean(default=True) active = fields.Boolean(default=True)
past_employment_ids = fields.One2many('past_employment.investment.type','investment_type') past_employment_ids = fields.One2many('past_employment.investment.type','investment_type')
@ -22,6 +39,45 @@ class ItInvestmentType(models.Model):
us17_ids = fields.One2many('us17.investment.type', 'investment_type') us17_ids = fields.One2many('us17.investment.type', 'investment_type')
other_il_ids = fields.One2many('other.il.investment.type', 'investment_type') other_il_ids = fields.One2many('other.il.investment.type', 'investment_type')
other_declaration_ids = fields.One2many('other.declaration.investment.type', 'investment_type') other_declaration_ids = fields.One2many('other.declaration.investment.type', 'investment_type')
period_ids = fields.Many2many(
'payroll.period',
'it_investment_type_payroll_period_rel',
'investment_type_id',
'period_id',
string='Periods'
)
def init(self):
self.env.cr.execute("""
INSERT INTO it_investment_type_payroll_period_rel (investment_type_id, period_id)
SELECT investment_type.id, period.id
FROM it_investment_type AS investment_type
JOIN payroll_period AS period ON TRUE
LEFT JOIN it_investment_type_payroll_period_rel AS rel
ON rel.investment_type_id = investment_type.id
WHERE investment_type.active = TRUE
AND rel.investment_type_id IS NULL
""")
@api.model
def _get_all_period_commands(self):
return [(6, 0, self.env['payroll.period'].search([]).ids)]
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if 'period_ids' not in vals and vals.get('active', True):
vals['period_ids'] = self._get_all_period_commands()
return super().create(vals_list)
def write(self, vals):
res = super().write(vals)
if vals.get('active') is True:
all_period_commands = self._get_all_period_commands()
self.filtered(lambda record: record.active and not record.period_ids).write({
'period_ids': all_period_commands,
})
return res
class pastEmpInvestmentType(models.Model): class pastEmpInvestmentType(models.Model):
_name = 'past_employment.investment.type' _name = 'past_employment.investment.type'

View File

@ -1,114 +0,0 @@
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from datetime import date, datetime, time
class ITTaxStatementWizard(models.TransientModel):
_name = 'it.tax.statement.wizard'
_description = 'Generate IT Tax Statement'
def _period_line_id_domain(self):
pass
employee_id = fields.Many2one('hr.employee', required=True, default=lambda self: self.env.user.employee_id.id)
emp_doj = fields.Date(related='employee_id.doj', store=True)
contract_id = fields.Many2one('hr.contract',related='employee_id.contract_id')
period_id = fields.Many2one('payroll.period', required=True)
period_line = fields.Many2one('payroll.period.line')
tax_regime = fields.Selection([
('new', 'New Regime'),
('old', 'Old Regime')
], string="Tax Regime", required=True, default='new')
def action_generate_report(self):
# declaration = self.env['emp.it.declaration'].search([
# ('employee_id', '=', self.employee_id.id),
# ('period_id', '=', self.period_id.id)
# ], limit=1)
#
# if not declaration:
# raise ValidationError("No IT Declaration found for the selected employee and period.")
# Prepare data for the report
report_data = self._prepare_income_tax_data()
# Return the report action
return {
'type': 'ir.actions.report',
'report_name': 'employee_it_declaration.income_tax_statement_report',
'report_type': 'qweb-pdf',
'data': {'model': 'it.tax.statement.wizard', 'ids': self.ids, 'report_data': report_data},
'context': {'active_model': 'it.tax.statement.wizard', 'active_id': self.id},
}
# return self.env.ref('your_module_name.action_report_it_tax_statement').report_action(declaration)
def _prepare_income_tax_data(self):
# Get fiscal year (April to March)
today = date.today()
if today.month >= 4:
fiscal_year_start = date(today.year, 4, 1)
fiscal_year_end = date(today.year + 1, 3, 31)
else:
fiscal_year_start = date(today.year - 1, 4, 1)
fiscal_year_end = date(today.year, 3, 31)
fiscal_year_str = f"{fiscal_year_start.year}-{fiscal_year_end.year}"
# Get company information
company = self.env.company
company_address = ', '.join(filter(None, [
company.street,
company.street2,
company.city,
company.state_id.name,
company.country_id.name,
company.zip
]))
# Get PAN and TAN (assuming they're stored in company)
pan_number = company.pan_number if hasattr(company, 'pan_number') else 'PAN1234567'
tan_number = company.tan_number if hasattr(company, 'tan_number') else 'TAN1234567'
# Prepare report data
data = {
'company_name': company.name,
'company_address': company_address,
'pan_number': pan_number,
'tan_number': tan_number,
'assessment_year': fiscal_year_end.year + 1,
'financial_year': fiscal_year_str,
'date': today.strftime('%d/%m/%Y'),
# Income details (simplified - you would query actual data)
'salary_income': 1200000.00,
'house_property_income': 300000.00,
'business_income': 500000.00,
'capital_gains': 200000.00,
'other_income': 100000.00,
'total_income': 2300000.00,
# Deductions
'section_80c': 150000.00,
'section_80d': 50000.00,
'section_80g': 10000.00,
'other_deductions': 30000.00,
'total_deductions': 240000.00,
# Tax computation
'taxable_income': 2060000.00,
'tax_payable': 450000.00,
'tax_paid': 400000.00,
'balance_tax': 50000.00,
# Additional details
'bank_name': 'State Bank of India',
'account_number': '1234567890',
'ifsc_code': 'SBIN0001234',
# For employee reports (if needed)
'employee_name': 'John Doe',
'employee_pan': 'ABCDE1234F',
'employee_address': '123, Main Street, Bangalore, Karnataka - 560001',
}
return {'data': data}

View File

@ -1,6 +1,5 @@
from odoo import models, fields, api from odoo import models, fields, api
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
from datetime import datetime, timedelta
import calendar import calendar
@ -8,6 +7,7 @@ class PayrollPeriod(models.Model):
_name = 'payroll.period' _name = 'payroll.period'
_description = 'Payroll Period' _description = 'Payroll Period'
_rec_name = 'name' _rec_name = 'name'
_order = 'id desc'
_sql_constraints = [ _sql_constraints = [
('unique_name', 'unique(name)', 'The name must be unique.') ('unique_name', 'unique(name)', 'The name must be unique.')
] ]
@ -17,6 +17,16 @@ class PayrollPeriod(models.Model):
name = fields.Char(string="Name", required=True) name = fields.Char(string="Name", required=True)
period_line_ids = fields.One2many('payroll.period.line', 'period_id', string="Monthly Periods") period_line_ids = fields.One2many('payroll.period.line', 'period_id', string="Monthly Periods")
@api.model_create_multi
def create(self, vals_list):
periods = super().create(vals_list)
active_investment_types = self.env['it.investment.type'].search([('active', '=', True)])
if active_investment_types:
active_investment_types.write({
'period_ids': [(4, period.id) for period in periods],
})
return periods
@api.onchange('from_date', 'to_date') @api.onchange('from_date', 'to_date')
def onchange_from_to_date(self): def onchange_from_to_date(self):
for rec in self: for rec in self:

View File

@ -8,21 +8,22 @@ class IncomeTaxSlabMaster(models.Model):
_sql_constraints = [ _sql_constraints = [
( (
'unique_slab', 'unique_slab',
'unique(regime, age_category, residence_type)', 'unique(period_id, regime, age_category, residence_type)',
'Slab must be unique for the same Regime, Age Category, and Residence Type!' 'Slab must be unique for the same name, Regime, Age Category, and Residence Type!'
) )
] ]
name = fields.Char(string="Slab Name", required=True) name = fields.Char(string="Slab Name", required=True, copy=False, default="AY")
period_id = fields.Many2one('payroll.period', copy=False)
regime = fields.Selection([ regime = fields.Selection([
('old', 'Old Tax Regime'), ('old', 'Old Tax Regime'),
('new', 'New Tax Regime') ('new', 'New Tax Regime')
], required=True) ], required=True, default='old')
age_category = fields.Selection([ age_category = fields.Selection([
('below_60', 'Below 60 Years'), ('below_60', 'Below 60 Years'),
('60_to_80', '60-80 Years'), ('60_to_80', '60-80 Years'),
('above_80', 'Above 80 Years') ('above_80', 'Above 80 Years')
], required=True) ], required=True, default='below_60')
residence_type = fields.Selection([ residence_type = fields.Selection([
('resident', 'Resident'), ('resident', 'Resident'),
('non_resident', 'Non Resident'), ('non_resident', 'Non Resident'),
@ -31,7 +32,39 @@ class IncomeTaxSlabMaster(models.Model):
standard_deduction = fields.Float(string="Standard Deduction") standard_deduction = fields.Float(string="Standard Deduction")
active = fields.Boolean(default=True) active = fields.Boolean(default=True)
rules = fields.One2many('it.slab.master.rules','slab_id', string="Slab Rules") rules = fields.One2many('it.slab.master.rules','slab_id', string="Slab Rules")
surcharges = fields.One2many('it.sur.charge.rules','slab_id', string="Surcharges Rules")
def copy(self, default=None):
"""Override copy to duplicate slab rules and surcharge rules"""
if default is None:
default = {}
# Check if we should duplicate from context
duplicate_rules = self.env.context.get('duplicate_slab_rules', True)
default.update({
'name': _("%s (copy)") % (self.name or 'Slab'),
'rules': [],
'surcharges': [],
})
new_slab = super(IncomeTaxSlabMaster, self).copy(default)
# Only duplicate if flag is True
if duplicate_rules:
if self.rules:
for rule in self.rules:
rule.copy({
'slab_id': new_slab.id,
})
if self.surcharges:
for surcharge in self.surcharges:
surcharge.copy({
'slab_id': new_slab.id,
})
return new_slab
class IncomeTaxSlabMasterRules(models.Model): class IncomeTaxSlabMasterRules(models.Model):
_name = 'it.slab.master.rules' _name = 'it.slab.master.rules'
_description = 'Income Tax slab rules' _description = 'Income Tax slab rules'
@ -44,6 +77,10 @@ class IncomeTaxSlabMasterRules(models.Model):
) )
] ]
sequence = fields.Integer(
'Sequence',
help='Used to deduct the taxes based on order')
min_income = fields.Float(string="Min Income (₹)", required=True) min_income = fields.Float(string="Min Income (₹)", required=True)
max_income = fields.Float(string="Max Income (₹)") max_income = fields.Float(string="Max Income (₹)")
tax_rate = fields.Float(string="Tax Rate (%)", required=True) tax_rate = fields.Float(string="Tax Rate (%)", required=True)
@ -55,6 +92,31 @@ class IncomeTaxSlabMasterRules(models.Model):
@api.constrains('min_income', 'max_income', 'slab_id')
def _check_overlap(self):
"""Ensure no overlapping or duplicate ranges within the same slab"""
for rule in self:
domain = [
('slab_id', '=', rule.slab_id.id),
('id', '!=', rule.id)
]
others = self.search(domain)
for other in others:
if not (rule.max_income and other.min_income >= rule.max_income) and \
not (other.max_income and rule.min_income >= other.max_income):
raise ValidationError(
f"Income ranges overlap with another slab rule: {other.min_income} - {other.max_income}"
)
class IncomeTaxSurchargeMasterRules(models.Model):
_name = 'it.sur.charge.rules'
min_income = fields.Float(string="Min Income (₹)", required=True)
max_income = fields.Float(string="Max Income (₹)")
surcharge_rate = fields.Float(string="Surcharge Rate (%)")
slab_id = fields.Many2one('it.slab.master')
@api.constrains('min_income', 'max_income', 'slab_id') @api.constrains('min_income', 'max_income', 'slab_id')
def _check_overlap(self): def _check_overlap(self):
"""Ensure no overlapping or duplicate ranges within the same slab""" """Ensure no overlapping or duplicate ranges within the same slab"""

View File

@ -1,145 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="income_tax_statement_report">
<t t-call="web.external_layout">
<main class="page">
<t t-set="data" t-value="report_data['data']"/>
<div>
<!-- Header -->
<div class="row text-center" style="margin-bottom: 20px; page-break-inside: avoid;">
<h2>INCOME TAX STATEMENT</h2>
<h4>Assessment Year: <span t-esc="data.get('assessment_year')"/></h4>
<h4>Financial Year: <span t-esc="data.get('financial_year')"/></h4>
</div>
<!-- Company Information -->
<div class="row" style="margin-bottom: 20px; page-break-inside: avoid;">
<div class="col-md-6">
<strong>Company Name:</strong> <span t-esc="data.get('company_name')"/><br/>
<strong>Address:</strong> <span t-esc="data.get('company_address')"/><br/>
<strong>PAN:</strong> <span t-esc="data.get('pan_number')"/><br/>
<strong>TAN:</strong> <span t-esc="data.get('tan_number')"/><br/>
</div>
<div class="col-md-6 text-right">
<strong>Date:</strong> <span t-esc="data.get('date')"/><br/>
</div>
</div>
<!-- Income Details -->
<div class="row" style="margin-bottom: 20px;">
<h4>Income Details</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Particulars</th>
<th class="text-right">Amount (₹)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Income from Salary</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('salary_income', 0))"/>
</tr>
<tr>
<td>Income from House Property</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('house_property_income', 0))"/>
</tr>
<tr>
<td>Income from Business/Profession</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('business_income', 0))"/>
</tr>
<tr>
<td>Capital Gains</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('capital_gains', 0))"/>
</tr>
<tr>
<td>Income from Other Sources</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('other_income', 0))"/>
</tr>
<tr style="font-weight: bold;">
<td>Total Income</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('total_income', 0))"/>
</tr>
</tbody>
</table>
</div>
<!-- Deductions -->
<div class="row" style="margin-bottom: 20px; page-break-inside: avoid;">
<h4>Deductions Under Chapter VI-A</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Section</th>
<th>Particulars</th>
<th class="text-right">Amount (₹)</th>
</tr>
</thead>
<tbody>
<tr>
<td>80C</td>
<td>Life Insurance, PF, PPF, etc.</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('section_80c', 0))"/>
</tr>
<tr>
<td>80D</td>
<td>Medical Insurance Premium</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('section_80d', 0))"/>
</tr>
<tr>
<td>80G</td>
<td>Donations to Charitable Institutions</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('section_80g', 0))"/>
</tr>
<tr>
<td>Others</td>
<td>Other Deductions</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('other_deductions', 0))"/>
</tr>
<tr style="font-weight: bold;">
<td colspan="2">Total Deductions</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('total_deductions', 0))"/>
</tr>
</tbody>
</table>
</div>
<!-- Tax Computation -->
<div class="row" style="margin-bottom: 20px; page-break-inside: avoid;">
<h4>Tax Computation</h4>
<table class="table table-bordered">
<tbody>
<tr>
<td>Total Income</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('total_income', 0))"/>
</tr>
<tr>
<td>Less: Deductions</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('total_deductions', 0))"/>
</tr>
<tr style="font-weight: bold;">
<td>Taxable Income</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('taxable_income', 0))"/>
</tr>
<tr>
<td>Tax Payable</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('tax_payable', 0))"/>
</tr>
<tr>
<td>Less: Tax Paid (Advance/Self-assessment)</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('tax_paid', 0))"/>
</tr>
<tr style="font-weight: bold;">
<td>Balance Tax Payable</td>
<td class="text-right" t-esc="'{:,.2f}'.format(data.get('balance_tax', 0))"/>
</tr>
</tbody>
</table>
</div>
</div>
</main>
</t>
</template>
</odoo>

View File

@ -30,6 +30,7 @@
<t t-set="tax_employment" t-value="'{:,.0f}'.format(deductions.get('professional_tax', 0))"/> <t t-set="tax_employment" t-value="'{:,.0f}'.format(deductions.get('professional_tax', 0))"/>
<t t-set="standard_deduction" t-value="'{:,.0f}'.format(deductions.get('standard_deduction', 0))"/> <t t-set="standard_deduction" t-value="'{:,.0f}'.format(deductions.get('standard_deduction', 0))"/>
<t t-set="other_income" t-value="'{:,.0f}'.format(income_details.get('other_income', 0))"/> <t t-set="other_income" t-value="'{:,.0f}'.format(income_details.get('other_income', 0))"/>
<t t-set="total_sec_16_deduction" t-value="'{:,.0f}'.format(deductions.get('total_sec_16_deduction', 0))"/>
<t t-set="gross_total_income" t-value="'{:,.0f}'.format(income_details.get('gross_total_income', 0))"/> <t t-set="gross_total_income" t-value="'{:,.0f}'.format(income_details.get('gross_total_income', 0))"/>
<t t-set="taxable_income" t-value="'{:,.0f}'.format(tax_computation.get('taxable_income', 0))"/> <t t-set="taxable_income" t-value="'{:,.0f}'.format(tax_computation.get('taxable_income', 0))"/>
<t t-set="roundoff_taxable_income" t-value="'{:,.0f}'.format(tax_computation.get('roundoff_taxable_income', 0))"/> <t t-set="roundoff_taxable_income" t-value="'{:,.0f}'.format(tax_computation.get('roundoff_taxable_income', 0))"/>
@ -37,6 +38,8 @@
<t t-set="rebate_87a" t-value="'{:,.0f}'.format(tax_computation.get('rebate_87a', 0))"/> <t t-set="rebate_87a" t-value="'{:,.0f}'.format(tax_computation.get('rebate_87a', 0))"/>
<t t-set="cess" t-value="'{:,.0f}'.format(tax_computation.get('cess_4pct', 0))"/> <t t-set="cess" t-value="'{:,.0f}'.format(tax_computation.get('cess_4pct', 0))"/>
<t t-set="total_tax" t-value="'{:,.0f}'.format(tax_computation.get('total_tax', 0))"/> <t t-set="total_tax" t-value="'{:,.0f}'.format(tax_computation.get('total_tax', 0))"/>
<t t-set="current_employer_deducted_tax" t-value="'{:,.0f}'.format(tax_computation.get('current_employer_deducted_tax', 0))"/>
<t t-set="balance_tax" t-value="'{:,.0f}'.format(tax_computation.get('balance_tax', 0))"/>
<t t-set="report_time" t-value="data.get('report_time', '')"/> <t t-set="report_time" t-value="data.get('report_time', '')"/>
<!-- Header --> <!-- Header -->
@ -149,6 +152,15 @@
<td style="text-align: right;" <td style="text-align: right;"
t-esc="'{:,.0f}'.format(salary_components.get('reimbursement', {}).get('total', 0))"/> t-esc="'{:,.0f}'.format(salary_components.get('reimbursement', {}).get('total', 0))"/>
</tr> </tr>
<tr t-foreach="salary_components.get('other_components', [])" t-as="component">
<td t-esc="component.get('name')"/>
<td style="text-align: right;"
t-esc="'{:,.0f}'.format(component.get('actual', 0))"/>
<td style="text-align: right;"
t-esc="'{:,.0f}'.format(component.get('projected', 0))"/>
<td style="text-align: right;"
t-esc="'{:,.0f}'.format(component.get('total', 0))"/>
</tr>
<tr style="border-top: 2px solid #ddd; font-weight: bold;"> <tr style="border-top: 2px solid #ddd; font-weight: bold;">
<td>Gross Salary</td> <td>Gross Salary</td>
<td style="text-align: right;" <td style="text-align: right;"
@ -158,6 +170,15 @@
<td style="text-align: right;" <td style="text-align: right;"
t-esc="'{:,.0f}'.format(salary_components.get('gross_salary', {}).get('total', 0))"/> t-esc="'{:,.0f}'.format(salary_components.get('gross_salary', {}).get('total', 0))"/>
</tr> </tr>
<tr t-if="salary_components.get('advance_recovery', {}).get('total', 0)">
<td>Advance Recovery</td>
<td style="text-align: right;"
t-esc="'{:,.0f}'.format(salary_components.get('advance_recovery', {}).get('actual', 0))"/>
<td style="text-align: right;"
t-esc="'{:,.0f}'.format(salary_components.get('advance_recovery', {}).get('projected', 0))"/>
<td style="text-align: right;"
t-esc="'{:,.0f}'.format(salary_components.get('advance_recovery', {}).get('total', 0))"/>
</tr>
<tr> <tr>
<td>Less: Exemption under section 10</td> <td>Less: Exemption under section 10</td>
<td colspan="3"></td> <td colspan="3"></td>
@ -180,17 +201,22 @@
</tr> </tr>
<tr style="border-top: 2px solid #ddd; margin-bottom: 8px; margin-top: 10px;"> <tr style="border-top: 2px solid #ddd; margin-bottom: 8px; margin-top: 10px;">
<td style="padding-left: 30px;">Less: Standard Deduction for Salaried Employees</td> <td style="padding-left: 30px;">Less: Standard Deduction for Salaried Employees</td>
<td style="text-align: right;">
-<span t-esc="standard_deduction"/>
</td>
<td colspan="2"></td> <td colspan="2"></td>
<td style="text-align: right;"
t-esc="standard_deduction"/>
</tr> </tr>
<tr style="border-top: 2px solid #ddd; margin-bottom: 8px; margin-top: 10px;"> <tr style="border-top: 2px solid #ddd; margin-bottom: 8px; margin-top: 10px;">
<td style="padding-left: 30px;">Total</td> <td style="padding-left: 30px;">Total</td>
<td colspan="2"></td>
<td style="text-align: right;" <td style="text-align: right;"
t-esc="tax_employment"/> t-esc="total_sec_16_deduction"/>
<td colspan="1"></td> </tr>
<td style="text-align: right;" <tr style="border-top: 2px solid #ddd; margin-bottom: 8px; margin-top: 10px;">
t-esc="standard_deduction"/> <td><strong>Less:</strong> Marginal Relief</td>
<td colspan="3"></td>
<td style="text-align: right;">0</td>
</tr> </tr>
<tr style="border-top: 2px solid #ddd; font-weight: bold; margin-bottom: 8px; margin-top: 10px;"> <tr style="border-top: 2px solid #ddd; font-weight: bold; margin-bottom: 8px; margin-top: 10px;">
@ -267,7 +293,7 @@
<td style="width: 70%;"> <td style="width: 70%;">
Round off to nearest 10 Rupee: Round off to nearest 10 Rupee:
</td> </td>
<td style="width: 30%; text-align: right;"> <td style="width: 30%; text-align: right; border-bottom: 1px solid #000; padding-bottom: 2px;">
<t t-esc="roundoff_taxable_income"/> <t t-esc="roundoff_taxable_income"/>
</td> </td>
</tr> </tr>
@ -354,7 +380,7 @@
<tr> <tr>
<td>Less: Tax deducted current employer (up to previous month)</td> <td>Less: Tax deducted current employer (up to previous month)</td>
<td style="text-align: right;">0</td> <td style="text-align: right;">0</td>
<td style="text-align: right;">0</td> <td style="text-align: right;" t-esc="current_employer_deducted_tax"/>
</tr> </tr>
<tr> <tr>
<td>Less: Tax deducted from previous Employer / Self Tax Paid</td> <td>Less: Tax deducted from previous Employer / Self Tax Paid</td>
@ -365,7 +391,7 @@
<tr style="font-weight: bold;"> <tr style="font-weight: bold;">
<td>Balance Tax for the year</td> <td>Balance Tax for the year</td>
<td style="text-align: right;">0</td> <td style="text-align: right;">0</td>
<td style="text-align: right;" t-esc="total_tax"/> <td style="text-align: right;" t-esc="balance_tax"/>
</tr> </tr>
<tr> <tr>
<td>Less: Adhoc tax deducted in Off-Cycle in current month</td> <td>Less: Adhoc tax deducted in Off-Cycle in current month</td>
@ -375,7 +401,7 @@
<tr style="font-weight: bold;"> <tr style="font-weight: bold;">
<td><strong>Balance Tax</strong></td> <td><strong>Balance Tax</strong></td>
<td style="text-align: right;">0</td> <td style="text-align: right;">0</td>
<td style="text-align: right;" t-esc="total_tax"/> <td style="text-align: right;" t-esc="balance_tax"/>
</tr> </tr>
<tr> <tr>
<td><strong>Tax deducted from current month salary</strong></td> <td><strong>Tax deducted from current month salary</strong></td>
@ -414,6 +440,69 @@
</div> </div>
</t> </t>
</template> </template>
<template id="generate_income_tax_comparison_rpt">
<t t-call="web.html_container">
<div class="page">
<t t-set="data" t-value="report_data['data']"/>
<t t-set="profile" t-value="data.get('profile')"/>
<t t-set="comparison" t-value="data.get('comparison')"/>
<div style="text-align: center; margin-bottom: 24px;">
<h2 style="font-weight: bold; margin-bottom: 5px;"><t t-esc="data.get('company_name')"/></h2>
<h3 style="font-weight: bold; margin-top: 0;">TAX REGIME COMPARISON</h3>
</div>
<table class="table table-sm" style="width: 100%; margin-bottom: 24px;">
<tr>
<td><strong>Employee:</strong> <t t-esc="profile.get('name', '')"/></td>
<td><strong>Emp Code:</strong> <t t-esc="data.get('emp_code', '')"/></td>
</tr>
<tr>
<td><strong>Financial Year:</strong> <t t-esc="data.get('financial_year', '')"/></td>
<td><strong>Selected Regime:</strong> <t t-esc="data.get('regime_info', {}).get('tax_regime', '')"/></td>
</tr>
</table>
<table class="table table-bordered table-sm" style="width: 100%; margin-bottom: 20px;">
<thead>
<tr style="background-color: #f8f9fa;">
<th style="font-weight: bold; text-align: left;">Particulars</th>
<th style="font-weight: bold; text-align: right;">Old Regime</th>
<th style="font-weight: bold; text-align: right;">New Regime</th>
</tr>
</thead>
<tbody>
<tr>
<td>Taxable Income</td>
<td style="text-align: right;" t-esc="'{:,.0f}'.format(comparison.get('old_taxable_income', 0))"/>
<td style="text-align: right;" t-esc="'{:,.0f}'.format(comparison.get('new_taxable_income', 0))"/>
</tr>
<tr>
<td>Tax Payable</td>
<td style="text-align: right;" t-esc="'{:,.0f}'.format(comparison.get('old_regime_tax', 0))"/>
<td style="text-align: right;" t-esc="'{:,.0f}'.format(comparison.get('new_regime_tax', 0))"/>
</tr>
<tr style="font-weight: bold;">
<td>Tax Difference</td>
<td colspan="2" style="text-align: right;" t-esc="'{:,.0f}'.format(comparison.get('tax_savings', 0))"/>
</tr>
<tr style="font-weight: bold;">
<td>Beneficial Regime</td>
<td colspan="2" style="text-align: right;">
<t t-esc="(comparison.get('beneficial_regime') or '').upper()"/>
</td>
</tr>
</tbody>
</table>
<div style="margin-top: 24px;">
<strong>Report Time:</strong>
<t t-esc="data.get('report_time', '')"/>
</div>
</div>
</t>
</template>
<!-- <template id="generate_income_tax_statement_rpt">--> <!-- <template id="generate_income_tax_statement_rpt">-->
<!-- <t t-call="web.basic_layout">--> <!-- <t t-call="web.basic_layout">-->
<!-- <main class="page">--> <!-- <main class="page">-->

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<odoo> <odoo>
<report <record id="action_report_it_tax_statement" model="ir.actions.report">
id="action_report_it_tax_statement" <field name="name">IT Declaration Submission</field>
model="emp.it.declaration" <field name="model">emp.it.declaration</field>
string="IT Tax Statement" <field name="report_type">qweb-pdf</field>
report_type="qweb-pdf" <field name="report_name">employee_it_declaration.report_it_tax_statement</field>
name="your_module_name.report_it_tax_statement" <field name="report_file">employee_it_declaration.report_it_tax_statement</field>
file="your_module_name.report_it_tax_statement" <field name="print_report_name">'IT Declaration - %s - %s' % (object.employee_id.name or '', object.period_id.name or '')</field>
print_report_name="'IT_Tax_Statement_%s' % (object.employee_id.name)" <field name="binding_model_id" eval="False"/>
/> </record>
</odoo> </odoo>

View File

@ -55,7 +55,8 @@ access_nsc_interest_entry_user,nsc.interest.entry,model_nsc_interest_entry,base.
access_house_rent_declaration_user,access.house.rent.declaration.user,model_house_rent_declaration,base.group_user,1,1,1,1 access_house_rent_declaration_user,access.house.rent.declaration.user,model_house_rent_declaration,base.group_user,1,1,1,1
access_it_tax_statement,it.tax.statement,model_it_tax_statement,base.group_user,1,0,0,0 access_it_tax_statement,it.tax.statement,model_it_tax_statement,base.group_user,1,0,0,0
access_it_tax_statement_wizard,it.tax.statement.wizard,model_it_tax_statement_wizard,base.group_user,1,0,0,0 access_it_tax_statement_wizard,it.tax.statement.wizard,model_it_tax_statement_wizard,base.group_user,1,1,1,0
access_employee_payslip_download_wizard,employee.payslip.download.wizard,model_employee_payslip_download_wizard,base.group_user,1,1,1,0
access_it_tax_statement_manager,it.tax.statement,model_it_tax_statement,hr.group_hr_manager,1,1,1,1 access_it_tax_statement_manager,it.tax.statement,model_it_tax_statement,hr.group_hr_manager,1,1,1,1
access_it_tax_statement_wizard_manager,it.tax.statement.wizard,model_it_tax_statement_wizard,hr.group_hr_manager,1,1,1,1 access_it_tax_statement_wizard_manager,it.tax.statement.wizard,model_it_tax_statement_wizard,hr.group_hr_manager,1,1,1,1
@ -63,3 +64,4 @@ access_it_tax_statement_wizard_manager,it.tax.statement.wizard,model_it_tax_stat
access_it_slab_master,it.slab.master,model_it_slab_master,base.group_user,1,1,1,1 access_it_slab_master,it.slab.master,model_it_slab_master,base.group_user,1,1,1,1
access_it_slab_master_rules,it.slab.master.rules,model_it_slab_master_rules,base.group_user,1,1,1,1 access_it_slab_master_rules,it.slab.master.rules,model_it_slab_master_rules,base.group_user,1,1,1,1
access_it_sur_charge_rules,it.sur.charge.rules.user,model_it_sur_charge_rules,base.group_user,1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
55
56
57
58
59
60
61
62
64
65
66
67

View File

@ -7,9 +7,11 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<list> <list>
<field name="employee_id"/>
<field name="period_id"/> <field name="period_id"/>
<field name="total_investment"/> <field name="total_investment"/>
<field name="tax_regime"/> <field name="tax_regime"/>
<field name="state"/>
</list> </list>
</field> </field>
</record> </record>
@ -20,28 +22,60 @@
<field name="model">emp.it.declaration</field> <field name="model">emp.it.declaration</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="IT Declaration"> <form string="IT Declaration">
<header>
<button name="action_submit"
string="Submit"
type="object"
class="btn-primary"
invisible="state != 'draft' or not costing_details_generated"/>
<button name="action_download_submission_pdf"
string="Download PDF"
type="object"
class="btn-primary"
icon="fa-download"
invisible="state != 'submitted'"/>
<button name="action_return_to_draft"
string="Return to Draft"
type="object"
class="btn-secondary"
invisible="state != 'submitted'"
groups="hr_payroll.group_hr_payroll_manager"/>
<field name="state" widget="statusbar" statusbar_visible="draft,submitted"/>
</header>
<sheet> <sheet>
<div class="oe_title mb24"> <div class="oe_title mb24">
<div class="o_row"> <div class="o_row">
<field name="employee_id" widget="res_partner_many2one" placeholder="Employee Name..." readonly="costing_details_generated"/> <field name="employee_id" widget="res_partner_many2one" placeholder="Employee Name..." readonly="costing_details_generated or state == 'submitted'"/>
</div> </div>
</div> </div>
<group> <group>
<group> <group>
<field name="period_id" readonly="costing_details_generated"/> <field name="period_id" readonly="costing_details_generated or state == 'submitted'"/>
</group> </group>
<group> <group>
<field name="total_investment"/> <field name="total_investment" readonly="state == 'submitted'"/>
<field name="return_reason" placeholder="Reason for returning the declaration to draft..." readonly="state != 'submitted' or not is_payroll_manager"/>
<field name="is_payroll_manager" invisible="1"/>
<field name="costing_details_generated" invisible="1" force_save="1"/> <field name="costing_details_generated" invisible="1" force_save="1"/>
<field name="house_rent_costing_id"/> <field name="house_rent_costing_id"/>
<field name="show_past_employment" invisible="1"/>
<field name="show_us_80c" invisible="1"/>
<field name="show_us_80d" invisible="1"/>
<field name="show_us_10" invisible="1"/>
<field name="show_us_80g" invisible="1"/>
<field name="show_chapter_via" invisible="1"/>
<field name="show_us_17" invisible="1"/>
<field name="show_house_rent" invisible="1"/>
<field name="show_other_i_or_l" invisible="1"/>
<field name="show_other_declaration" invisible="1"/>
</group> </group>
</group> </group>
<br/> <br/>
<br/> <br/>
<field name="tax_regime" nolabel="1" widget="radio" options="{'horizontal': true}"/> <field name="tax_regime" nolabel="1" widget="radio" options="{'horizontal': true}" readonly="state == 'submitted'"/>
<br/> <br/>
<button name="generate_declarations" type="object" class="btn-primary" string="Generate" confirm="Upon Confirming you won't be able to change the Period &amp; Employee" help="Generate Data to upload the declaration Costing" invisible="costing_details_generated"/> <button name="generate_declarations" type="object" class="btn-primary" string="Generate" confirm="Upon Confirming you won't be able to change the Period &amp; Employee" help="Generate Data to upload the declaration Costing" invisible="costing_details_generated or state == 'submitted'"/>
<field name="is_section_open" invisible="1"/> <!-- Store toggle state --> <field name="is_section_open" invisible="1"/> <!-- Store toggle state -->
<group invisible="not costing_details_generated"> <group invisible="not costing_details_generated">
@ -61,7 +95,7 @@
<page string="Total Investment Costing"> <page string="Total Investment Costing">
<group> <group>
<group> <group>
<field name="investment_costing_ids" nolabel="1"> <field name="visible_investment_costing_ids" nolabel="1" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0" edit="0"> <list editable="bottom" create="0" delete="0" edit="0">
<field name="investment_type_id"/> <field name="investment_type_id"/>
<field name="amount"/> <field name="amount"/>
@ -90,9 +124,9 @@
<!-- </list>--> <!-- </list>-->
<!-- </field>--> <!-- </field>-->
<!-- </page>--> <!-- </page>-->
<page name="past_employment_costings" string="PAST EMPLOYMENT"> <page name="past_employment_costings" string="PAST EMPLOYMENT" invisible="not show_past_employment">
<field name="past_employment_costings" invisible="tax_regime != 'old'"> <field name="past_employment_costings" invisible="tax_regime != 'old'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -102,7 +136,7 @@
<field name="limit" readonly="1" force_save="1"/> <field name="limit" readonly="1" force_save="1"/>
</list> </list>
</field> </field>
<field name="past_employment_costings_new" invisible="tax_regime != 'new'"> <field name="past_employment_costings_new" invisible="tax_regime != 'new'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -114,9 +148,25 @@
</field> </field>
</page> </page>
<page name="us_80c_costings" string="US 80C" invisible="tax_regime != 'old'"> <page name="us_80c_costings" string="US 80C" invisible="not show_us_80c">
<field name="us80c_costings"> <field name="us80c_costings" invisible="tax_regime != 'old'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/>
<field name="action_id" column_invisible="1"/>
<button name="open_action_wizard"
string="Action"
type="object"
icon="fa-external-link"
invisible="not action_id" width="60px"/>
<field name="proof_amount" width="100px" readonly="1" force_save="1"/>
<field name="remarks" width="200px"/>
<field name="proof" width="100px"/>
<field name="limit" readonly="1" force_save="1"/>
</list>
</field>
<field name="us80c_costings_new" invisible="tax_regime != 'new'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -134,12 +184,12 @@
</field> </field>
</page> </page>
<page name="us_80d_costings" string="US 80D" invisible="tax_regime != 'old'"> <page name="us_80d_costings" string="US 80D" invisible="not show_us_80d">
<group> <group>
<field name="us80d_selection_type" widget="radio" options="{'horizontal': true}" required="tax_regime == 'old' and costing_details_generated"/> <field name="us80d_selection_type" widget="radio" options="{'horizontal': true}" required="tax_regime == 'old' and costing_details_generated" readonly="state == 'submitted'"/>
<field name="us80d_health_checkup"/> <field name="us80d_health_checkup" readonly="state == 'submitted'"/>
</group> </group>
<field name="us80d_costings" invisible="us80d_selection_type != 'self_family'"> <field name="us80d_costings" invisible="tax_regime != 'old' or us80d_selection_type != 'self_family'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -149,7 +199,17 @@
<field name="limit" readonly="1" force_save="1"/> <field name="limit" readonly="1" force_save="1"/>
</list> </list>
</field> </field>
<field name="us80d_costings_parents" invisible="us80d_selection_type != 'self_family_parent'"> <field name="us80d_costings_new" invisible="tax_regime != 'new' or us80d_selection_type != 'self_family'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/>
<field name="proof_amount" width="100px" readonly="1" force_save="1"/>
<field name="remarks" width="250px"/>
<field name="proof" width="120px"/>
<field name="limit" readonly="1" force_save="1"/>
</list>
</field>
<field name="us80d_costings_parents" invisible="tax_regime != 'old' or us80d_selection_type != 'self_family_parent'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -160,7 +220,29 @@
</list> </list>
</field> </field>
<field name="us80d_costings_senior_parents" invisible="us80d_selection_type != 'self_family_senior_parent'"> <field name="us80d_costings_parents_new" invisible="tax_regime != 'new' or us80d_selection_type != 'self_family_parent'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/>
<field name="proof_amount" width="100px" readonly="1" force_save="1"/>
<field name="remarks" width="250px"/>
<field name="proof" width="120px"/>
<field name="limit" readonly="1" force_save="1"/>
</list>
</field>
<field name="us80d_costings_senior_parents" invisible="tax_regime != 'old' or us80d_selection_type != 'self_family_senior_parent'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/>
<field name="proof_amount" width="100px" readonly="1" force_save="1"/>
<field name="remarks" width="250px"/>
<field name="proof" width="120px"/>
<field name="limit" readonly="1" force_save="1"/>
</list>
</field>
<field name="us80d_costings_senior_parents_new" invisible="tax_regime != 'new' or us80d_selection_type != 'self_family_senior_parent'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -172,8 +254,18 @@
</field> </field>
</page> </page>
<page name="us_10_costing" string="US 10" invisible="tax_regime != 'old'"> <page name="us_10_costing" string="US 10" invisible="not show_us_10">
<field name="us10_costings"> <field name="us10_costings" invisible="tax_regime != 'old'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/>
<field name="proof_amount" width="100px" readonly="1" force_save="1"/>
<field name="remarks" width="250px"/>
<field name="proof" width="120px"/>
<field name="limit" readonly="1" force_save="1"/>
</list>
</field>
<field name="us10_costings_new" invisible="tax_regime != 'new'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -184,8 +276,18 @@
</list> </list>
</field> </field>
</page> </page>
<page name="us_80g_costing" string="US 80G" invisible="tax_regime != 'old'"> <page name="us_80g_costing" string="US 80G" invisible="not show_us_80g">
<field name="us80g_costings"> <field name="us80g_costings" invisible="tax_regime != 'old'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/>
<field name="proof_amount" width="100px" readonly="1" force_save="1"/>
<field name="remarks" width="250px"/>
<field name="proof" width="120px"/>
<field name="limit" readonly="1" force_save="1"/>
</list>
</field>
<field name="us80g_costings_new" invisible="tax_regime != 'new'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -197,8 +299,8 @@
</field> </field>
</page> </page>
<page name="chapter_via_costings" string="CHAPTER VIA"> <page name="chapter_via_costings" string="CHAPTER VIA" invisible="not show_chapter_via">
<field name="chapter_via_costings" invisible="tax_regime != 'old'"> <field name="chapter_via_costings" invisible="tax_regime != 'old'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -208,7 +310,7 @@
<field name="limit" readonly="1" force_save="1"/> <field name="limit" readonly="1" force_save="1"/>
</list> </list>
</field> </field>
<field name="chapter_via_costings_new" invisible="tax_regime != 'new'"> <field name="chapter_via_costings_new" invisible="tax_regime != 'new'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -220,8 +322,18 @@
</field> </field>
</page> </page>
<page name="us_17_costings" string="US 17" invisible="tax_regime != 'old'"> <page name="us_17_costings" string="US 17" invisible="not show_us_17">
<field name="us17_costings"> <field name="us17_costings" invisible="tax_regime != 'old'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/>
<field name="proof_amount" width="100px" readonly="1" force_save="1"/>
<field name="remarks" width="250px"/>
<field name="proof" width="120px"/>
<field name="limit" readonly="1" force_save="1"/>
</list>
</field>
<field name="us17_costings_new" invisible="tax_regime != 'new'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -232,9 +344,9 @@
</list> </list>
</field> </field>
</page> </page>
<page name="house_rent_costings" string="HOUSE RENT" invisible="tax_regime != 'old'"> <page name="house_rent_costings" string="HOUSE RENT" invisible="not show_house_rent">
<!-- <field name="house_rent_costing_line_ids"/>--> <!-- <field name="house_rent_costing_line_ids"/>-->
<field name="house_rent_costings" context="{ <field name="house_rent_costings" readonly="state == 'submitted'" context="{
'default_costing_type': house_rent_costing_id 'default_costing_type': house_rent_costing_id
}"> }">
<list string="House Rent Declarations"> <list string="House Rent Declarations">
@ -284,8 +396,8 @@
</form> </form>
</field> </field>
</page> </page>
<page name="other_i_or_l_costings" string="OTHER INCOME/LOSS"> <page name="other_i_or_l_costings" string="OTHER INCOME/LOSS" invisible="not show_other_i_or_l">
<field name="other_il_costings" invisible="tax_regime != 'old'"> <field name="other_il_costings" invisible="tax_regime != 'old'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -302,7 +414,7 @@
<field name="limit" readonly="1" force_save="1"/> <field name="limit" readonly="1" force_save="1"/>
</list> </list>
</field> </field>
<field name="other_il_costings_new" invisible="tax_regime != 'new'"> <field name="other_il_costings_new" invisible="tax_regime != 'new'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -319,10 +431,19 @@
<field name="limit" readonly="1" force_save="1"/> <field name="limit" readonly="1" force_save="1"/>
</list> </list>
</field> </field>
</page> </page>
<page name="other_declaration_costings" string="Other Declarations" invisible="tax_regime != 'old'"> <page name="other_declaration_costings" string="Other Declarations" invisible="not show_other_declaration">
<field name="other_declaration_costings"> <field name="other_declaration_costings" invisible="tax_regime != 'old'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/>
<field name="proof_amount" width="100px" readonly="1" force_save="1"/>
<field name="remarks" width="250px"/>
<field name="proof" width="120px"/>
<field name="limit" readonly="1" force_save="1"/>
</list>
</field>
<field name="other_declaration_costings_new" invisible="tax_regime != 'new'" readonly="state == 'submitted'">
<list editable="bottom" create="0" delete="0"> <list editable="bottom" create="0" delete="0">
<field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/> <field name="investment_type_line_id" width="600px" readonly="1" force_save="1" options="{'no_open': True, 'no_quick_create': True}"/>
<field name="declaration_amount" width="130px"/> <field name="declaration_amount" width="130px"/>
@ -344,12 +465,23 @@
<field name="name">IT Declarations</field> <field name="name">IT Declarations</field>
<field name="path">income-tax-declaration</field> <field name="path">income-tax-declaration</field>
<field name="res_model">emp.it.declaration</field> <field name="res_model">emp.it.declaration</field>
<field name="domain">[('employee_id.user_id', '=', uid)]</field>
<field name="view_mode">list,form</field>
</record>
<record id="action_manager_it_declaration" model="ir.actions.act_window">
<field name="name">IT Declarations</field>
<field name="path">employees-tax-declarations</field>
<field name="res_model">emp.it.declaration</field>
<field name="view_mode">list,form</field> <field name="view_mode">list,form</field>
</record> </record>
<menuitem id="menu_hr_payroll_emp_root" name="Payroll" sequence="190" web_icon="hr_payroll,static/description/icon.png" groups="base.group_user"/>
<menuitem id="menu_it_declarations" name="IT Declarations" <menuitem id="menu_it_declarations" name="IT Declarations"
parent="hr_payroll.menu_hr_payroll_root" parent="hr_payroll.menu_hr_payroll_root"
action="action_emp_it_declaration" sequence="99"/> action="action_manager_it_declaration" sequence="99"/>
<menuitem id="menu_it_declarations_emp" name="IT Declarations"
parent="menu_hr_payroll_emp_root"
action="action_emp_it_declaration" sequence="1"/>
</data> </data>
</odoo> </odoo>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_employee_payslip_download_wizard_form" model="ir.ui.view">
<field name="name">employee.payslip.download.wizard.form</field>
<field name="model">employee.payslip.download.wizard</field>
<field name="arch" type="xml">
<form string="Download Payslips">
<header>
<button name="action_download_payslips"
string="Download Payslip"
type="object"
class="oe_stat_button"
icon="fa-download"
invisible="download_type != 'single'"/>
<button name="action_download_payslips"
string="Download ZIP"
type="object"
class="oe_stat_button"
icon="fa-file-archive-o"
invisible="download_type != 'multi'"/>
</header>
<sheet>
<group>
<field name="is_hr_manager" invisible="1"/>
<field name="employee_id" readonly="not is_hr_manager" options="{'no_edit': True, 'no_create': True}"/>
<field name="download_type" widget="radio" options="{'horizontal': true}"/>
</group>
<group>
<group>
<field name="period_id" domain="[('id', 'in', available_period_ids)]" options="{'no_edit': True, 'no_create': True, 'no_open': True}"/>
</group>
<group>
<field name="period_line"
force_save="1"
required="download_type == 'single'"
invisible="download_type != 'single'"/>
</group>
</group>
<group>
<field name="payslip_count" readonly="1"/>
</group>
</sheet>
<footer>
<button string="Close"
special="cancel"
class="btn-secondary"/>
</footer>
</form>
</field>
</record>
<record id="action_employee_payslip_download_wizard" model="ir.actions.act_window">
<field name="name">Download Payslips</field>
<field name="res_model">employee.payslip.download.wizard</field>
<field name="path">download-payslips</field>
<field name="view_mode">form</field>
<field name="target">current</field>
</record>
<menuitem id="menu_employee_payslip_download_wizard"
name="Salary Payslip"
parent="employee_it_declaration.menu_hr_payroll_emp_root"
action="action_employee_payslip_download_wizard"
sequence="2"
groups="base.group_user"/>
</odoo>

View File

@ -22,7 +22,8 @@
<group> <group>
<field name="sequence" invisible="1"/> <field name="sequence" invisible="1"/>
<field name="investment_type"/> <field name="investment_type"/>
<field name="regime"/>
<field name="period_ids" widget="many2many_tags"/>
<field name="active"/> <field name="active"/>
</group> </group>
<notebook> <notebook>

View File

@ -8,7 +8,7 @@
<list> <list>
<field name="employee_id"/> <field name="employee_id"/>
<field name="period_id"/> <field name="period_id"/>
<field name="period_line"/> <field name="period_line" force_save="1"/>
<field name="tax_regime"/> <field name="tax_regime"/>
</list> </list>
</field> </field>
@ -26,10 +26,25 @@
type="object" type="object"
class="oe_stat_button" class="oe_stat_button"
icon="fa-file-text"/> icon="fa-file-text"/>
<button name="action_check_regime_comparison"
string="Check Comparison"
type="object"
class="oe_stat_button"
icon="fa-calculator"/>
<button name="action_generate_comparison_report"
string="Download Comparison"
type="object"
class="oe_stat_button"
icon="fa-balance-scale"
invisible="not comparison_available"/>
</header> </header>
<sheet> <sheet>
<field name="comparison_available" invisible="1"/>
<field name="currency_id" invisible="1"/>
<field name="is_general_tax_statement" invisible="1"/>
<group> <group>
<field name="employee_id" options="{'no_edit': True, 'no_create': True}"/> <field name="is_hr_manager" invisible="1" force_save="1"/>
<field name="employee_id" readonly="not is_hr_manager" options="{'no_edit': True, 'no_create': True}"/>
<field name="contract_id" readonly="1" force_save="1" invisible="0"/> <field name="contract_id" readonly="1" force_save="1" invisible="0"/>
</group> </group>
<group> <group>
@ -40,16 +55,30 @@
</group> </group>
<group> <group>
<group> <group>
<field name="period_id" options="{'no_edit': True, 'no_create': True, 'no_open': True}"/> <field name="period_id" domain="[('id', 'in', available_period_ids)]"
options="{'no_edit': True, 'no_create': True, 'no_open': True}"/>
</group> </group>
<group> <group>
<field name="period_line" domain="[('period_id', '=', period_id),('to_date','&lt;',datetime.datetime.now()),('from_date','&gt;',emp_doj)]" options="{'no_edit': True, 'no_create': True, 'no_open': True}" invisible="not emp_doj"/> <field name="period_line" force_save="1" domain="[('period_id', '=', period_id),('to_date','&lt;',(context_today() + datetime.timedelta(days=30)).strftime('%Y-%m-%d')),('to_date','&gt;',emp_doj)]"/>
<field name="period_line" domain="[('period_id', '=', period_id),('to_date','&lt;',datetime.datetime.now())]" options="{'no_edit': True, 'no_create': True, 'no_open': True}" invisible="emp_doj"/>
</group> </group>
</group> </group>
<group> <group>
<field name="tax_regime" nolabel="1" widget="radio" options="{'horizontal': true}" on_change="1"/> <field name="tax_regime" nolabel="1" widget="radio" options="{'horizontal': true}" on_change="1"/>
</group> </group>
<group string="Tax Regime Comparison" invisible="not comparison_available">
<group string="Old Regime">
<field name="old_regime_taxable_income" readonly="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="old_regime_tax_payable" readonly="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
</group>
<group string="New Regime">
<field name="new_regime_taxable_income" readonly="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="new_regime_tax_payable" readonly="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
</group>
<group>
<field name="beneficial_regime" readonly="1"/>
<field name="tax_difference" readonly="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
</group>
</group>
</sheet> </sheet>
</form> </form>
</field> </field>
@ -60,17 +89,20 @@
<field name="name">Generate Tax Statement</field> <field name="name">Generate Tax Statement</field>
<field name="res_model">it.tax.statement.wizard</field> <field name="res_model">it.tax.statement.wizard</field>
<field name="path">tax-statement</field> <field name="path">tax-statement</field>
<field name="view_mode">list,form</field> <field name="view_mode">form</field>
<field name="domain">[("activity_ids.active", "in", [True, False])]</field>
<field name="help" type="html"> <field name="help" type="html">
<p class="o_view_nocontent_smiling_face"> <p class="o_view_nocontent_smiling_face">
Create a new employment type Create a new employment type
</p> </p>
</field> </field>
</record> </record>
<menuitem id="menu_it_tax_statement_root" name="IT Tax Statement" <menuitem id="menu_it_tax_statement_root" name="IT Tax Statement"
parent="hr_payroll.menu_hr_payroll_root" parent="employee_it_declaration.menu_hr_payroll_emp_root"
action="action_it_tax_statement_wizard" sequence="99"/> groups="base.group_user"
action="action_it_tax_statement_wizard" sequence="3"/>
<record id="it_statement_paper_format" model="report.paperformat"> <record id="it_statement_paper_format" model="report.paperformat">
<field name="name">A4 - statement</field> <field name="name">A4 - statement</field>
@ -95,7 +127,19 @@
<field name="report_name">employee_it_declaration.generate_income_tax_statement_rpt</field> <field name="report_name">employee_it_declaration.generate_income_tax_statement_rpt</field>
<field name="report_file">employee_it_declaration.generate_income_tax_statement_rpt</field> <field name="report_file">employee_it_declaration.generate_income_tax_statement_rpt</field>
<field name="binding_model_id" ref="employee_it_declaration.model_it_tax_statement_wizard"/> <field name="binding_model_id" ref="employee_it_declaration.model_it_tax_statement_wizard"/>
<field name="print_report_name">'INCOMETAX - %s' % (object.display_name)</field> <field name="print_report_name">'%s - %s' % (object.employee_id.name or '', object.period_line.name or '')</field>
<field name="paperformat_id" ref="it_statement_paper_format"/>
<field name="binding_type">report</field>
</record>
<record id="income_tax_comparison_action_report" model="ir.actions.report">
<field name="name">Download Tax Regime Comparison</field>
<field name="model">it.tax.statement.wizard</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">employee_it_declaration.generate_income_tax_comparison_rpt</field>
<field name="report_file">employee_it_declaration.generate_income_tax_comparison_rpt</field>
<field name="binding_model_id" ref="employee_it_declaration.model_it_tax_statement_wizard"/>
<field name="print_report_name">'%s - Tax Regime Comparison' % (object.employee_id.name or '')</field>
<field name="paperformat_id" ref="it_statement_paper_format"/> <field name="paperformat_id" ref="it_statement_paper_format"/>
<field name="binding_type">report</field> <field name="binding_type">report</field>
</record> </record>

View File

@ -1,28 +1,158 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo> <odoo>
<template id="report_it_tax_statement"> <template id="report_it_tax_statement">
<t t-call="web.html_container"> <t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="web.external_layout"> <t t-call="web.external_layout">
<div class="page"> <div class="page">
<h2>IT Tax Statement</h2> <style>
<p><strong>Employee:</strong> <t t-esc="doc.employee_id.name"/></p> .it-title { text-align: center; margin-bottom: 18px; }
<p><strong>Period:</strong> <t t-esc="doc.period_id.name"/></p> .it-title h2 { margin: 0; font-size: 21px; font-weight: 700; }
<p><strong>Tax Regime:</strong> <t t-esc="dict(doc._fields['tax_regime'].selection).get(doc.tax_regime)"/></p> .it-title p { margin: 4px 0 0; color: #555; }
<table class="table table-sm"> .it-section { margin-top: 18px; }
<thead> .it-section h4 { font-size: 14px; font-weight: 700; border-bottom: 1px solid #999; padding-bottom: 4px; margin-bottom: 8px; }
<tr><th>Section</th><th>Amount</th></tr> .it-table { width: 100%; border-collapse: collapse; font-size: 11px; }
</thead> .it-table th { background: #f2f2f2; font-weight: 700; }
.it-table th, .it-table td { border: 1px solid #ddd; padding: 5px; vertical-align: top; }
.it-right { text-align: right; }
.it-muted { color: #777; }
</style>
<div class="it-title">
<h2>IT Declaration Submission</h2>
<p>
<span t-esc="doc.employee_id.company_id.name"/>
</p>
</div>
<table class="it-table">
<tbody> <tbody>
<t t-foreach="doc.investment_costing_ids" t-as="line">
<tr> <tr>
<td><t t-esc="line.investment_type_id.name"/></td> <th>Employee</th>
<td><t t-esc="line.amount"/></td> <td><span t-esc="doc.employee_id.name"/></td>
<th>Payroll Period</th>
<td><span t-esc="doc.period_id.name"/></td>
</tr>
<tr>
<th>Tax Regime</th>
<td><span t-esc="doc._get_regime_label()"/></td>
<th>Status</th>
<td><span t-esc="dict(doc._fields['state'].selection).get(doc.state)"/></td>
</tr>
<tr>
<th>Submitted On</th>
<td><span t-esc="doc.write_date"/></td>
<th>Total Investment</th>
<td class="it-right"><span t-esc="'{:,.2f}'.format(doc.total_investment or 0.0)"/></td>
</tr>
<tr t-if="doc.return_reason">
<th>Return Reason</th>
<td colspan="3"><span t-esc="doc.return_reason"/></td>
</tr> </tr>
</t>
</tbody> </tbody>
</table> </table>
<p><strong>Total:</strong> <t t-esc="sum(doc.investment_costing_ids.mapped('amount'))"/></p>
<t t-set="sections" t-value="doc._get_report_sections()"/>
<t t-if="not sections">
<div class="it-section">
<p class="it-muted">No declaration lines are available for the selected regime.</p>
</div> </div>
</t> </t>
<t t-foreach="sections" t-as="section">
<div class="it-section">
<h4><span t-esc="section.get('title')"/></h4>
<t t-if="section.get('house_rent')">
<table class="it-table">
<thead>
<tr>
<th>Type</th>
<th>Rent Amount</th>
<th>From</th>
<th>To</th>
<th>Landlord PAN</th>
<th>Remarks</th>
<th>Proof</th>
</tr>
</thead>
<tbody>
<tr t-foreach="section.get('lines')" t-as="line">
<td><span t-esc="line.get('hra_exemption_type')"/></td>
<td class="it-right"><span t-esc="'{:,.2f}'.format(line.get('rent_amount') or 0.0)"/></td>
<td><span t-esc="line.get('from_date')"/></td>
<td><span t-esc="line.get('to_date')"/></td>
<td>
<span t-esc="line.get('landlord_pan_status')"/>
<br t-if="line.get('landlord_pan_no')"/>
<span t-if="line.get('landlord_pan_no')" t-esc="line.get('landlord_pan_no')"/>
</td>
<td><span t-esc="line.get('remarks')"/></td>
<td>
<a t-if="line.get('attachment_url')" t-att-href="line.get('attachment_url')">
<span t-esc="line.get('attachment_name')"/>
</a>
<span t-if="not line.get('attachment_url')" class="it-muted">No proof</span>
</td>
</tr>
</tbody>
</table>
</t>
<t t-else="">
<table class="it-table">
<thead>
<tr>
<th>Description</th>
<th>Declaration Amount</th>
<th>Proof Amount</th>
<th>Limit</th>
<th>Remarks</th>
<th>Proof</th>
</tr>
</thead>
<tbody>
<tr t-foreach="section.get('lines')" t-as="line">
<td><span t-esc="line.get('name')"/></td>
<td class="it-right"><span t-esc="'{:,.2f}'.format(line.get('declaration_amount') or 0.0)"/></td>
<td class="it-right"><span t-esc="'{:,.2f}'.format(line.get('proof_amount') or 0.0)"/></td>
<td class="it-right"><span t-esc="'{:,.2f}'.format(line.get('limit') or 0.0)"/></td>
<td><span t-esc="line.get('remarks')"/></td>
<td>
<a t-if="line.get('attachment_url')" t-att-href="line.get('attachment_url')">
<span t-esc="line.get('attachment_name')"/>
</a>
<span t-if="not line.get('attachment_url')" class="it-muted">No proof</span>
</td>
</tr>
</tbody>
</table>
</t>
</div>
</t>
<t t-foreach="doc._get_report_extra_sections()" t-as="extra_section">
<div class="it-section">
<h4><span t-esc="extra_section.get('title')"/></h4>
<table class="it-table">
<thead>
<tr>
<th t-foreach="extra_section.get('headers')" t-as="header">
<span t-esc="header"/>
</th>
</tr>
</thead>
<tbody>
<tr t-foreach="extra_section.get('rows')" t-as="row">
<td t-foreach="row" t-as="cell">
<span t-esc="cell"/>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</div>
</t>
</t>
</t> </t>
</template> </template>
</odoo> </odoo>

View File

@ -24,6 +24,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<list> <list>
<field name="name"/> <field name="name"/>
<field name="period_id"/>
<field name="regime"/> <field name="regime"/>
<field name="age_category"/> <field name="age_category"/>
<field name="residence_type"/> <field name="residence_type"/>
@ -42,6 +43,7 @@
<sheet> <sheet>
<group> <group>
<field name="name"/> <field name="name"/>
<field name="period_id"/>
<field name="regime"/> <field name="regime"/>
<field name="age_category"/> <field name="age_category"/>
<field name="residence_type"/> <field name="residence_type"/>
@ -52,16 +54,27 @@
<page string="Slab Rules"> <page string="Slab Rules">
<field name="rules"> <field name="rules">
<list editable="bottom"> <list editable="bottom">
<field name="sequence" widget='handle'/>
<field name="min_income"/> <field name="min_income"/>
<field name="max_income"/> <field name="max_income"/>
<field name="tax_rate"/> <field name="tax_rate"/>
<field name="fixed_amount"/> <field name="fixed_amount"/>
<field name="excess_threshold"/> <field name="excess_threshold" optional="hide"/>
<field name="surcharge_rate"/> <field name="surcharge_rate" column_invisible="1" invisible="1"/>
<field name="cess_rate"/> <field name="cess_rate"/>
</list> </list>
</field> </field>
</page> </page>
<page string="Surcharge Rules">
<field name="surcharges">
<list editable="bottom">
<field name="min_income"/>
<field name="max_income"/>
<field name="surcharge_rate"/>
</list>
</field>
</page>
</notebook> </notebook>
</sheet> </sheet>
</form> </form>

View File

@ -1,3 +1,4 @@
from . import hr_tds_calculation
from . import children_education_costing from . import children_education_costing
from . import employee_life_insurance from . import employee_life_insurance
from . import nsc_declaration from . import nsc_declaration

View File

@ -2,6 +2,7 @@ from odoo import models, fields, api
class ChildrenEducation(models.Model): class ChildrenEducation(models.Model):
_name = "children.education" _name = "children.education"
_inherit = ['it.declaration.submitted.lock.mixin']
_description = "Children Education" _description = "Children Education"
_rec_name = 'it_declaration_id' _rec_name = 'it_declaration_id'
@ -38,6 +39,7 @@ class ChildrenEducation(models.Model):
class ChildrenEducationCosting(models.Model): class ChildrenEducationCosting(models.Model):
_name = 'children.education.costing' _name = 'children.education.costing'
_inherit = ['it.declaration.submitted.lock.mixin']
_description = "Children Education Costing" _description = "Children Education Costing"
child_id = fields.Char('Child ID') child_id = fields.Char('Child ID')

View File

@ -3,6 +3,7 @@ from odoo import models, fields, api, _
class US80CInsuranceLine(models.Model): class US80CInsuranceLine(models.Model):
_name = 'us80c.insurance.line' _name = 'us80c.insurance.line'
_inherit = ['it.declaration.submitted.lock.mixin']
_description = 'US80C Insurance Line' _description = 'US80C Insurance Line'
it_declaration_id = fields.Many2one('emp.it.declaration', string="IT Declaration") it_declaration_id = fields.Many2one('emp.it.declaration', string="IT Declaration")
@ -30,6 +31,7 @@ class US80CInsuranceLine(models.Model):
class EmployeeLifeInsurance(models.Model): class EmployeeLifeInsurance(models.Model):
_name = 'employee.life.insurance' _name = 'employee.life.insurance'
_inherit = ['it.declaration.submitted.lock.mixin']
_description = 'Employee Life Insurance' _description = 'Employee Life Insurance'
parent_id = fields.Many2one('us80c.insurance.line', string="Parent Line") # Link to parent parent_id = fields.Many2one('us80c.insurance.line', string="Parent Line") # Link to parent

View File

@ -0,0 +1,308 @@
from datetime import date
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models, _
from odoo.exceptions import UserError
class HrTdsCalculation(models.TransientModel):
_inherit = 'l10n.in.tds.computation.wizard'
def default_get(self, fields):
res = super().default_get(fields)
# Remove the standard_deduction if it was set by parent
if 'standard_deduction' in res:
del res['standard_deduction']
return res
tax_regime = fields.Selection([
('new', 'New Regime'),
('old', 'Old Regime')
], string="Tax Regime", required=True, default='new')
standard_deduction = fields.Float(
string="Standard Deduction",
compute="_compute_standard_deduction",
readonly=True,
)
def _get_regular_pay_structure(self):
self.ensure_one()
if self.payslip_id and self.payslip_id.struct_id:
return self.payslip_id.struct_id
if self.contract_id.structure_type_id.default_struct_id:
return self.contract_id.structure_type_id.default_struct_id
return self.env['hr.payroll.structure']
def _get_annualization_factor(self):
self.ensure_one()
if self.contract_id:
return self.contract_id._get_salary_costs_factor()
return 12
def _get_monthly_gross_from_structure(self):
self.ensure_one()
if not self.contract_id or not self.contract_id.employee_id:
return 0.0
structure = self._get_regular_pay_structure()
payslip = self.payslip_id
dummy_payslip = self.env['hr.payslip']
if not payslip:
today = fields.Date.today()
period_start = today.replace(day=1)
period_end = fields.Date.end_of(period_start, 'month')
dummy_payslip = self.env['hr.payslip'].sudo().create({
'name': 'TDS Gross Preview',
'employee_id': self.contract_id.employee_id.id,
'contract_id': self.contract_id.id,
'struct_id': structure.id or self.contract_id.structure_type_id.default_struct_id.id,
'date_from': period_start,
'date_to': period_end,
})
dummy_payslip.sudo().compute_sheet()
payslip = dummy_payslip
try:
gross_lines = payslip.line_ids.filtered(lambda line: line.salary_rule_id.code == 'GROSS')
if gross_lines:
return sum(gross_lines.mapped('total'))
return self.contract_id.wage or 0.0
finally:
if dummy_payslip:
dummy_payslip.sudo().action_payslip_cancel()
dummy_payslip.sudo().unlink()
def _get_current_payroll_period(self):
today = fields.Date.today()
return self.env['payroll.period'].search([
('from_date', '<=', today),
('to_date', '>=', today),
], limit=1)
def _get_age_category(self, age):
if age < 60:
return 'below_60'
if age < 80:
return '60_to_80'
return 'above_80'
def _get_employee_age(self):
self.ensure_one()
employee = self.contract_id.employee_id
if employee and employee.birthday:
return relativedelta(date.today(), employee.birthday).years
return 30
def _find_applicable_slab(self, regime):
self.ensure_one()
period = self._get_current_payroll_period()
if not period:
return self.env['it.slab.master']
age_category = self._get_age_category(self._get_employee_age())
return self.env['it.slab.master'].search([
('period_id', '=', period.id),
('regime', '=', regime),
('age_category', '=', age_category),
'|',
('residence_type', '=', 'resident'),
('residence_type', '=', 'both'),
], limit=1)
def _get_standard_deduction_amount(self, regime, slab_master=False):
if slab_master and slab_master.standard_deduction:
return slab_master.standard_deduction
return 75000.0 if regime == 'new' else 50000.0
def _compute_tax_using_slab(self, taxable_income, slab_master):
rules = slab_master.rules.sorted(lambda r: (r.sequence, r.max_income or float('inf')))
applicable_rule = False
previous_rules = self.env['it.slab.master.rules']
for rule in rules:
min_income = rule.min_income or 0.0
max_income = rule.max_income or float('inf')
if min_income < taxable_income <= max_income:
applicable_rule = rule
previous_rules = rules.filtered(
lambda r: r.sequence < rule.sequence or
(r.sequence == rule.sequence and (r.max_income or float('inf')) < max_income)
)
break
if not applicable_rule:
return 0.0
previous_max_income = previous_rules[-1].max_income if previous_rules else 0.0
current_tax = (taxable_income - previous_max_income) * (applicable_rule.tax_rate / 100.0)
previous_fixed_amounts = sum(previous_rules.mapped('fixed_amount'))
return current_tax + previous_fixed_amounts
def _compute_rebate(self, regime, taxable_income, slab_tax):
if regime == 'old':
if taxable_income <= 500000.0:
return min(12500.0, slab_tax)
return 0.0
if taxable_income >= 1200000.0:
return max(0.0, slab_tax - (taxable_income - 1200000.0))
return min(60000.0, slab_tax)
def _compute_surcharge(self, slab_master, taxable_income, tax_after_rebate):
surcharge_rate = 0.0
for rule in slab_master.surcharges.sorted('min_income'):
max_income = rule.max_income or float('inf')
if rule.min_income < taxable_income <= max_income:
surcharge_rate = rule.surcharge_rate
return tax_after_rebate * (surcharge_rate / 100.0)
def _compute_cess(self, slab_master, taxable_income, tax_with_surcharge):
cess_rate = 4.0
for rule in slab_master.rules.sorted('min_income'):
max_income = rule.max_income or float('inf')
if rule.min_income < taxable_income <= max_income:
cess_rate = rule.cess_rate or 4.0
break
return tax_with_surcharge * (cess_rate / 100.0)
def _compute_tax_from_custom_slab(self, total_income, regime, slab_master):
taxable_income = max(total_income - self._get_standard_deduction_amount(regime, slab_master), 0.0)
slab_tax = self._compute_tax_using_slab(taxable_income, slab_master)
rebate = self._compute_rebate(regime, taxable_income, slab_tax)
total_tax_on_income = max(0.0, slab_tax - rebate)
surcharge = self._compute_surcharge(slab_master, taxable_income, total_tax_on_income)
tax_with_surcharge = total_tax_on_income + surcharge
cess = self._compute_cess(slab_master, taxable_income, tax_with_surcharge) if tax_with_surcharge else 0.0
return {
'taxable_income': taxable_income,
'tax_on_taxable_income': slab_tax,
'rebate': rebate,
'total_tax_on_income': total_tax_on_income,
'surcharge': surcharge,
'cess': cess,
'total_tax': tax_with_surcharge + cess,
}
def _compute_tax_from_rule_parameters(self, total_income, standard_deduction):
rule_parameter = self.env['hr.rule.parameter']
tax_slabs = rule_parameter._get_parameter_from_code('l10n_in_tds_rate_chart')
tax_slabs_for_surcharge = rule_parameter._get_parameter_from_code('l10n_in_surcharge_rate')
min_income_for_surcharge = rule_parameter._get_parameter_from_code('l10n_in_min_income_surcharge')
min_income_for_rebate = rule_parameter._get_parameter_from_code('l10n_in_min_income_tax_rebate')
taxable_income = max(total_income - standard_deduction, 0.0)
tax = 0.0
for rate, (lower, upper) in tax_slabs:
if taxable_income <= lower:
break
taxable_amount = min(taxable_income, float(upper)) - lower
tax += round(taxable_amount * rate)
if taxable_income >= min_income_for_rebate:
marginal_income = taxable_income - min_income_for_rebate
rebate = max(tax - marginal_income, 0.0)
else:
rebate = tax
total_tax_on_income = tax - rebate
surcharge = 0.0
if taxable_income > min_income_for_surcharge:
for rate, amount in tax_slabs_for_surcharge:
if taxable_income <= float(amount[1]):
surcharge = total_tax_on_income * rate
break
max_tax_slabs = rule_parameter._get_parameter_from_code('l10n_in_max_surcharge_tax_rate')
max_taxable_income, max_tax, max_surcharge = 0.0, 0.0, 0.0
for income, tax_amount, surcharge_rate in max_tax_slabs:
if taxable_income <= income:
break
max_taxable_income, max_tax, max_surcharge = income, tax_amount, surcharge_rate
excess_income = taxable_income - max_taxable_income
max_tax_with_surcharge = max_tax + max_surcharge
total_tax_with_surcharge = total_tax_on_income + surcharge
excess_tax = total_tax_with_surcharge - max_tax_with_surcharge
if excess_tax - excess_income > 0:
surcharge = max_tax_with_surcharge + taxable_income - max_taxable_income - total_tax_on_income
cess = (total_tax_on_income + surcharge) * 0.04
return {
'taxable_income': taxable_income,
'tax_on_taxable_income': tax,
'rebate': rebate,
'total_tax_on_income': total_tax_on_income,
'surcharge': surcharge,
'cess': cess,
'total_tax': total_tax_on_income + surcharge + cess,
}
@api.depends('contract_id', 'payslip_id', 'contract_id.structure_type_id', 'contract_id.wage')
def _compute_total_income(self):
for record in self:
if not record.contract_id:
record.total_income = 0.0
continue
monthly_gross = record._get_monthly_gross_from_structure()
rule_parameter = self.env['hr.rule.parameter']
pf = 0
if record.contract_id:
amounts = rule_parameter._get_parameter_from_code('l10n_in_professional_tax')
cost = record.contract_id.wage -1800
if cost >= 20000:
pf = amounts[0]
elif cost >= 15001 and cost < 20000:
pf = amounts[1]
else:
pf = 0
record.total_income = (monthly_gross * record._get_annualization_factor()) + (pf * 12)
@api.depends('contract_id', 'payslip_id', 'total_income')
def _compute_net_monthly(self):
for record in self:
factor = record._get_annualization_factor() if record.contract_id else 12
if record.payslip_id and record.payslip_id.net_wage:
record.net_monthly = record.payslip_id.net_wage
elif factor:
record.net_monthly = record.total_income / factor
else:
record.net_monthly = 0.0
@api.depends('tax_regime', 'contract_id')
def _compute_standard_deduction(self):
for record in self:
slab_master = record._find_applicable_slab(record.tax_regime) if record.tax_regime else False
record.standard_deduction = record._get_standard_deduction_amount(record.tax_regime or 'new', slab_master)
@api.depends('total_income', 'tax_regime', 'standard_deduction', 'contract_id')
def _compute_taxable_income(self):
for record in self:
if not record.total_income:
record.taxable_income = 0.0
record.tax_on_taxable_income = 0.0
record.rebate = 0.0
record.total_tax_on_income = 0.0
record.surcharge = 0.0
record.cess = 0.0
record.total_tax = 0.0
continue
slab_master = record._find_applicable_slab(record.tax_regime) if record.tax_regime else False
if slab_master:
values = record._compute_tax_from_custom_slab(record.total_income, record.tax_regime, slab_master)
else:
values = record._compute_tax_from_rule_parameters(record.total_income, record.standard_deduction)
record.taxable_income = values['taxable_income']
record.tax_on_taxable_income = values['tax_on_taxable_income']
record.rebate = values['rebate']
record.total_tax_on_income = values['total_tax_on_income']
record.surcharge = values['surcharge']
record.cess = values['cess']
record.total_tax = values['total_tax']

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="l10n_in_tds_computation_wizard_view_form_inherit" model="ir.ui.view">
<field name="name">l10n.in.tds.computation.wizard.view.form</field>
<field name="model">l10n.in.tds.computation.wizard</field>
<field name="inherit_id" ref="l10n_in_hr_payroll.l10n_in_tds_computation_wizard_view_form"/>
<field name="arch" type="xml">
<xpath expr="//form/group/field[@name='total_income']" position="after">
<field name="tax_regime" widget="radio" options="{'horizontal': true}"/>
</xpath>
<xpath expr="//form/group/field[@name='standard_deduction']" position="attributes">
<attribute name="force_save">1</attribute>
</xpath>
</field>
</record>
</odoo>

View File

@ -3,6 +3,7 @@ import math
class LetoutHouseProperty(models.Model): class LetoutHouseProperty(models.Model):
_name = 'letout.house.property' _name = 'letout.house.property'
_inherit = ['it.declaration.submitted.lock.mixin']
_description = 'Letout House Property Details' _description = 'Letout House Property Details'
it_declaration_id = fields.Many2one('emp.it.declaration', string="IT Declaration") it_declaration_id = fields.Many2one('emp.it.declaration', string="IT Declaration")
@ -35,9 +36,6 @@ class LetoutHouseProperty(models.Model):
deduction = net_annual_value * 0.30 deduction = net_annual_value * 0.30
income_loss = net_annual_value - deduction - record.interest_paid_to income_loss = net_annual_value - deduction - record.interest_paid_to
print(net_annual_value)
print(deduction)
print(income_loss)
record.net_annual_value = net_annual_value record.net_annual_value = net_annual_value
record.deduction_for_repairs = round(deduction) record.deduction_for_repairs = round(deduction)
record.income_loss = round(income_loss) record.income_loss = round(income_loss)

View File

@ -3,6 +3,7 @@ from odoo import models, fields, api
class NSCDeclarationLine(models.Model): class NSCDeclarationLine(models.Model):
_name = 'nsc.declaration.line' _name = 'nsc.declaration.line'
_inherit = ['it.declaration.submitted.lock.mixin']
_description = 'NSC Declaration Line' _description = 'NSC Declaration Line'
it_declaration_id = fields.Many2one('emp.it.declaration', string="IT Declaration", required=True) it_declaration_id = fields.Many2one('emp.it.declaration', string="IT Declaration", required=True)
@ -19,6 +20,7 @@ class NSCDeclarationLine(models.Model):
class NSCEntry(models.Model): class NSCEntry(models.Model):
_name = 'nsc.entry' _name = 'nsc.entry'
_inherit = ['it.declaration.submitted.lock.mixin']
_description = 'NSC Entry' _description = 'NSC Entry'
parent_id = fields.Many2one('nsc.declaration.line', string="NSC Declaration") parent_id = fields.Many2one('nsc.declaration.line', string="NSC Declaration")

View File

@ -3,6 +3,7 @@ from odoo import models, fields, api
class NSCInterestLine(models.Model): class NSCInterestLine(models.Model):
_name = 'nsc.interest.line' _name = 'nsc.interest.line'
_inherit = ['it.declaration.submitted.lock.mixin']
_description = 'NSC Interest Line' _description = 'NSC Interest Line'
@ -23,6 +24,7 @@ class NSCInterestLine(models.Model):
class NSCEntry(models.Model): class NSCEntry(models.Model):
_name = 'nsc.interest.entry' _name = 'nsc.interest.entry'
_inherit = ['it.declaration.submitted.lock.mixin']
_description = 'NSC Entry' _description = 'NSC Entry'
parent_id = fields.Many2one('nsc.interest.line', string="NSC Interest") parent_id = fields.Many2one('nsc.interest.line', string="NSC Interest")

View File

@ -3,6 +3,7 @@ from odoo import models, fields, api
class SelfOccupiedProperty(models.Model): class SelfOccupiedProperty(models.Model):
_name = 'self.occupied.property' _name = 'self.occupied.property'
_inherit = ['it.declaration.submitted.lock.mixin']
_description = 'Self Occupied House Property Details' _description = 'Self Occupied House Property Details'
it_declaration_id = fields.Many2one('emp.it.declaration', string="IT Declaration") it_declaration_id = fields.Many2one('emp.it.declaration', string="IT Declaration")

View File

@ -18,7 +18,7 @@ class website_hr_recruitment_applications_extended(website_hr_recruitment_applic
applicant = request.env['hr.applicant'].sudo().browse(applicant_id) applicant = request.env['hr.applicant'].sudo().browse(applicant_id)
if not applicant.exists(): if not applicant.exists():
return request.not_found() return request.not_found()
if applicant and applicant.send_post_onboarding_form: if applicant:
if applicant.post_onboarding_form_status == 'done': if applicant.post_onboarding_form_status == 'done':
return request.render("hr_recruitment_extended.thank_you_template", { return request.render("hr_recruitment_extended.thank_you_template", {
'applicant': applicant 'applicant': applicant
@ -38,7 +38,7 @@ class website_hr_recruitment_applications_extended(website_hr_recruitment_applic
return f"Error: Applicant with ID {applicant_id} not found" return f"Error: Applicant with ID {applicant_id} not found"
# Business logic check # Business logic check
if not applicant.send_post_onboarding_form or applicant.post_onboarding_form_status != 'done': if applicant.post_onboarding_form_status != 'done':
return f"Error: Applicant {applicant_id} does not meet the criteria for download" return f"Error: Applicant {applicant_id} does not meet the criteria for download"
# Get the template # Get the template

View File

@ -1,4 +1,4 @@
from odoo import fields, api, models, _ from odoo import api, fields, models, _
from odoo.exceptions import UserError from odoo.exceptions import UserError
@ -31,8 +31,7 @@ class HREmployee(models.Model):
'recruitment_stage_id': self.env.ref('employee_jod.hired_stage8').id, 'recruitment_stage_id': self.env.ref('employee_jod.hired_stage8').id,
}) })
rec.applicant_id = application.id rec.applicant_id = application.id
rec.sudo().applicant_id.send_post_onboarding_form = True return rec.sudo().applicant_id.send_jod_form_to_employee()
return rec.sudo().applicant_id.send_post_onboarding_form_to_candidate()
class PostOnboardingAttachmentWizard(models.TransientModel): class PostOnboardingAttachmentWizard(models.TransientModel):
@ -44,11 +43,12 @@ class PostOnboardingAttachmentWizard(models.TransientModel):
def _onchange_template_id(self): def _onchange_template_id(self):
""" Update the email body and recipients based on the selected template. """ """ Update the email body and recipients based on the selected template. """
if self.template_id: if self.template_id:
record_id = self.env.context.get('active_id') record_id = self.env.context.get('applicant_id')
model = self.env.context.get('active_model') model = self.env.context.get('active_model')
if model == 'applicant.request.forms':
if model == 'hr.applicant':
applicant = self.env['hr.applicant'].browse(record_id) applicant = self.env['hr.applicant'].browse(record_id)
elif model == 'hr.applicant':
applicant = self.env['hr.applicant'].browse(self.env.context.get('active_id'))
else: else:
if model == 'hr.employee': if model == 'hr.employee':
applicant = self.env['hr.employee'].browse(record_id).applicant_id applicant = self.env['hr.employee'].browse(record_id).applicant_id
@ -74,14 +74,30 @@ class PostOnboardingAttachmentWizard(models.TransientModel):
for rec in self: for rec in self:
self.ensure_one() self.ensure_one()
context = self.env.context context = self.env.context
active_id = context.get('active_id') active_id = context.get('applicant_id')
model = context.get('active_model') model = context.get('active_model')
request_token = False
request_upload_url = False
if model == 'hr.applicant': if model == 'applicant.request.forms':
applicant = self.env['hr.applicant'].browse(active_id) applicant = self.env['hr.applicant'].browse(active_id)
else: elif model == 'hr.applicant':
if model == 'hr.employee': applicant = self.env['hr.applicant'].browse(context.get('active_id'))
elif model == 'hr.employee':
applicant = self.env['hr.employee'].browse(active_id).applicant_id applicant = self.env['hr.employee'].browse(active_id).applicant_id
else:
applicant = self.env['hr.applicant'].browse(active_id)
if rec.is_pre_onboarding_attachment_request and not rec.request_form_id:
raise UserError("A document request form is required before sending this email.")
if rec.request_form_id:
request_token = rec.request_form_id._issue_new_access_token()
base_url = self.get_base_url()
request_upload_url = (
f"{base_url}/FTPROTECH/DocRequests/"
f"{applicant.id}/{rec.request_form_id.id}?token={request_token}"
)
applicant.recruitment_attachments = [(4, attachment.id) for attachment in rec.req_attachment_ids] applicant.recruitment_attachments = [(4, attachment.id) for attachment in rec.req_attachment_ids]
@ -93,22 +109,29 @@ class PostOnboardingAttachmentWizard(models.TransientModel):
lambda a: a.attachment_type == 'previous_employer').mapped('name') lambda a: a.attachment_type == 'previous_employer').mapped('name')
other_docs = rec.req_attachment_ids.filtered(lambda a: a.attachment_type == 'others').mapped('name') other_docs = rec.req_attachment_ids.filtered(lambda a: a.attachment_type == 'others').mapped('name')
# Prepare context for the template
email_context = { email_context = {
'applicant_request_form_id': rec.request_form_id.id,
'applicant_request_form_token': request_token,
'applicant_request_form_url': request_upload_url,
'personal_docs': personal_docs, 'personal_docs': personal_docs,
'education_docs': education_docs, 'education_docs': education_docs,
'previous_employer_docs': previous_employer_docs, 'previous_employer_docs': previous_employer_docs,
'other_docs': other_docs, 'other_docs': other_docs,
} }
rendered_subject = template.with_context(**email_context)._render_field(
'subject', [applicant.id]
)[applicant.id]
rendered_body_html = template.with_context(**email_context)._render_field(
'body_html', [applicant.id], compute_lang=True
)[applicant.id]
email_values = { email_values = {
'email_from': rec.email_from, 'email_from': rec.email_from,
'email_to': rec.email_to, 'email_to': rec.email_to,
'email_cc': rec.email_cc, 'email_cc': rec.email_cc,
'subject': rec.email_subject, 'subject': rendered_subject or rec.email_subject,
'body_html': rendered_body_html,
'attachment_ids': [(6, 0, rec.attachment_ids.ids)], 'attachment_ids': [(6, 0, rec.attachment_ids.ids)],
} }
# Use 'with_context' to override the email template fields dynamically
if rec.send_mail: if rec.send_mail:
template.sudo().with_context(default_body_html=rec.email_body, template.sudo().with_context(default_body_html=rec.email_body,
**email_context).send_mail(applicant.id, email_values=email_values, **email_context).send_mail(applicant.id, email_values=email_values,
@ -116,7 +139,7 @@ class PostOnboardingAttachmentWizard(models.TransientModel):
base_url = self.get_base_url() base_url = self.get_base_url()
if rec.is_pre_onboarding_attachment_request: if rec.is_pre_onboarding_attachment_request:
applicant.doc_requests_form_status = 'email_sent_to_candidate' rec.request_form_id.status = 'email_sent_to_candidate'
else: else:
applicant.post_onboarding_form_status = 'email_sent_to_candidate' applicant.post_onboarding_form_status = 'email_sent_to_candidate'
applicant.joining_form_link = '%s/FTPROTECH/JoiningForm/%s'%(base_url,applicant.id) applicant.joining_form_link = '%s/FTPROTECH/JoiningForm/%s'%(base_url,applicant.id)

View File

@ -35,7 +35,7 @@
<field name="model">hr.applicant</field> <field name="model">hr.applicant</field>
<field name="inherit_id" ref="hr_recruitment_extended.hr_applicant_view_form_inherit"/> <field name="inherit_id" ref="hr_recruitment_extended.hr_applicant_view_form_inherit"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='post_onboarding_form_status']" position="after"> <xpath expr="//field[@name='candidate_id']" position="after">
<field name="joining_form_link" force_save="1" readonly="1"/> <field name="joining_form_link" force_save="1" readonly="1"/>
</xpath> </xpath>
</field> </field>

Some files were not shown because too many files have changed in this diff Show More