Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
3676 Vues

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: 


Avatar
Ignorer
Meilleure réponse

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.

Avatar
Ignorer
Auteur

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>

Auteur

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.

Auteur

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.

Auteur

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.

Auteur

still nothing happened ToT

Auteur

Ok I can do that by other way, thanks

Publications associées Réponses Vues Activité
0
sept. 23
2441
0
avr. 19
3584
2
mars 15
7218
1
août 24
3243
0
avr. 23
442