Skip to content
Snippets Groups Projects
Commit 7c18c68f authored by qsm-odoo's avatar qsm-odoo
Browse files

[FIX] hr_timesheet_sheet: '0' values when adding a new line

When a new line was added, all the others changed their value to 0.
This was because of a property : the sheets propertywas read thanks
to a get('sheets') but as it is an array of object, modifying those
object will modify the sheets (without calling any handler attached
to the 'change:sheets' event). It appeared the form_view set_values
method changed those objects.

A simple solution from a timesheet point of vue was to deep clone the
sheets property before using it.
parent 1a405ed7
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,8 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg
this.updating = true;
var commands = [form_common.commands.delete_all()];
_(this.get("sheets")).each(function (data) {
_.each(this.get("sheets"), function (_data) {
var data = _.clone(_data);
if(data.id) {
commands.push(form_common.commands.link_to(data.id));
commands.push(form_common.commands.update(data.id, data));
......@@ -125,7 +126,8 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg
start = m_start.toDate();
}
// group by account
accounts = _(self.get("sheets")).chain()
accounts = _.chain(self.get("sheets"))
.map(_.clone)
.each(function(el) {
// much simpler to use only the id in all cases
if (typeof(el.account_id) === "object") {
......
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