From a2b23a1ca71a25f912c5f92e8a1dbfdde69bc568 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 29 Nov 2012 12:23:50 +0100 Subject: [PATCH 1/5] [REM] merge conflict file committed bzr revid: xmo@openerp.com-20121129112350-egvxrg8ii71wzdx6 --- addons/web/static/test/test.html.THIS | 63 --------------------------- 1 file changed, 63 deletions(-) delete mode 100644 addons/web/static/test/test.html.THIS diff --git a/addons/web/static/test/test.html.THIS b/addons/web/static/test/test.html.THIS deleted file mode 100644 index f5f29f88d7c..00000000000 --- a/addons/web/static/test/test.html.THIS +++ /dev/null @@ -1,63 +0,0 @@ - - - - - OpenERP Web Test Suite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - From fe3d493cc84583fbdd8da4917f9199fdef751dc0 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 29 Nov 2012 12:24:13 +0100 Subject: [PATCH 2/5] [FIX] searches with filters using "empty" domain/context values (but not attributes) e.g. @domain="[]" would be seen as non-empty by the search view, and if multiple domains the search view would generate a nonliteral ``['|', '[]', '[]]`` which would just yield ``['|']`` after evaluation and concatenation, which is an invalid domain and would blow up the server. Specifically filter out the values ``[]`` and ``{}`` from filters bzr revid: xmo@openerp.com-20121129112413-yrgncnesqs093jwf --- addons/web/static/src/js/search.js | 3 +++ addons/web/static/test/search.js | 36 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 5b59c7d6912..3917f342391 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1009,6 +1009,7 @@ instance.web.search.FilterGroup = instance.web.search.Input.extend(/** @lends in get_context: function (facet) { var contexts = facet.values.chain() .map(function (f) { return f.get('value').attrs.context; }) + .without('{}') .reject(_.isEmpty) .value(); @@ -1027,6 +1028,7 @@ instance.web.search.FilterGroup = instance.web.search.Input.extend(/** @lends in get_groupby: function (facet) { return facet.values.chain() .map(function (f) { return f.get('value').attrs.context; }) + .without('{}') .reject(_.isEmpty) .value(); }, @@ -1039,6 +1041,7 @@ instance.web.search.FilterGroup = instance.web.search.Input.extend(/** @lends in get_domain: function (facet) { var domains = facet.values.chain() .map(function (f) { return f.get('value').attrs.domain; }) + .without('[]') .reject(_.isEmpty) .value(); diff --git a/addons/web/static/test/search.js b/addons/web/static/test/search.js index 45f6d2c715b..db9e7aa3ed9 100644 --- a/addons/web/static/test/search.js +++ b/addons/web/static/test/search.js @@ -845,6 +845,42 @@ openerp.testing.section('search-serialization', { ok(!context.get_eval_context(), "context should have no evaluation context"); }); }); + test('Empty filter domains', {asserts: 4}, function (instance) { + var view = {inputs: [], query: {on: function () {}}}; + var filter_a = new instance.web.search.Filter( + {attrs: {name: 'a', context: '{}', domain: '[]'}}, view); + var filter_b = new instance.web.search.Filter( + {attrs: {name: 'b', context: '{}', domain: '[]'}}, view); + var filter_c = new instance.web.search.Filter( + {attrs: {name: 'c', context: '{b: 42}', domain: '[["a", "=", 3]]'}}, view); + var group = new instance.web.search.FilterGroup( + [filter_a, filter_b, filter_c], view); + var t1 = group.facet_for_defaults({a: true, c: true}) + .done(function (facet) { + var model = facet; + if (!(model instanceof instance.web.search.Facet)) { + model = new instance.web.search.Facet(facet); + } + + var domain = group.get_domain(model); + deepEqual(domain, '[["a", "=", 3]]', "domain should ignore empties"); + var context = group.get_context(model); + deepEqual(context, '{b: 42}', "context should ignore empties"); + }); + var t2 = group.facet_for_defaults({a: true, b: true}) + .done(function (facet) { + var model = facet; + if (!(model instanceof instance.web.search.Facet)) { + model = new instance.web.search.Facet(facet); + } + + var domain = group.get_domain(model); + equal(domain, null, "domain should ignore empties"); + var context = group.get_context(model); + equal(context, null, "context should ignore empties"); + }); + return $.when(t1, t2); + }); }); openerp.testing.section('removal', { dependencies: ['web.search'], From 93eddbd4a8e60522c209761da08b7b4d200e7f00 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 29 Nov 2012 12:27:37 +0100 Subject: [PATCH 3/5] [IMP] fixes for kanban column visible in tasks & issues bzr revid: fp@tinyerp.com-20121129112737-w3h80e7nbxs0l5lp --- addons/project/project.py | 14 +++----------- addons/project_issue/project_issue.py | 8 +++----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 68122d1a614..c6577b00e6a 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -603,18 +603,13 @@ class task(base_stage, osv.osv): stage_obj = self.pool.get('project.task.type') order = stage_obj._order access_rights_uid = access_rights_uid or uid - # lame way to allow reverting search, should just work in the trivial case if read_group_order == 'stage_id desc': order = '%s desc' % order - # retrieve section_id from the context and write the domain - # - ('id', 'in', 'ids'): add columns that should be present - # - OR ('case_default', '=', True), ('fold', '=', False): add default columns that are not folded - # - OR ('project_ids', 'in', project_id), ('fold', '=', False) if project_id: add project columns that are not folded search_domain = [] project_id = self._resolve_project_id_from_context(cr, uid, context=context) if project_id: search_domain += ['|', ('project_ids', '=', project_id)] - search_domain += ['|', ('id', 'in', ids), ('case_default', '=', True)] + search_domain += [('id', 'in', ids)] stage_ids = stage_obj._search(cr, uid, search_domain, order=order, access_rights_uid=access_rights_uid, context=context) result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context) # restore order of the search @@ -750,7 +745,7 @@ class task(base_stage, osv.osv): 'priority': fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Important'), ('0','Very important')], 'Priority', select=True), 'sequence': fields.integer('Sequence', select=True, help="Gives the sequence order when displaying a list of tasks."), 'stage_id': fields.many2one('project.task.type', 'Stage', - domain="['&', ('fold', '=', False), '|', ('project_ids', '=', project_id), ('case_default', '=', True)]"), + domain="['&', ('fold', '=', False), ('project_ids', '=', project_id)]"), 'state': fields.related('stage_id', 'state', type="selection", store=True, selection=_TASK_STATE, string="Status", readonly=True, help='The status is set to \'Draft\', when a case is created.\ @@ -936,14 +931,11 @@ class task(base_stage, osv.osv): for task in cases: if task.project_id: section_ids.append(task.project_id.id) - # OR all section_ids and OR with case_default search_domain = [] if section_ids: - search_domain += [('|')] * len(section_ids) + search_domain = [('|')] * (len(section_ids)-1) for section_id in section_ids: search_domain.append(('project_ids', '=', section_id)) - search_domain.append(('case_default', '=', True)) - # AND with the domain in parameter search_domain += list(domain) # perform search, return the first found stage_ids = self.pool.get('project.task.type').search(cr, uid, search_domain, order=order, context=context) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 90640363906..fe5ce9f325b 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -89,7 +89,7 @@ class project_issue(base_stage, osv.osv): project_id = self._resolve_project_id_from_context(cr, uid, context=context) if project_id: search_domain += ['|', ('project_ids', '=', project_id)] - search_domain += ['|', ('id', 'in', ids), ('case_default', '=', True)] + search_domain += [('id', 'in', ids)] # perform search stage_ids = stage_obj._search(cr, uid, search_domain, order=order, access_rights_uid=access_rights_uid, context=context) result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context) @@ -244,7 +244,7 @@ class project_issue(base_stage, osv.osv): 'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority', select=True), 'version_id': fields.many2one('project.issue.version', 'Version'), 'stage_id': fields.many2one ('project.task.type', 'Stage', - domain="['&', ('fold', '=', False), '|', ('project_ids', '=', project_id), ('case_default', '=', True)]"), + domain="['&', ('fold', '=', False), ('project_ids', '=', project_id)]"), 'project_id':fields.many2one('project.project', 'Project'), 'duration': fields.float('Duration'), 'task_id': fields.many2one('project.task', 'Task', domain="[('project_id','=',project_id)]"), @@ -442,11 +442,9 @@ class project_issue(base_stage, osv.osv): # OR all section_ids and OR with case_default search_domain = [] if section_ids: - search_domain += [('|')] * len(section_ids) + search_domain += [('|')] * (len(section_ids)-1) for section_id in section_ids: search_domain.append(('project_ids', '=', section_id)) - search_domain.append(('case_default', '=', True)) - # AND with the domain in parameter search_domain += list(domain) # perform search, return the first found stage_ids = self.pool.get('project.task.type').search(cr, uid, search_domain, order=order, context=context) From 7bfab22e1f6699890d79512f2b7f8ac486fa52f0 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 29 Nov 2012 13:07:38 +0100 Subject: [PATCH 4/5] [FIX] Propagate context to kanban's add_group() action bzr revid: fme@openerp.com-20121129120738-fgulo5hqib2uqeqa --- addons/web_kanban/static/src/js/kanban.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 4e9157e1d75..4eabcf0533b 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -190,6 +190,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ views: [[false, 'form']], type: 'ir.actions.act_window', target: "new", + context: self.dataset.get_context(), flags: { action_buttons: true, } From bd61641572949ab2c9b1a07267cd7d7344d17a7d Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 29 Nov 2012 14:06:55 +0100 Subject: [PATCH 5/5] [FIX] project issue bzr revid: fp@tinyerp.com-20121129130655-rm5hrk8m7tsy8g4v --- addons/project/project.py | 6 ++++++ addons/project/project_demo.xml | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index c6577b00e6a..b7c88f3532b 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -49,11 +49,17 @@ class project_task_type(osv.osv): 'fold': fields.boolean('Hide in views if empty', help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."), } + def _get_default_project_id(self, cr, uid, ctx={}): + proj = ctx.get('default_project_id', False) + if type(proj) is int: + return [proj] + return proj _defaults = { 'sequence': 1, 'state': 'open', 'fold': False, 'case_default': True, + 'project_ids': _get_default_project_id } _order = 'sequence' diff --git a/addons/project/project_demo.xml b/addons/project/project_demo.xml index ee887c2728c..d2bf7d0a2df 100644 --- a/addons/project/project_demo.xml +++ b/addons/project/project_demo.xml @@ -36,6 +36,10 @@ Implement new website for Sale and Warehouse Management for a customer. project.task + + + + @@ -45,6 +49,10 @@ public project.task + + + + @@ -58,6 +66,9 @@ + + + @@ -67,24 +78,30 @@ Website Design Templates project.task - + + + + 2 Data Import/Export Plugin project.task - + + + +