Skip to Content
Menu
This question has been flagged
1 Reply
1639 Views

I have added two additional fields to the partners model to clearly identify them as customers or suppliers.

    is_customer = fields.Boolean(string='Is a Customer')
is_supplier = fields.Boolean(string='Is a Vendor')


We need that in the account.view_move_form form, when a customer invoice is transacted, only the business partners marked as customers appear, and when a supplier invoice is transacted, only the suppliers appear.

Try replacing the partner_id field using domain to filter and move_type to make the field invisible in each case.


" rel="ugc">ir.ui.view">
account.move









Apparently this worked well in the BIlls, but in the invoices the Customer field appears with the supplier domain.

Avatar
Discard
Author

The form code was truncated

<record id="account_invoice_form" model="ir.ui.view">
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="replace">
<field name="partner_id" widget="res_partner_many2one" string="Customer" context="{'res_partner_search_mode': (context.get('default_move_type', 'entry') in ('out_invoice', 'out_refund', 'out_receipt') and 'customer') or (context.get('default_move_type', 'entry') in ('in_invoice', 'in_refund', 'in_receipt') and 'supplier') or False,'show_address': 1, 'default_is_company': True, 'show_vat': True}" domain="[('type', '!=', 'private'), ('company_id', 'in', (False, company_id)),['is_customer','=',True]]" options="{'always_reload': True, 'no_quick_create': True}" attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/>
<field name="partner_id" widget="res_partner_many2one" string="Vendor" context="{'res_partner_search_mode': (context.get('default_move_type', 'entry') in ('out_invoice', 'out_refund', 'out_receipt') and 'customer') or (context.get('default_move_type', 'entry') in ('in_invoice', 'in_refund', 'in_receipt') and 'supplier') or False,'show_address': 1, 'default_is_company': True, 'show_vat': True}" domain="[('type', '!=', 'private'), ('company_id', 'in', (False, company_id)),['is_supplier','=',True]]" options="{'always_reload': True, 'no_quick_create': True}" attrs="{'invisible': [('move_type', 'not in', ('in_invoice', 'in_refund', 'in_receipt'))]}"/>
</xpath>
</field>
</record>

Best Answer

the "Customer" field in the account_invoice_form view. The current domain filter used for the customer field is:

[('type', '!=', 'private'), ('company_id', 'in', (False, company_id)),['is_customer','=',True]]

This domain filter includes an extra list [ ] enclosing the condition ['is_customer','=',True]. This is causing the domain filter to fail since the condition is not being applied properly.

you might want ti replace with 

[('type', '!=', 'private'), ('company_id', 'in', (False, company_id)), ('is_customer','=',True)]


Avatar
Discard
Author

Thanks for your answer Youssef!
But it didn't work :(

I posted a video in this thread to show the behavior..