Reputation: 23
In odoo 10.0, I have added a field invoice_id
:
invoice_id = fields.Many2one('account.invoice', 'Invoice', domain=[('state','=','open')])
I want to show this field on two views: one view for customer and other one for supplier.
Now I'd like to show in this field only customer invoices for the customer form view and supplier invoice for the supplier form view.
Upvotes: 0
Views: 1125
Reputation: 9620
If you just want to filter the invoices for a specific user go to the invoices view, filter by open
invoices and then filter by writing the customer as well. You can even create a button to show the open invoices, you should return the action window with the right domain.
In fact, I think there is already a button to show the invoiced invoices, maybe you need to activate it on the accounting settings.
But setting aside all of this and getting to the point, you could add a domain in the field for each form view:
Customer view:
<field name="invoice_id" domain="[('type','=','out_invoice')]" />
Supplier view:
<field name="invoice_id" domain="[('type','=','in_invoice')]" />
Note: possible values for type
type = fields.Selection(
string='Type',
selection=[
('out_invoice', 'Customer Invoice'),
('in_invoice', 'Supplier Invoice'),
('out_refund', 'Customer Refund'),
('in_refund', 'Supplier Refund')
],
)
Upvotes: 2