From 3e797902fcfb664dc2695e2b09aae9c81a6930ed Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 14 Aug 2012 14:03:35 +0200 Subject: [PATCH 01/32] [FIX] /login route bzr revid: chs@openerp.com-20120814120335-6lc0u21r0mhd9bl2 --- addons/web/common/http.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/web/common/http.py b/addons/web/common/http.py index 6c71e4696b5..93c8af711b3 100644 --- a/addons/web/common/http.py +++ b/addons/web/common/http.py @@ -568,6 +568,8 @@ class Root(object): _logger.debug("Dispatching to %s %s %s", ps, c, meth) return m ps, _slash, meth = ps.rpartition('/') + if not ps and meth: + ps = '/' return None class LibException(Exception): From 076fdb09940c57c385c3b3f7639bb893464afb69 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 14 Aug 2012 18:38:21 +0530 Subject: [PATCH 02/32] [IMP] views should show the button create/edit/delete/duplicate on the view tag create/edit/delete attributes bzr revid: jam@tinyerp.com-20120814130821-ret2z62dsthle39p --- addons/web/static/src/js/view_form.js | 15 +++++++++++++-- addons/web/static/src/js/view_list.js | 11 +++++++++-- addons/web/static/src/xml/base.xml | 18 ++++++++++++------ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index baf8c151b83..2e800191749 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -148,9 +148,17 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM if(this.fields_view.toolbar) { this.sidebar.add_toolbar(this.fields_view.toolbar); } + if (self._is_action_enabled('delete')){ + this.sidebar.add_items('other', [ + { label: _t('Delete'), callback: self.on_button_delete }, + ]); + } + if (self._is_action_enabled('create')){ + this.sidebar.add_items('other', [ + { label: _t('Duplicate'), callback: self.on_button_duplicate } + ]); + } this.sidebar.add_items('other', [ - { label: _t('Delete'), callback: self.on_button_delete }, - { label: _t('Duplicate'), callback: self.on_button_duplicate }, { label: _t('Set Default'), callback: function (item) { self.open_defaults_dialog(); } } ]); } @@ -1042,6 +1050,9 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM open_translate_dialog: function(field) { return this._super(field); }, + _is_action_enabled: function(action) { + return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; + } }); /** diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 986b0e49faf..3d6ec27d065 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -353,9 +353,13 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.sidebar.appendTo(this.options.$sidebar); this.sidebar.add_items('other', [ { label: _t("Import"), callback: this.on_sidebar_import }, - { label: _t("Export"), callback: this.on_sidebar_export }, - { label: _t('Delete'), callback: this.do_delete_selected } + { label: _t("Export"), callback: this.on_sidebar_export } ]); + if (self._is_action_enabled('delete')){ + this.sidebar.add_items('other', [ + { label: _t('Delete'), callback: this.do_delete_selected } + ]); + } this.sidebar.add_toolbar(this.fields_view.toolbar); this.sidebar.$element.hide(); } @@ -831,6 +835,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.$element.prepend( $('
').html(this.options.action.help) ); + }, + _is_action_enabled: function(action) { + return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; } }); instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.ListView.List# */{ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 0eddd914f01..21d006e23ab 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -672,9 +672,11 @@
- + + + or Import @@ -747,10 +749,14 @@
-
- -
+ +
+ +
+
+ +
or Discard From 9c04845999c0c7176077781650332beb673e7a70 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 14 Aug 2012 19:02:42 +0530 Subject: [PATCH 03/32] [IMP] Addded the common view attrib check method for the access ui support bzr revid: jam@tinyerp.com-20120814133242-y7ofa6oy59gj0uj4 --- addons/web/static/src/js/view_form.js | 3 --- addons/web/static/src/js/view_list.js | 3 --- addons/web/static/src/js/views.js | 8 ++++++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 2e800191749..239460bbcb4 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1050,9 +1050,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM open_translate_dialog: function(field) { return this._super(field); }, - _is_action_enabled: function(action) { - return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; - } }); /** diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 3d6ec27d065..f420001669b 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -835,9 +835,6 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.$element.prepend( $('
').html(this.options.action.help) ); - }, - _is_action_enabled: function(action) { - return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; } }); instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.ListView.List# */{ diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 7c9dfe1d543..0fdd49633b1 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1357,6 +1357,14 @@ instance.web.View = instance.web.Widget.extend({ */ reload: function () { return $.when(); + }, + _is_action_enabled: function(action) { + /** + * Takes action (e.g. create/edit/delete) and return the tag attribute from + * the view (e.g. ) + * will help to check access ui of the view. + */ + return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; } }); From cf464eb2733efc5a872451c08208410a45bd1b79 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 16 Aug 2012 10:03:10 +0530 Subject: [PATCH 04/32] [FIX] kanban : Keep is_action_enable consistant as per previous commit bzr revid: jam@tinyerp.com-20120816043310-b0sbicnv73jgzhti --- addons/web_kanban/static/src/js/kanban.js | 6 +++--- addons/web_kanban/static/src/xml/web_kanban.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 6c70ecfb8ec..155f03b8aae 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -68,11 +68,11 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ return JSON.parse(this.fields_view.arch.attrs.quick_create); return !! this.group_by; }, - _is_create_enabled: function() { + _is_action_enabled: function(action) { if (! this.options.creatable) return false; - if (this.fields_view.arch.attrs.create !== undefined) - return JSON.parse(this.fields_view.arch.attrs.create); + if (_.has(this.fields_view.arch.attrs, action)) + return JSON.parse(this.fields_view.arch.attrs[action]); return true; }, add_qweb_template: function() { diff --git a/addons/web_kanban/static/src/xml/web_kanban.xml b/addons/web_kanban/static/src/xml/web_kanban.xml index 4bcc9a709a3..7aba4d6ee87 100644 --- a/addons/web_kanban/static/src/xml/web_kanban.xml +++ b/addons/web_kanban/static/src/xml/web_kanban.xml @@ -14,7 +14,7 @@
- + From a1182d97ed749ddf175d1c6f9f88ca3dc8ebdb1b Mon Sep 17 00:00:00 2001 From: "Twinkle Christian (OpenERP)" Date: Thu, 16 Aug 2012 15:11:23 +0530 Subject: [PATCH 05/32] [IMP]Remove or bzr revid: tch@tinyerp.com-20120816094123-f1yiealw1p59j95n --- addons/web/static/src/xml/base.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 1728bfb584b..96adbd42d2e 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -678,7 +678,7 @@ - or Import + Import
From 4c9205ff4aa8590ec49cc9131e312c6158a8819c Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 16 Aug 2012 15:57:58 +0530 Subject: [PATCH 06/32] [IMP] Kanan quick create action should also repect the create tag on view bzr revid: jam@tinyerp.com-20120816102758-2swimfa9dxu3uotv --- addons/web_kanban/static/src/js/kanban.js | 7 ++++++- addons/web_kanban/static/src/xml/web_kanban.xml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 155f03b8aae..27b3184977c 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -514,7 +514,12 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({ self.view.dataset.ids.push(id); self.do_add_records(records, true); }); - } + }, + _is_action_enabled: function(action) { + if (_.has(this.fields_view.arch.attrs, action)) + return JSON.parse(this.fields_view.arch.attrs[action]); + return true; + } }); instance.web_kanban.KanbanRecord = instance.web.Widget.extend({ diff --git a/addons/web_kanban/static/src/xml/web_kanban.xml b/addons/web_kanban/static/src/xml/web_kanban.xml index 7aba4d6ee87..7e316a2b47e 100644 --- a/addons/web_kanban/static/src/xml/web_kanban.xml +++ b/addons/web_kanban/static/src/xml/web_kanban.xml @@ -25,7 +25,7 @@
- +
]
From d42261907c2bb2f2e3c690b2d88720e6b7ecc838 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 16 Aug 2012 16:32:43 +0530 Subject: [PATCH 07/32] [FIX] Gantt View Create button Shouls repect the view create teg bzr revid: jam@tinyerp.com-20120816110243-blbjzmb2xdemoupg --- addons/web_gantt/static/src/js/gantt.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 202fb2aecc6..05488fcdca9 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -183,12 +183,14 @@ instance.web_gantt.GanttView = instance.web.View.extend({ self.on_task_display(task_info.internal_task); } }); - - // insertion of create button - var td = $($("table td", self.$element)[0]); - var rendered = QWeb.render("GanttView-create-button"); - $(rendered).prependTo(td); - $(".oe_gantt_button_create", this.$element).click(this.on_task_create); + + // insertion of create button if gantt has crate false do not render create button + if (this._is_action_enabled('create')){ + var td = $($("table td", self.$element)[0]); + var rendered = QWeb.render("GanttView-create-button"); + $(rendered).prependTo(td); + $(".oe_gantt_button_create", this.$element).click(this.on_task_create); + } }, on_task_changed: function(task_obj) { var self = this; From 9ec6f82e382984c9e0fc415090d8c5c56892b6c4 Mon Sep 17 00:00:00 2001 From: "Twinkle Christian (OpenERP)" Date: Thu, 16 Aug 2012 16:59:20 +0530 Subject: [PATCH 08/32] [IMP]Remove or bzr revid: tch@tinyerp.com-20120816112920-i4gnwzn7z7n3v0gs --- addons/web/static/src/xml/base.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 96adbd42d2e..614c2a91d79 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -678,7 +678,7 @@ - Import + or Import
From 41964c4b9d9b53358b3fc01700bd2306f13916c6 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 16 Aug 2012 18:30:12 +0530 Subject: [PATCH 09/32] [IMP] View Button Constrains: Diagrem view add node button, kanban record slidebar widget mnethod support bzr revid: jam@tinyerp.com-20120816130012-ibtv0ipbbnpznqb1 --- addons/web_diagram/static/src/js/diagram.js | 2 +- addons/web_diagram/static/src/xml/base_diagram.xml | 8 +++++--- addons/web_kanban/static/src/js/kanban.js | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/web_diagram/static/src/js/diagram.js b/addons/web_diagram/static/src/js/diagram.js index f06e757f7f1..02216052c69 100644 --- a/addons/web_diagram/static/src/js/diagram.js +++ b/addons/web_diagram/static/src/js/diagram.js @@ -44,7 +44,7 @@ instance.web.DiagramView = instance.web.View.extend({ this.node = this.nodes.attrs.object, this.connector = this.connectors.attrs.object; - this.$element.html(QWeb.render("DiagramView", this)); + this.$element.html(QWeb.render("DiagramView", {'widget':self})); this.$element.addClass(this.fields_view.arch.attrs['class']); this.$element.find('div.oe_diagram_pager button[data-pager-action]').click(function() { diff --git a/addons/web_diagram/static/src/xml/base_diagram.xml b/addons/web_diagram/static/src/xml/base_diagram.xml index 96e32f59648..f883f949457 100644 --- a/addons/web_diagram/static/src/xml/base_diagram.xml +++ b/addons/web_diagram/static/src/xml/base_diagram.xml @@ -2,9 +2,11 @@

-
- -
+ +
+ +
+
0 / 0 diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 27b3184977c..84a0a76ba0d 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -785,6 +785,9 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({ }, kanban_compute_domain: function(domain) { return instance.web.form.compute_domain(domain, this.values); + }, + _is_action_enabled: function(action) { + return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; } }); From 0f364e1acd876183e5957db99e73d6869b684d08 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Mon, 20 Aug 2012 16:10:55 +0530 Subject: [PATCH 10/32] [IMP] removed Import action if create = false bzr revid: jam@tinyerp.com-20120820104055-mgw4y5csa31poa33 --- addons/web/static/src/js/view_list.js | 6 +++++- addons/web/static/src/xml/base.xml | 12 +++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index fa6f48b37fa..bf8ee05d925 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -351,8 +351,12 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi if (!this.sidebar && this.options.$sidebar) { this.sidebar = new instance.web.Sidebar(this); this.sidebar.appendTo(this.options.$sidebar); + if (self._is_action_enabled('create')){ + this.sidebar.add_items('other', [ + { label: _t("Import"), callback: this.on_sidebar_import } + ]); + } this.sidebar.add_items('other', [ - { label: _t("Import"), callback: this.on_sidebar_import }, { label: _t("Export"), callback: this.on_sidebar_export } ]); if (self._is_action_enabled('delete')){ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 2d86b40f44f..61a1a834d0d 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -671,14 +671,12 @@
- - - - + + - or Import + or Import
From c1b7de054cbc59fa93f367d46ab31e31eb794801 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Mon, 20 Aug 2012 17:50:20 +0530 Subject: [PATCH 11/32] [IMP] Kanban type action edit and delete on edit and delete falase bzr revid: jam@tinyerp.com-20120820122020-8tszb43bivfgq72v --- addons/web_kanban/static/src/js/kanban.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 154df0f8b6b..96f28dff196 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -734,7 +734,9 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({ var $action = $(this), type = $action.data('type') || 'button', method = 'do_action_' + (type === 'action' ? 'object' : type); - if (_.str.startsWith(type, 'switch_')) { + if ((type === 'edit' || type === 'delete') && ! self.view._is_action_enabled(type)){ + self.view.open_record(self.id); + } else if (_.str.startsWith(type, 'switch_')) { self.view.do_switch_view(type.substr(7)); } else if (typeof self[method] === 'function') { self[method]($action); From 09f031cd99d41dd3ef8e89439d575e5aac8f10ed Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 21 Aug 2012 12:47:02 +0530 Subject: [PATCH 12/32] [IMP] If edit = false and trww views Editable shoue not allow edit column instead redirect normal behaviour bzr revid: jam@tinyerp.com-20120821071702-pknuv44poe1hvlfx --- addons/web/static/src/js/view_list_editable.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 9a101a5ac1a..74dba11394f 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -750,7 +750,8 @@ openerp.web.list_editable = function (instance) { instance.web.ListView.List.include(/** @lends instance.web.ListView.List# */{ row_clicked: function (event) { - if (!this.view.editable()) { + + if (!this.view.editable() || ! this.view._is_action_enabled('edit')) { return this._super.apply(this, arguments); } var record_id = $(event.currentTarget).data('id'); From a02de882a2f711414c64213ef0382c5bada5fbf5 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 21 Aug 2012 12:48:42 +0530 Subject: [PATCH 13/32] [USA] Reomved the unxpected lines bzr revid: jam@tinyerp.com-20120821071842-srbnqutwfia8m5cb --- addons/web/static/src/js/view_list_editable.js | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 74dba11394f..cea51b38833 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -750,7 +750,6 @@ openerp.web.list_editable = function (instance) { instance.web.ListView.List.include(/** @lends instance.web.ListView.List# */{ row_clicked: function (event) { - if (!this.view.editable() || ! this.view._is_action_enabled('edit')) { return this._super.apply(this, arguments); } From ec67f4444772c18872d72f975259caf71f84a706 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 23 Aug 2012 17:01:15 +0530 Subject: [PATCH 14/32] [FIX] The trash can icons (on the right of lines) should be hidden when delete=false in the corresponding tree view bzr revid: jam@tinyerp.com-20120823113115-7rc1skcdy6pekqq3 --- addons/web/static/src/xml/base.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 05d921bc679..fe02ee5ff93 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -657,7 +657,7 @@ - + @@ -666,7 +666,7 @@ - + @@ -713,7 +713,7 @@ t-att-data-field="column.id" > - + From 51df98c72ad95edb466cc3a773c59dfc9155071b Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 23 Aug 2012 17:15:57 +0530 Subject: [PATCH 15/32] [FIX] the link 'Add a row' should be hidden when create='false' in the corresponding tree view bzr revid: jam@tinyerp.com-20120823114557-ibid3ob03k864o06 --- addons/web/static/src/js/view_form.js | 60 ++++++++++++++------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 069c1840611..97e4b976c04 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3578,36 +3578,38 @@ instance.web.form.One2ManyList = instance.web.ListView.List.extend({ }).length; if (this.options.selectable) { columns++; } if (this.options.deletable) { columns++; } - var $cell = $('', { - colspan: columns, - 'class': 'oe_form_field_one2many_list_row_add' - }).append( - $('', {href: '#'}).text(_t("Add a row")) - .mousedown(function () { - // FIXME: needs to be an official API somehow - if (self.view.editor.is_editing()) { - self.view.__ignore_blur = true; - } - }) - .click(function (e) { - e.preventDefault(); - e.stopPropagation(); - // FIXME: there should also be an API for that one - if (self.view.editor.form.__blur_timeout) { - clearTimeout(self.view.editor.form.__blur_timeout); - self.view.editor.form.__blur_timeout = false; - } - self.view.ensure_saved().then(function () { - self.view.do_add_record(); - }); - })); + if (this.view._is_action_enabled('create')){ + var $cell = $('', { + colspan: columns, + 'class': 'oe_form_field_one2many_list_row_add' + }).append( + $('', {href: '#'}).text(_t("Add a row")) + .mousedown(function () { + // FIXME: needs to be an official API somehow + if (self.view.editor.is_editing()) { + self.view.__ignore_blur = true; + } + }) + .click(function (e) { + e.preventDefault(); + e.stopPropagation(); + // FIXME: there should also be an API for that one + if (self.view.editor.form.__blur_timeout) { + clearTimeout(self.view.editor.form.__blur_timeout); + self.view.editor.form.__blur_timeout = false; + } + self.view.ensure_saved().then(function () { + self.view.do_add_record(); + }); + })); - var $padding = this.$current.find('tr:not([data-id]):first'); - var $newrow = $('').append($cell); - if ($padding.length) { - $padding.before($newrow); - } else { - this.$current.append($newrow) + var $padding = this.$current.find('tr:not([data-id]):first'); + var $newrow = $('').append($cell); + if ($padding.length) { + $padding.before($newrow); + } else { + this.$current.append($newrow) + } } } }); From 12f01f09a12548e7f984449d46206864eebed409 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 24 Aug 2012 11:04:59 +0530 Subject: [PATCH 16/32] [IMP] 1] if create='false' no extra row in a editable embeded list. 2] If edit='false' o2mfrom pop should be on readony mode bzr revid: jam@tinyerp.com-20120824053459-91ejrex8ox4hfptz --- addons/web/static/src/js/view_form.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 97e4b976c04..e91d343a618 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3461,7 +3461,8 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ } }, do_activate_record: function(index, id) { - var self = this; + var self = this, + attr_readonly = (_.has(this.fields_view.arch.attrs, 'edit'))?JSON.parse(this.fields_view.arch.attrs.edit):true; var pop = new instance.web.form.FormOpenPopup(self.o2m.view); pop.show_element(self.o2m.field.relation, id, self.o2m.build_context(), { title: _t("Open: ") + self.o2m.string, @@ -3477,7 +3478,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ return self.o2m.dataset.read_ids.apply(self.o2m.dataset, arguments); }, form_view_options: {'not_interactible_on_create':true}, - readonly: self.o2m.get("effective_readonly") + readonly: attr_readonly ? self.o2m.get("effective_readonly") : true, }); }, do_button_action: function (name, id, callback) { @@ -3565,7 +3566,11 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ }); instance.web.form.One2ManyList = instance.web.ListView.List.extend({ pad_table_to: function (count) { - this._super(count > 0 ? count - 1 : 0); + count = count > 0 ? count - 1 : 0 + if (! this.view._is_action_enabled('create')){ + count = this.records.length + } + this._super(count); // magical invocation of wtf does that do if (this.view.o2m.get('effective_readonly')) { From 813db083ff7844d2ffcdcb8a2ad5bedf3a0bfaf4 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 24 Aug 2012 11:15:47 +0530 Subject: [PATCH 17/32] [REF] refectroed the row count code bzr revid: jam@tinyerp.com-20120824054547-v3me14ca341rkj44 --- addons/web/static/src/js/view_form.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index e91d343a618..de7b737ad34 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3566,11 +3566,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ }); instance.web.form.One2ManyList = instance.web.ListView.List.extend({ pad_table_to: function (count) { - count = count > 0 ? count - 1 : 0 - if (! this.view._is_action_enabled('create')){ - count = this.records.length - } - this._super(count); + this._super(this.view._is_action_enabled('create') ? (count > 0 ? count - 1 : 0) : this.records.length); // magical invocation of wtf does that do if (this.view.o2m.get('effective_readonly')) { From e79baa9e8a5759a3626c15dba76b1f03d8ecd098 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Mon, 27 Aug 2012 10:31:51 +0530 Subject: [PATCH 18/32] [FIX] resolve Conflicts reverts bzr revid: jam@tinyerp.com-20120827050151-yinbjtladoe3vu5w --- addons/web_diagram/static/src/js/diagram.js | 2 +- addons/web_diagram/static/src/xml/base_diagram.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web_diagram/static/src/js/diagram.js b/addons/web_diagram/static/src/js/diagram.js index 657e68d6f06..543cc6a9c12 100644 --- a/addons/web_diagram/static/src/js/diagram.js +++ b/addons/web_diagram/static/src/js/diagram.js @@ -47,7 +47,7 @@ instance.web.DiagramView = instance.web.View.extend({ return label.tag == "label"; }); - this.$el.html(QWeb.render("DiagramView", this)); + this.$el.html(QWeb.render("DiagramView", {'widget': this})); this.$el.addClass(this.fields_view.arch.attrs['class']); _.each(self.labels,function(label){ diff --git a/addons/web_diagram/static/src/xml/base_diagram.xml b/addons/web_diagram/static/src/xml/base_diagram.xml index b6065093231..f883f949457 100644 --- a/addons/web_diagram/static/src/xml/base_diagram.xml +++ b/addons/web_diagram/static/src/xml/base_diagram.xml @@ -2,7 +2,7 @@

- +
From 3e5c6a4d95f1957bcc64f43603228f8e744cfc87 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 31 Aug 2012 17:37:58 +0200 Subject: [PATCH 19/32] [IMP] fix code spacing and indentation bzr revid: rco@openerp.com-20120831153758-3l46jbvtifix5s9v --- addons/web/static/src/js/view_form.js | 14 +++++++------- addons/web/static/src/js/view_list.js | 4 ++-- addons/web/static/src/js/views.js | 10 +++++----- addons/web_diagram/static/src/xml/base_diagram.xml | 10 +++++----- addons/web_gantt/static/src/js/gantt.js | 2 +- addons/web_kanban/static/src/js/kanban.js | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 2e577e740f8..a38a71d638c 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -145,15 +145,15 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM if (!this.sidebar && this.options.$sidebar) { this.sidebar = new instance.web.Sidebar(this); this.sidebar.appendTo(this.$sidebar); - if(this.fields_view.toolbar) { + if (this.fields_view.toolbar) { this.sidebar.add_toolbar(this.fields_view.toolbar); } - if (self._is_action_enabled('delete')){ + if (self._is_action_enabled('delete')) { this.sidebar.add_items('other', [ - { label: _t('Delete'), callback: self.on_button_delete }, + { label: _t('Delete'), callback: self.on_button_delete } ]); } - if (self._is_action_enabled('create')){ + if (self._is_action_enabled('create')) { this.sidebar.add_items('other', [ { label: _t('Duplicate'), callback: self.on_button_duplicate } ]); @@ -3469,8 +3469,8 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ } }, do_activate_record: function(index, id) { - var self = this, - attr_readonly = (_.has(this.fields_view.arch.attrs, 'edit'))?JSON.parse(this.fields_view.arch.attrs.edit):true; + var self = this; + var attr_readonly = (_.has(this.fields_view.arch.attrs, 'edit')) ? JSON.parse(this.fields_view.arch.attrs.edit) : true; var pop = new instance.web.form.FormOpenPopup(self.o2m.view); pop.show_element(self.o2m.field.relation, id, self.o2m.build_context(), { title: _t("Open: ") + self.o2m.string, @@ -3587,7 +3587,7 @@ instance.web.form.One2ManyList = instance.web.ListView.List.extend({ }).length; if (this.options.selectable) { columns++; } if (this.options.deletable) { columns++; } - if (this.view._is_action_enabled('create')){ + if (this.view._is_action_enabled('create')) { var $cell = $('', { colspan: columns, 'class': 'oe_form_field_one2many_list_row_add' diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index a0e903c7205..e3006a31757 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -351,7 +351,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi if (!this.sidebar && this.options.$sidebar) { this.sidebar = new instance.web.Sidebar(this); this.sidebar.appendTo(this.options.$sidebar); - if (self._is_action_enabled('create')){ + if (self._is_action_enabled('create')) { this.sidebar.add_items('other', [ { label: _t("Import"), callback: this.on_sidebar_import } ]); @@ -359,7 +359,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.sidebar.add_items('other', [ { label: _t("Export"), callback: this.on_sidebar_export } ]); - if (self._is_action_enabled('delete')){ + if (self._is_action_enabled('delete')) { this.sidebar.add_items('other', [ { label: _t('Delete'), callback: this.do_delete_selected } ]); diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 6ec579e59e4..183b63a218e 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1358,13 +1358,13 @@ instance.web.View = instance.web.Widget.extend({ reload: function () { return $.when(); }, - _is_action_enabled: function(action) { /** - * Takes action (e.g. create/edit/delete) and return the tag attribute from - * the view (e.g. ) - * will help to check access ui of the view. + * Return whether the user can perform the action ('create', 'edit', 'delete') in this view. + * An action is disabled by setting the corresponding attribute in the view's main element, + * like:
*/ - return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; + _is_action_enabled: function(action) { + return (_.has(this.fields_view.arch.attrs, action)) ? JSON.parse(this.fields_view.arch.attrs[action]) : true; } }); diff --git a/addons/web_diagram/static/src/xml/base_diagram.xml b/addons/web_diagram/static/src/xml/base_diagram.xml index f883f949457..619ebb241f4 100644 --- a/addons/web_diagram/static/src/xml/base_diagram.xml +++ b/addons/web_diagram/static/src/xml/base_diagram.xml @@ -2,11 +2,11 @@

- -
- -
-
+ +
+ +
+
0 / 0 diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 4d678810980..44adbc41b10 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -183,7 +183,7 @@ instance.web_gantt.GanttView = instance.web.View.extend({ self.on_task_display(task_info.internal_task); } }); - if (this._is_action_enabled('create')){ + if (this._is_action_enabled('create')) { // insertion of create button var td = $($("table td", self.$el)[0]); var rendered = QWeb.render("GanttView-create-button"); diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 1b1442faf6d..f599342541c 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -742,7 +742,7 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({ var $action = $(this), type = $action.data('type') || 'button', method = 'do_action_' + (type === 'action' ? 'object' : type); - if ((type === 'edit' || type === 'delete') && ! self.view._is_action_enabled(type)){ + if ((type === 'edit' || type === 'delete') && ! self.view._is_action_enabled(type)) { self.view.open_record(self.id); } else if (_.str.startsWith(type, 'switch_')) { self.view.do_switch_view(type.substr(7)); @@ -916,7 +916,7 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({ return instance.web.form.compute_domain(domain, this.values); }, _is_action_enabled: function(action) { - return (_.has(this.fields_view.arch.attrs, action))?JSON.parse(this.fields_view.arch.attrs[action]):true; + return (_.has(this.fields_view.arch.attrs, action)) ? JSON.parse(this.fields_view.arch.attrs[action]) : true; } }); From 01887ce1f3ca1778d192d8a56e17679582a17f9c Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 3 Sep 2012 09:07:25 +0200 Subject: [PATCH 20/32] [FIX] in One2ManyListView, use method _is_action_enabled() instead of specific code bzr revid: rco@openerp.com-20120903070725-qpwseju4ryuh9bc2 --- addons/web/static/src/js/view_form.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a38a71d638c..cca3d410a50 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3470,7 +3470,6 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ }, do_activate_record: function(index, id) { var self = this; - var attr_readonly = (_.has(this.fields_view.arch.attrs, 'edit')) ? JSON.parse(this.fields_view.arch.attrs.edit) : true; var pop = new instance.web.form.FormOpenPopup(self.o2m.view); pop.show_element(self.o2m.field.relation, id, self.o2m.build_context(), { title: _t("Open: ") + self.o2m.string, @@ -3486,7 +3485,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ return self.o2m.dataset.read_ids.apply(self.o2m.dataset, arguments); }, form_view_options: {'not_interactible_on_create':true}, - readonly: attr_readonly ? self.o2m.get("effective_readonly") : true, + readonly: !this._is_action_enabled('edit') || self.o2m.get("effective_readonly") }); }, do_button_action: function (name, id, callback) { From 00b8441f0a71547586499ab517fe8c4ce476a488 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 3 Sep 2012 09:24:39 +0200 Subject: [PATCH 21/32] [IMP] web_kanban: use proper inheritance for method _is_action_enabled bzr revid: rco@openerp.com-20120903072439-yh0ncl8nbxcg47um --- addons/web_kanban/static/src/js/kanban.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index f599342541c..6efd8593deb 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -72,11 +72,9 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ return !! this.group_by; }, _is_action_enabled: function(action) { - if (! this.options.creatable) + if (action === 'create' && !this.options.creatable) return false; - if (_.has(this.fields_view.arch.attrs, action)) - return JSON.parse(this.fields_view.arch.attrs[action]); - return true; + return this._super(action); }, add_qweb_template: function() { for (var i=0, ii=this.fields_view.arch.children.length; i < ii; i++) { @@ -637,9 +635,7 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({ }); }, _is_action_enabled: function(action) { - if (_.has(this.fields_view.arch.attrs, action)) - return JSON.parse(this.fields_view.arch.attrs[action]); - return true; + return (_.has(this.fields_view.arch.attrs, action)) ? JSON.parse(this.fields_view.arch.attrs[action]) : true; } }); From b203377994ff51231a632f5b940c14482b9c3206 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 4 Sep 2012 09:41:45 +0200 Subject: [PATCH 22/32] [IMP] in list views: hide drag-n-drop handle and trash can with css classes bzr revid: rco@openerp.com-20120904074145-5mefinpkz0pl0qyb --- addons/web/static/src/css/base.css | 9 +++++++-- addons/web/static/src/css/base.sass | 7 +++++++ addons/web/static/src/js/view_list.js | 12 ++++++++++++ addons/web/static/src/xml/base.xml | 6 +++--- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 06a37a54727..d32b0a9f42a 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -69,7 +69,6 @@ display: none !important; } } - .openerp.openerp_webclient_container { height: 100%; position: relative; @@ -85,7 +84,7 @@ text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5); /* http://www.quirksmode.org/dom/inputfile.html * http://stackoverflow.com/questions/2855589/replace-input-type-file-by-an-image - */ */ + */ } .openerp :-moz-placeholder { color: #afafb6 !important; @@ -2638,6 +2637,12 @@ content: "ö"; color: #404040; } +.openerp .oe_list_cannot_edit .oe_list_header_handle, .openerp .oe_list_cannot_edit .oe_list_field_handle { + display: none !important; +} +.openerp .oe_list_cannot_delete .oe_list_header_delete, .openerp .oe_list_cannot_delete .oe_list_record_delete { + display: none !important; +} .openerp .tree_header { background-color: #f0f0f0; border-bottom: 1px solid #cacaca; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index c238ef6ee07..8ddf9b56b9f 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -2050,6 +2050,13 @@ $sheet-max-width: 860px .oe_list_handle @include text-to-icon("ö") + .oe_list_cannot_edit + .oe_list_header_handle, .oe_list_field_handle + display: none !important + .oe_list_cannot_delete + .oe_list_header_delete, .oe_list_record_delete + display: none !important + // }}} // Tree view {{{ .tree_header diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index e3006a31757..06d2548339c 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -250,6 +250,18 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.$el.html(QWeb.render(this._template, this)); this.$el.addClass(this.fields_view.arch.attrs['class']); + + // add css classes that reflect the (absence of) access rights + if (!this._is_action_enabled('create')) { + this.$el.addClass('oe_list_cannot_create'); + } + if (!this._is_action_enabled('edit')) { + this.$el.addClass('oe_list_cannot_edit'); + } + if (!this._is_action_enabled('delete')) { + this.$el.addClass('oe_list_cannot_delete'); + } + // Head hook // Selecting records this.$el.find('.oe_list_record_selector').click(function(){ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 3bee6eebcc5..7c135ad047c 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -635,7 +635,7 @@ - + @@ -644,7 +644,7 @@ - + @@ -691,7 +691,7 @@ t-att-data-field="column.id" > - + From 8b98de00e43b2ba0a3df676f0362a9d3d342092b Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 4 Sep 2012 09:49:21 +0200 Subject: [PATCH 23/32] [IMP] simplification in list views: merge two css classes bzr revid: rco@openerp.com-20120904074921-ff9pkr64g58ku9n3 --- addons/web/static/src/css/base.css | 2 +- addons/web/static/src/css/base.sass | 2 +- addons/web/static/src/xml/base.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index d32b0a9f42a..bbee2adfbc4 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -2640,7 +2640,7 @@ .openerp .oe_list_cannot_edit .oe_list_header_handle, .openerp .oe_list_cannot_edit .oe_list_field_handle { display: none !important; } -.openerp .oe_list_cannot_delete .oe_list_header_delete, .openerp .oe_list_cannot_delete .oe_list_record_delete { +.openerp .oe_list_cannot_delete .oe_list_record_delete { display: none !important; } .openerp .tree_header { diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 8ddf9b56b9f..63c6f3398fa 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -2054,7 +2054,7 @@ $sheet-max-width: 860px .oe_list_header_handle, .oe_list_field_handle display: none !important .oe_list_cannot_delete - .oe_list_header_delete, .oe_list_record_delete + .oe_list_record_delete display: none !important // }}} diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 7c135ad047c..a92eacc0710 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -635,7 +635,7 @@ - + From a0704feafd897d1f7e408464e09d1ea255850209 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 4 Sep 2012 10:03:02 +0200 Subject: [PATCH 24/32] [FIX] web_kanban: remove unexpected css class bzr revid: rco@openerp.com-20120904080302-dcxytj3tkin6fdt3 --- addons/web_kanban/static/src/xml/web_kanban.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_kanban/static/src/xml/web_kanban.xml b/addons/web_kanban/static/src/xml/web_kanban.xml index d3ed0fed129..b2f9e757b43 100644 --- a/addons/web_kanban/static/src/xml/web_kanban.xml +++ b/addons/web_kanban/static/src/xml/web_kanban.xml @@ -28,7 +28,7 @@ -
+
]
From 440b8aabbd9ca0e1928d39207c6ed957fec613c8 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 4 Sep 2012 15:59:05 +0200 Subject: [PATCH 25/32] [IMP] web_kanban: remove inappropriate method _is_action_enabled bzr revid: rco@openerp.com-20120904135905-4f7lu2qk0p5qk8cs --- addons/web_kanban/static/src/js/kanban.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 6efd8593deb..143ff7d685b 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -633,9 +633,6 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({ self.view.dataset.ids.push(id); self.do_add_records(records, true); }); - }, - _is_action_enabled: function(action) { - return (_.has(this.fields_view.arch.attrs, action)) ? JSON.parse(this.fields_view.arch.attrs[action]) : true; } }); @@ -910,9 +907,6 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({ }, kanban_compute_domain: function(domain) { return instance.web.form.compute_domain(domain, this.values); - }, - _is_action_enabled: function(action) { - return (_.has(this.fields_view.arch.attrs, action)) ? JSON.parse(this.fields_view.arch.attrs[action]) : true; } }); From 14e87c09f3ecf5cefd9b6d6bcfc6b5efa35e7729 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 4 Sep 2012 16:11:55 +0200 Subject: [PATCH 26/32] [IMP] rename method _is_action_enabled to is_action_enabled bzr revid: rco@openerp.com-20120904141155-288vwhonbt07dfcs --- addons/web/static/src/js/view_form.js | 10 +++++----- addons/web/static/src/js/view_list.js | 10 +++++----- addons/web/static/src/js/view_list_editable.js | 2 +- addons/web/static/src/js/views.js | 2 +- addons/web/static/src/xml/base.xml | 6 +++--- addons/web_diagram/static/src/xml/base_diagram.xml | 2 +- addons/web_gantt/static/src/js/gantt.js | 2 +- addons/web_kanban/static/src/js/kanban.js | 4 ++-- addons/web_kanban/static/src/xml/web_kanban.xml | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index cca3d410a50..669126820e8 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -148,12 +148,12 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM if (this.fields_view.toolbar) { this.sidebar.add_toolbar(this.fields_view.toolbar); } - if (self._is_action_enabled('delete')) { + if (self.is_action_enabled('delete')) { this.sidebar.add_items('other', [ { label: _t('Delete'), callback: self.on_button_delete } ]); } - if (self._is_action_enabled('create')) { + if (self.is_action_enabled('create')) { this.sidebar.add_items('other', [ { label: _t('Duplicate'), callback: self.on_button_duplicate } ]); @@ -3485,7 +3485,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ return self.o2m.dataset.read_ids.apply(self.o2m.dataset, arguments); }, form_view_options: {'not_interactible_on_create':true}, - readonly: !this._is_action_enabled('edit') || self.o2m.get("effective_readonly") + readonly: !this.is_action_enabled('edit') || self.o2m.get("effective_readonly") }); }, do_button_action: function (name, id, callback) { @@ -3573,7 +3573,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ }); instance.web.form.One2ManyList = instance.web.ListView.List.extend({ pad_table_to: function (count) { - this._super(this.view._is_action_enabled('create') ? (count > 0 ? count - 1 : 0) : this.records.length); + this._super(this.view.is_action_enabled('create') ? (count > 0 ? count - 1 : 0) : this.records.length); // magical invocation of wtf does that do if (this.view.o2m.get('effective_readonly')) { @@ -3586,7 +3586,7 @@ instance.web.form.One2ManyList = instance.web.ListView.List.extend({ }).length; if (this.options.selectable) { columns++; } if (this.options.deletable) { columns++; } - if (this.view._is_action_enabled('create')) { + if (this.view.is_action_enabled('create')) { var $cell = $('', { colspan: columns, 'class': 'oe_form_field_one2many_list_row_add' diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 06d2548339c..da806f415cf 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -252,13 +252,13 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.$el.addClass(this.fields_view.arch.attrs['class']); // add css classes that reflect the (absence of) access rights - if (!this._is_action_enabled('create')) { + if (!this.is_action_enabled('create')) { this.$el.addClass('oe_list_cannot_create'); } - if (!this._is_action_enabled('edit')) { + if (!this.is_action_enabled('edit')) { this.$el.addClass('oe_list_cannot_edit'); } - if (!this._is_action_enabled('delete')) { + if (!this.is_action_enabled('delete')) { this.$el.addClass('oe_list_cannot_delete'); } @@ -363,7 +363,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi if (!this.sidebar && this.options.$sidebar) { this.sidebar = new instance.web.Sidebar(this); this.sidebar.appendTo(this.options.$sidebar); - if (self._is_action_enabled('create')) { + if (self.is_action_enabled('create')) { this.sidebar.add_items('other', [ { label: _t("Import"), callback: this.on_sidebar_import } ]); @@ -371,7 +371,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.sidebar.add_items('other', [ { label: _t("Export"), callback: this.on_sidebar_export } ]); - if (self._is_action_enabled('delete')) { + if (self.is_action_enabled('delete')) { this.sidebar.add_items('other', [ { label: _t('Delete'), callback: this.do_delete_selected } ]); diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 2615d8c66dd..5a1eac23a90 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -750,7 +750,7 @@ openerp.web.list_editable = function (instance) { instance.web.ListView.List.include(/** @lends instance.web.ListView.List# */{ row_clicked: function (event) { - if (!this.view.editable() || ! this.view._is_action_enabled('edit')) { + if (!this.view.editable() || ! this.view.is_action_enabled('edit')) { return this._super.apply(this, arguments); } var record_id = $(event.currentTarget).data('id'); diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 183b63a218e..43d935b91e8 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1363,7 +1363,7 @@ instance.web.View = instance.web.Widget.extend({ * An action is disabled by setting the corresponding attribute in the view's main element, * like: */ - _is_action_enabled: function(action) { + is_action_enabled: function(action) { return (_.has(this.fields_view.arch.attrs, action)) ? JSON.parse(this.fields_view.arch.attrs[action]) : true; } }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index a92eacc0710..789fbcb4baa 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -649,7 +649,7 @@
- + @@ -725,12 +725,12 @@
- +
- +
diff --git a/addons/web_diagram/static/src/xml/base_diagram.xml b/addons/web_diagram/static/src/xml/base_diagram.xml index 619ebb241f4..eec8e4f9139 100644 --- a/addons/web_diagram/static/src/xml/base_diagram.xml +++ b/addons/web_diagram/static/src/xml/base_diagram.xml @@ -2,7 +2,7 @@

- +
diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 44adbc41b10..8d782c5fd51 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -183,7 +183,7 @@ instance.web_gantt.GanttView = instance.web.View.extend({ self.on_task_display(task_info.internal_task); } }); - if (this._is_action_enabled('create')) { + if (this.is_action_enabled('create')) { // insertion of create button var td = $($("table td", self.$el)[0]); var rendered = QWeb.render("GanttView-create-button"); diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 143ff7d685b..cbe88ec847b 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -71,7 +71,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ return JSON.parse(this.fields_view.arch.attrs.quick_create); return !! this.group_by; }, - _is_action_enabled: function(action) { + is_action_enabled: function(action) { if (action === 'create' && !this.options.creatable) return false; return this._super(action); @@ -735,7 +735,7 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({ var $action = $(this), type = $action.data('type') || 'button', method = 'do_action_' + (type === 'action' ? 'object' : type); - if ((type === 'edit' || type === 'delete') && ! self.view._is_action_enabled(type)) { + if ((type === 'edit' || type === 'delete') && ! self.view.is_action_enabled(type)) { self.view.open_record(self.id); } else if (_.str.startsWith(type, 'switch_')) { self.view.do_switch_view(type.substr(7)); diff --git a/addons/web_kanban/static/src/xml/web_kanban.xml b/addons/web_kanban/static/src/xml/web_kanban.xml index b2f9e757b43..278b9cc02b6 100644 --- a/addons/web_kanban/static/src/xml/web_kanban.xml +++ b/addons/web_kanban/static/src/xml/web_kanban.xml @@ -14,7 +14,7 @@
- + From bf20cd701840bd8e08ca05207566c4ddcbad6ced Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 4 Sep 2012 16:30:24 +0200 Subject: [PATCH 27/32] [IMP] view_form: improve code formatting bzr revid: rco@openerp.com-20120904143024-g6fmxpkcjmg95zcu --- addons/web/static/src/js/view_form.js | 71 +++++++++++++++------------ 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 669126820e8..3ea3e853894 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3573,7 +3573,11 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ }); instance.web.form.One2ManyList = instance.web.ListView.List.extend({ pad_table_to: function (count) { - this._super(this.view.is_action_enabled('create') ? (count > 0 ? count - 1 : 0) : this.records.length); + if (!this.view.is_action_enabled('create')) { + this._super(count); + } else { + this._super(count > 0 ? count - 1 : 0); + } // magical invocation of wtf does that do if (this.view.o2m.get('effective_readonly')) { @@ -3586,38 +3590,41 @@ instance.web.form.One2ManyList = instance.web.ListView.List.extend({ }).length; if (this.options.selectable) { columns++; } if (this.options.deletable) { columns++; } - if (this.view.is_action_enabled('create')) { - var $cell = $('', { - colspan: columns, - 'class': 'oe_form_field_one2many_list_row_add' - }).append( - $('', {href: '#'}).text(_t("Add a row")) - .mousedown(function () { - // FIXME: needs to be an official API somehow - if (self.view.editor.is_editing()) { - self.view.__ignore_blur = true; - } - }) - .click(function (e) { - e.preventDefault(); - e.stopPropagation(); - // FIXME: there should also be an API for that one - if (self.view.editor.form.__blur_timeout) { - clearTimeout(self.view.editor.form.__blur_timeout); - self.view.editor.form.__blur_timeout = false; - } - self.view.ensure_saved().then(function () { - self.view.do_add_record(); - }); - })); - var $padding = this.$current.find('tr:not([data-id]):first'); - var $newrow = $('').append($cell); - if ($padding.length) { - $padding.before($newrow); - } else { - this.$current.append($newrow) - } + if (!this.view.is_action_enabled('create')) { + return; + } + + var $cell = $('', { + colspan: columns, + 'class': 'oe_form_field_one2many_list_row_add' + }).append( + $('', {href: '#'}).text(_t("Add a row")) + .mousedown(function () { + // FIXME: needs to be an official API somehow + if (self.view.editor.is_editing()) { + self.view.__ignore_blur = true; + } + }) + .click(function (e) { + e.preventDefault(); + e.stopPropagation(); + // FIXME: there should also be an API for that one + if (self.view.editor.form.__blur_timeout) { + clearTimeout(self.view.editor.form.__blur_timeout); + self.view.editor.form.__blur_timeout = false; + } + self.view.ensure_saved().then(function () { + self.view.do_add_record(); + }); + })); + + var $padding = this.$current.find('tr:not([data-id]):first'); + var $newrow = $('').append($cell); + if ($padding.length) { + $padding.before($newrow); + } else { + this.$current.append($newrow) } } }); From d6dc264ea28dff087c75c67ff36e2b82aa1a2b70 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 4 Sep 2012 16:50:17 +0200 Subject: [PATCH 28/32] [IMP] web, web_diagram: improve code formatting bzr revid: rco@openerp.com-20120904145017-qw6n8clak9byw1w3 --- addons/web/static/src/js/view_list.js | 12 +++--------- addons/web/static/src/js/views.js | 3 ++- addons/web/static/src/xml/base.xml | 14 ++++++-------- addons/web_diagram/static/src/xml/base_diagram.xml | 10 ++++------ 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index da806f415cf..0c1e6805f9a 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -252,15 +252,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.$el.addClass(this.fields_view.arch.attrs['class']); // add css classes that reflect the (absence of) access rights - if (!this.is_action_enabled('create')) { - this.$el.addClass('oe_list_cannot_create'); - } - if (!this.is_action_enabled('edit')) { - this.$el.addClass('oe_list_cannot_edit'); - } - if (!this.is_action_enabled('delete')) { - this.$el.addClass('oe_list_cannot_delete'); - } + this.$el.toggleClass('oe_list_cannot_create', !this.is_action_enabled('create')) + .toggleClass('oe_list_cannot_edit', !this.is_action_enabled('edit')) + .toggleClass('oe_list_cannot_delete', !this.is_action_enabled('delete')); // Head hook // Selecting records diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 43d935b91e8..83c1ecaa679 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1364,7 +1364,8 @@ instance.web.View = instance.web.Widget.extend({ * like: */ is_action_enabled: function(action) { - return (_.has(this.fields_view.arch.attrs, action)) ? JSON.parse(this.fields_view.arch.attrs[action]) : true; + var attrs = this.fields_view.arch.attrs; + return (action in attrs) ? JSON.parse(attrs[action]) : true; } }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 789fbcb4baa..2e2935a7bc6 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -725,14 +725,12 @@
- -
- -
-
- - - + +
+ +
+
diff --git a/addons/web_diagram/static/src/xml/base_diagram.xml b/addons/web_diagram/static/src/xml/base_diagram.xml index eec8e4f9139..388092b3d23 100644 --- a/addons/web_diagram/static/src/xml/base_diagram.xml +++ b/addons/web_diagram/static/src/xml/base_diagram.xml @@ -1,12 +1,10 @@