我正在尝试根据需要设置invoice_payment_term_id字段。通常只需添加required =“ 1”应该可以,但不能在这里使用:
<!-- Invoice payment terms (only invoices) + due date (only invoices / receipts) -->
<label for="invoice_payment_term_id" attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/>
<div class="d-flex" attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}">
<field name="invoice_payment_term_id" placeholder="Terms" attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/>
<span class="o_form_label mx-3 oe_edit_only" attrs="{'invisible': [ '|', '|', '|', ('state', '!=', 'draft'), ('invoice_payment_term_id', '!=', False), ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"> or </span>
<field name="invoice_date_due" force_save="1" placeholder="Date" attrs="{'invisible': ['|', ('invoice_payment_term_id', '!=', False), ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/>
</div>
我尝试过:<field name="invoice_payment_term_id" placeholder="Terms" required="1" attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/>
和
<field name="invoice_payment_term_id" placeholder="Terms" attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))], 'required': [('type', 'not in', 'in_refund')]}"/>
请确保大多数情况下是在表单视图上执行的,这是在您继承错误的视图时发生的>]