Mohammed Shekha(Open ERP) has proposed merging
lp:~openerp-dev/openobject-client-web/6.0-opw-575545-msh into
lp:openobject-client-web.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-575545-msh/+merge/110069
Hello,
Fixed the issue of domain on many2one field on search view not passed, here
domain was not passed from many2one widget of search.py itself, so passed the
m2o_filter_domain, evaluate it, there might be more than one many2one field
that is there will field wise domain so evaluate domain field wise and added it
into main domain.
Demo :- Go to Warehouse -> Reporting -> Inventory Analysis -> Search by
location (There is many2one field location_id) search for particular location
-> So here you will see you will get the stock of only parent location because
child_of operator is not supported which is passed in domain from addons code.
Currently what web do, it will iterate through each field of search view and
creates a domain manually (search.js parse_domain function), sends the parsed
domain to eval_domain_filter method of search.py of controller and here based
on field type operator is applied, so here the domain passed from addons will
worthless.
This branch will supports domain on many2one field.
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-575545-msh/+merge/110069
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-client-web/6.0-opw-575545-msh.
=== modified file 'addons/openerp/controllers/search.py'
--- addons/openerp/controllers/search.py 2012-06-01 10:56:49 +0000
+++ addons/openerp/controllers/search.py 2012-06-13 13:21:40 +0000
@@ -285,7 +285,9 @@
if check_domain and isinstance(check_domain, basestring):
domain = expr_eval(check_domain, context) or []
-
+ m2o_filter_domain = all_domains.get('m2o_filter_domain', [])
+ for dom in m2o_filter_domain:
+ domain += expr_eval(dom['domain'], {'self': dom['self']}) or []
search_data = {}
model = kw.get('model')
proxy = rpc.RPCProxy(model)
=== modified file 'addons/openerp/static/javascript/search.js'
--- addons/openerp/static/javascript/search.js 2012-05-03 20:52:57 +0000
+++ addons/openerp/static/javascript/search.js 2012-06-13 13:21:40 +0000
@@ -474,6 +474,7 @@
var all_boxes = [];
var $filter_list = jQuery('#filter_list');
var domain = '[]';
+ var m2o_filter_domain = [];
if (jQuery('div.group-data').length) {
jQuery('div.group-data button').each(function(){
if (jQuery(this).hasClass('active')) {
@@ -561,7 +562,8 @@
} else if(kind == 'many2one') {
fld_name = $fld.attr('id').split('_text')[0]
if($fld.attr('m2o_filter_domain')){
- fld_value = 'm2o_'+ fld_value;
+ fld_value = parseInt(jQuery(idSelector(fld_name)).val()) || fld_value;
+ m2o_filter_domain.push({'domain':$fld.attr('m2o_filter_domain'), 'self': fld_value})
}
else {
fld_value = parseInt(jQuery(idSelector(fld_name)).val()) || fld_value;
@@ -578,12 +580,13 @@
domains[fld_name] = fld_value;
}
- if(fld_value && fld_value!='')
+ if(!$fld.attr('m2o_filter_domain') && fld_value && fld_value!='')
domains[fld_name] = fld_value;
});
domains = serializeJSON(domains);
all_domains['domains'] = domains;
all_domains['search_context'] = search_context;
+ all_domains['m2o_filter_domain'] = m2o_filter_domain
var selected_boxes = getElementsByTagAndClassName('input', 'grid-domain-selector');
forEach(selected_boxes, function(box){
=== modified file 'addons/openerp/widgets/form/templates/many2one.mako'
--- addons/openerp/widgets/form/templates/many2one.mako 2011-10-05 10:10:37 +0000
+++ addons/openerp/widgets/form/templates/many2one.mako 2012-06-13 13:21:40 +0000
@@ -10,11 +10,17 @@
% if editable:
<%self:m2o_container>
<span class="m2o">
- <input type="hidden" id="${name}" name="${name}" class="${css_class}" value="${value}"
- ${py.attrs(attrs, kind=kind, domain=domain, context=ctx, relation=relation, fld_required=required and 1 or 0, fld_readonly=readonly and 1 or 0)}/>
- <input type="text" id="${name}_text" class="${css_class}" size="1"
- ${py.attrs(attrs, kind=kind, relation=relation, value=text)}/>
-
+ % if m2o_filter_domain:
+ <input type="hidden" id="${name}" name="${name}" class="${css_class}" value="${value}"
+ ${py.attrs(attrs, kind=kind, domain=domain, m2o_filter_domain=m2o_filter_domain, context=ctx, relation=relation, fld_required=required and 1 or 0, fld_readonly=readonly and 1 or 0)}/>
+ <input type="text" id="${name}_text" class="${css_class}" size="1"
+ ${py.attrs(attrs, kind=kind, m2o_filter_domain=m2o_filter_domain, relation=relation, value=text)}/>
+ % else:
+ <input type="hidden" id="${name}" name="${name}" class="${css_class}" value="${value}"
+ ${py.attrs(attrs, kind=kind, domain=domain, context=ctx, relation=relation, fld_required=required and 1 or 0, fld_readonly=readonly and 1 or 0)}/>
+ <input type="text" id="${name}_text" class="${css_class}" size="1"
+ ${py.attrs(attrs, kind=kind, relation=relation, value=text)}/>
+ % endif
<input type="hidden" id="_hidden_${name}" value=""/>
% if error:
<span class="fielderror">${error}</span>
=== modified file 'addons/openerp/widgets/search.py'
--- addons/openerp/widgets/search.py 2011-02-22 14:26:34 +0000
+++ addons/openerp/widgets/search.py 2012-06-13 13:21:40 +0000
@@ -176,7 +176,9 @@
class M2O_search(form.M2O):
template = "/openerp/widgets/templates/search/many2one.mako"
+ params = ['m2o_filter_domain']
def __init__(self, **attrs):
+ self.m2o_filter_domain = attrs.get('filter_domain')
attrs['m2o_filter_domain'] = attrs.get('filter_domain')
super(M2O_search, self).__init__(**attrs)
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp