如何构建过滤器以便合同发票行产品下拉列表仅显示可销售产品

How to build filter so contract invoice lines product dropdown shows sellable products only

我在 Odoo 中使用合约。在合同中我检查了 generate recurring invoices,然后我可以添加产品以生成发票行。

如果我添加产品,会出现该产品的搜索下拉菜单,但它会显示可能无法售出的商品。

我想解决这个问题,所以我搜索了视图并在 addons/./account_analytic_analysis/account_analytic_analysis_view.xml 中找到了它。这是相关的 xml:

   <div attrs="{'invisible': [('recurring_invoices','=',False)]}">
        <field name="recurring_invoice_line_ids">
            <tree string="Account Analytic Lines" editable="bottom">
                <field name="product_id" on_change="product_id_change(product_id, uom_id, quantity, False, parent.partner_id, False, parent.pricelist_id, parent.company_id)"/>
                <field name="name"/>
                <field name="quantity"/>
                <field name="uom_id"/>
                <field name="price_unit"/>
                <field name="price_subtotal"/>
            </tree>
        </field>
    </div>

为了过滤掉不可销售的产品,我想添加一个 filter_domain,如下所示:

<field name="product_id"  
       filter_domain="[('product_id.product_tmpl_id.sale_ok','=',True)]"
       on_change="product_id_change(product_id, uom_id, quantity, False, parent.partner_id, False, parent.pricelist_id, parent.company_id)"
/>

实际上我尝试了多种形式,但都没有用,仍然列出了不可销售的项目。如何构建正确的过滤器?

<field name="product_id" .../> 添加属性 domain="[('sale_ok', '=', True)]"