コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
3182 ビュー

Hello guys, help me please!

I want to inherit module mail.model for custom _computeDateFromNow, I want to display format ("DD MMM YYYY HH:mm:ss") in log note, (now it's showing "a day ago") 

here is root code 

it my try: 


アバター
破棄
最善の回答

Hi, You can change "a day ago" or "hours ago" format in log note without changing the js function. For that you need to inherit and change the mail.Message template. 

You can replace the small tag in the template with o_Message_headerDate class. Try replacing the messageView.dateFromNow  with messageView.message.date


Regards.

アバター
破棄
著作者

I tried it but I cannot upgrade because error this is my code, check for me please
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<template id="my_module_mail_message" inherit_id="mail.Message" name="My Module Mail Message">
<xpath expr="//div[@class='o_Message_date o_Message_headerDate']" position="attributes">
<div class="o_Message_date o_Message_headerDate" t-att-class="{'o-message-selected': isSelected}" t-att-title="datetime">
- <t t-esc="messageView.message.date"/>
</div>
</xpath>
</template>
</data>
</odoo>

著作者

I also was add to manifest views/mail_message.xml

Hi, The xml file should not e written in the views, First of all you need to add the xml file in the path your_module_name/static/src/xml/your_filename.xml, Then you need to import this file in manifest like :
'assets': {
'web.assets_backend': [

'your_module_name/static/src/xml/your_filename.xml',
],
},
---------------------------------------------------------------------------------
And in the xml file try adding like:
<templates id="template" xml:space="preserve">
<t t-name="mail.Message" t-inherit="mail.Message" t-inherit-mode="primary" owl="1">
<xpath expr="//small[hasclass('o_Message_headerDate')]" position="replace">
<small class="o_Message_date o_Message_headerDate text-muted opacity-50"
t-att-class="{ 'o-message-selected': messageView.isSelected, 'me-2': !(messageView.isInChatWindowAndIsAlignedRight) }"
t-att-title="messageView.message.datetime">
<t t-esc="messageView.message.date"/>
</small>
</xpath>
</t>
</templates>

Regards.

著作者

The error that i get
Traceback (most recent call last):
File "C:\Program Files\Odoo 15\server\odoo\http.py", line 654, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\Program Files\Odoo 15\server\odoo\http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
AssertionError: Element odoo has extra content: data, line 3

To check the issue correctly, can you share the xml screenshot please.

著作者

when I follow you, nothing happened, then I tried add to the existing "view" file have error https://drive.google.com/drive/folders/1KcWoHzp3ldM2Z500pnZuRpEDCvbHv2aR?usp=sharing

The mail_message.png and manifest.png files are ok, but you just need to remove the <odoo> and <data> tag from the xml file. Try by removing both.

著作者

still nothing happened ToT

著作者

Ok I can do that by other way, thanks

関連投稿 返信 ビュー 活動
0
9月 23
1656
0
4月 19
3145
2
3月 15
6740
1
8月 24
2547
0
4月 23
442