Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
26170 Tampilan

What is the right way to change the text-align property for a column in a tree view.  

I have a custom css file in the static/src/css directory.  

I also have it registered in the __openerp__.py file in the 'css': [ 'static/src/css/custom_style.css' ].  

I also made sure the field in the xml file had the right class name set like class="change_text_align"

For some reason though, it will not change the text-align for the column for the field in the tree view.  Is there anything that I am missing?  I just want to align the text on the left side of the column instead of the right.

I also tried adding a style attribute to the field like this, but it still didnt work:

         <field name="my_field" style="text-align: left" /> 

Avatar
Buang

texts are aligned at the left side anyway, you have nothing to change. Probably you mean numbers?

Hope this will helps: https://goo.gl/Wz5KEW

Jawaban Terbai

quote from question:

I just want to align the text on the left side of the column instead of the right.

NOTE: text is aligned at the left side anyway (fields of type char or text), so question is not correctly describes the problem and requires further clarification.

Perhaps, if question is about numeric (integer or float) fields (as numeric fields are aligned at the right side), then it's possible to align them to the left side like text fields, using type="char" attribute in xml record:

<field name="my_numeric_field" type="char" />


Avatar
Buang

if we use this way, then we do not need additional css for this purpose.

Penulis

Thank you so much! That did the trick.

Hi Temur, I want my Integer/float field aligned at Centre, can you please help me out ?

one thing more i am having a widget already in my field for regex. so in that case i am not able to use any other widget in same field.

Thank You @Temur for your answer.

Jawaban Terbai

well the type conversion method is not valid solution because it change objective of the problem i mean it change the type of the field which is very important the SCSS method solved my problem also we should inherit it from base as mention by @waqas also should follow the file structuring and include in manifest:           

custom_module
├── __init__.py
├── models
│   ├── __init__.py
│   └── ...
├── static
│   └── src
│       └── scss
│           └── style.scss
└── views
    ├── __init__.py
    └── assets_backend_custom.xml
Avatar
Buang
Jawaban Terbai

Found a solution for this
create scss
 and add this 

.o_list_view .o_list_table thead > tr > th:not(.o_list_record_selector).o_list_number_th {
text-align: center;
}
.o_list_view .o_list_table tbody > tr > td:not(.o_list_record_selector).o_list_number {
text-align: center;
}
and inherit template
  <template id="assets_backend_custom" name="assets_backend_custom" inherit_id="web.assets_backend" >
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss" href="/modulename/static/src/scss/style.scss"/>
xpath>

template>


this will centralize both header and fields
Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
0
Mar 15
3323
0
Mar 15
4759
2
Mar 15
5148
3
Feb 16
6401
1
Sep 15
5818