Merge lp:~openerp-dev/openobject-client-web/6.0-opw-516504-msh into lp:openobject-client-web

Proposed by Mohammed Shekha(Open ERP)
Status: Merged
Merged at revision: 4800
Proposed branch: lp:~openerp-dev/openobject-client-web/6.0-opw-516504-msh
Merge into: lp:openobject-client-web
Diff against target: 22 lines (+6/-5)
1 file modified
addons/openerp/controllers/listgrid.py (+6/-5)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client-web/6.0-opw-516504-msh
Reviewer Review Type Date Requested Status
Vaibhav Darji (community) Approve
Review via email: mp+96061@code.launchpad.net

Description of the change

Hello,

Fixed the issue of many2many in which record is disappeared when we selects some record from manymany and without saving parent record when we edit many2many record and save it, the records of many2many which we just selected will disappeared.

Demo :- To face this issue make tree view of account.tax editable, now go to Products -> Edit any product -> account tax(many2many field) in Accounting tab -> Select some records in many2many field now without saving the parent record of product edit any many2many record and save it, you will see the record will disappeared from the list.

Reason :- The reason is when we edit and save the record for editable list view at that time save method of listgrid.py is called, here we replace the ids by all_ids, all_ids is the result of read method, here we have not saved parent record so database does not contains that many2many entries with this product.

Hence changed the code to fix this issue.

Thanks.

To post a comment you must log in.
Revision history for this message
Vaibhav Darji (vaibhav-openerp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/controllers/listgrid.py'
2--- addons/openerp/controllers/listgrid.py 2011-07-04 07:22:13 +0000
3+++ addons/openerp/controllers/listgrid.py 2012-03-06 05:40:21 +0000
4@@ -71,12 +71,13 @@
5 data = {fld : [(id and 1, id, data.copy())]}
6 proxy.write([params.parent.id], data, ctx)
7
8- all_ids = proxy.read([params.parent.id], [fld])[0][fld]
9- new_ids = [i for i in all_ids if i not in ids]
10+ if not id:
11+ all_ids = proxy.read([params.parent.id], [fld])[0][fld]
12+ new_ids = [i for i in all_ids if i not in ids]
13
14- ids = all_ids
15- if new_ids:
16- id = new_ids[0]
17+ ids = all_ids
18+ if new_ids:
19+ id = new_ids[0]
20
21 else:
22 data = frm.copy()