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

good night,

please request your support, thank you very much.

When I open a new invoice, I want to hide a field in the invoice according to a value of another model. I am trying with:

class ResCompany(models.Model):

    _inherit="res.company"

    tipo_envio = fields.Selection(selection=[("0","p"),("3","a")])


class AccountInvoice(models.Model):

     _inherit = "account.invoice"

     related_tipo_envio = fields.Selection(related="company_id.tipo_envio",store=True)

     tipo = fields.Selection(selection=[("01","cat"),("02","dog")],default="01",required=True,copy=False)


    <xpath expr="//field[@name='date_due']" position="after">

    <field name="related_tipo_envio" invisible="1"/>

    <field name="tipo" string="Tipo" attrs="{'readonly':[['state','not in',['draft']]],'invisible':[('related_tipo_envio','=','3')]}" />


but the "type" field that I want to hide is always visible.

that could be happening? or that may be missing.

Thank you.


Avatar
Discard

Check odoo customization tips: https://goo.gl/8HgnCF

Best Answer

Hello,

May be you missing the set the value into company fields tipo_envio so that default not set value into fields tipo_envio of company.So that that related fields value also not set into customer invoice and your fields not hide.

So first your set the tipo_envio fields value that exist into company.

Thanks

Haresh Chavda

Avatar
Discard