From dbe22a3c06a5e25f28fd33ef5ca24e4f86ebb327 Mon Sep 17 00:00:00 2001 From: Nidhi Patel Date: Tue, 24 Aug 2021 08:07:55 +0000 Subject: [PATCH] [IMP] {hr,sale}_timesheet: improve setting in the timesheet module The purpose of this task is to improve the setting of the timesheet module. In this commit, we improve the following: - Rename the label, description and align the field with the name and description of the feature - Add an 'OK' button in the 'download our app' modal - Render the frequency field properly in the employee/manager reminders setting on mobile view - In configure your services link: change the name of the action to "Services" - Display the following options in the community, with the usual 'Enterprise' tag: Round Timesheet, Employee/Manager reminder, Invoicing Policy closes odoo/odoo#74967 Task-id: 2531338 Related: odoo/enterprise#20182 Related: odoo/upgrade#2771 Signed-off-by: LTU-Odoo --- .../hr_timesheet/data/hr_timesheet_data.xml | 11 ------ .../models/res_config_settings.py | 6 +-- .../src/js/timesheet_config_form_view.js | 37 +++++++++++++----- .../views/res_config_settings_views.xml | 39 ++++++++++++------- .../views/res_config_settings_views.xml | 8 ++-- addons/sale_timesheet/models/__init__.py | 1 + .../models/res_config_settings.py | 10 +++++ addons/sale_timesheet/views/product_views.xml | 2 +- .../views/res_config_settings_views.xml | 11 ++++++ 9 files changed, 82 insertions(+), 43 deletions(-) create mode 100644 addons/sale_timesheet/models/res_config_settings.py diff --git a/addons/hr_timesheet/data/hr_timesheet_data.xml b/addons/hr_timesheet/data/hr_timesheet_data.xml index 044a7959001..909fdd0f61e 100644 --- a/addons/hr_timesheet/data/hr_timesheet_data.xml +++ b/addons/hr_timesheet/data/hr_timesheet_data.xml @@ -15,17 +15,6 @@ name="_init_data_analytic_account" eval="[]"/> - - - hr_timesheet.timesheet_rounding - 15 - - - hr_timesheet.timesheet_min_duration - 15 - - - 1 Internal diff --git a/addons/hr_timesheet/models/res_config_settings.py b/addons/hr_timesheet/models/res_config_settings.py index 51f2fe5eb8a..cf259bc21c9 100644 --- a/addons/hr_timesheet/models/res_config_settings.py +++ b/addons/hr_timesheet/models/res_config_settings.py @@ -9,8 +9,10 @@ class ResConfigSettings(models.TransientModel): module_project_timesheet_synchro = fields.Boolean("Awesome Timesheet", compute="_compute_timesheet_modules", store=True, readonly=False) - module_project_timesheet_holidays = fields.Boolean("Record Time Off", + module_project_timesheet_holidays = fields.Boolean("Time Off", compute="_compute_timesheet_modules", store=True, readonly=False) + reminder_user_allow = fields.Boolean(string="Employee Reminder", help="If checked, send an email to all users who have not recorded their timesheet") + reminder_manager_allow = fields.Boolean(string="Manager Reminder", help="If checked, send an email to all manager") project_time_mode_id = fields.Many2one( 'uom.uom', related='company_id.project_time_mode_id', string='Project Time Unit', readonly=False, help="This will set the unit of measure used in projects and tasks.\n" @@ -20,8 +22,6 @@ class ResConfigSettings(models.TransientModel): related='company_id.timesheet_encode_uom_id', readonly=False, help="""This will set the unit of measure used to encode timesheet. This will simply provide tools and widgets to help the encoding. All reporting will still be expressed in hours (default value).""") - timesheet_min_duration = fields.Integer('Minimal duration', default=15, config_parameter='hr_timesheet.timesheet_min_duration') - timesheet_rounding = fields.Integer('Rounding up', default=15, config_parameter='hr_timesheet.timesheet_rounding') is_encode_uom_days = fields.Boolean(compute='_compute_is_encode_uom_days') @api.depends('timesheet_encode_uom_id') diff --git a/addons/hr_timesheet/static/src/js/timesheet_config_form_view.js b/addons/hr_timesheet/static/src/js/timesheet_config_form_view.js index 3ab983ba862..16229773037 100644 --- a/addons/hr_timesheet/static/src/js/timesheet_config_form_view.js +++ b/addons/hr_timesheet/static/src/js/timesheet_config_form_view.js @@ -3,27 +3,46 @@ odoo.define('hr_timesheet.res.config.form', function (require) { const core = require('web.core'); const config = require('web.config'); + const Dialog = require('web.Dialog'); const viewRegistry = require('web.view_registry'); const BaseSetting = require('base.settings'); + const QWeb = core.qweb; const _t = core._t; + const TimesheetConfigQRCodeDialog = Dialog.extend({ + /** + * @override + */ + init: function (parent, url) { + this.url = _.str.sprintf("/report/barcode/?type=QR&value=%s&width=256&height=256&humanreadable=1", url); + this._super(parent, { + title: _t('Download our App'), + buttons: [{ + text: _t('View App'), + classes: 'btn-primary', + click: function() { + window.open(url, '_blank'); + } + }, { + text: _t('Discard'), + close: true + }], + $content: QWeb.render('hr_timesheet_qr_code', {widget: this}) + }); + }, + }); + const TimesheetConfigQRCodeMixin = { async _renderView() { const self = this; await this._super(...arguments); const google_url = "https://play.google.com/store/apps/details?id=com.odoo.OdooTimesheets"; const apple_url = "https://apps.apple.com/be/app/awesome-timesheet/id1078657549"; - const action_desktop = { - name: _t('Download our App'), - type: 'ir.actions.client', - tag: 'timesheet_qr_code_modal', - target: 'new', - }; this.$el.find('img.o_config_app_store').on('click', function(event) { event.preventDefault(); if (!config.device.isMobile) { - self.do_action(_.extend(action_desktop, {params: {'url': apple_url}})); + new TimesheetConfigQRCodeDialog(this, apple_url).open(); } else { self.do_action({type: 'ir.actions.act_url', url: apple_url}); } @@ -31,7 +50,7 @@ odoo.define('hr_timesheet.res.config.form', function (require) { this.$el.find('img.o_config_play_store').on('click', function(event) { event.preventDefault(); if (!config.device.isMobile) { - self.do_action(_.extend(action_desktop, {params: {'url': google_url}})); + new TimesheetConfigQRCodeDialog(this, google_url).open(); } else { self.do_action({type: 'ir.actions.act_url', url: google_url}); } @@ -50,6 +69,6 @@ odoo.define('hr_timesheet.res.config.form', function (require) { viewRegistry.add('hr_timesheet_config_form', TimesheetConfigFormView); - return {TimesheetConfigQRCodeMixin, TimesheetConfigFormRenderer, TimesheetConfigFormView}; + return {TimesheetConfigQRCodeDialog, TimesheetConfigQRCodeMixin, TimesheetConfigFormRenderer, TimesheetConfigFormView}; }); diff --git a/addons/hr_timesheet/views/res_config_settings_views.xml b/addons/hr_timesheet/views/res_config_settings_views.xml index 72977ef9a97..1c940094c47 100644 --- a/addons/hr_timesheet/views/res_config_settings_views.xml +++ b/addons/hr_timesheet/views/res_config_settings_views.xml @@ -37,7 +37,7 @@
- +
@@ -69,21 +69,30 @@ -
-
- Time Rounding +
+

Timesheets Control

+
+
+
+ +
+
+
+
+
+ +
+
+
@@ -99,7 +108,7 @@
+
+
+ +
+
+
+