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

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" /> 

Awatar
Odrzuć

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

Najlepsza odpowiedź

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" />


Awatar
Odrzuć

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

Autor

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.

Najlepsza odpowiedź

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
Awatar
Odrzuć
Najlepsza odpowiedź

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
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
mar 15
3404
0
mar 15
4807
2
mar 15
5274
3
lut 16
6481
1
wrz 15
5972