[FIX] account: domain on product

- Create a product P which cannot be sold (purchase only)
- Create a customer invoice

The product can be select on the invoice.

The `sale_ok` (as well as the `purchase_ok`) field is not taken into
account in the domain.

The solution is a bit hacky but has the advantage to be safe in regards
to customizations.

opw-2308897

closes odoo/odoo#55442

X-original-commit: 88b0b664606bb42acf26165e2b7fdda44a15e0a7
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-08-05 09:06:12 +00:00
parent cfc066c323
commit 88fa6f774b
+7 -1
View File
@@ -705,7 +705,13 @@
<!-- Displayed fields -->
<field name="sequence" widget="handle"/>
<field name="move_name" invisible="1"/>
<field name="product_id" optional="show" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/>
<field name="product_id"
optional="show"
domain="
context.get('default_move_type') in ('out_invoice', 'out_refund', 'out_receipt')
and [('sale_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]
or [('purchase_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]
"/>
<field name="name" widget="section_and_note_text" attrs="{'required': [('parent.move_type', 'not in', ('in_invoice', 'in_refund','in_receipt'))]}"/>
<field name="account_id"
groups="account.group_account_readonly"