Merge pull request !708 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2024-12-10 03:14:41 +00:00
committed by Gitee
11 changed files with 98 additions and 43 deletions
+2
View File
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models
+17
View File
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
{
'name': 'boolean_group_operator',
'summary': 'boolean group operator',
'description': 'boolean_group_operator',
'author': 'CY',
'website': '',
'category': 'Tools',
'version': '17.0',
'depends': ['base'],
'assets': {
'web.assets_backend': [
'/boolean_group_operator/static/src/**/*',
]
}
}
+20
View File
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# import odoo
#
# from odoo.tools import SQL
#
# odoo.models.READ_GROUP_AGGREGATE.update({
# 'count_true': lambda table, expr: SQL('COUNT(*) FILTER (WHERE %s = true)', expr),
# 'count_false': lambda table, expr: SQL('COUNT(*) FILTER (WHERE %s = false)', expr),
# })
# 哪个模型需要就移植到哪个模型下
# @api.model
# def web_read_group(self, domain, fields, groupby, limit=None, offset=0, orderby=False, lazy=True):
# result = super().web_read_group(domain, fields, groupby, limit, offset, orderby, lazy)
# fields_dict = self.fields_get(fields)
# for group in result.get('groups'):
# for field in fields:
# if fields_dict[field].get('type') == 'boolean':
# group[field] = len([r for r in self.search_read(group['__domain'], fields=[field]) if r.get(field)])
# return result
@@ -5,6 +5,17 @@ import { ListRenderer } from "@web/views/list/list_renderer";
patch(ListRenderer.prototype, {
getAggregateColumns(group) {
const result = super.getAggregateColumns(group);
result.forEach((column) => {
if (column.type === "field") {
column.field_type = this.props.list.fields[column.name].type;
}
});
return result;
},
formatAggregateValue(group, column) {
const result = super.formatAggregateValue(group, column);
const field = this.props.list.fields[column.name];
@@ -0,0 +1,3 @@
.o_list_boolean {
text-align: left;
}
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-inherit="web.ListRenderer.GroupRow" t-inherit-mode="extension">
<xpath expr="//t[@t-if=&quot;column.type === 'field'&quot;]" position="replace">
<div t-att-class="{'o_list_boolean': column.field_type === 'boolean'}">
<t t-if="column.type === 'field'" t-esc="formatAggregateValue(group, column)"/>
</div>
</xpath>
</t>
</templates>
+1 -1
View File
@@ -37,6 +37,7 @@
'views/attendance_scheme.xml',
'views/duty_approval.xml',
'views/all_attendance_menu.xml',
],
'assets': {
'web.assets_backend': [
@@ -46,7 +47,6 @@
'yuthon_hr_attendance/static/src/planning_gantt/planning_gantt_renderer.js',
'yuthon_hr_attendance/static/src/components/*/*.xml',
'yuthon_hr_attendance/static/src/css/*.css',
'yuthon_hr_attendance/static/src/**/*',
],
},
'installable': True,
+8
View File
@@ -15,3 +15,11 @@ from . import yuthon_shift_planning
from . import yuthon_run_planning
from . import duty_approval
from . import yuthon_customer_approval
# from odoo.tools import SQL
# import odoo
# odoo.models.READ_GROUP_AGGREGATE.update({
# 'count_true': lambda table, expr: SQL('COUNT(*) FILTER (WHERE %s = true)', expr),
# 'count_false': lambda table, expr: SQL('COUNT(*) FILTER (WHERE %s = false)', expr),
# })
+16 -6
View File
@@ -8,18 +8,18 @@ import logging
_logger = logging.getLogger(__name__)
class HrAttendance(models.Model):
_inherit = "hr.attendance"
_description = "Attendance"
_rec_name = 'current_data'
is_clock_card = fields.Boolean(string="外勤")
is_no_card = fields.Boolean(string="缺卡", compute='_compute_attendance_flags')
is_early_card = fields.Boolean(string="早退", compute='_compute_attendance_flags')
is_late_card = fields.Boolean(string="迟到", compute='_compute_attendance_flags')
is_no_card = fields.Boolean(string="缺卡", compute='_compute_attendance_flags', groups_operator='count_false')
is_early_card = fields.Boolean(string="早退", compute='_compute_attendance_flags', groups_operator='count_false')
is_late_card = fields.Boolean(string="迟到", compute='_compute_attendance_flags', groups_operator='count_false')
is_abnormal = fields.Boolean(string="异常", compute='_compute_is_abnormal', groups_operator='count_false')
work_time_type = fields.Selection([('close_day', '休息日'), ('work_day', '工作日')], string="工作时间类型")
is_abnormal = fields.Boolean(string="异常", compute='_compute_is_abnormal')
# 暂时不用
company_id = fields.Many2one('res.company', string='公司', index=True, default=lambda self: self.env.company)
on_card_location = fields.Char(string="上班打卡地点")
down_card_location = fields.Char(string="下班打卡地点")
@@ -33,6 +33,16 @@ class HrAttendance(models.Model):
abnormal = fields.Integer(string="异常计算")
is_approval = fields.Boolean(string="是否审批修正", default=False)
@api.model
def web_read_group(self, domain, fields, groupby, limit=None, offset=0, orderby=False, lazy=True):
result = super().web_read_group(domain, fields, groupby, limit, offset, orderby, lazy)
fields_dict = self.fields_get(fields)
for group in result.get('groups'):
for field in fields:
if fields_dict[field].get('type') == 'boolean':
group[field] = len([r for r in self.search_read(group['__domain'], fields=[field]) if r.get(field)])
return result
@api.depends('employee_id', 'check_in', 'check_out')
def _compute_display_name(self):
for attendance in self:
@@ -79,7 +89,7 @@ class HrAttendance(models.Model):
attendance_id.is_no_card = True
if attendance_id.check_out:
check_in = attendance_id.check_in + timedelta(hours=8)
attendance_id.is_early_card = planning_id.end_datetime > check_in
attendance_id.is_early_card = planning_id.end_datetime > check_in
else:
attendance_id.is_no_card = True
else:
@@ -4,43 +4,15 @@
<field name="name">hr.attendance.going.tree2</field>
<field name="model">hr.attendance</field>
<field name="arch" type="xml">
<tree string="出勤" create="false" edit="false" delete="false" editable="bottom" decoration-danger="is_abnormal" banner_route="/attendance/banner/route">
<tree string="出勤" decoration-danger="abnormal == 1"
edit="false" delete="false" create="false"
editable="bottom" banner_route="/attendance/banner/route">
<field name="employee_id" widget="many2one_avatar_user"/>
<field name="is_clock_card" optional="show" class="list_width"/>
<field name="is_no_card" optional="show" class="list_width" group_operator='count_false'/>
<field name="is_early_card" optional="show" class="list_width" group_operator='count_false'/>
<field name="is_late_card" optional="show" class="list_width" group_operator='count_false'/>
<field name="is_abnormal" optional="show" class="list_width" group_operator='count_false'/>
<field name="week" optional="show"/>
<field name="abnormal" optional="show" column_invisible="1"/>
<field name="work_time_type" optional="hidden"/>
<field name="check_in" optional="show" widget="time"/>
<field name="check_out" optional="show" widget="time"/>
<field name="is_approval" column_invisible="1"/>
<button name="button_leave" type="object" string="请假" class="oe_highlight"
invisible="not is_abnormal"/>
<button name="button_card_approval" type="object" string="补卡" class="oe_highlight"
invisible="not is_abnormal"/>
<button name="button_duty_approval" type="object" string="外出" class="oe_highlight"
invisible="not is_abnormal"/>
<button name="button_correct_approval" type="object" string="修正" class="oe_highlight"
invisible="not is_abnormal"/>
</tree>
</field>
</record>
<record id="view_attendance_going_tree3" model="ir.ui.view">
<field name="name">hr.attendance.going.tree3</field>
<field name="model">hr.attendance</field>
<field name="arch" type="xml">
<tree string="出勤" create="false" edit="false" delete="false" decoration-danger="is_abnormal"
banner_route="/attendance/banner/route">
<field name="employee_id" widget="many2one_avatar_user"/>
<field name="is_clock_card" optional="show" class="list_width"/>
<field name="is_no_card" optional="show" class="list_width" group_operator='count_false'/>
<field name="is_early_card" optional="show" class="list_width" group_operator='count_false'/>
<field name="is_late_card" optional="show" class="list_width" group_operator='count_false'/>
<field name="is_abnormal" optional="show" class="list_width" group_operator='count_false'/>
<field name="is_no_card" optional="show" class="list_width"/>
<field name="is_early_card" optional="show" class="list_width"/>
<field name="is_late_card" optional="show" class="list_width"/>
<field name="is_abnormal" optional="show" class="list_width"/>
<field name="week" optional="show"/>
<field name="abnormal" optional="show" column_invisible="1"/>
<field name="work_time_type" optional="hidden"/>
@@ -85,7 +57,7 @@
<field name="domain">[('employee_id.user_id', '=', uid), ('abnormal', '=', 1), ('week', 'not in', ['seven', 'six'])]
</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_hr_attendance.view_attendance_going_tree3')})]"/>
(0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_hr_attendance.view_attendance_going_tree2')})]"/>
</record>
<record id="action_attendance_yuthon_company_form1" model="ir.actions.act_window">
<field name="name">天河投资</field>