new module to open full form view from a dialog.

This commit is contained in:
Marc Durepos 2023-12-04 13:58:58 -05:00
parent be0af4dc17
commit 535c6f1ff6
3 changed files with 80 additions and 0 deletions

View file

@ -0,0 +1,37 @@
#
# Bemade Inc.
#
# Copyright (C) 2023-June Bemade Inc. (<https://www.bemade.org>).
# 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
}

View file

@ -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,
})
}
});