Odoo Help


how to hide a field in another model when a boolean field is false in odoo9

on 10/1/16, 3:13 AM 913 views

i would like to create a module which hide a field `discount` in `account.invoice.line` if a boolean field `discount_bool` is set to false in `account.invoice`. when i tried below mentioned code i got an error raise TypeError("Type of related field %s is inconsistent with %s" % (self, field))TypeError: Type of related field account.invoice.line.fd is inconsistent with account.invoice.discount_bool

in xml

<record id="discount_invoice_lines_ids" model="ir.ui.view">

                <field name="model">account.invoice</field>

                <field name="name">discount_invoice_lines</field>

               <field name="inherit_id" ref="account.invoice_form"/>

                <field name="arch" type="xml">

                    <xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='discount']" position="replace">

                        <field name="discount" attrs="{'invisible':[('discount_bool', '!=', False)]}"/>




in py

orderline = fields.Many2one('account.invoice') 

discount = fields.Char(string='Discount (%)', default=0.0)

fd = fields.Char(related='orderline.discount_bool'

--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 10/1/16, 5:26 AM


The error in the .py file not in the attrs expr. 

fd = fields.Char(related='orderline.discount_bool'

you defined the fd with type Char which I think it should be with type Boolean !!

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.


Odoo Training Center

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

Test it now

Question tools

1 follower(s)


Asked: 10/1/16, 3:13 AM
Seen: 913 times
Last updated: 3/4/17, 5:19 AM