Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
7513 Ansichten

Odoo 9.0 community edition.

When there is a many2one field in an odoo from it is possible to select "create and edit" from the dropdown menu when populating this field in edit mode. This brings up a window which allows you to create a record. I know that you can also provide a "context" such that some of the fields of the new record are pre-populated for you.

I'd like to have a button with a server action that let's me do some calculations on what the context should be and then bring up this same window (new window). In particular this is about creating a contact from a sales opportunity. I was not able to find the window action to call. I tried the window action called Contacts, and this brings up a contact edit window, although there is no Save button at the bottom.

Avatar
Verwerfen

Hey, did you ever find a solution for this? I am experiencing exactly the same problem and I am very excited to find a solution.

Beste Antwort

So, it turns out there is *not* a window action behind the "create and edit" button -- it's a widget not an action.


Because of this, you need to set the context attribute on the field node in your view.

<field name="many_to_one_model" context="{'default_field': 'prepopulated value'}"/>

Additionally, you may have to explicitly supply the view to use (in cases where there are two views of the same type for a particular model). To specify a form view, for example, set a form_view_ref context option with the xml id of your view.

'form_view_ref': 'module.many_to_one_model_form_view'
Avatar
Verwerfen

Isaac,

How can I do this for the customer many2one field on sale.order model. When I create a new contact. I want the wizard that opens to be populated with value from sale.order field.

Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Jan. 19
11127
0
Juni 15
3740
1
Okt. 17
4258
1
Jan. 25
1278
2
Aug. 24
1397