跳至内容
菜单
此问题已终结
3 回复
7181 查看

Hello all,

I have added some custom fields to the sales order line tree view, in the sales order form.

This has caused the sales order lines tree view to overflow and a scroll bar appeared to be able to navigate.

I would like to see all the sales order lines columns without having to scroll horizontally, I have already reduced width in all my custom fields but it isn't enough. 

Is there a way to reduce the width in the columns of base fields such as "Quantity", "Delivered", etc ? 

I tried to add custom CSS but I can't seem to overwrite the widths, which seems generated in a dynamic way.

Any ideas ?

Thank you !

Ernesto. 

形象
丢弃
编写者

Hi all !

No one can help me or point me in the right direction on this one ?

Thanks !

最佳答案

Hello everyone!

I have found a somewhat reliable method to resize the columns in tree:


Create an scss file whith your choice of name (like custom_tree.scss) and inside it write the following:

.custom__tree {
    [data-name="product_id"] {
        width: 800px; //or what value you want, it can be in % as well    
    }
}

//next add the scss file to the assets like:
< template id="assets_backend" name="custom table assets" inherit_id="web.assets_backend">
< xpath expr=" / / script[last()]" position="after">
< link rel="stylesheet" type="text/scss" href=" / module_name / static / src / scss / custom_tree.scss" / >
< / xpath>
< / template>

    
        
    


// in your view just add to the < tree > element the class "custom__tree"
// note that it works even if it is added by xpath

形象
丢弃

Worked for my in V16. Thanks for taking the time!

最佳答案

Hi,

Please try to inherit base fields which all you want and put inline css with !important. By default odoo will take the core css and using !important we can override the particular style.

if you want to reduce size of Quantity

<field name="qty" style="width:20px !important;"/>

Hope this will help you.

Thanks

形象
丢弃
编写者

Hi Silpa and thank you for your answer !!

I've located the right field with xpath, but the attribute width isn't affected at all :(

Here's my xpath sentence:

<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='order_lines']/field[@name='order_line']/tree[1]/field[@name='product_uom_qty']" position="attributes">

<attribute name="style">width:20px !important;</attribute>

</xpath>

What is weird is that if I do the same thing with another attribute, like invisible, it works:

<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='order_lines']/field[@name='order_line']/tree[1]/field[@name='product_uom_qty']" position="attributes">

<attribute name="invisible">1</attribute>

</xpath>

It's like the width isn't affected ...

Here's the fragment I want to modify from the sales form view:

<label for="product_uom_qty"/>

<div class="o_row" name="ordered_qty">

<field

context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom, 'uom_qty_change':True, 'company_id': parent.company_id}"

name="product_uom_qty"/>

</div>

Any idea why the style isn't applied ?

Thank you !!

最佳答案

You can do this via custom CSS. create a file css and give there your own columns width.

Like that:

<template id="assets_login_backend" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/yourmodulename/static/src/css/web_backend_style.css"/>
</xpath>

</template> 

then do css according to your need. I have done this once. If you will feel any issue let me know. I will help you in that.


Thank

MUHAMMAD IMRAN

形象
丢弃
编写者

Thank you Muhammad for your answer ! I'm sorry to reply this late.

If I do what you propose, let's say I create a custom class, then how can I insert it onto the standard Odoo code ? Xpath the class into the div or the element I want to modify ?

相关帖文 回复 查看 活动
1
11月 24
573
1
7月 24
1162
1
7月 24
1236
5
12月 23
21147
1
4月 23
2002