[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
This commit is contained in:
Géry Debongnie
2022-05-25 20:31:41 +02:00
parent 2507e8d5d3
commit 8313a66a52
13 changed files with 27 additions and 124 deletions
@@ -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);
}
},
});
});
@@ -197,7 +197,7 @@
<field name="name">fleet.vehicle.model.brandkanban</field>
<field name="model">fleet.vehicle.model.brand</field>
<field name="arch" type="xml">
<kanban default_order="name">
<kanban default_order="name" action="action_brand_model" type="object">
<field name="id"/>
<field name="name" />
<templates>
@@ -221,7 +221,6 @@
</a>
</h4>
<div>
<a type="object" name="action_brand_model" class="oe_kanban_fleet_model"/>
<field name="model_count"/> MODELS
</div>
</div>
@@ -5,7 +5,7 @@
<field name="name">Badge User Kanban View</field>
<field name="model">gamification.badge.user</field>
<field name="arch" type="xml">
<kanban class="oe_background_grey">
<kanban class="oe_background_grey" action="action_open_badge" type="object">
<field name="badge_name"/>
<field name="badge_id"/>
<field name="user_id"/>
+1 -8
View File
@@ -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'),
@@ -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,
}
@@ -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);
}
}
});
});
@@ -130,7 +130,7 @@
<field name="model">hr.employee</field>
<field name="priority">99</field>
<field name="arch" type="xml">
<kanban class="o_hr_employee_attendance_kanban" create="false">
<kanban class="o_hr_employee_attendance_kanban" create="false" action="action_employee_kiosk_confirm" type="object">
<field name="attendance_state"/>
<field name="hours_today"/>
<field name="total_overtime"/>
-5
View File
@@ -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',
}
@@ -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'
@@ -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);
}
}
});
});
@@ -18,7 +18,7 @@
Badges are rewards of good work. Give them to people you believe deserve it.
</p>
</div>
<field name="badge_ids" mode="kanban" widget="many2many"/>
<field name="badge_ids" mode="kanban" />
</page>
</xpath>
@@ -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);
}
}
});
+2 -5
View File
@@ -11,7 +11,7 @@
<field name="name">hr.job.kanban</field>
<field name="model">hr.job</field>
<field name="arch" type="xml">
<kanban class="oe_background_grey o_kanban_dashboard o_hr_recruitment_kanban" on_create="hr_recruitment.create_job_simple" sample="1" limit="40">
<kanban class="oe_background_grey o_kanban_dashboard o_hr_recruitment_kanban" on_create="hr_recruitment.create_job_simple" sample="1" limit="40" action="%(action_hr_job_applications)d" type="action">
<field name="active"/>
<field name="name"/>
<field name="alias_name"/>
@@ -32,7 +32,7 @@
<div class="o_kanban_card_header_title">
<field name="is_favorite" widget="boolean_favorite" nolabel="1"/>
<div class="o_primary col-12">
<a name="%(action_hr_job_applications)d" type="action"><t t-esc="record.name.value"/></a>
<t t-esc="record.name.value"/>
</div>
<div class="col-12 text-muted">
<field name="user_id" />
@@ -118,9 +118,6 @@
</div>
</div>
</div>
<div class="o_hr_job_boxes">
<a class="o_hr_job_box" name="%(action_hr_job_applications)d" type="action"/>
</div>
</div>
</t>
</templates>