Merge lp:~openerp-dev/openobject-addons/7.0-opw-598634-msh into lp:openobject-addons/7.0

Proposed by Mohammed Shekha(Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-598634-msh
Merge into: lp:openobject-addons/7.0
Diff against target: 44 lines (+12/-1)
1 file modified
hr_timesheet_sheet/static/src/js/timesheet.js (+12/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-598634-msh
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) Pending
Naresh(OpenERP) Pending
Review via email: mp+194067@code.launchpad.net

Description of the change

Hello,

Fixed the issue of timesheet, set_value of timesheet_ids remove some reference field value, as new entry is always created and old one is removed.

Demo: To reproduce this issue go through following bug report:
https://bugs.launchpad.net/openobject-addons/+bug/1229187

Thanks.

To post a comment you must log in.

Unmerged revisions

9542. By Mohammed Shekha(OpenERP)<email address hidden>

[FIX]Fixed the issue of timesheet, set_value of timesheet_ids remove some reference field value, as new entry is always created and old one is removed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_timesheet_sheet/static/src/js/timesheet.js'
2--- hr_timesheet_sheet/static/src/js/timesheet.js 2013-06-13 15:03:42 +0000
3+++ hr_timesheet_sheet/static/src/js/timesheet.js 2013-11-06 05:28:55 +0000
4@@ -114,6 +114,7 @@
5 account_defaults = _.extend({}, default_get, (accounts_defaults[account_id] || {}).value || {});
6 // group by days
7 account_id = account_id === "false" ? false : Number(account_id);
8+ line_id = lines.id;
9 var index = _.groupBy(lines, "date");
10 var days = _.map(dates, function(date) {
11 var day = {day: date, lines: index[instance.web.date_to_str(date)] || []};
12@@ -124,6 +125,7 @@
13 day.lines.unshift(to_add);
14 } else {
15 day.lines.unshift(_.extend(_.clone(account_defaults), {
16+ id: line_id,
17 name: self.description_line,
18 unit_amount: 0,
19 date: instance.web.date_to_str(date),
20@@ -313,7 +315,7 @@
21 generate_o2m_value: function() {
22 var self = this;
23 var ops = [];
24-
25+
26 _.each(self.accounts, function(account) {
27 var auth_keys = _.extend(_.clone(account.account_defaults), {
28 name: true, amount:true, unit_amount: true, date: true, account_id:true,
29@@ -334,6 +336,15 @@
30 tmp[key] = undefined;
31 }
32 });
33+ //Call write if timesheet entry is already available, otherwise create
34+ //It not passed in array then one2many set_value will first remove all entry(delete_all)
35+ //and then create new all new entries this cause issue in some scenarios, may remove some reference data
36+ if(line.id) {
37+ delete tmp.id;
38+ tmp = [1, line.id, tmp]
39+ } else {
40+ tmp = [0, false, tmp]
41+ }
42 ops.push(tmp);
43 }
44 });