跳至内容
菜单
此问题已终结

I added 2 fields to an existing form: "x_supplier1099" which is a checkbox and "x_supplier1099TaxID" which is "Char" field). I want to set the "required=False" of the "x_supplier1099TaxID" after I check the checkbox. I did it with XML (check the code below), but I'd like to know how to do it with Python method. Need assistance please!

class add_supplier1099(models.Model):
    _inherit = ['res.partner']
    _description = "Add Checkbox and TaxID Field if Supplier Requires 1099"
 
    x_supplier1099 = fields.Boolean(string='1099?', default=False)
    x_supplier1099TaxID = fields.Char(string='Tax ID', help='Supplier Tax ID or SS#')


<record id="add_supplier1099_view_inherit" model="ir.ui.view">	
    <field name="name">res.partner.form</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
    <field name='lang' position="after">
        <field name="x_supplier1099" string="1099?"/>
        <field name="x_supplier1099TaxID" string="Tax ID"/>
    </field>
    </field>
</record>
形象
丢弃
编写者

Can't edit the post, so here is the correct line:

<field name="x_supplier1099TaxID" string="Tax ID" attrs="{'required': [('x_supplier1099','=', True)]}"/>

相关帖文 回复 查看 活动
1
9月 23
2505
2
12月 23
12960
3
7月 22
23385
2
6月 21
18736
0
9月 20
3826