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

:ambulace: get_multi on one2many field returned id instead of a record #761

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions web_website/README.rst
Expand Up @@ -58,7 +58,7 @@ Maintainers

To get a guaranteed support
you are kindly requested to purchase the module
at `odoo apps store <https://apps.odoo.com/apps/modules/10.0/web_website/>`__.
at `odoo apps store <https://apps.odoo.com/apps/modules/12.0/web_website/>`__.

Thank you for understanding!

Expand All @@ -67,14 +67,14 @@ Maintainers
Further information
===================

Demo: http://runbot.it-projects.info/demo/misc-addons/10.0
Demo: http://runbot.it-projects.info/demo/misc-addons/12.0

HTML Description: https://apps.odoo.com/apps/modules/10.0/web_website/
HTML Description: https://apps.odoo.com/apps/modules/12.0/web_website/

Usage instructions: `<doc/index.rst>`_

Changelog: `<doc/changelog.rst>`_

Notifications on updates: `via Atom <https://github.com/it-projects-llc/misc-addons/commits/10.0/web_website.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/misc-addons/commits/10.0/web_website.atom>`_
Notifications on updates: `via Atom <https://github.com/it-projects-llc/misc-addons/commits/12.0/web_website.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/misc-addons/commits/12.0/web_website.atom>`_

Tested on Odoo 12.0 d75de9ae5370869eaa220f5fdfb335d1b7e40acf
2 changes: 1 addition & 1 deletion web_website/__manifest__.py
Expand Up @@ -7,7 +7,7 @@
"category": "Hidden",
# "live_test_url": "",
"images": [],
"version": "12.0.3.0.3",
"version": "12.0.3.0.4",
"application": False,

"author": "IT-Projects LLC, Ivan Yelizariev",
Expand Down
4 changes: 4 additions & 0 deletions web_website/doc/changelog.rst
@@ -1,3 +1,7 @@
`3.0.4`
-------
- **Fix:** Incorrect return data in get_multi in case of 'many2one' field, id instead of a record

`3.0.3`
-------
- **Fix:** Error related to incorrect getting properties for html fields
Expand Down
23 changes: 15 additions & 8 deletions web_website/models/ir_property.py
Expand Up @@ -184,31 +184,38 @@ def get_multi(self, name, model, ids):
default_value = result.pop(None, None)
default_company_id = default_value and default_value[2]
default_website_id = default_value and default_value[3]
for id in ids:
if id not in result:
for ID in ids:
if ID not in result:
# 5 Company, Resource and Website are empty (i.e. only Field is matched)
result[id] = default_value
result[ID] = default_value
else:
result_website_id = result[id][3]
result_website_id = result[ID][3]
if result_website_id:
# 1 Website and Resource are matched
continue
if default_website_id:
# 2 Website is matched, Resource is empty
result[id] = default_value
result[ID] = default_value
# No properties with website
result_company_id = result[id][2]
result_company_id = result[ID][2]
if result_company_id:
# 3 Company and Resource are matched, Website is empty
continue
# no property for res and company
if default_company_id:
# 4 Company is matched, Resource and Website are empty
result[id] = default_value
result[ID] = default_value

if field.type == 'many2one':
def clean(data):
return data and self.env[field.comodel_name].browse(data[1])
else:
def clean(data):
return data and data[1]

for key, value in result.items():
# set data to appropriate form
result[key] = value and value[1]
result[key] = clean(value)
# result format: {id: val, ...}
return result

Expand Down