Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V12] Unable to populate a select field with odoo data #11

Closed
ygol opened this issue Feb 10, 2020 · 19 comments
Closed

[V12] Unable to populate a select field with odoo data #11

ygol opened this issue Feb 10, 2020 · 19 comments
Labels
bug Something isn't working question Further information is requested

Comments

@ygol
Copy link

ygol commented Feb 10, 2020

I am trying to create a simple form containing a select field that is populated with odoo data.

  1. created a form builder & added resource model (formio_res_model_id) = "Sale Order".
  2. the notebook tab "Resource Settings" is unhided but empty.
  3. click on "Form Builder".
  4. add a "Select" component and under Data choose Data Source Type = "Resource"

Am I missing something?

Thanks in advance.

@bobslee
Copy link
Member

bobslee commented Feb 10, 2020

Hi,
No.. a Formio Resource isn't integrated with Odoo.
Did you installed the formio_sale module as well?

Which version of the module do you use?
Did you tried on the Demo environment?

@ygol
Copy link
Author

ygol commented Feb 10, 2020

Hi,
No.. a Formio Resource isn't integrated with Odoo.
Did you installed the formio_sale module as well?

Which version of the module do you use?
Did you tried on the Demo environment?

I tried on the Demo too. and also have installed "formio_sale".

So how would I demo: ?

"Provide Form-fields with data from Odoo. For example: a selection/dropdown field where choices are Odoo Products, filtered by some product-category."

tnx again

@bobslee
Copy link
Member

bobslee commented Feb 14, 2020

This (for I know currently) only works with Select component.

For example - the following shows (product) names from Sale order lines.
So resource model: sale.order

image

Also see the URL endpoint (Odoo formio controller) which implements this. See the comment and options to use in URL query-params.
https://github.com/novacode-nl/odoo-formio/blob/12.0/formio/controllers/main.py#L321

@ygol
Copy link
Author

ygol commented Feb 15, 2020

Yes, I tried that but it doesn't seem to work for me.

On your runbot:

  • to what version of the builder does your snapshot correspond? I could not find the same one. I tried latest and 4.7.8.
  • I tried both examples from your code (access to data unrelated to res_data at L278 and your example at L326)
  • I succeeded to get something with the following direct URL:

https://odoo12-b4a887d572e9.victhorious.com/formio/form/data/1961b599-a67c-4164-a0f8-814fdcf8e92a?model=res.partner&label=name&domain_fields=function&city=Sittard

I get:

[{"id": 14, "label": "Azure Interior"}, {"id": 26, "label": "Brandon Freeman"}, {"id": 33, "label": "Colleen Diaz"}, {"id": 27, "label": "Nicole Ford"}, {"id": 10, "label": "Deco Addict"}, {"id": 35, "label": "Addison Olson"}, {"id": 18, "label": "Douglas Fletcher"}, {"id": 19, "label": "Floyd Steward"}, {"id": 11, "label": "Gemini Furniture"}, {"id": 20, "label": "Edwin Hansen"}, {"id": 22, "label": "Jesse Brown"}, {"id": 31, "label": "Oscar Morgan"}, {"id": 23, "label": "Soham Palmer"}, {"id": 15, "label": "Lumber Inc"}, {"id": 34, "label": "Lorraine Douglas"}, {"id": 12, "label": "Ready Mat"}, {"id": 21, "label": "Billy Fox"}, {"id": 25, "label": "Edith Sanchez"}, {"id": 37, "label": "Julie Richards"}, {"id": 24, "label": "Kim Snyder"}, {"id": 36, "label": "Sandra Neal"}, {"id": 30, "label": "Theodore Gardner"}, {"id": 38, "label": "Travis Mendoza"}, {"id": 13, "label": "The Jackson Group"}, {"id": 29, "label": "Gordon Owens"}, {"id": 28, "label": "Toni Rhodes"}, {"id": 9, "label": "Wood Corner"}, {"id": 17, "label": "Ron Gibson"}, {"id": 32, "label": "Tom Ruiz"}, {"id": 16, "label": "Willie Burke"}, {"id": 1, "label": "YourCompany"}, {"id": 39, "label": "Chester Reed"}, {"id": 40, "label": "Dwayne Newman"}, {"id": 8, "label": "Joel Willis"}, {"id": 7, "label": "Marc Demo"}, {"id": 3, "label": "Mitchell Admin"}, {"id": 41, "label": "celery"}]

But as you can see, the "filtering part" ("&domain_fields=function&city=Sittard") doesn't work. But I am unable to get the same result into a list element in the form.

  • I can't get anything useful in the logs (on my server).

@bobslee
Copy link
Member

bobslee commented Feb 15, 2020

Ok thanks for checking and the log.
I shall take a look (and fix) upcoming days.
Shall let you know.

@bobslee bobslee added the question Further information is requested label Feb 29, 2020
@lieblinger
Copy link
Contributor

lieblinger commented Mar 2, 2020

Can confirm when I'm passing the url directly with following schema it works.

https://server_adress/formio/form/data/uuid_from_db?model=res.partner&label=name

It looks like the form is not transmitting the uuid to the controller and that's why the function isn't transmitting the desired content to the formio form.

Wouldn't it a work around to remove the "if not form" check from the controller?

@bobslee bobslee closed this as completed in 02ecc1a Mar 4, 2020
bobslee added a commit that referenced this issue Mar 4, 2020
Change URLs so Formio JS client doesn't strip the UUID (issue #11)
@bobslee bobslee reopened this Mar 4, 2020
@bobslee bobslee added the bug Something isn't working label Mar 4, 2020
bobslee added a commit that referenced this issue Mar 4, 2020
[UPD] Resolves #11. Change URLs so Formio JS client doesn't strip the…
@bobslee
Copy link
Member

bobslee commented Mar 4, 2020

Hi @ygol, @lieblinger
I just pushed some changes to v11 and v12 branches, to address this issue.
Please could you test and report here?

Required steps:

  • Download and replace with latest version of modules: formio and formio_sale
  • Install or upgrade formio_sale
  • Test with the new formio_sale Form Builder record Demo Sale 1

v12:
https://github.com/novacode-nl/odoo-formio/blob/12.0/formio_sale/data/formio_demo_data.xml

v11:
https://github.com/novacode-nl/odoo-formio/blob/11.0/formio_sale/data/formio_demo_data.xml

@bobslee
Copy link
Member

bobslee commented Mar 4, 2020

By the way, mind the URL in the Select component it's Data Source URL field.
From now on it's without a leading "/".

So the correct Date Source URL are just:

  • data (to query all Odoo models)
  • res_data (to query from related/resource Odoo model)

@bobslee
Copy link
Member

bobslee commented Mar 5, 2020

You could check my v12 demo. It's already deployed over there.
https://odoo12-b4a887d572e9.victhorious.com/

Login: demo / demo

There's a "Demo Sale 1" form builder, with 2 Select components fetching data from Odoo.
https://odoo12-b4a887d572e9.victhorious.com/web#id=97&action=114&model=formio.builder&view_type=form&menu_id=83

However notice (unrelated) issue #20 tough.

@lieblinger
Copy link
Contributor

Checked your updated online instance and tried it also on my local odoo and flectra enviroment, but it's stilll not working.

I've putted a print statement into the form_data controller function. The print() command is never excuted, so it seems like there's still something wrong.

By the way... Before your last commit it only worked with fqdn + /formio/form/data/ + manual uuid in the formio url field. When I putted only /formio/form/data without fqdn in the url field it didn't work.

@bobslee
Copy link
Member

bobslee commented Mar 6, 2020

Did you merged all my latest changes into your Flectra fork?
Also cleared your webbrowser cache?

@lieblinger
Copy link
Contributor

Tested your online demo (link below) right now in edge and chrome with cleared browser cache and it's not working. See screenshot.

https://odoo12-b4a887d572e9.victhorious.com/web#id=97&action=114&model=formio.builder&view_type=form&menu_id=83
formio

@bobslee
Copy link
Member

bobslee commented Mar 6, 2020

That makes sense. Such events don't work (yet) from the Form Builder.
Please create a Form and try again :)

I just tested with the Form: https://odoo12-b4a887d572e9.victhorious.com/web?#id=96&view_type=form&model=formio.form&action=116&menu_id=83

The JSON-RPC request from the Form Builder needs to be blocked somehow.

@lieblinger
Copy link
Contributor

That really makes sense 👍

In a Form it works great on flectra and odoo v11.

@bobslee
Copy link
Member

bobslee commented Mar 7, 2020

Thanks for reviewing @lieblinger. I really appreciate it!
BTW you can also enable the "Multiple values" option for a Select component.

@bobslee
Copy link
Member

bobslee commented Mar 9, 2020

Closed this issue. No further info received.

@bobslee bobslee closed this as completed Mar 9, 2020
@bobslee
Copy link
Member

bobslee commented Sep 15, 2020

Prefix the "Data Source URLs" with a "/", indicating it's relative. So from now on:

  • /data
  • /res_data

@framatt
Copy link

framatt commented Nov 19, 2020

Does someone have a working example on how to set this up?

@bobslee
Copy link
Member

bobslee commented Nov 23, 2020

@framatt see this issue with my examples.
You only need to change the Data Source URLs... like a mentoined in my previous comment.

If you need more support, send me a DM mail: bob (at) novacode (dot) nl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants