Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
3700 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

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>

Autore

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.

Autore

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.

Autore

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.

Autore

still nothing happened ToT

Autore

Ok I can do that by other way, thanks

Post correlati Risposte Visualizzazioni Attività
0
set 23
2445
0
apr 19
3589
2
mar 15
7220
1
ago 24
3249
0
apr 23
442