Odoo Help

0

0
11 Answers
2
Tintu Mon
11/4/16 09:36

In Tree view doesn't hide complete column when we use attrs="{'invisible':[('partner_name', '!=', 'XYZ')]}", I found it only hides the data/content in that column. So I tried to using invisible="context.get('partner_name') != 'XYZ'" instead of above one. It hides the complete column in Tree view. I hope it will help you.

1
acha aslam
20/2/19 07:05

This code is used to hide fields in one2many(tree) in odoo11

<field name="my_field" attrs="{'column_invisible': [('parent.field_name','=',False)]}" />


this type of code only works gives 'parent' in condition
1 Comment
David Moreno
20/6/19 06:38

You found the holy grain! This solutions works as a charm, thank you!!

1
Avatar

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--

4324
| 6 6 10
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
12/3/15 19:04

try to add this code in a new module to install :

python code with new api v8 :

from openerp import models, fileds, api

 

class SaleOrderLine(models.Model):

    _inherit = 'sale.order.line'

    partner_name = fields.Char(_get_partner_order_name, string="Partner order name")

    @api.one

    @api.depends('order_id', 'order_id.partner_id')

    def _get_partner_order_name(self):

        self.ensure_one()

        self.partner_name = self.order_id.partner_id.name or ''

 

xml : hide column price_unit

?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_order_hide_columns_form" model="ir.ui.view">
            <field name="name">sale.order.hide.columns.form</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='order_line']/tree/field[@name='product_id'] position="after">
                    <field name="partner_name" invisible="1"/>
                <xpath expr="//field[@name='order_line']/tree/field[@name='price_unit'] position="attributes">
                    <attribute name="attrs">{'invisible': [('partner_name', '=', 'XYZ')]}</attribute>
                </xpath>

        </record>
    </data>
</openerp>

 

Bye

5 Comments
José
13/3/15 08:16

It works fine, except by the hiding of the field. My attribute is: attrs="{'invisible':[('partner_name', '!=', 'XYZ')]}" but if the partner_name is XYZ, the field is still invisibile. Why?

José
13/3/15 08:24

If I put operator '=' works correctly. If the partner_name is XYZ, then hide the field. But if I put '!=' not works, if the partner_name isn't XYZ the field is still invisible.

José
13/3/15 09:30

I solved the problem. Is there any way to hide the entire column of the tree? With the invisibiel attr the field is not editable, but the column is still there.

Cyril Gaspard (GEM)
14/3/15 12:05

in sale.order, add a function field stored to get partner name partner_name. in view duplicate field order_line with form and tree; and in this second tree, remove colums you don't want. Add in two fiels order_line respectively attrs="{'invisible': [('partner_name', '=', 'value1')]}" attrs="{'invisible': [('partner_name', 'not in', ['value1')]]}" depending the tree you want to display. Bye

Tintu Mon
11/4/16 09:36

In Tree view does it hide complete column when we use attrs="{'invisible':[('partner_name', '!=', 'XYZ')]}", I found it only hides the data/content in that column. So I tried to using invisible="context.get('partner_name') != 'XYZ'" instead of above one. It hides the complete column in Tree view. I hope it will help you.

Ask a Question
Writer
Tags
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now