Skip to content
Snippets Groups Projects
Commit 83faf981 authored by Thomas Lefebvre (thle)'s avatar Thomas Lefebvre (thle)
Browse files

[FIX] hr_work_entry_contract: avoid infinite reload


Versions:
---------
- 16.0
- saas-16.1

Issue:
------
In the Payroll module, in the Gantt view of work entries,
when a work entry is deleted, the wizard doesn't close.

Cause:
------
When we go to the Gantt view of work entries, we trigger
the function `_generateWorkEntries` (because we trigger an update at `start`).
An RPC call will be made, and the response will be the new work entries
that have been generated in string format (`'hr.work.entry()'`).
This response will always be interpreted as `true` in an if condition.
If there are new work entries, a reload is triggered,
leaving no time to close the wizard.
These steps are repeated
and we are "stuck" in an infinite loop.

Note:
The problem doesn't occur in the calendar view,
as a hook is provided for this purpose
and we will trigger the `generateWorkEntries` function
which won't have a reload effect if work entry has been generated.

Solution:
---------
Create a method that returns an array with
the ids of the new work entries generated.
This response will be more easily interpreted by the frontend
to decide whether or not we have to reload the page.

opw-3504435

closes odoo/odoo#136101

Signed-off-by: default avatarSofie Gvaladze (sgv) <sgv@odoo.com>
parent 62a6fe27
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,11 @@ from odoo import fields, models
class HrEmployee(models.Model):
_inherit = 'hr.employee'
def generate_work_entries_web(self, date_start, date_stop, force=False):
# Used to generate work_entries via call RPC
new_work_entries = self.generate_work_entries(date_start, date_stop, force)
return new_work_entries.ids
def generate_work_entries(self, date_start, date_stop, force=False):
date_start = fields.Date.to_date(date_start)
date_stop = fields.Date.to_date(date_stop)
......
......@@ -78,10 +78,10 @@ odoo.define('hr_work_entry_contract.WorkEntryControllerMixin', function(require)
var self = this;
return this._rpc({
model: 'hr.employee',
method: 'generate_work_entries',
method: 'generate_work_entries_web',
args: [[], time.date_to_str(this.firstDay), time.date_to_str(this.lastDay)],
}).then(function (new_work_entries) {
if (new_work_entries) {
}).then(function (new_work_entries_ids) {
if (new_work_entries_ids.length > 0) {
self.reload();
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment