Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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)?

Awatar
Odrzuć
Najlepsza odpowiedź

@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.

Awatar
Odrzuć
Autor

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.

Powiązane posty Odpowiedzi Widoki Czynność
1
kwi 16
5989
1
mar 15
4054
5
gru 19
8082
3
lip 16
7919
1
mar 15
5173