Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to remove seconds from a specific fields.Datetime field on a form view.

By
Pieter Paulussen
on 9/23/16, 10:57 AM 287 views

I need to hide the secondes from a fields.Datetime in a form view. What is the best way to do this?


Try by creating new widget for datetime, i don't know more

Refer:

1) odoo-9.0c-20160806/openerp/addons/web/static/src/xml/base.xml

2) https://www.odoo.com/documentation/9.0/howtos/web.html#read-write-field

shameem@aχoncoms
on 9/23/16, 10:54 PM

Yeah I'm more looking to an option like in qweb: t-field-option='{"hide_seconds":"True"}' 

Pieter Paulussen
on 9/25/16, 5:39 PM
1

Ermin Trevisan

--Ermin Trevisan--
3546
| 6 3 7
Walchwil, Switzerland
--Ermin Trevisan--


Ermin Trevisan
On 9/24/16, 4:08 AM

I do that not only for particular forms, but generally for each database and language by specifying the corresponding time format under "Settings/Languages".

Fine :)

shameem@aχoncoms
on 9/24/16, 5:00 AM
0
shameem@aχoncoms
On 9/26/16, 12:38 AM

Hi Pieter Paulussen,

You add a class to your date time filed and write a script. Then include maxlength property to the date to remove from right side.

For example

<script type="text/javascript">
     $('.your_date_field').css({"color": "red", "border": "2px solid red"});//TO TEST
     // CODE WHEN READ ONLY
     //CODE WHEN EDIT
</script>
<field name="date" class="your_date_field"/>  

Isn't the javascript supposed to be put after the field definition?

Also I think that when you want to extend the javascript, it's best to extend the full date-time widget rather than just changing the css.

Pieter Paulussen
on 9/26/16, 2:37 AM

Javascript near the field definition is not supposed :)

shameem@aχoncoms
on 9/26/16, 5:02 AM

My code works, I tested

shameem@aχoncoms
on 9/26/16, 5:04 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/23/16, 10:57 AM
Seen: 287 times
Last updated: 9/26/16, 12:38 AM