Skip to content
Permalink
Browse files

Merge pull request #764 from KolushovAlexandr/11.0-web_website-many2o…

…ne_field

:ambulace: get_multi on one2many field returned id instead of a record
  • Loading branch information...
yelizariev committed Jun 27, 2019
2 parents 28573b3 + 99ef097 commit 1a6b92877cc3865a6ef3e7104cc7f38cd9f867eb
@@ -56,7 +56,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/11.0/web_website/>`__.

Thank you for understanding!

@@ -65,14 +65,14 @@ Maintainers
Further information
===================

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

HTML Description: https://apps.odoo.com/apps/modules/10.0/web_website/
HTML Description: https://apps.odoo.com/apps/modules/11.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/11.0/web_website.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/misc-addons/commits/11.0/web_website.atom>`_

Tested on Odoo 10.0 2da4eb58989af1fc0280f5fec12deca2aa6eae88
Tested on Odoo 11.0 aefbd6da12748f078a197e5e3ae0c1cd68b2e6c5
@@ -6,7 +6,7 @@
"category": "Hidden",
# "live_test_url": "",
"images": [],
"version": "11.0.3.0.3",
"version": "11.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
@@ -6,7 +6,7 @@ Installation
============

* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
* As this is a technical module, consider to install other modules that use this one, for example `ir_config_parameter_multi_company <https://apps.odoo.com/apps/modules/10.0/ir_config_parameter_multi_company/>`_
* As this is a technical module, consider to install other modules that use this one, for example `ir_config_parameter_multi_company <https://apps.odoo.com/apps/modules/11.0/ir_config_parameter_multi_company/>`_

Configuration
=============
@@ -1,5 +1,5 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# Copyright 2018-2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
import logging
from odoo import models, fields, api
@@ -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

@@ -36,7 +36,7 @@ <h2>Need our service?</h2>
-o-transform: rotate(6deg);
-moz-transform: rotate(6deg);
-ms-transform: rotate(6deg);">
Tested on Odoo<br/>10.0 community
Tested on Odoo<br/>11.0 community
</div>
<!--<div style="margin-top: 15px;
position: relative;
@@ -53,7 +53,7 @@ <h2>Need our service?</h2>
-o-transform: rotate(7deg);
-moz-transform: rotate(7deg);
-ms-transform: rotate(7deg);">
Tested on Odoo<br/>10.0 enterprise
Tested on Odoo<br/>11.0 enterprise
</div>-->
</div>
</div>

0 comments on commit 1a6b928

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