diff --git a/bemade_full_formview_from_modal/__init__.py b/bemade_full_formview_from_modal/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bemade_full_formview_from_modal/__manifest__.py b/bemade_full_formview_from_modal/__manifest__.py new file mode 100644 index 0000000..66d3327 --- /dev/null +++ b/bemade_full_formview_from_modal/__manifest__.py @@ -0,0 +1,37 @@ +# +# Bemade Inc. +# +# Copyright (C) 2023-June Bemade Inc. (). +# Author: Marc Durepos (Contact : mdurepos@durpro.com) +# +# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) +# It is forbidden to publish, distribute, sublicense, or sell copies of the Software +# or modified copies of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +{ + 'name': 'Full Form from Dialog', + 'version': '15.0.1.0.0', + 'summary': 'Allows opening the full form view from the dialog (modal) view.', + 'description': 'Adds a button to open the full form view when viewing the form view for a record in a dialog.', + 'category': 'Technical', + 'author': 'Bemade Inc.', + 'website': 'http://www.bemade.org', + 'license': 'OPL-1', + 'depends': [], + 'data': [], + 'assets': { + 'web.assets_backend': [ + 'bemade_full_formview_from_modal/static/src/js/form_view_dialog.js', + ], + }, + 'installable': True, + 'auto_install': False +} diff --git a/bemade_full_formview_from_modal/static/src/js/form_view_dialog.js b/bemade_full_formview_from_modal/static/src/js/form_view_dialog.js new file mode 100644 index 0000000..e94ad00 --- /dev/null +++ b/bemade_full_formview_from_modal/static/src/js/form_view_dialog.js @@ -0,0 +1,43 @@ +/** @odoo-module **/ + +import FormViewDialog from 'web.FormView'; +import Dialog from 'web.Dialog'; +import {patch} from '@web/core/utils/patch'; +import {_t} from 'web.core'; + +const dom = require('web.dom') + +patch(Dialog.prototype, "bemade_full_formview_from_modal.Dialog", { + init: function (parent, options) { + this._super(...arguments); + }, + custom_events: _.extend({}, Dialog.prototype.custom_events, { + open_full_form_view: '_onOpen', + }), + willStart: function () { + const self = this; + return this._super(...arguments).then(function () { + if (self.$footer) { + const $button = dom.renderButton({ + attrs: { + class: 'btn btn-secondary o_form_button_open', + }, + text: _t('Open'), + }); + $button.on('click', function() {self._onOpen.call(self)}); + self.$footer.append($button); + } + } + ); + }, + _onOpen: function () { + this.do_action({ + type: 'ir.actions.act_window', + res_model: this.options.res_model, + res_id: this.options.res_id, + views: [[false, 'form']], + target: 'current', + context: this.context, + }) + } +});