Skip to Content
Menu
This question has been flagged
2 Replies
3925 Views

I'm trying to make invisible two fields on invoice lines on odoo, but I can't.
These fields should only show for invoice lines on  Vendor Bills but they are also being shown for customers invoices.  How can I control it?

My code: 

Python

class accountMoveLineInherit2(models.Model):
    _inherit = "account.move.line"

    hs_type = fields.Selection(related='move_id.type', store=True)
    
    hs_concepto = fields.Selection([
        ('1', 'Compras o adquisiciones de bienes muebles'),
        ('2', 'Servicios Básicos'),
        ('3', 'Honorarios y Comisiones por Servicios Personales'),
        ('4', 'Alquileres por Arrendamientos Comerciales'),
        ('5', 'Cargos Bancarios, Intereses y otros Gastos Financieros'),
        ('6', 'Compras o Servicios del Exterior'),
        ('7', 'Compras o Servicios Consolidados'),],string = 'Concepto', required=True)

    hs_compra = fields.Selection([
        ('1', 'Locales'),
        ('2', 'Importaciones')], string='Tipo de Compra', required=True)

XML
<xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='name']" position = "after" > 
                    <field name="hs_type" invisible="1"/> 
                    <field name="hs_concepto" attrs="{'invisible': [('hs_type', 'not in', ('in_invoice', 'in_refund', 'in_receipt'))]}"/>
                    <field name="hs_compra"/> 
                </xpath> 
                <xpath expr="//field[@name='line_ids']/tree/field[@name ='account_id']" position = "before" > 
                    <field name="hs_type" invisible="1"/>
                    <field name="hs_concepto" attrs="{'invisible': [('hs_type', 'not in', ('in_invoice', 'in_refund', 'in_receipt'))]}"/>
                    <field name="hs_compra"/> 
                </xpath>

But doesn't work !
Avatar
Discard
Best Answer

Hi,

in V13, it is possible to hide a column in O2M field. 

try this :

<field name="hs_concepto" attrs="{'column_invisible': [('parent.type', 'not in', ('in_invoice', 'in_refund', 'in_receipt'))]}"/>

Avatar
Discard
Best Answer

attrs invisible only work for form view field. here you are trying to apply it on the list view 

list/tree view has many records so base on one record(row) value you could not hide an entire column because other record(s) may not satisfied attrs invisible condition.

there is column_invisible options (attrs="{'column_invisible': [condition]) based on parent record value but it's not fix with your requirement.



Avatar
Discard