openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #00024
[Merge] lp:~openerp-dev-web/openobject-client-web/root_actions into lp:~openerp-dev/openobject-client-web/trunk-dev-web
vda(Open ERP) has proposed merging lp:~openerp-dev-web/openobject-client-web/root_actions into lp:~openerp-dev/openobject-client-web/trunk-dev-web.
Requested reviews:
OpenERP SA's Web Client R&D (openerp-dev-web)
Display Sum of total selected records
root level menu's action.
--
https://code.launchpad.net/~openerp-dev-web/openobject-client-web/root_actions/+merge/24794
Your team OpenERP SA's Web Client R&D is requested to review the proposed merge of lp:~openerp-dev-web/openobject-client-web/root_actions into lp:~openerp-dev/openobject-client-web/trunk-dev-web.
=== modified file 'addons/openerp/controllers/listgrid.py'
--- addons/openerp/controllers/listgrid.py 2010-04-23 06:16:06 +0000
+++ addons/openerp/controllers/listgrid.py 2010-05-06 06:08:34 +0000
@@ -317,7 +317,30 @@
for r in res:
proxy.write([r['id']], {'sequence': res_ids.index(r['id'])+1}, ctx)
return dict()
-
+
+ @expose('json')
+ def count_sum(self, model, ids, sum_fields):
+ selected_ids = ast.literal_eval(ids)
+ sum_fields = ast.literal_eval(sum_fields)
+ ctx = rpc.session.context.copy()
+
+ proxy = rpc.RPCProxy(model)
+ res = proxy.read(selected_ids, sum_fields, ctx)
+
+ total = []
+ for field in sum_fields:
+ total.append([])
+
+ for i in range(len(selected_ids)):
+ for k in range(len(sum_fields)):
+ total[k].append(res[i][sum_fields[k]])
+
+ total_sum = []
+ for s in total:
+ total_sum.append(sum(s))
+
+ return dict(sum = total_sum)
+
@expose('json')
def moveUp(self, **kw):
=== modified file 'addons/openerp/controllers/root.py'
--- addons/openerp/controllers/root.py 2010-04-15 12:08:47 +0000
+++ addons/openerp/controllers/root.py 2010-05-06 06:08:34 +0000
@@ -104,19 +104,25 @@
ids = proxy.search([('parent_id', '=', False)], 0, 0, 0, ctx)
parents = proxy.read(ids, ['name', 'icon'], ctx)
-
+
if not id and ids:
id = ids[0]
ids = proxy.search([('parent_id', '=', id)], 0, 0, 0, ctx)
- tools = proxy.read(ids, ['name', 'icon'], ctx)
-
+ tools = proxy.read(ids, [], ctx)
view = cache.fields_view_get('ir.ui.menu', 1, 'tree', {})
fields = cache.fields_get(view['model'], False, ctx)
for tool in tools:
tid = tool['id']
tool['icon'] = icons.get_icon(tool['icon'])
+ if tool['action']:
+ act_proxy = rpc.RPCProxy(tool['action'].split(",")[0])
+ res_act = act_proxy.read([tool['action'].split(",")[1]],[], ctx)
+ seach_action_id = proxy.search([('name','=',res_act[0]['name'])], 0, 0, 0, ctx)
+ if seach_action_id:
+ tool['action_id'] = seach_action_id[-1]
+
tool['tree'] = tree = tree_view.ViewTree(view, 'ir.ui.menu', tid,
domain=[('parent_id', '=', tid)],
context=ctx, action="/tree/action", fields=fields)
=== modified file 'addons/openerp/controllers/templates/menu.mako'
--- addons/openerp/controllers/templates/menu.mako 2010-04-01 10:24:44 +0000
+++ addons/openerp/controllers/templates/menu.mako 2010-05-06 06:08:34 +0000
@@ -69,7 +69,14 @@
<table class="accordion-title">
<tr>
<td><img alt="" src="${tool['icon']}" width="16" height="16" align="left"/></td>
- <td>${tool['name']}</td>
+ <td id="${tool['id']}">${tool['name']}</td>
+ % if tool.get('action_id'):
+ <script type="text/javascript">
+ jQuery("#${tool['id']}").click(function() {
+ jQuery('#appFrame').attr("src", openobject.http.getURL('/tree/open', {'model': "ir.ui.menu", 'id': "${tool['action_id']}"}))
+ });
+ </script>
+ % endif
</tr>
</table>
<div class="accordion-content">
=== modified file 'addons/openerp/static/css/style.css'
--- addons/openerp/static/css/style.css 2010-04-29 06:23:04 +0000
+++ addons/openerp/static/css/style.css 2010-05-06 06:08:34 +0000
@@ -134,6 +134,26 @@
padding: 1px;
}
+img.group_expand {
+ cursor: pointer;
+ background: url(../images/treegrid/expand.gif) no-repeat top left;
+ padding-left: 15px;
+}
+
+img.group_expand:hover {
+ background: url(../images/treegrid/expandh.gif) no-repeat top left;
+}
+
+img.group_collapse {
+ cursor: pointer;
+ background: url(../images/treegrid/collapse.gif) no-repeat top left;
+ padding-left: 15px;
+}
+
+img.group_collapse:hover {
+ background: url(../images/treegrid/collapseh.gif) no-repeat top left;
+}
+
div.group-expand {
cursor: pointer;
background: url(../images/treegrid/expand.gif) no-repeat top left;
=== modified file 'addons/openerp/static/javascript/listgrid.js'
--- addons/openerp/static/javascript/listgrid.js 2010-04-28 05:45:13 +0000
+++ addons/openerp/static/javascript/listgrid.js 2010-05-06 06:08:34 +0000
@@ -81,8 +81,31 @@
});
var sb = openobject.dom.get('sidebar');
if (sb) toggle_sidebar();
+
+ this.getRecordssum();
},
-
+
+ getRecordssum: function() {
+ if(jQuery('tr.field_sum').find('td.grid-cell').find('span').length>0) {
+ var selected_ids = this.getSelectedRecords();
+ var sum_fields = new Array();
+
+ jQuery('tr.field_sum').find('td.grid-cell').find('span').each(function() {
+ sum_fields.push(jQuery(this).attr('id'))
+ });
+
+ jQuery.post('/listgrid/count_sum',
+ {'model':this.model, 'ids': selected_ids.toSource(), 'sum_fields': sum_fields.toSource()},
+ function(obj) {
+ for(i in obj.sum) {
+ jQuery('tr.field_sum').find('td.grid-cell').find('span[id="'+sum_fields[i]+'"]').html(obj.sum[i])
+ }
+ },
+ "json"
+ );
+ }
+ },
+
getRecords: function() {
var records = map(function(row) {
return parseInt(getNodeAttribute(row, 'record')) || 0;
@@ -128,6 +151,8 @@
});
jQuery('[id$=_terp_checked_ids]').attr('value', '[' + new_ids.join(',') + ']');
}
+
+ this.getRecordssum();
},
getColumns: function(dom) {
=== modified file 'addons/openerp/widgets/templates/listgrid.mako'
--- addons/openerp/widgets/templates/listgrid.mako 2010-04-23 14:07:31 +0000
+++ addons/openerp/widgets/templates/listgrid.mako 2010-05-06 06:08:34 +0000
@@ -181,7 +181,7 @@
% if 'sum' in field_attrs:
% for key, val in field_total.items():
% if field == key:
- <span style="border-top: 1px inset ; display: block; padding: 0 1px;">${val[1]}</span>
+ <span id="${field}" style="border-top: 1px inset ; display: block; padding: 0 1px;">${val[1]}</span>
% endif
% endfor
% else:
Follow ups