pythonodooodoo-17

Filters in inherited views


Create a new invoice type for Odoo "Facturas especiales", they share the "in_invoice" type, but "Facturas especiales" have a boolean field that differentiates them from normal vendor invoices. The filter to not show normal vendor invoices in the "Facturas especiales" view works, but the filter to NOT show "Facturas especiales" in the vendor invoices view does not work.

Filter that works

  <record id="account_move_special_invoice_menu" model="ir.actions.act_window">
    <field name="name">Facturas especiales</field>
    <field name="res_model">account.move</field>
    <field name="view_mode">tree,form</field>
    <field name="domain">[("factura_especial", "=", True)]</field>
    <field name="context">{"default_move_type": "in_invoice", "default_factura_especial": True}</field>
  </record>

Filter does not work

  <record id="account_move_supplier_invoice_action" model="ir.actions.act_window">
    <field name="name">Facturas de proveedor</field>
    <field name="res_model">account.move</field>
    <field name="view_mode">tree,form</field>
    <field name="domain">[("move_type", "=", "in_invoice"), ("factura_especial", "=", False)]</field>
  </record>

I can't think of any other way to try to filter the records and would like to know why the filter is not working and the "Facturas especiales" are still displayed in the vendor invoice view.


Solution

  • Odoo will create a new action and will not override the bill action domain (the filter will not apply on the bills menu action)

    To inherit the bills action and set a new domain use its external id account.action_move_in_invoice_type

    Example:

    <record id="account.action_move_in_invoice_type" model="ir.actions.act_window">
        <field name="domain">[("move_type", "=", "in_invoice"), ("factura_especial", "!=", False)]</field>
    </record>