Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
3665 Widoki

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: 


Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

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>

Autor

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.

Autor

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.

Autor

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.

Autor

still nothing happened ToT

Autor

Ok I can do that by other way, thanks

Powiązane posty Odpowiedzi Widoki Czynność
0
wrz 23
2439
0
kwi 19
3582
2
mar 15
7218
1
sie 24
3241
0
kwi 23
442