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

FAQ

Terminology:

  • component: could be read as textfield, select, column, datagrid, button etc.
  • Form Builder: shall explicitly reference here the Odoo formio.builder record or the Form Builder tool.

1. Prefill a Form input component with data from Odoo (model) field

Whereas (for now) an input component primary references a textfield.

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. Open the Form Builder (tool), 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. Prefill a Form Datagrid or editgrid component with data from Odoo One2many or Many2many field

Whereas (for now) an input component primary references a textfield.

EXAMPLE with Sale Quotation/Order Lines

Create a form for a Sale Quote/Order, and generate rows with info/fields for every Order Line.

At least the following modules are required:

  • formio_data_api (makes the data loading possible)
  • formio_sale (ensures the linking between a Form and Sale Quote/Order).

Configuration necessities:

  1. In the Odoo form-view ensure the field "Resource Model" contains "Sale Order" (sale.order).
  2. Open the Form Builder (tool), add Data Grid or Edit Grid component and open the "API" tab.

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

3. Populate a select 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 in the Form Builder (tool)
  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

Previous 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