I have a type of invoice called “Facturas especiales”. This invoice type has the basis of a vendor invoice, but has a boolean that differentiates it from a vendor invoice and is handled as different entities.
I created a boolean field called “facturas_especiales” and placed it in the journals.
I want that when I am creating a special invoice, only the journals that have “special_invoices” with value True will be shown.
<odoo>
<record id="account_move_special_invoice_form_view" model="ir.ui.view">
<field name="name">account.move.special.invoice.view</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='journal_id']" position="attributes">
<attribute name="domain">[("facturas_especiales", "=", True)]</attribute>
</xpath>
<xpath expr="//form" position="attributes">
<attribute name="create">[("factura_especial", "=", True)]</attribute>
</xpath>
<xpath expr="//button[@name='action_reverse']" position="attributes">
<attribute name="invisible">factura_especial</attribute>
</xpath>
<xpath expr="//field[@name='name']" position="after">
<field name="factura_especial" invisible="1" />
</xpath>
</field>
</record>
I am editing the domain of the “journal_id” field to make it do the journal filtering, but it doesn’t work, it keeps showing other journals like “vendor invoices”, how can I make it to only show journals that have the boolean “special_invoices”?
As far as I can see, the journal_id
field is defined twice in the view. Your XPath finds the first definition. This embeds the field completely invisibly. The second definition must be addressed using XPath. Then it should work.
<xpath expr="//div[@name='journal_div']/field[@name='journal_id']" position="attributes">
<attribute name="domain">[("facturas_especiales", "=", True)]</attribute>
</xpath>
Shouldn’t the domain be dynamic? This would allow you to select only specific journals in each invoice, regardless of whether it is a customer or supplier invoice.