Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Proper selection of invoice lines for a many-to-one field

By
Peter Nietz
on 1/8/15, 4:29 AM 838 views

In our custom module we have introduced a new model (for software licenses) that needs to reference the according invoice line. The field is declared as follows (API v8):

invoice_line = fields.Many2one(string='Invoice line', comodel_name='account.invoice.line')

The view includes the field as follows:

<field name="invoice_line" options="{'no_create_edit':'1'}"/>

Now our problem is that the selection widget for the field only presents the descriptions of the invoice lines... giving absolutely no indication about e.g. the invoice number. This is really an issue since we use standardized invoice line descriptions and thus have many invoices containing invoice lines with identical descriptions (which makes it impossible to select the correct invoice line from the correct invoice).

What would be the best strategy to overcome this issue?

Do we have to introduce an additional field to select the invoice first and then (in the second step) select an invoice line from a filtered list (showing only the invoice lines from the previously selected invoice)?

1

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 1/8/15, 6:59 AM

@Peter, the information displayed in the widget (and views) is controlled by: field which is called name, the _name attribute of the object which can override which field is considered to be 'name', and ultimately the name_get method.  So, you can inherit the name_get method of account.invoice.line to display the name as you'll require.

As for the searching, you can use the filtering method as you've desribed, or you can inherit name_search method of account.invoice.line to also consider the account.invoice's name during searching.

Thanks for the suggestion. That would have worked. However we decided to have nested fields (one field for the invoice and one for the invoice line with domain set to the selected invoice) anyway. The total number of invoice lines was too big to allow a feasible selection.

Peter Nietz
on 1/21/15, 3:24 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/8/15, 4:29 AM
Seen: 838 times
Last updated: 3/16/15, 8:10 AM