Skip to content
Bob Leers edited this page Apr 20, 2021 · 19 revisions

FAQ

1. Prefill a Form input field with data from a model in Odoo

EXAMPLE with CRM Lead

Create a form for a CRM Lead, and have it autofill certain information such as the customer info.

At least the following modules are required:

  • formio_data_api (makes the data loading possible)
  • formio_crm (ensures the linking between a Form and CRM Lead).

Configuration necessities:

  1. In the Odoo form-view ensure the field "Resource Model" contains "CRM Lead" (crm.lead).
  2. Go to the Form Builder, edit some input component and open the "API" tab.
  3. To use the Lead name field, fill in (setting field) Property Name: Odoo__name
    (double underscore is required to traverse fields).

About the prefixes:

  • Odoo : Uses the stored value after the Form has been submitted (state != pending).
  • OdooRF : Refreshes the data even if the Form has been completed (for every state).

2. Populate a select field/component with Odoo data

Possible use case: Use a select field/component to load and provide the Odoo customers (display name), available in the res. partner model.

Important, not supported: To keep data secure, this currently only works in the Odoo backend and portal. In case you want to use this on the website (public user) this won't work (yet).

Required setup/actions:

  1. Drop a Select component on the Form Builder
  2. Edit Select component and open the Data tab
  3. Fill in the field Data Source URL: /data
  4. Fill in the field Filter Query: model=res.partner&label=name

This Filter Query will get all partners. It's also possible to filter certain partners, by adding extra URL query-params. Following example loads data into Select Component, whereby choices are the partner names with city "Sittard".

Filter Query: model=res.partner&label=name&domain_fields=city&city=Sittard

Clone this wiki locally