Here's the challenge:
I have added a custom field to the mail.message model.
I want to expose that field in the message thread. I can change the way the thread looks but the value of the new field always comes empty.
I can make the values to be shown by directly editing the /mail/static/src/models/message.js in two places:
1) add...
if ('read_by' in data) {
data2.read_by = data.read_by;
}
inside convertData(data)
2) Add...
read_by = attr();
inside "fields"
Obviously, I can't edit the base code and I need to apply these changes in my own code. How?!
I've tried the following (it's not working):
odoo.define('MY_MODULE.message', function (require) {
"use strict";
const { Message } = require('mail.models');
const Registries = require('mail.Registries');
const MessageFields = (Message) => class MessageFields extends Message {
convertData(data) {
super.convertData(data);
if ('read_by' in data) {
data2.read_by = data.read_by;
}
}
fields['read_by'] = attr();
}
Registries.Model.extend(Message, MessageFields);
});
Can anyone, please, tell me how to achieve this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
1
Trả lời
4040
Lượt xem
/** @odoo-module **/
import { registerPatch } from '@mail/model/model_core';
import { attr } from '@mail/model/model_field';
registerPatch({
name: 'Message',
modelMethods: {
convertData(data) {
const data2 = this._super(data);
if ('read_by' in data) {
data2.read_by = data.read_by;
}
return data2;
},
},
fields: {
read_by: attr(),
},
});
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 4 24
|
1480 | ||
|
0
thg 1 24
|
1207 | ||
|
1
thg 9 23
|
2515 | ||
|
2
thg 4 23
|
4514 | ||
|
2
thg 1 23
|
7087 |