[MIG] base_jsonify: Migration to 14.0

pull/2418/head
Chafique 2020-10-12 15:43:34 +02:00 committed by Sébastien BEAU
parent b03b7e6808
commit 5c6520adfa
8 changed files with 18 additions and 29 deletions

View File

@ -14,13 +14,13 @@ Base Jsonify
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/13.0/base_jsonify
:target: https://github.com/OCA/server-tools/tree/14.0/base_jsonify
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_jsonify
:target: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-base_jsonify
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/149/13.0
:target: https://runbot.odoo-community.org/runbot/149/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -200,7 +200,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_jsonify%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_jsonify%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -233,6 +233,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/13.0/base_jsonify>`_ project on GitHub.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/14.0/base_jsonify>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -6,7 +6,7 @@
{
"name": "Base Jsonify",
"summary": "Base module that provide the jsonify method on all models",
"version": "13.0.3.0.0",
"version": "14.0.1.0.0",
"category": "Uncategorized",
"website": "https://github.com/OCA/server-tools",
"author": "Akretion, Odoo Community Association (OCA)",

View File

@ -1,8 +0,0 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_columns(env.cr, {"ir_exports_line": [("alias", "target")]})

View File

@ -8,15 +8,15 @@ from odoo import fields, models
from odoo.tools import ormcache
def partition(l, accessor):
def partition(line, accessor):
"""Partition a recordset according to an accessor (e.g. a lambda).
Returns a dictionary whose keys are the values obtained from accessor,
and values are the items that have this value.
Example: partition([{"name": "ax"}, {"name": "by"}], lambda x: "x" in x["name"])
=> {True: [{"name": "ax"}], False: [{"name": "by"}]}
Returns a dictionary whose keys are the values obtained from accessor,
and values are the items that have this value.
Example: partition([{"name": "ax"}, {"name": "by"}], lambda x: "x" in x["name"])
=> {True: [{"name": "ax"}], False: [{"name": "by"}]}
"""
result = {}
for item in l:
for item in line:
key = accessor(item)
if key not in result:
result[key] = []

View File

@ -17,8 +17,7 @@ help_message = [
class FieldResolver(models.Model):
"""Arbitrary function to process a field or a dict at export time.
"""
"""Arbitrary function to process a field or a dict at export time."""
_name = "ir.exports.resolver"
_description = "Export Resolver"

View File

@ -6,7 +6,7 @@ def convert_simple_to_full_parser(parser):
def _f(f, function=None):
"""Return a dict from the string encoding a field to export.
The : is used as a separator to specify a target, if any.
The : is used as a separator to specify a target, if any.
"""
field_split = f.split(":")
field_dict = {"name": field_split[0]}
@ -19,7 +19,7 @@ def _f(f, function=None):
def _convert_parser(parser):
"""Recursively process each list to replace encoding fields as string
by dicts specifying each attribute by its relevant key.
by dicts specifying each attribute by its relevant key.
"""
result = []
for line in parser:

View File

@ -233,8 +233,7 @@ class TestParser(SavepointCase):
self.assertEqual(json["X"], "X") # added by global resolver
def test_simple_parser_translations(self):
"""The simple parser result should depend on the context language.
"""
"""The simple parser result should depend on the context language."""
parser = ["name"]
json = self.category.jsonify(parser)[0]
json_fr = self.category_lang.jsonify(parser)[0]
@ -243,8 +242,7 @@ class TestParser(SavepointCase):
self.assertEqual(json_fr["name"], self.translated_target)
def test_simple_star_target_and_field_resolver(self):
"""The simple parser result should depend on the context language.
"""
"""The simple parser result should depend on the context language."""
code = (
"is_number = field_type in ('integer', 'float');"
"ftype = 'NUMBER' if is_number else 'TEXT';"

View File

@ -7,7 +7,7 @@ from odoo.tests.common import TransactionCase
class TestIrExportsLine(TransactionCase):
def setUp(self):
super(TestIrExportsLine, self).setUp()
super().setUp()
self.ir_export = self.env.ref("base_jsonify.ir_exp_partner")
def test_target_contrains(self):