summaryrefslogtreecommitdiff
path: root/hrms_dashboard/report
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 17:14:58 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 17:14:58 +0700
commit1ca3b3df3421961caec3b747a364071c80f5c7da (patch)
tree6778a1f0f3f9b4c6e26d6d87ccde16e24da6c9d6 /hrms_dashboard/report
parentb57188be371d36d96caac4b8d65a40745c0e972c (diff)
initial commit
Diffstat (limited to 'hrms_dashboard/report')
-rw-r--r--hrms_dashboard/report/__init__.py3
-rw-r--r--hrms_dashboard/report/broadfactor.py49
-rw-r--r--hrms_dashboard/report/broadfactor.xml47
3 files changed, 99 insertions, 0 deletions
diff --git a/hrms_dashboard/report/__init__.py b/hrms_dashboard/report/__init__.py
new file mode 100644
index 0000000..c5b299d
--- /dev/null
+++ b/hrms_dashboard/report/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+from . import broadfactor
diff --git a/hrms_dashboard/report/broadfactor.py b/hrms_dashboard/report/broadfactor.py
new file mode 100644
index 0000000..dfda9d3
--- /dev/null
+++ b/hrms_dashboard/report/broadfactor.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+from datetime import date, datetime
+
+from odoo import tools
+from odoo import api, fields, models
+
+
+class EmployeeBroadFactor(models.Model):
+ _name = "hr.employee.broad.factor"
+ _description = "Employee Broadfactor"
+ _auto = False
+
+ name = fields.Char()
+ no_of_occurrence = fields.Integer()
+ no_of_days = fields.Integer()
+ broad_factor = fields.Integer()
+
+ def init(self):
+ tools.drop_view_if_exists(self._cr, 'hr_employee_broad_factor')
+ date_today = date.today()
+ print("date_today", date_today)
+ self._cr.execute("""
+ create or replace view hr_employee_broad_factor as (
+ select
+ e.id,
+ e.name,
+ count(h.*) as no_of_occurrence,
+ sum(h.number_of_days) as no_of_days,
+ count(h.*)*count(h.*)*sum(h.number_of_days) as broad_factor
+ from hr_employee e
+ full join (select * from hr_leave where state = 'validate' and date_to <= now()::timestamp) h
+ on e.id =h.employee_id
+ group by e.id
+ )""")
+
+
+class ReportOverdue(models.AbstractModel):
+ _name = 'report.hrms_dashboard.report_broadfactor'
+
+ @api.model
+ def get_report_values(self, docids=None, data=None):
+ sql = """select * from hr_employee_broad_factor"""
+ self.env.cr.execute(sql)
+ lines = self.env.cr.dictfetchall()
+ return {
+ 'doc_model': 'hr.employee.broad_factor',
+ 'lines': lines,
+ 'Date': fields.date.today(),
+ }
diff --git a/hrms_dashboard/report/broadfactor.xml b/hrms_dashboard/report/broadfactor.xml
new file mode 100644
index 0000000..032a8dc
--- /dev/null
+++ b/hrms_dashboard/report/broadfactor.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <template id="report_broadfactor">
+ <t t-call="web.html_container">
+ <t t-call="web.external_layout">
+ <div class="page">
+ <h2>Broad Factor Report</h2>
+ <table class="table table-condensed">
+ <thead>
+ <tr>
+ <th>Employee</th>
+ <th></th>
+ <th class="text-right">Broad Factor</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr t-foreach="lines" t-as="line">
+ <t t-if="line['broad_factor']">
+ <t t-set="broad_factor" t-value="line['broad_factor']"/>
+ </t>
+ <t t-if="not line['broad_factor']">
+ <t t-set="broad_factor" t-value="0"/>
+ </t>
+ <td>
+ <span t-esc="line['name']"/>
+ </td>
+ <td></td>
+ <td class="text-right">
+ <span t-esc="broad_factor"/>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </t>
+ </t>
+ </template>
+
+ <report
+ id="action_report_broad_factor"
+ model="hr.employee.broad.factor"
+ string="Broad Factor"
+ report_type="qweb-pdf"
+ name="hrms_dashboard.report_broadfactor"
+ file="hrms_dashboard.report_broadfactor"
+ />
+</odoo>