Skip to content
Permalink
Browse files

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

  • Loading branch information...
KolushovAlexandr committed Jun 10, 2019
1 parent e9631fc commit ca34041ca4e623c4ffa063cbe23b25275917d481
Showing with 24 additions and 13 deletions.
  1. +4 −4 web_website/README.rst
  2. +1 −1 web_website/__manifest__.py
  3. +4 −0 web_website/doc/changelog.rst
  4. +15 −8 web_website/models/ir_property.py
@@ -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!

@@ -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
@@ -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",
@@ -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
@@ -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

0 comments on commit ca34041

Please sign in to comment.
You can’t perform that action at this time.