From 8313a66a522cce3ceb81ca8ede07255785c4431f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A9ry=20Debongnie?=
Date: Wed, 25 May 2022 12:40:11 +0000
Subject: [PATCH] [REF] *: remove some kanbanrecord .includes
The kanban view was recently improved to add the support of 'action' and
'type' attributes on the kanban arch. This commit takes advantage of
that change to simplify a few views in various addons.
Part-of: odoo/odoo#92071
---
addons/fleet/static/src/js/fleet_kanban.js | 20 -----------
.../fleet/views/fleet_vehicle_model_views.xml | 3 +-
.../views/gamification_badge_user_views.xml | 2 +-
addons/hr_attendance/__manifest__.py | 9 +----
.../models/hr_employee_public.py | 12 +++++++
.../src/js/employee_kanban_view_handler.js | 35 -------------------
.../hr_attendance/views/hr_employee_view.xml | 2 +-
addons/hr_gamification/__manifest__.py | 5 ---
addons/hr_gamification/models/gamification.py | 8 +++++
.../static/src/js/gamification.js | 31 ----------------
.../views/hr_employee_views.xml | 2 +-
.../static/src/js/recruitment.js | 15 --------
addons/hr_recruitment/views/hr_job_views.xml | 7 ++--
13 files changed, 27 insertions(+), 124 deletions(-)
delete mode 100644 addons/fleet/static/src/js/fleet_kanban.js
delete mode 100644 addons/hr_attendance/static/src/js/employee_kanban_view_handler.js
delete mode 100644 addons/hr_gamification/static/src/js/gamification.js
diff --git a/addons/fleet/static/src/js/fleet_kanban.js b/addons/fleet/static/src/js/fleet_kanban.js
deleted file mode 100644
index e731146a26c..00000000000
--- a/addons/fleet/static/src/js/fleet_kanban.js
+++ /dev/null
@@ -1,20 +0,0 @@
-odoo.define('fleet.fleet_kanban', function (require) {
- 'use strict';
-
- const KanbanRecord = require('web.KanbanRecord');
-
- KanbanRecord.include({
-
- /**
- * @override
- * @private
- */
- _openRecord() {
- if (this.modelName === 'fleet.vehicle.model.brand' && this.$(".oe_kanban_fleet_model").length) {
- this.$('.oe_kanban_fleet_model').first().click();
- } else {
- this._super.apply(this, arguments);
- }
- },
- });
-});
diff --git a/addons/fleet/views/fleet_vehicle_model_views.xml b/addons/fleet/views/fleet_vehicle_model_views.xml
index 5b8e5b6a180..1cf26913c01 100644
--- a/addons/fleet/views/fleet_vehicle_model_views.xml
+++ b/addons/fleet/views/fleet_vehicle_model_views.xml
@@ -197,7 +197,7 @@
fleet.vehicle.model.brandkanban
fleet.vehicle.model.brand
-
+
@@ -221,7 +221,6 @@
diff --git a/addons/gamification/views/gamification_badge_user_views.xml b/addons/gamification/views/gamification_badge_user_views.xml
index d09d7f69e6e..a4ab16719a9 100644
--- a/addons/gamification/views/gamification_badge_user_views.xml
+++ b/addons/gamification/views/gamification_badge_user_views.xml
@@ -5,7 +5,7 @@
Badge User Kanban View
gamification.badge.user
-
+
diff --git a/addons/hr_attendance/__manifest__.py b/addons/hr_attendance/__manifest__.py
index 34684b3e605..b0cf465a82b 100644
--- a/addons/hr_attendance/__manifest__.py
+++ b/addons/hr_attendance/__manifest__.py
@@ -34,14 +34,7 @@ actions(Check in/Check out) performed by them.
'application': True,
'assets': {
'web.assets_backend': [
- 'hr_attendance/static/src/js/attendance_report_views.js',
- 'hr_attendance/static/src/js/employee_kanban_view_handler.js',
- 'hr_attendance/static/src/js/greeting_message.js',
- 'hr_attendance/static/src/js/kiosk_mode.js',
- 'hr_attendance/static/src/js/kiosk_confirm.js',
- 'hr_attendance/static/src/js/my_attendances.js',
- 'hr_attendance/static/src/js/time_widget.js',
- 'hr_attendance/static/src/scss/hr_attendance.scss',
+ 'hr_attendance/static/src/**/*',
],
'web.qunit_suite_tests': [
('after', 'web/static/tests/legacy/views/kanban_tests.js', 'hr_attendance/static/tests/hr_attendance_tests.js'),
diff --git a/addons/hr_attendance/models/hr_employee_public.py b/addons/hr_attendance/models/hr_employee_public.py
index 11de7a2c14b..826122fef89 100644
--- a/addons/hr_attendance/models/hr_employee_public.py
+++ b/addons/hr_attendance/models/hr_employee_public.py
@@ -15,3 +15,15 @@ class HrEmployeePublic(models.Model):
groups="hr_attendance.group_hr_attendance_kiosk,hr_attendance.group_hr_attendance")
total_overtime = fields.Float(related='employee_id.total_overtime', readonly=True,
groups="hr_attendance.group_hr_attendance_kiosk,hr_attendance.group_hr_attendance")
+
+ def action_employee_kiosk_confirm(self):
+ self.ensure_one()
+ return {
+ 'type': 'ir.actions.client',
+ 'name': 'Confirm',
+ 'tag': 'hr_attendance_kiosk_confirm',
+ 'employee_id': self.id,
+ 'employee_name': self.name,
+ 'employee_state': self.attendance_state,
+ 'employee_hours_today': self.hours_today,
+ }
diff --git a/addons/hr_attendance/static/src/js/employee_kanban_view_handler.js b/addons/hr_attendance/static/src/js/employee_kanban_view_handler.js
deleted file mode 100644
index 02801f79275..00000000000
--- a/addons/hr_attendance/static/src/js/employee_kanban_view_handler.js
+++ /dev/null
@@ -1,35 +0,0 @@
-
-odoo.define('hr_attendance.employee_kanban_view_handler', function(require) {
-"use strict";
-
-var KanbanRecord = require('web.KanbanRecord');
-
-KanbanRecord.include({
- //--------------------------------------------------------------------------
- // Private
- //--------------------------------------------------------------------------
-
- /**
- * @override
- * @private
- */
- _openRecord: function () {
- if (this.modelName === 'hr.employee.public' && this.$el.parents('.o_hr_employee_attendance_kanban').length) {
- // needed to diffentiate : check in/out kanban view of employees <-> standard employee kanban view
- var action = {
- type: 'ir.actions.client',
- name: 'Confirm',
- tag: 'hr_attendance_kiosk_confirm',
- employee_id: this.record.id.raw_value,
- employee_name: this.record.name.raw_value,
- employee_state: this.record.attendance_state.raw_value,
- employee_hours_today: this.record.hours_today.raw_value,
- };
- this.do_action(action);
- } else {
- this._super.apply(this, arguments);
- }
- }
-});
-
-});
diff --git a/addons/hr_attendance/views/hr_employee_view.xml b/addons/hr_attendance/views/hr_employee_view.xml
index a51240e8fdb..f24f2f1843d 100644
--- a/addons/hr_attendance/views/hr_employee_view.xml
+++ b/addons/hr_attendance/views/hr_employee_view.xml
@@ -130,7 +130,7 @@
hr.employee
99
-
+
diff --git a/addons/hr_gamification/__manifest__.py b/addons/hr_gamification/__manifest__.py
index 3aa770e726f..5f3d5e0566d 100644
--- a/addons/hr_gamification/__manifest__.py
+++ b/addons/hr_gamification/__manifest__.py
@@ -19,10 +19,5 @@ Badge received are displayed on the user profile.
'views/hr_employee_views.xml',
],
'auto_install': True,
- 'assets': {
- 'web.assets_backend': [
- 'hr_gamification/static/**/*',
- ],
- },
'license': 'LGPL-3',
}
diff --git a/addons/hr_gamification/models/gamification.py b/addons/hr_gamification/models/gamification.py
index 4fc2831f169..0fc3fcb9440 100644
--- a/addons/hr_gamification/models/gamification.py
+++ b/addons/hr_gamification/models/gamification.py
@@ -17,6 +17,14 @@ class GamificationBadgeUser(models.Model):
if badge_user.employee_id not in badge_user.user_id.employee_ids:
raise ValidationError(_('The selected employee does not correspond to the selected user.'))
+ def action_open_badge(self):
+ self.ensure_one()
+ return {
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'gamification.badge',
+ 'view_mode': 'form',
+ 'res_id': self.id,
+ }
class GamificationBadge(models.Model):
_inherit = 'gamification.badge'
diff --git a/addons/hr_gamification/static/src/js/gamification.js b/addons/hr_gamification/static/src/js/gamification.js
deleted file mode 100644
index 32c0fdba77f..00000000000
--- a/addons/hr_gamification/static/src/js/gamification.js
+++ /dev/null
@@ -1,31 +0,0 @@
-odoo.define('hr_gamification.hr_gamification', function(require) {
-"use strict";
-
-var KanbanRecord = require('web.KanbanRecord');
-
-KanbanRecord.include({
- //--------------------------------------------------------------------------
- // Private
- //--------------------------------------------------------------------------
-
- /**
- * @override
- * @private
- */
- _openRecord: function () {
- if (this.modelName === 'gamification.badge.user') {
- var action = {
- type: 'ir.actions.act_window',
- res_model: 'gamification.badge',
- view_mode: 'form',
- views: [[false, 'form']],
- res_id: this.record.badge_id.raw_value
- };
- this.do_action(action);
- } else {
- this._super.apply(this, arguments);
- }
- }
-});
-
-});
diff --git a/addons/hr_gamification/views/hr_employee_views.xml b/addons/hr_gamification/views/hr_employee_views.xml
index f489a73a1c6..c0fb6679f4b 100644
--- a/addons/hr_gamification/views/hr_employee_views.xml
+++ b/addons/hr_gamification/views/hr_employee_views.xml
@@ -18,7 +18,7 @@
Badges are rewards of good work. Give them to people you believe deserve it.
-
+
diff --git a/addons/hr_recruitment/static/src/js/recruitment.js b/addons/hr_recruitment/static/src/js/recruitment.js
index 49a7fab691c..fbfbc79e057 100644
--- a/addons/hr_recruitment/static/src/js/recruitment.js
+++ b/addons/hr_recruitment/static/src/js/recruitment.js
@@ -1,6 +1,4 @@
/** @odoo-module **/
-import KanbanRecord from 'web.KanbanRecord';
-
import fieldRegistry from 'web.field_registry';
import { FieldChar, StateSelectionWidget } from 'web.basic_fields';
@@ -41,16 +39,3 @@ fieldRegistry
.add('recruitment_state_selection', RecruitmentStateSelectionWidget)
.add('applicant_char', ApplicantChar);
-KanbanRecord.include({
- /**
- * @override
- * @private
- */
- _openRecord: function () {
- if (this.modelName === 'hr.job' && this.$(".o_hr_job_boxes a").length) {
- this.$(".o_hr_job_boxes a").first().click();
- } else {
- this._super.apply(this, arguments);
- }
- }
-});
diff --git a/addons/hr_recruitment/views/hr_job_views.xml b/addons/hr_recruitment/views/hr_job_views.xml
index 2151a32bec2..198ac889a8c 100644
--- a/addons/hr_recruitment/views/hr_job_views.xml
+++ b/addons/hr_recruitment/views/hr_job_views.xml
@@ -11,7 +11,7 @@
hr.job.kanban
hr.job
-
+
@@ -32,7 +32,7 @@
-