This question has been flagged
1 Reply
5046 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)]}"/>

                    </xpath>

               </field>

</record>


in py

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

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

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

Avatar
Discard
Best Answer

Hi,

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 !!

Avatar
Discard