Added sync with o2m

bzr revid: nicolas.vanhoren@openerp.com-20121001145516-x2bidvidn0fswi4u
This commit is contained in:
niv-openerp 2012-10-01 16:55:16 +02:00
parent 5441985399
commit 7234ef203c
1 changed files with 19 additions and 0 deletions

View File

@ -123,6 +123,7 @@ openerp.hr_timesheet_sheet = function(instance) {
} else {
account.days[day_count].lines[0].unit_amount += num - self.sum_case(account, day_count);
self.get_total(account).html(self.sum_total(account));
self.sync();
}
});
});
@ -151,6 +152,24 @@ openerp.hr_timesheet_sheet = function(instance) {
});
return total;
},
sync: function() {
var self = this;
var lst = [];
_.each(self.accounts, function(account) {
_.each(account.days, function(day) {
_.each(day.lines, function(line) {
if (line.unit_amount != 0) {
var tmp = _.clone(line);
line.id = undefined;
lst.push(tmp);
}
});
});
});
self.setting = true;
self.set({sheets: lst});
self.setting = false;
},
});
instance.web.form.custom_widgets.add('weekly_timesheet', 'instance.hr_timesheet_sheet.WeeklyTimesheet');