Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
524 Lượt xem

 I want to show the upload date of an attachment in Chatter. Is there any way to do this? I tried searching but didn't find an answer to this problem. 

attachment.js


import { clear } from '@mail/model/model_field_command';

import { attr } from '@mail/model/model_field';

import { registerPatch } from '@mail/model/model_core';

registerPatch({

    name: 'Attachment',    modelMethods: {

        /**

         * @override

         */

        convertData(data) {

            const res = this._super(data);

            if ('create_date' in data) { 

               res.create_date = data.create_date;

            }           

​ return res;

        },

    },

    fields: {

        create_date: attr({

            compute() {

                const create_date = this.create_date;

                if (create_date) {

                    return create_date;

                }

                return clear();

            },        

​}),

    },

});

attachtment_thread.js


import { registerPatch } from '@mail/model/model_core';

import { insertAndReplace } from '@mail/model/model_field_command';

registerPatch({        ​name: 'Thread',        ​modelMethods: {            ​   ​async fetchAttachments() {                ​   ​   ​let attachmentsData = await this.async(() => this.env.services.rpc({                   ​   ​   ​model: 'ir.attachment',    ​                method: 'search_read',    ​                domain: [                        ​   ​   ​   ​   ​['res_id', '=', this.id],    ​                    ['res_model', '=', this.model],    ​                ],                    ​   ​   ​fields: ['id', 'name', 'mimetype', 'create_date'],                orderBy: [{name: 'id', asc: false}],            }, {shadow: true}));            this. Update({                originThreadAttachments: insertAndReplace(attachmentsData),            });            this.update({ areAttachmentsLoaded: true });        }    },}); 


attachtment.xml

I add attachmentCard.attachment.create_date

by  expr="//*[hasclass('o_AttachmentCard_filename')]" position="after"

Ảnh đại diện
Huỷ bỏ