콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
5 답글
11111 화면

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

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

베스트 답변

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

아바타
취소
베스트 답변

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.

Javascript near the field definition is not supposed :)

My code works, I tested

관련 게시물 답글 화면 활동
3
6월 25
1012
3
2월 25
4745
1
7월 23
3710
4
12월 22
9653
2
4월 21
3714