diff --git a/cmis_web/i18n/cmis_web.pot b/cmis_web/i18n/cmis_web.pot index 19fe5dbb..ebbed1cf 100644 --- a/cmis_web/i18n/cmis_web.pot +++ b/cmis_web/i18n/cmis_web.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 13.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-09-29 09:27+0000\n" -"PO-Revision-Date: 2022-09-29 09:27+0000\n" +"POT-Creation-Date: 2022-09-29 10:37+0000\n" +"PO-Revision-Date: 2022-09-29 10:37+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -142,6 +142,13 @@ msgstr "" msgid "Cancel Edit" msgstr "" +#. module: cmis_web +#. openerp-web +#: code:addons/cmis_web/static/src/xml/form_widgets.xml:0 +#, python-format +msgid "Cancel checkout" +msgstr "" + #. module: cmis_web #. openerp-web #: code:addons/cmis_web/static/src/xml/form_widgets.xml:0 diff --git a/cmis_web/i18n/fr.po b/cmis_web/i18n/fr.po index 1e611882..0a5bb967 100644 --- a/cmis_web/i18n/fr.po +++ b/cmis_web/i18n/fr.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-09-29 09:27+0000\n" +"POT-Creation-Date: 2022-09-29 10:37+0000\n" "PO-Revision-Date: 2019-04-25 16:05+0000\n" "Last-Translator: <>\n" "Language-Team: \n" @@ -54,6 +54,7 @@ msgstr "Un document avec le même nom existe déjà." #. module: cmis_web #. openerp-web #: code:addons/cmis_web/static/src/xml/form_widgets.xml:0 +#, python-format msgid "Actions" msgstr "" @@ -135,6 +136,12 @@ msgstr "Annuler" msgid "Cancel Edit" msgstr "Annuler l'édition" +#. module: cmis_web +#. openerp-web +#: code:addons/cmis_web/static/src/xml/form_widgets.xml:0 +msgid "Cancel checkout" +msgstr "Annuler la modification en cours" + #. module: cmis_web #. openerp-web #: code:addons/cmis_web/static/src/xml/form_widgets.xml:0 diff --git a/cmis_web/static/src/js/form_widgets.js b/cmis_web/static/src/js/form_widgets.js index 8de594b2..5b0f055c 100644 --- a/cmis_web/static/src/js/form_widgets.js +++ b/cmis_web/static/src/js/form_widgets.js @@ -647,6 +647,7 @@ odoo.define('cmis_web.form_widgets', function (require) { this.versionSeriesId = this.getSuccinctProperty('cmis:versionSeriesId', cmis_object); this.versionLabel = this.getSuccinctProperty('cmis:versionLabel'); this.url = this.cmis_session.getContentStreamURL(this.objectId, 'attachment'); + this.isCheckedOut = !!this.getSuccinctProperty("cmis:versionSeriesCheckedOutId"); this.allowableActions = cmis_object.allowableActions; this.renditions = cmis_object.renditions; }, @@ -1102,10 +1103,20 @@ odoo.define('cmis_web.form_widgets', function (require) { this.cmis_session.checkOut(self.document.objectId) .ok(function(data) { var dialog = new CmisCheckinDialog(self, self.wrap_cmis_object(data), true); + dialog.onDestroy(function() { + self.verify_is_checked_out() + .then(function (isCheckedOut) { + if (isCheckedOut) { + return self._cancel_checkout.bind(self)(); + } + }) + .catch((error) => console.log("error")) + .finally(() => self.trigger_up("reload")); + }); dialog.open(); }) .notOk(function() { - self._cancel_checkout(); + self._cancel_checkout.bind(self); }); }, @@ -1124,8 +1135,32 @@ odoo.define('cmis_web.form_widgets', function (require) { }, + on_cancel_checkout: function (e) { + var self = this; + this._cancel_checkout().finally(() => self.trigger_up('reload')); + }, + _cancel_checkout: function () { - this.cmis_session.cancelCheckOut(this.document.objectId); + var self = this; + return new Promise(function(resolve, reject) { + self.cmis_session.cancelCheckOut(self.document.objectId) + .ok((data) => resolve(data)) + .notOk((error) => reject(error)); + }); + }, + + verify_is_checked_out: function() { + var self = this; + return new Promise(function (resolve) { + self.cmis_session.getObject(self.document.objectId) + .ok(function (doc) { + resolve(self.wrap_cmis_object(doc).isCheckedOut) + }) + .notOk(function (doc) { + // safer to assume the doc is checked out + resolve(true) + }) + }); }, toggle_more_action: function name() { @@ -1179,6 +1214,10 @@ odoo.define('cmis_web.form_widgets', function (require) { self.stopEvent(e); self.on_click_get_properties(); }); + $el_actions.find('.content-action-cancel-checkout').on('click', function (e) { + self.stopEvent(e); + self.on_cancel_checkout(); + }); }, register_document_add_events: function () { diff --git a/cmis_web/static/src/xml/form_widgets.xml b/cmis_web/static/src/xml/form_widgets.xml index 4472e7e9..d417a6a4 100644 --- a/cmis_web/static/src/xml/form_widgets.xml +++ b/cmis_web/static/src/xml/form_widgets.xml @@ -502,8 +502,10 @@