diff --git a/hr_timesheet_portal/README.rst b/hr_timesheet_portal/README.rst index edb00b09c..a2783263c 100644 --- a/hr_timesheet_portal/README.rst +++ b/hr_timesheet_portal/README.rst @@ -17,13 +17,13 @@ Timesheet portal (editable) :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Ftimesheet-lightgray.png?logo=github - :target: https://github.com/OCA/timesheet/tree/12.0/hr_timesheet_portal + :target: https://github.com/OCA/timesheet/tree/14.0/hr_timesheet_portal :alt: OCA/timesheet .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/timesheet-12-0/timesheet-12-0-hr_timesheet_portal + :target: https://translation.odoo-community.org/projects/timesheet-14-0/timesheet-14-0-hr_timesheet_portal :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=12.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/timesheet&target_branch=14.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -53,7 +53,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -83,6 +83,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/timesheet `_ project on GitHub. +This module is part of the `OCA/timesheet `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_timesheet_portal/__manifest__.py b/hr_timesheet_portal/__manifest__.py index 30e9f9162..a472f17ea 100644 --- a/hr_timesheet_portal/__manifest__.py +++ b/hr_timesheet_portal/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Timesheet portal (editable)", "summary": "Fill in timesheets via the portal", - "version": "12.0.1.0.1", + "version": "14.0.1.0.0", "development_status": "Alpha", "category": "Website", "website": "https://github.com/OCA/timesheet", diff --git a/hr_timesheet_portal/static/description/index.html b/hr_timesheet_portal/static/description/index.html index 70b6788b4..260e2e041 100644 --- a/hr_timesheet_portal/static/description/index.html +++ b/hr_timesheet_portal/static/description/index.html @@ -1,4 +1,3 @@ - @@ -369,7 +368,7 @@

Timesheet portal (editable)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:b83149749c355494cfa2ceb00ef516875d7fab19a7e347b02e2bae0b5614449e !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Alpha License: AGPL-3 OCA/timesheet Translate me on Weblate Try me on Runboat

+

Alpha License: AGPL-3 OCA/timesheet Translate me on Weblate Try me on Runboat

This module allows portal users to edit their timesheets via the frontend.

Important

@@ -402,7 +401,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -426,7 +425,7 @@

Maintainers

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/timesheet project on GitHub.

+

This module is part of the OCA/timesheet project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/hr_timesheet_portal/static/src/js/hr_timesheet_portal.js b/hr_timesheet_portal/static/src/js/hr_timesheet_portal.js index ebf3a7b22..9d14eccf7 100644 --- a/hr_timesheet_portal/static/src/js/hr_timesheet_portal.js +++ b/hr_timesheet_portal/static/src/js/hr_timesheet_portal.js @@ -4,13 +4,13 @@ odoo.define("hr_timesheet_portal", function (require) { "use strict"; - var sAnimation = require("website.content.snippets.animation"), - rpc = require("web.rpc"), - core = require("web.core"), - _t = core._t; + const sAnimation = require("website.content.snippets.animation"); + const core = require("web.core"); + const _t = core._t; sAnimation.registry.hr_timesheet_portal = sAnimation.Class.extend({ selector: "div.hr_timesheet_portal", + disabledInEditableMode: true, events: { "click h5": "_onclick_add", "click tr[data-line-id]:not(.edit)": "_onclick_edit", @@ -20,47 +20,40 @@ odoo.define("hr_timesheet_portal", function (require) { "click button.cancel": "_reload_timesheet", }, - start: function (editable_mode) { - if (editable_mode) { - this.stop(); - return; - } - }, - _onclick_delete: function (e) { e.stopPropagation(); - rpc.query({ + return this._rpc({ model: "account.analytic.line", method: "unlink", args: [[jQuery(e.currentTarget).parents("tr").data("line-id")]], - }) - .done(this.proxy("_reload_timesheet")) - .fail(this.proxy("_display_failure")); + }).then(this.proxy("_reload_timesheet"), this.proxy("_display_failure")); }, _onclick_add: function (e) { + var $currentTarget = jQuery(e.currentTarget); + if ($currentTarget.prop("disabled") || this.$("input").length) { + return; + } + $currentTarget.prop("disabled", true); var self = this; - return rpc - .query({ - model: "account.analytic.line", - method: "create", - args: [ - { - user_id: this.getSession().user_id, - account_id: this.$el.data("account-id"), - project_id: this.$el.data("project-id"), - task_id: this.$el.data("task-id"), - unit_amount: 0, - name: "/", - }, - ], - }) - .done(function (line_id) { - return self._reload_timesheet().then(function () { - setTimeout(self._edit_line.bind(self, line_id), 0); - }); - }) - .fail(this.proxy("_display_failure")); + return this._rpc({ + model: "account.analytic.line", + method: "create", + args: [ + { + user_id: this.getSession().user_id, + account_id: this.$el.data("account-id"), + project_id: this.$el.data("project-id"), + task_id: this.$el.data("task-id"), + unit_amount: 0, + name: "/", + }, + ], + }).then(function (line_id) { + return self._reload_timesheet().then(function () { + setTimeout(self._edit_line.bind(self, line_id), 0); + }); + }, this.proxy("_display_failure")); }, _onclick_edit: function (e) { @@ -75,14 +68,11 @@ odoo.define("hr_timesheet_portal", function (require) { return [a.name, a.value]; }) ); - return rpc - .query({ - model: "account.analytic.line", - method: "write", - args: [$tr.data("line-id"), data], - }) - .done(this.proxy("_reload_timesheet")) - .fail(this.proxy("_display_failure")); + return this._rpc({ + model: "account.analytic.line", + method: "write", + args: [$tr.data("line-id"), data], + }).then(this.proxy("_reload_timesheet"), this.proxy("_display_failure")); }, _reload_timesheet: function () { @@ -96,23 +86,31 @@ odoo.define("hr_timesheet_portal", function (require) { jQuery(element).find("div.hr_timesheet_portal").length > 0 ); }), - $tbody = jQuery(timesheets).find("tbody"); + $tbody = jQuery(timesheets).find("div.hr_timesheet_portal tbody"), + $existing_tbody = self.$("tbody"); + if (!$existing_tbody.length) { + return self.$("thead").after($tbody); + } + self.$("h5").prop("disabled", false); return self.$("tbody").replaceWith($tbody); }); }, _display_failure: function (error) { this.$el.prepend( - jQuery('
').text(error.data.message) + jQuery('
').text( + error.message.data.message + ) ); this.$el.prepend( - jQuery('
').text(error.message) + jQuery('
').text(error.message.message) ); }, _edit_line(line_id) { var $line = this.$(_.str.sprintf("tr[data-line-id=%s]", line_id)), $edit_line = $line.clone(); + this.$("h5").prop("disabled", true); this.$("tbody tr.edit").remove(); this.$("tbody tr").show(); $line.before($edit_line); @@ -142,5 +140,5 @@ odoo.define("hr_timesheet_portal", function (require) { }, }); - return {animation: hr_timesheet_portal}; + return {animation: sAnimation.registry.hr_timesheet_portal}; }); diff --git a/hr_timesheet_portal/templates/portal.xml b/hr_timesheet_portal/templates/portal.xml index d09892df1..6b2d2f3fd 100644 --- a/hr_timesheet_portal/templates/portal.xml +++ b/hr_timesheet_portal/templates/portal.xml @@ -4,7 +4,7 @@ +