I wanted to hide a field in one2many treeview based on a boolean field,

[![Boolean field](https://i.stack.imgur.com/LIZUo.jpg)](https://i.stack.imgur.com/LIZUo.jpg)

If the boolean field is checked, then the field total quantity to be displayed in the following tree view..

[![Tree view](https://i.stack.imgur.com/doJ2F.jpg)](https://i.stack.imgur.com/doJ2F.jpg)

The tree view is of class'account.invoice.line' and the code is as follows(the boolean field):

```
class account_invoice_line(models.Model):
    _name = "account.invoice.line"
    _description = "Invoice Line"
    _order = "invoice_id,sequence,id"

    name = fields.Text(string='Description')
    tot_qty_bool = fields.Boolean(string='Total Quantity', default=False)
    tot_qty = fields.Float(string='Total Quantity')
    origin = fields.Char(string='Source Document',
        help="Reference of the document that produced this invoice.")
    sequence = fields.Integer(string='Sequence', default=10,
        help="Gives the sequence of this line when displaying the 
invoice.")
    invoice_id = fields.Many2one('account.invoice', string='Invoice 
Reference',
        ondelete='cascade', index=True)
    uos_id = fields.Many2one('product.uom', string='Unit of Measure',
        ondelete='set null', index=True)
    product_id = fields.Many2one('product.product', string='Product',
        ondelete='set null', index=True)
    account_id = fields.Many2one('account.account', string='Account',
        domain=[('type', 'not in', ['view', 'closed'])],
        default=_default_account,
        help="The income or expense account related to the selected 
product.")
    price_unit = fields.Float(string='Unit Price', required=True,
        digits= dp.get_precision('Product Price'),
        default=_default_price_unit)
    price_subtotal = fields.Float(string='Amount', digits= 
dp.get_precision('Account'),
        store=True, readonly=True, compute='_compute_price')
    quantity = fields.Float(string='Actual Quantity', digits= 
dp.get_precision('Product Unit of Measure'),
        required=True, default=1)
    discount = fields.Float(string='Discount (%)', digits= 
dp.get_precision('Discount'),
        default=0.0)
    invoice_line_tax_id = fields.Many2many('account.tax',
        'account_invoice_line_tax', 'invoice_line_id', 'tax_id',
        string='Taxes', domain=[('parent_id', '=', False)])
    account_analytic_id = fields.Many2one('account.analytic.account',
        string='Analytic Account')
    company_id = fields.Many2one('res.company', string='Company',
        related='invoice_id.company_id', store=True, readonly=True)
    partner_id = fields.Many2one('res.partner', string='Partner',
        related='invoice_id.partner_id', store=True, readonly=True)

```

and the code part I had tried something like this in fields\_view\_get(which was not successful)

```
def fields_view_get(self, view_id=None, view_type='form', 
toolbar=False, submenu=False):
        res = super(account_invoice_line, self).fields_view_get(
            view_id=view_id, view_type=view_type, toolbar=toolbar, 
submenu=submenu)
        if self._context.get('tot_qty_bool'):
            doc1 = etree.XML(res['arch'])
            for node in doc.xpath("//field[@name='tot_qty']"):
                if self._context['tot_qty_bool'] in ('False'):
                    node.set('invisible', '1')
                else:
                    node.set('invisible', '0')
            res['arch'] = etree.tostring(doc)
        return res

```

Please guide me on the correct way of doing this or let me know if there is any other alternative correct way of achieving the same. Would be really a great help.