This question has been flagged

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>
Avatar
Discard
Author

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

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