Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6413 มุมมอง

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'

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ย. 23
4958
Remove "add an item" แก้ไขแล้ว
12
ต.ค. 23
36021
1
ต.ค. 21
4477
2
พ.ค. 19
6301
How to apply char input field mask? แก้ไขแล้ว
2
พ.ค. 19
8977