Closed Home-Based closed 2 years ago
Hi Seb @Home-Based, Thanks for your report. I just tested your steps and found your issue. Please close this GitHub issue if affirmative.
This indeed fails due to the Title API config you used, with partner_id.title
.
The error can be determined from the Odoo server log (see below), also shown in the browser's webdeveloper tools (F12) Console tab.
SOLUTION:
The (partner) Title is a Many2one field in res.partner
, so the API user_field
should resolve to a scalar/value field:
parnter_id.title.name
It works with the following Builder JSON:
{"components": [{"label": "Columns", "labelWidth": "", "labelMargin": "", "columns": [{"components": [{"label": "Name", "labelPosition": "top", "labelWidth": "", "labelMargin": "", "placeholder": "", "description": "", "tooltip": "", "prefix": "", "suffix": "", "widget": {"type": "input"}, "inputMask": "", "displayMask": "", "allowMultipleMasks": false, "customClass": "", "tabindex": "", "autocomplete": "", "hidden": false, "hideLabel": false, "showWordCount": false, "showCharCount": false, "mask": false, "autofocus": false, "spellcheck": true, "disabled": false, "tableView": true, "modalEdit": false, "multiple": false, "persistent": true, "inputFormat": "plain", "protected": false, "dbIndex": false, "case": "", "truncateMultipleSpaces": false, "encrypted": false, "redrawOn": "", "clearOnHide": true, "customDefaultValue": "", "calculateValue": "", "calculateServer": false, "allowCalculateOverride": false, "validateOn": "change", "validate": {"required": false, "minLength": "", "maxLength": "", "minWords": "", "maxWords": "", "pattern": "", "customMessage": "", "custom": "", "customPrivate": false, "json": "", "strictDateValidation": false, "multiple": false, "unique": false}, "unique": false, "errorLabel": "", "errors": "", "key": "email", "tags": [], "properties": {"user_field": "partner_id.name"}, "conditional": {"show": null, "when": null, "eq": "", "json": ""}, "customConditional": "", "logic": [], "attributes": {}, "overlay": {"style": "", "page": "", "left": "", "top": "", "width": "", "height": ""}, "addons": [], "type": "textfield", "input": true, "refreshOn": "", "dataGridLabel": false, "inputType": "text", "id": "eh9l99q", "defaultValue": ""}], "width": 6, "offset": 0, "push": 0, "pull": 0, "size": "md", "currentWidth": 6}, {"components": [{"label": "Email", "labelPosition": "top", "labelWidth": "", "labelMargin": "", "placeholder": "", "description": "", "tooltip": "", "prefix": "", "suffix": "", "widget": {"type": "input"}, "displayMask": "", "customClass": "", "tabindex": "", "autocomplete": "", "hidden": false, "hideLabel": false, "mask": false, "autofocus": false, "spellcheck": true, "disabled": false, "tableView": true, "modalEdit": false, "multiple": false, "persistent": true, "inputFormat": "plain", "protected": false, "dbIndex": false, "case": "", "truncateMultipleSpaces": false, "encrypted": false, "redrawOn": "", "clearOnHide": true, "customDefaultValue": "", "calculateValue": "", "calculateServer": false, "allowCalculateOverride": false, "validateOn": "change", "validate": {"required": false, "minLength": "", "maxLength": "", "pattern": "", "customMessage": "", "custom": "", "customPrivate": false, "json": "", "strictDateValidation": false, "multiple": false, "unique": false}, "unique": false, "kickbox": {"enabled": false}, "errorLabel": "", "errors": "", "key": "email1", "tags": [], "properties": {"user_field": "partner_id.email"}, "conditional": {"show": null, "when": null, "eq": "", "json": ""}, "customConditional": "", "logic": [], "attributes": {}, "overlay": {"style": "", "page": "", "left": "", "top": "", "width": "", "height": ""}, "addons": [], "type": "email", "input": true, "refreshOn": "", "dataGridLabel": false, "showCharCount": false, "showWordCount": false, "allowMultipleMasks": false, "inputType": "email", "inputMask": "", "id": "e36605q", "defaultValue": ""}], "width": 6, "offset": 0, "push": 0, "pull": 0, "size": "md", "currentWidth": 6}, {"components": [{"label": "Title", "labelPosition": "top", "labelWidth": "", "labelMargin": "", "placeholder": "", "description": "", "tooltip": "", "prefix": "", "suffix": "", "widget": {"type": "input"}, "inputMask": "", "displayMask": "", "allowMultipleMasks": false, "customClass": "", "tabindex": "", "autocomplete": "", "hidden": false, "hideLabel": false, "showWordCount": false, "showCharCount": false, "mask": false, "autofocus": false, "spellcheck": true, "disabled": false, "tableView": true, "modalEdit": false, "multiple": false, "persistent": true, "inputFormat": "plain", "protected": false, "dbIndex": false, "case": "", "truncateMultipleSpaces": false, "encrypted": false, "redrawOn": "", "clearOnHide": true, "customDefaultValue": "", "calculateValue": "", "calculateServer": false, "allowCalculateOverride": false, "validateOn": "change", "validate": {"required": false, "minLength": "", "maxLength": "", "minWords": "", "maxWords": "", "pattern": "", "customMessage": "", "custom": "", "customPrivate": false, "json": "", "strictDateValidation": false, "multiple": false, "unique": false}, "unique": false, "errorLabel": "", "errors": "", "key": "title", "tags": [], "properties": {"user_field": "partner_id.title.name"}, "conditional": {"show": null, "when": null, "eq": "", "json": ""}, "customConditional": "", "logic": [], "attributes": {}, "overlay": {"style": "", "page": "", "left": "", "top": "", "width": "", "height": ""}, "addons": [], "type": "textfield", "input": true, "refreshOn": "", "dataGridLabel": false, "inputType": "text", "id": "ee7bim", "defaultValue": ""}], "size": "md", "width": 6, "offset": 0, "push": 0, "pull": 0, "currentWidth": 6}, {"components": [{"label": "Company", "labelPosition": "top", "labelWidth": "", "labelMargin": "", "placeholder": "", "description": "", "tooltip": "", "prefix": "", "suffix": "", "widget": {"type": "input"}, "inputMask": "", "displayMask": "", "allowMultipleMasks": false, "customClass": "", "tabindex": "", "autocomplete": "", "hidden": false, "hideLabel": false, "showWordCount": false, "showCharCount": false, "mask": false, "autofocus": false, "spellcheck": true, "disabled": false, "tableView": true, "modalEdit": false, "multiple": false, "persistent": true, "inputFormat": "plain", "protected": false, "dbIndex": false, "case": "", "truncateMultipleSpaces": false, "encrypted": false, "redrawOn": "", "clearOnHide": true, "customDefaultValue": "", "calculateValue": "", "calculateServer": false, "allowCalculateOverride": false, "validateOn": "change", "validate": {"required": false, "minLength": "", "maxLength": "", "minWords": "", "maxWords": "", "pattern": "", "customMessage": "", "custom": "", "customPrivate": false, "json": "", "strictDateValidation": false, "multiple": false, "unique": false}, "unique": false, "errorLabel": "", "errors": "", "key": "company", "tags": [], "properties": {"user_field": "partner_id.company_id.name"}, "conditional": {"show": null, "when": null, "eq": "", "json": ""}, "customConditional": "", "logic": [], "attributes": {}, "overlay": {"style": "", "page": "", "left": "", "top": "", "width": "", "height": ""}, "addons": [], "type": "textfield", "input": true, "refreshOn": "", "dataGridLabel": false, "inputType": "text", "id": "ey9a7yl", "defaultValue": ""}], "size": "md", "width": 6, "offset": 0, "push": 0, "pull": 0, "currentWidth": 6}], "autoAdjust": false, "customClass": "", "hidden": false, "hideLabel": false, "modalEdit": false, "key": "columns", "tags": [], "properties": {}, "conditional": {"show": null, "when": null, "eq": "", "json": ""}, "customConditional": "", "logic": [], "attributes": {}, "overlay": {"style": "", "page": "", "left": "", "top": "", "width": "", "height": ""}, "addons": [], "type": "columns", "input": false, "placeholder": "", "prefix": "", "suffix": "", "multiple": false, "defaultValue": null, "protected": false, "unique": false, "persistent": false, "clearOnHide": false, "refreshOn": "", "redrawOn": "", "tableView": false, "dataGridLabel": false, "labelPosition": "top", "description": "", "errorLabel": "", "tooltip": "", "tabindex": "", "disabled": false, "autofocus": false, "dbIndex": false, "customDefaultValue": "", "calculateValue": "", "calculateServer": false, "widget": null, "validateOn": "change", "validate": {"required": false, "custom": "", "customPrivate": false, "strictDateValidation": false, "multiple": false, "unique": false}, "allowCalculateOverride": false, "encrypted": false, "showCharCount": false, "showWordCount": false, "allowMultipleMasks": false, "tree": false, "lazyLoad": false, "id": "eyssm9"}, {"type": "button", "label": "Submit", "key": "submit", "size": "md", "block": false, "action": "submit", "disableOnInvalid": true, "theme": "primary", "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": "", "id": "eqtdlrq"}]}
Odoo server log (with error)
2021-12-17 21:19:24,779 7866 ERROR dev5 odoo.http: Exception during JSON request handling.
Traceback (most recent call last):
File "/home/odoo/odoo/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/odoo/odoo/odoo/odoo/http.py", line 684, in dispatch
result = self._call_function(**self.params)
File "/home/odoo/odoo/odoo/odoo/http.py", line 360, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odoo/odoo/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/odoo/odoo/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/home/odoo/odoo/odoo/odoo/http.py", line 913, in __call__
return self.method(*args, **kw)
File "/home/odoo/odoo/odoo/odoo/http.py", line 532, in response_wrap
response = f(*args, **kw)
File "/home/odoo/odoo/addons/odoo-formio/formio/controllers/main.py", line 180, in form_submission
return json.dumps(submission_data)
File "/usr/lib/python3.8/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/odoo/odoo/odoo/odoo/http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odoo/odoo/odoo/odoo/http.py", line 316, in _handle_exception
raise exception.with_traceback(None) from new_cause
TypeError: Object of type res.partner.title is not JSON serializable
2021-12-17 21:19:24,786 7866 INFO dev5 werkzeug: 10.85.186.1 - - [17/Dec/2021 21:19:24] "POST /formio/form/c36bbf5b-76fe-4524-89f0-6e2449790957/submission HTTP/1.1" 200 - 12 0.007 0.028
2021-12-17 21:19:24,681 7866 INFO dev5 werkzeug: 10.85.186.1 - - [17/Dec/2021 21:19:24] "POST /formio/form/c36bbf5b-76fe-4524-89f0-6e2449790957/config HTTP/1.1" 200 - 12 0.007 0.018
2021-12-17 21:19:24,779 7866 ERROR dev5 odoo.http: Exception during JSON request handling.
Traceback (most recent call last):
File "/home/odoo/odoo/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/odoo/odoo/odoo/odoo/http.py", line 684, in dispatch
result = self._call_function(**self.params)
File "/home/odoo/odoo/odoo/odoo/http.py", line 360, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odoo/odoo/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/odoo/odoo/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/home/odoo/odoo/odoo/odoo/http.py", line 913, in __call__
return self.method(*args, **kw)
File "/home/odoo/odoo/odoo/odoo/http.py", line 532, in response_wrap
response = f(*args, **kw)
File "/home/odoo/odoo/addons/odoo-formio/formio/controllers/main.py", line 180, in form_submission
return json.dumps(submission_data)
File "/usr/lib/python3.8/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/odoo/odoo/odoo/odoo/http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odoo/odoo/odoo/odoo/http.py", line 316, in _handle_exception
raise exception.with_traceback(None) from new_cause
TypeError: Object of type res.partner.title is not JSON serializable
2021-12-17 21:19:24,786 7866 INFO dev5 werkzeug: 10.85.186.1 - - [17/Dec/2021 21:19:24] "POST /formio/form/c36bbf5b-76fe-4524-89f0-6e2449790957/submission HTTP/1.1" 200 - 12 0.007 0.028
Hello,
Thanks for checking this issue. I got it working, but... it shows the name of the logged in user "eg. John Doe" in the corresponding field, instead of his title "Mister" or his company "His Company"...
JSON title
{ "label": "Civilité", "tableView": true, "key": "title", "properties": { "user_field": "partner_id.title.name" }, "type": "textfield", "input": true }
JSON company
{ "label": "Civilité", "tableView": true, "key": "title", "properties": { "user_field": "partner_id.company_id.name" }, "type": "textfield", "input": true }
Best regards,
Seb
Indeed, I can reproduce this issue now. I shall fix upcoming days.
Thanks for sharing Seb - @Home-Based !
Should be fixed now.
Please replace the formio_data_api
module and let me know whether fixed.
Thanks !
Hi Bob,
I replaced the formio_data_api module with your updated one. Sorry but... no change on my side.
Regards,
Seb
Hey Seb, I again tested on v14 and v13 demo (see links below). Works fine for me.
Questions:
Builder: https://demo13.novacode.nl/web#id=296&action=136&model=formio.builder&view_type=form&cids=1&menu_id=
@Home-Based did you already checked out on my demo environment? 2 links in previous comment. It works, also in datagrid.
Maybe it's related...
Did you already upgrade the Python formio-data
package?
Commandline: pip3 install -U formiodata
Should be present in the PATH of the odoo system user.
Hi all,
It globally works.
Fields like Title accept now partner_id.title.name as user_field key.
For Company field, partner_id.parent_id.name should be used instead of partner_id.company_id.name as user_field key. The later one only works with company names that were filled in via the portal interface, not via the Odoo "Contact" interface. When a company name is linked to an existing company partner, the field in the form gets no value. Using the proposed solution allows to get a value even if the company is an existing partner in Odoo.
Thanks for your investment, Bob. This issue may be closed if you agree with what I'm proposing.
Regards,
Seb.
Hi Seb, @Home-Based
For company fields, try partner_id.commercial_partner_id.<FIELD>
.
Thanks for your response. Please close the issue if all good.
partner_id.commercial_partner_id.
I close this issue.
Seb
Odoo v14, latest Forms module, formio.js v4.14.1-rc4 installed.
Fields as partner_id.company or partner_id.title are fields that are select or "linked" fields in res.partner. So they have no "direct" input as regular text fields.
When they are used in a form, company field or title field prevent the other "regular" textfields to be automatically filled in.
Steps to reproduce
Note. Custom fields work, but I only tried with textfield, not with selectfield.
Regards,
Seb