Skip to Content
Menu
This question has been flagged
4 Replies
1167 Views

I've been following the written tutorial, and I am currently at Chapter 6: Basic Views.

The next step was to create the following list view (tried to upload image, couldn't), and I got everything to work except the Title and Postcode (both char fields) take up almost all of the width, and the columns don't equally divide the width.

I looked for ways to make this work, but the only "decent" solution was to set the width to a fixed amount in pixels.


My question would be, how did the guide achieve making all columns take up equal space.


Thank you for your time :)

Avatar
Discard
Best Answer

Hi Blerton,


Edit: 

I see you mentioned list. My bad haha.

What you do is already on the right track by adjusting the "width" attribute. But, as you need to know that odoo's table is auto adjusted to fit the contents. If you have a very long title and very short postcode, it will auto adjust to try to fit it as "fair" as possible. Check the reference here


If you really insist to change the width. It might be too "forcing" and I afraid mess up other columns size. You can dive into the css or js files in the web module to know what's the width for each field types.


Hope this helps.


Previous reply:

I assume you are referring to this. It would be best if you could share your current code so we can work from there.


I would suggest you to follow this code as reference only and I only write the starting from the <form> tag only

<form string="Property Form">

<sheet>

<div class="oe_title">

<label for="name"/> <!-- This is the label for the name field: optional -->

<h1><field name="name" class="oe_inline"/></h1>

</div>

<group>

<group>

<field name="postcode"/>

<field name="available_from"/>

</group>

<group>

<field name="expected_price"/>

<field name="selling_price"/>

</group>

</group>

<!-- This is a notebook with description page: I skip this -->

<notebook></notebook>

</sheet>

</form>

Hope this helps.

Avatar
Discard
Best Answer

https://www.odoo.com/documentation/18.0/developer/tutorials/server_framework_101/06_basicviews.html#list

Just so we're talking about the same thing here: the columns shown in the tutorial have never been equally sized nor equally spaced to begin with.


Given a small enough view port, any list will look 'almost equally spaced' if enough columns are there.

Apart from that the width-attribute is correct. Else you would need to add a class to the list and create a stylesheet specific to it (which I wouldn't suggest you to do just for the sake of column widths unless the nature of the data in that list explicitly require it).

Avatar
Discard
Best Answer

Ran into the same isuue. Getting results different from those expected by the tutorial is a huge bad learning experience. If the tutorial intended to delay explanations on column width customization, the tutorial should have explicitly stated this.

Avatar
Discard
Author Best Answer

This was described as the form view, what I meant is the list view, where you can see all record and choose a single record to view. (I would post a picture but I dont have enough karma).

<record id="estate_property_view_list" model="ir.ui.view">
<field name="name">estate.property.view.list</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list string="Properties">
<field name="title" width="150px"/>
<field name="postcode" width="50px"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="expected_price"/>
<field name="selling_price"/>
<field name="date_availability"/>
</list>
</field>
</record>


This is the code I'm using, where I use the width attribute to kind-of fix this issue (but if there were texts longer than this they wont be entirely visible), but isn't there any better way to make it only take up as much space as it needs.

What I want is each column to take the same amount of space, these char fields mess things up.


Thanks for your time


Edit: I somehow messed this up, didn't know I had to comment your response .-.

Avatar
Discard
Author

"But, as you need to know that odoo's table is auto adjusted to fit the contents." - This is the part that I find confusing since it doesn't seem to do that for me.

The width is *WAY* bigger than the content, meaning the width isn't correctly adjusting to the content.

In my case the title takes like 40% of the screen, same for the postcode, and then all the other fields are crammed into the rest of the screen. (If i dont specify the width my self)

Any idea why that might be happening?

In the meantime manually setting the width will have to do I guess

Related Posts Replies Views Activity
1
Jul 25
487
2
Jul 25
450
1
Jul 25
1707
2
Jul 25
232
2
Jul 25
1227