【问题标题】:Is there any way to override standard many2many field pop up after clickin add an item?单击添加项目后,有什么方法可以覆盖标准的 many2many 字段弹出?
【发布时间】:2017-07-21 14:14:41
【问题描述】:

当我在 many2many 字段标准弹出窗口中单击添加项目时,会出现所有过滤器、分组依据等。我想要做的是保持弹出状态不变,只是稍微改变一下它的风格。我通过检查元素对其进行了测试,我所要做的就是从 div 中删除一个类。现在我需要在代码中找到一种方法来做到这一点。 感谢您考虑我的问题!

【问题讨论】:

    标签: openerp odoo-8 odoo-9 odoo-10


    【解决方案1】:

    这是我在 One2many Pop up 中更改的一些样式

    如果您只需要更改一些样式,这将对您有所帮助

    你只需要找到类名

    Many2Many 中“创建”按钮的示例类名是“oe_selectcreatepopup-search-create”

    在你的模块中创建 .js 文件,然后像这样包含它

    <?xml version="1.0" encoding="utf-8"?>
    <!-- vim:fdn=3: -->
    <openerp>
        <data>
            <template id="assets_backend" name="nstda_bst assets" inherit_id="web.assets_backend">
                <xpath expr="." position="inside">
                    <link rel="stylesheet" href="/nstda_bst/static/css/nstda_bst.css"/>
                    <script type="text/javascript" src="/nstda_bst/static/js/nstda_bst.js"></script>
                </xpath>
            </template>
        </data>
    </openerp>
    

    然后在core/addons/web/static/scr/js/view_form.js中复制'oe_selectcreatepopup'js函数

    到你模块中的新js

    然后改变它。

    openerp.nstda_bst = function(instance) {
    
    var MODELS_TO_HIDE = [ 'nstda.bst', 'nstda.bst.hbill', 'nstda.bst.dbill' ];
    
    var QWeb = instance.web.qweb, _t = instance.web._t, _lt = instance.web._lt;
    var dateBefore = null;
    
    instance.web.form.AbstractFormPopup.include({
        template : "AbstractFormPopup.render",
    
        setup_form_view : function() {
            var self = this;
            var tmp = this._super.apply(this, arguments);
            var res_model = this.dataset.model;
    
            if ($.inArray(res_model, MODELS_TO_HIDE) != -1) {
                var  button_t = setInterval(function(){
    
                    $(".oe_abstractformpopup-form-close").addClass('oe_button oe_form_button_cancel oe_highlight .openerp button.oe_highlight button.oe_highlight:hover');
                    $(".oe_abstractformpopup-form-close").removeClass('oe_bold');
                    $(".oe_abstractformpopup-form-close").css('display', 'inline-block');
                    $(".oe_abstractformpopup-form-close").css('line-height', '1.7em;');
                    $(".oe_abstractformpopup-form-close").css('background-color', 'c02c2c');
                    $(".oe_abstractformpopup-form-close").css('background-image', '-webkit-gradient(linear, left top, left bottom, from(#df3f3f), to(#a21a1a))');
                    $(".oe_abstractformpopup-form-close").css('background-image', '-webkit-linear-gradient(top, #df3f3f, #a21a1a)');
                    $(".oe_abstractformpopup-form-close").css('background-image', '-moz-linear-gradient(top, #df3f3f, #a21a1a)');
                    $(".oe_abstractformpopup-form-close").css('background-image', '-ms-linear-gradient(top, #df3f3f, #a21a1a)');
                    $(".oe_abstractformpopup-form-close").css('background-image', '-o-linear-gradient(top, #df3f3f, #a21a1a)');
                    $(".oe_abstractformpopup-form-close").css('background-image', 'linear-gradient(to bottom, #df3f3f, #a21a1a)');
                    $(".oe_abstractformpopup-form-close").css('-moz-box-shadow', '0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(155, 155, 155, 0.4) inset');
                    $(".oe_abstractformpopup-form-close").css('-webkit-box-shadow', '0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(155, 155, 155, 0.4) inset');
                    $(".oe_abstractformpopup-form-close").css('box-shadow', '0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(155, 155, 155, 0.4) inset');
    
                }, 50);
    
            }
        }       
    });
    

    }

    【讨论】:

    • 感谢您的回答,这些信息在很多情况下都会有所帮助:)
    猜你喜欢
    • 2012-10-29
    • 2011-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-07
    • 1970-01-01
    • 1970-01-01
    • 2013-05-11
    相关资源
    最近更新 更多