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

QWeb Select component: dict value with data source URL #157

Open
bobslee opened this issue Jun 29, 2021 · 8 comments
Open

QWeb Select component: dict value with data source URL #157

bobslee opened this issue Jun 29, 2021 · 8 comments
Labels
bug Something isn't working formio_report_qweb (module)

Comments

@bobslee
Copy link
Member

bobslee commented Jun 29, 2021

Regular select component stores the selected value.
However, with datasource URL it stores a dict.

Problem:
This results in empty select component (input) in the QWeb report.
No value visible.

@bobslee bobslee added formio_report_qweb (module) bug Something isn't working labels Jun 29, 2021
@zuher83
Copy link

zuher83 commented Jan 11, 2024

Hi,
It's curious because it returns an empty boolean object in QWEB render 🤔
However, in screen views there is no problem

@bobslee
Copy link
Member Author

bobslee commented Jan 11, 2024

@zuher83 What's your question actually?

@zuher83
Copy link

zuher83 commented Jan 11, 2024

@bobslee , I'm looking for an idea to help solve the bug because it's been unresolved for a long time. I've spent a few hours debugging and I still haven't found anything...

Url returns a dictionary eg: {'id': self.id, 'value_label': self.name} this is stored (object or str) I've tried everything and it's visible everywhere except when printing.

When debugging with ipb I see that it has an object but it's empty.

My question is, do you have any idea how to fix this bug or a different way of displaying the values?

@bobslee
Copy link
Member Author

bobslee commented Jan 11, 2024

@zuher83 Can you provide some test data:

  • Builder JSON
  • Form submission JSON

Maybe I can find some time to fix this... upcoming days, weeks.

@zuher83
Copy link

zuher83 commented Jan 11, 2024

@bobslee ok thanks

This is form builder JSON

{"components": [{"label": "Partner", "labelPosition": "top", "widget": "choicesjs", "placeholder": "", "description": "", "tooltip": "", "customClass": "", "tabindex": "", "hidden": false, "hideLabel": false, "uniqueOptions": false, "autofocus": false, "disabled": false, "tableView": true, "modalEdit": false, "multiple": false, "dataSrc": "url", "data": {"resource": "", "url": "ressource/partner", "json": "", "custom": "", "headers": [{"key": "", "value": ""}], "values": [{"label": "", "value": ""}]}, "dataType": "", "idPath": "id", "valueProperty": "value_labels", "template": "<span>{{ item.label }}</span>", "refreshOn": "", "refreshOnBlur": "", "clearOnRefresh": false, "searchEnabled": true, "selectThreshold": 0.3, "readOnlyValue": false, "customOptions": {}, "useExactSearch": false, "persistent": true, "protected": false, "dbIndex": false, "encrypted": false, "clearOnHide": true, "customDefaultValue": "", "calculateValue": "", "calculateServer": false, "allowCalculateOverride": false, "validateOn": "change", "validate": {"required": false, "customMessage": "", "custom": "", "customPrivate": false, "json": "", "strictDateValidation": false, "multiple": false, "unique": false, "onlyAvailableItems": false}, "unique": false, "errorLabel": "", "errors": "", "key": "partner", "tags": [], "properties": {}, "conditional": {"show": null, "when": null, "eq": "", "json": ""}, "customConditional": "", "logic": [], "attributes": {}, "overlay": {"style": "", "page": "", "left": "", "top": "", "width": "", "height": ""}, "type": "select", "indexeddb": {"filter": {}}, "selectFields": "", "searchField": "", "searchDebounce": 0.3, "minSearch": 0, "filter": "", "limit": 100, "redrawOn": "", "input": true, "prefix": "", "suffix": "", "dataGridLabel": false, "showCharCount": false, "showWordCount": false, "allowMultipleMasks": false, "addons": [], "authenticate": false, "ignoreCache": false, "lazyLoad": true, "fuseOptions": {"include": "score", "threshold": 0.3}, "id": "emqxebi", "defaultValue": "", "selectValues": "", "disableLimit": false, "sort": "", "noRefreshOnScroll": false}, {"type": "button", "label": "Submit", "key": "submit", "size": "md", "block": false, "action": "submit", "disableOnInvalid": true, "theme": "primary", "id": "eooush2", "input": true, "placeholder": "", "prefix": "", "customClass": "", "suffix": "", "multiple": false, "defaultValue": null, "protected": false, "unique": false, "persistent": false, "hidden": false, "clearOnHide": true, "refreshOn": "", "redrawOn": "", "tableView": false, "modalEdit": false, "dataGridLabel": true, "labelPosition": "top", "description": "", "errorLabel": "", "tooltip": "", "hideLabel": false, "tabindex": "", "disabled": false, "autofocus": false, "dbIndex": false, "customDefaultValue": "", "calculateValue": "", "calculateServer": false, "widget": {"type": "input"}, "attributes": {}, "validateOn": "change", "validate": {"required": false, "custom": "", "customPrivate": false, "strictDateValidation": false, "multiple": false, "unique": false}, "conditional": {"show": null, "when": null, "eq": ""}, "overlay": {"style": "", "left": "", "top": "", "width": "", "height": ""}, "allowCalculateOverride": false, "encrypted": false, "showCharCount": false, "showWordCount": false, "properties": {}, "allowMultipleMasks": false, "addons": [], "leftIcon": "", "rightIcon": ""}]}

Create test controller:

import logging
from odoo.http import request
from odoo.addons.formio.controllers.main import FormioController

class FormioController(FormioController):

    @http.route(['/formio/form/ressource/partner', '/formio/builder/ressource/partner'], type='http', auth='user', csrf=False)
    def get_partner_data(self, **kwargs):

        partners = request.env['res.partner'].sudo().search(
            [('active', '=', True)])
        partners_ids = []
        for partner in partners:
            label = '%s - %s' % (partner.name, partner.ref)
            vals = {
                'id': partner.id,
                'name': partner.name,
                'display_name': partner.display_name,
                'email': partner.email or '',
                'phone': partner.phone or '',
                'mobile': partner.mobile or '',
                'street': partner.street or '',
                'street2': partner.street2 or '',
                'zip': partner.zip or '',
                'city': partner.city or '',
                'country_id': partner.country_id.name or '',
                'function': partner.function or '',
                'vat': partner.vat or '',
                'ref': partner.ref or '',
                'value_labels': label,
                'label': label,
            }
            partners_ids.append(vals)

        return json.dumps(partners_ids)

result in form submission:

{"partner": "Martine VENTURA - 03FSUD001", "submit": true}

@bobslee
Copy link
Member Author

bobslee commented Jan 11, 2024

@zuher83 Why the (test) controller is need?

I suppose the endpoint fetches partner records to load into a Select component?
Similar (generic) functionality provided by module: https://apps.odoo.com/apps/modules/16.0/formio_components_api/

@zuher83
Copy link

zuher83 commented Jan 11, 2024

@bobslee Yes, I know, this is an easy example for URL, because the forms in my case are integrated into a complex logic and other endpoints than Odoo 🙂

@bobslee
Copy link
Member Author

bobslee commented Jan 12, 2024

@zuher83 Concerning the form submission JSON. I didn't expect the label, but the ID value.

Also I expect it will take a few hours to analyse and develop this.
We offer this as paid service.
You can submit a request to discuss on https://www.novacode.nl/contact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working formio_report_qweb (module)
Projects
None yet
Development

No branches or pull requests

2 participants