跳至内容
菜单
此问题已终结
3 回复
8112 查看

Since, the content of my form is small and the default width of the modal is always set to 'modal-lg', i wanna know if there is a way that i can set a button call to use 'modal-md' to perfectly fit the content of the form?

I like to do it in this button call.

<button class="btn btn-md btn-secondary" name="add_teacher_comment" type="object" attrs="{'invisible':[('id', '=', False)]}">Add</button>
@api.multi    
def add_teacher_comment(self):
return {
            'type': 'ir.actions.act_window',            
            'name': _('Add Teacher Comment'),            
            'res_model': 'teacher.comment',            
            'target': 'new',            
            'views': [[False, 'form']],            
            'nodestroy' : True,            
         }
Any input please? 
形象
丢弃
最佳答案

Hi,​

I think there is no such feature to add window size from python code

you can change window size by extending Dialog widget:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets" inherit_id="web.assets_common">
<xpath expr="." position="inside">
<script type="text/javascript" src="/custom_module/static/src/js/dialog.js"/>
</xpath>
</template>
</odoo>

dialog.js :-

odoo.define('custom_module.small_dialog', function (require) {
"use strict";
var Dialog = require('web.Dialog');

Dialog.include({
willStart: function () {
var self = this;
if(this.title === 'Create new interest note'){
this.size = 'small';
}
return this._super.apply(this, arguments);
}
});

});

You can also use 

this.size = 'medium'; 

by adding necessary changes in the code.


Thanks

形象
丢弃
最佳答案

You should be able to do this by customizing the view which contains the button.

形象
丢弃
相关帖文 回复 查看 活动
0
6月 21
4695
2
1月 25
6701
1
4月 24
2671
1
12月 23
4844
2
11月 22
4006