Merge lp:~openerp-dev-web/openobject-client-web/o2m_improved into lp:~openerp-dev/openobject-client-web/trunk-dev-web

Proposed by Vaibhav Darji
Status: Merged
Merged at revision: not available
Proposed branch: lp:~openerp-dev-web/openobject-client-web/o2m_improved
Merge into: lp:~openerp-dev/openobject-client-web/trunk-dev-web
Diff against target: 47 lines (+10/-8)
2 files modified
addons/openerp/widgets/form/_o2m.py (+2/-2)
addons/openerp/widgets/form/templates/one2many.mako (+8/-6)
To merge this branch: bzr merge lp:~openerp-dev-web/openobject-client-web/o2m_improved
Reviewer Review Type Date Requested Status
Xavier (Open ERP) (community) Approve
Review via email: mp+24213@code.launchpad.net

Description of the change

Improve o2m for unsaved parent when creating new child.

To post a comment you must log in.
3055. By Vaibhav Darji

Remove unnecessary import.

Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Code is simple and pretty clean, which is nice, but from a UI standpoint there are still issues, I believe this needs deeper modifications as to how o2m is handled:

* (minor) the label on the "new o2m" button is still "save parent record" when parent is saved
* bigger issue, when an o2m is created the parent is automatically saved even though user never tried to save anything, and so if user changes mind (and goes do something else) record has still been created. Likewise, means one can not create o2m record if parent form is incomplete. Ideally, parent should be saved as late as possible (as in GTK client), meaning when *saving* the o2m record, not when adding new line I think

What do you think?

review: Needs Fixing
Revision history for this message
Navrang Oza (noz-tiny) wrote :

I agree whatever you said, but here problem is we are calling submit method to SAVE the current form (which includes everything - parent, o2m, m2m...).

- To make it like GTK, we have to change whole architecture for o2m.
- We have to save all o2m entries somewhere while creating new records more than one without affecting parent.
- To save the o2m records somewhere means we again have to call submit method or something? and without Parent ID what will be the reference for o2m records ?

you can understand what I mean to say.

Actually Amit sir sent a mail for this problem to FP sir when he created backlog first time for this task.

Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

> - To save the o2m records somewhere means we again have to call submit method or something? and without Parent ID what will be the reference for o2m records ?

yeah basically I was thinking of having the o2m record's save check if parent id exists, and if not ask for parent to save and then save itself. But if you think it's going to be too much work, we can just go with vda's current solution (which works) and add UI/UX improvements to the backlog.

3056. By Vaibhav Darji

[FIX] Fixed title.

Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/widgets/form/_o2m.py'
2--- addons/openerp/widgets/form/_o2m.py 2010-04-14 10:11:55 +0000
3+++ addons/openerp/widgets/form/_o2m.py 2010-04-29 10:04:28 +0000
4@@ -48,7 +48,7 @@
5 """One2Many widget
6 """
7 template = "templates/one2many.mako"
8- params = ['id', 'parent_id', 'new_attrs', 'pager_info', 'switch_to', 'default_get_ctx']
9+ params = ['id', 'parent_id', 'new_attrs', 'pager_info', 'switch_to', 'default_get_ctx', 'source']
10 member_widgets = ['screen']
11
12 form = None
13@@ -66,7 +66,7 @@
14
15 # get top params dictionary
16 params = cherrypy.request.terp_params
17-
18+ self.source = params.source
19 pprefix = ''
20 if '/' in self.name:
21 pprefix = self.name[:self.name.rindex('/')]
22
23=== modified file 'addons/openerp/widgets/form/templates/one2many.mako'
24--- addons/openerp/widgets/form/templates/one2many.mako 2010-03-26 10:20:08 +0000
25+++ addons/openerp/widgets/form/templates/one2many.mako 2010-04-29 10:04:28 +0000
26@@ -6,13 +6,15 @@
27 <td width="100%"><strong>${screen.string}</strong></td>
28 <td>
29 % if screen.editable and not readonly:
30- <button type="button" id="${name}_btn_" title="${new_attrs['help']}" onclick="new One2Many('${name}', ${(screen.view_type == 'tree' or 0) and len(screen.widget.editors)}).create()" style="padding: 2px">
31- % if parent_id:
32+ <button type="button" id="${name}_btn_" title="${_('Create new record.')}" onclick="new One2Many('${name}', ${(screen.view_type == 'tree' or 0) and len(screen.widget.editors)}).create()" style="padding: 2px">
33 <img src="/openerp/static/images/stock/gtk-new.png" width="16" height="16"/>
34- % endif
35- % if not parent_id:
36- <img src="/openerp/static/images/stock/gtk-save.png" width="16" height="16"/>
37- % endif
38+ % if name == source:
39+ <script type="text/javascript">
40+ jQuery('#${name}_btn_').find('img').load(function() {
41+ jQuery(this).click();
42+ });
43+ </script>
44+ % endif
45 </button>
46 % endif
47 % if pager_info:

Subscribers

People subscribed via source and target branches