zoukankan      html  css  js  c++  java
  • Odoo的附件大小限制

    Odoo使用binary类型来保存附件数据,可以直接支持附件数据的上传。但是在实际使用中,有可能遇到附件文件大小超过限制的情况,如下图:

    但是ERP定制过程中难免会遇到客户确实需要上传超大附件,那么怎么办呢?

    比较好的模块:https://github.com/JZ10UJS/extra-addons

    我们需要到代码中修改相应的配置文件即可,负责定义该最大值的代码在:web/static/src/js/fields/basic_fields.js中。具体代码如下:

    var AbstractFieldBinary = AbstractField.extend({
        events: _.extend({}, AbstractField.prototype.events, {
            'change .o_input_file': 'on_file_change',
            'click .o_select_file_button': function () {
                this.$('.o_input_file').click();
            },
            'click .o_clear_file_button': '_onClearClick',
        }),
        init: function (parent, name, record) {
            this._super.apply(this, arguments);
            this.fields = record.fields;
            this.useFileAPI = !!window.FileReader;
            this.max_upload_size = 25 * 1024 * 1024; // 25Mo
            if (!this.useFileAPI) {
                var self = this;
                this.fileupload_id = _.uniqueId('o_fileupload');
                $(window).on(this.fileupload_id, function () {
                    var args = [].slice.call(arguments).slice(1);
                    self.on_file_uploaded.apply(self, args);
                });
            }
        },
        destroy: function () {
            if (this.fileupload_id) {
                $(window).off(this.fileupload_id);
            }
            this._super.apply(this, arguments);
    },

    注意:该字段不建议修改,除非特殊情况,上传过大附件速度会非常慢,甚至影响整个系统的使用性能问题,大文件建议分割为多个小文件上传。


    文章来源链接:https://www.jianshu.com/p/4877158a07d0

  • 相关阅读:
    mysql高可用架构的构想
    shell进阶——expect免交互工具的使用
    Mysql性能优化之参数配置(转)
    mysql主从同步问题梳理
    使用mysql-proxy实现mysql的读写分离
    Mysql数据库的主从与主主
    Mariadb远程登陆配置及相关问题排查
    redis集群搭建及常用操作
    weblogic的linux静默搭建
    Python traceback 模块,追踪错误
  • 原文地址:https://www.cnblogs.com/1314520xh/p/12153854.html
Copyright © 2011-2022 走看看