[REF] base_jsonify: rename ir.exports.line field `alias` to `target`
parent
3812375799
commit
74a4c2c713
|
@ -96,11 +96,11 @@ To use these features, a full parser follows the following structure:
|
|||
False: [
|
||||
{'name': 'description'},
|
||||
{'name': 'number', 'resolver': 5},
|
||||
({'name': 'partner_id', 'alias': 'partner'}, [{'name': 'display_name'}])
|
||||
({'name': 'partner_id', 'target': 'partner'}, [{'name': 'display_name'}])
|
||||
],
|
||||
'fr_FR': [
|
||||
{'name': 'description', 'alias': 'descriptions_fr'},
|
||||
({'name': 'partner_id', 'alias': 'partner'}, [{'name': 'description', 'alias': 'description_fr'}])
|
||||
{'name': 'description', 'target': 'descriptions_fr'},
|
||||
({'name': 'partner_id', 'target': 'partner'}, [{'name': 'description', 'target': 'description_fr'}])
|
||||
],
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ but other features like custom resolvers are:
|
|||
"fields": [
|
||||
{'name': 'description'},
|
||||
{'name': 'number', 'resolver': 5},
|
||||
({'name': 'partner_id', 'alias': 'partners'}, [{'name': 'display_name'}]),
|
||||
({'name': 'partner_id', 'target': 'partners'}, [{'name': 'display_name'}]),
|
||||
],
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ If the global resolver is given, then the json_dict goes through:
|
|||
Which allows to add external data from the context or transform the dictionary
|
||||
if necessary. Similarly if given for a field the resolver evaluates the result.
|
||||
|
||||
It is possible for an alias to end with a '*':
|
||||
It is possible for a target to end with a '*':
|
||||
in that case the result is put into a list.
|
||||
|
||||
.. code-block:: python
|
||||
|
@ -165,8 +165,8 @@ in that case the result is put into a list.
|
|||
parser = {
|
||||
fields: [
|
||||
{'name': 'name'},
|
||||
{'name': 'field_1', 'alias': 'customTags*'},
|
||||
{'name': 'field_2', 'alias': 'customTags*'},
|
||||
{'name': 'field_1', 'target': 'customTags*'},
|
||||
{'name': 'field_2', 'target': 'customTags*'},
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
{
|
||||
"name": "Base Jsonify",
|
||||
"summary": "Base module that provide the jsonify method on all models",
|
||||
"version": "13.0.1.3.1",
|
||||
"version": "13.0.2.0.0",
|
||||
"category": "Uncategorized",
|
||||
"website": "https://github.com/OCA/server-tools",
|
||||
"author": "Akretion, Odoo Community Association (OCA)",
|
||||
|
|
|
@ -19,8 +19,8 @@ msgid "Active"
|
|||
msgstr ""
|
||||
|
||||
#. module: base_jsonify
|
||||
#: model:ir.model.fields,field_description:base_jsonify.field_ir_exports_line__alias
|
||||
msgid "Alias"
|
||||
#: model:ir.model.fields,field_description:base_jsonify.field_ir_exports_line__target
|
||||
msgid "Target"
|
||||
msgstr ""
|
||||
|
||||
#. module: base_jsonify
|
||||
|
@ -57,20 +57,20 @@ msgstr ""
|
|||
#. module: base_jsonify
|
||||
#: code:addons/base_jsonify/models/ir_exports_line.py:0
|
||||
#, python-format
|
||||
msgid "Name and Alias must have the same hierarchy depth"
|
||||
msgid "Name and Target must have the same hierarchy depth"
|
||||
msgstr ""
|
||||
|
||||
#. module: base_jsonify
|
||||
#: code:addons/base_jsonify/models/ir_exports_line.py:0
|
||||
#, python-format
|
||||
msgid "The alias must reference the same field as in name '%s' not in '%s'"
|
||||
msgid "The target must reference the same field as in name '%s' not in '%s'"
|
||||
msgstr ""
|
||||
|
||||
#. module: base_jsonify
|
||||
#: model:ir.model.fields,help:base_jsonify.field_ir_exports_line__alias
|
||||
#: model:ir.model.fields,help:base_jsonify.field_ir_exports_line__target
|
||||
msgid ""
|
||||
"The complete path to the field where you can specify an alias on the a step "
|
||||
"as field:alias"
|
||||
"The complete path to the field where you can specify a target on the a step "
|
||||
"as field:target"
|
||||
msgstr ""
|
||||
|
||||
#. module: base_jsonify
|
||||
|
|
|
@ -22,8 +22,8 @@ msgid "Active"
|
|||
msgstr ""
|
||||
|
||||
#. module: base_jsonify
|
||||
#: model:ir.model.fields,field_description:base_jsonify.field_ir_exports_line__alias
|
||||
msgid "Alias"
|
||||
#: model:ir.model.fields,field_description:base_jsonify.field_ir_exports_line__target
|
||||
msgid "Target"
|
||||
msgstr "别名"
|
||||
|
||||
#. module: base_jsonify
|
||||
|
@ -60,20 +60,20 @@ msgstr "索引"
|
|||
#. module: base_jsonify
|
||||
#: code:addons/base_jsonify/models/ir_exports_line.py:0
|
||||
#, python-format
|
||||
msgid "Name and Alias must have the same hierarchy depth"
|
||||
msgid "Name and Target must have the same hierarchy depth"
|
||||
msgstr "名称和别名必须具有相同的层次结构深度"
|
||||
|
||||
#. module: base_jsonify
|
||||
#: code:addons/base_jsonify/models/ir_exports_line.py:0
|
||||
#, python-format
|
||||
msgid "The alias must reference the same field as in name '%s' not in '%s'"
|
||||
msgid "The target must reference the same field as in name '%s' not in '%s'"
|
||||
msgstr "别名必须引用与名称相同的字段'%s'不在'%s'"
|
||||
|
||||
#. module: base_jsonify
|
||||
#: model:ir.model.fields,help:base_jsonify.field_ir_exports_line__alias
|
||||
#: model:ir.model.fields,help:base_jsonify.field_ir_exports_line__target
|
||||
msgid ""
|
||||
"The complete path to the field where you can specify an alias on the a step "
|
||||
"as field:alias"
|
||||
"The complete path to the field where you can specify a target on the a step "
|
||||
"as field:target"
|
||||
msgstr "字段的完整路径,您可以在其中指定步骤作为字段的别名:别名"
|
||||
|
||||
#. module: base_jsonify
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
query = """ALTER TABLE "ir_exports_line" RENAME COLUMN "alias" TO "target";"""
|
||||
cr.execute(query)
|
|
@ -49,7 +49,7 @@ def update_dict(data, fields, options):
|
|||
def convert_dict(dict_parser):
|
||||
"""Convert dict returned by update_dict to list consistent w/ Odoo API.
|
||||
|
||||
The list is composed of strings (field names or aliases) or tuples.
|
||||
The list is composed of strings (field names or targets) or tuples.
|
||||
"""
|
||||
parser = []
|
||||
for field, value in dict_parser.items():
|
||||
|
@ -63,7 +63,7 @@ def convert_dict(dict_parser):
|
|||
def field_dict(field, options=None):
|
||||
result = {"name": field.split(":")[0]}
|
||||
if len(field.split(":")) > 1:
|
||||
result["alias"] = field.split(":")[1]
|
||||
result["target"] = field.split(":")[1]
|
||||
for option in options or {}:
|
||||
if options[option]:
|
||||
result[option] = options[option]
|
||||
|
@ -100,8 +100,8 @@ class IrExport(models.Model):
|
|||
dict_parser = OrderedDict()
|
||||
for line in lang_to_lines[lang]:
|
||||
names = line.name.split("/")
|
||||
if line.alias:
|
||||
names = line.alias.split("/")
|
||||
if line.target:
|
||||
names = line.target.split("/")
|
||||
options = {"resolver": line.resolver_id, "function": line.function}
|
||||
update_dict(dict_parser, names, options)
|
||||
lang_parsers[lang] = convert_dict(dict_parser)
|
||||
|
|
|
@ -8,10 +8,10 @@ from odoo.exceptions import ValidationError
|
|||
class IrExportsLine(models.Model):
|
||||
_inherit = "ir.exports.line"
|
||||
|
||||
alias = fields.Char(
|
||||
"Alias",
|
||||
help="The complete path to the field where you can specify an "
|
||||
"alias on the a step as field:alias",
|
||||
target = fields.Char(
|
||||
"Target",
|
||||
help="The complete path to the field where you can specify a "
|
||||
"target on the a step as field:target",
|
||||
)
|
||||
active = fields.Boolean(string="Active", default=True)
|
||||
lang_id = fields.Many2one(
|
||||
|
@ -38,24 +38,24 @@ class IrExportsLine(models.Model):
|
|||
_("Either set a function or a resolver, not both.")
|
||||
)
|
||||
|
||||
@api.constrains("alias", "name")
|
||||
def _check_alias(self):
|
||||
@api.constrains("target", "name")
|
||||
def _check_target(self):
|
||||
for rec in self:
|
||||
if not rec.alias:
|
||||
if not rec.target:
|
||||
continue
|
||||
names = rec.name.split("/")
|
||||
names_with_alias = rec.alias.split("/")
|
||||
if len(names) != len(names_with_alias):
|
||||
names_with_target = rec.target.split("/")
|
||||
if len(names) != len(names_with_target):
|
||||
raise ValidationError(
|
||||
_("Name and Alias must have the same hierarchy depth")
|
||||
_("Name and Target must have the same hierarchy depth")
|
||||
)
|
||||
for name, name_with_alias in zip(names, names_with_alias):
|
||||
field_name = name_with_alias.split(":")[0]
|
||||
for name, name_with_target in zip(names, names_with_target):
|
||||
field_name = name_with_target.split(":")[0]
|
||||
if name != field_name:
|
||||
raise ValidationError(
|
||||
_(
|
||||
"The alias must reference the same field as in "
|
||||
"The target must reference the same field as in "
|
||||
"name '%s' not in '%s'"
|
||||
)
|
||||
% (name, name_with_alias)
|
||||
% (name, name_with_target)
|
||||
)
|
||||
|
|
|
@ -25,7 +25,7 @@ class Base(models.AbstractModel):
|
|||
field_split = f.split(":")
|
||||
field_dict = {"name": field_split[0]}
|
||||
if len(field_split) > 1:
|
||||
field_dict["alias"] = field_split[1]
|
||||
field_dict["target"] = field_split[1]
|
||||
if function:
|
||||
field_dict["function"] = function
|
||||
return field_dict
|
||||
|
@ -86,7 +86,7 @@ class Base(models.AbstractModel):
|
|||
for field in parser:
|
||||
field_dict, subparser = rec.__parse_field(field)
|
||||
field_name = field_dict["name"]
|
||||
json_key = field_dict.get("alias", field_name)
|
||||
json_key = field_dict.get("target", field_name)
|
||||
field = rec._fields[field_name]
|
||||
if field_dict.get("function"):
|
||||
function = field_dict["function"]
|
||||
|
|
|
@ -69,11 +69,11 @@ To use these features, a full parser follows the following structure:
|
|||
False: [
|
||||
{'name': 'description'},
|
||||
{'name': 'number', 'resolver': 5},
|
||||
({'name': 'partner_id', 'alias': 'partner'}, [{'name': 'display_name'}])
|
||||
({'name': 'partner_id', 'target': 'partner'}, [{'name': 'display_name'}])
|
||||
],
|
||||
'fr_FR': [
|
||||
{'name': 'description', 'alias': 'descriptions_fr'},
|
||||
({'name': 'partner_id', 'alias': 'partner'}, [{'name': 'description', 'alias': 'description_fr'}])
|
||||
{'name': 'description', 'target': 'descriptions_fr'},
|
||||
({'name': 'partner_id', 'target': 'partner'}, [{'name': 'description', 'target': 'description_fr'}])
|
||||
],
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ but other features like custom resolvers are:
|
|||
"fields": [
|
||||
{'name': 'description'},
|
||||
{'name': 'number', 'resolver': 5},
|
||||
({'name': 'partner_id', 'alias': 'partners'}, [{'name': 'display_name'}]),
|
||||
({'name': 'partner_id', 'target': 'partners'}, [{'name': 'display_name'}]),
|
||||
],
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ If the global resolver is given, then the json_dict goes through:
|
|||
Which allows to add external data from the context or transform the dictionary
|
||||
if necessary. Similarly if given for a field the resolver evaluates the result.
|
||||
|
||||
It is possible for an alias to end with a '*':
|
||||
It is possible for a target to end with a '*':
|
||||
in that case the result is put into a list.
|
||||
|
||||
.. code-block:: python
|
||||
|
@ -138,8 +138,8 @@ in that case the result is put into a list.
|
|||
parser = {
|
||||
fields: [
|
||||
{'name': 'name'},
|
||||
{'name': 'field_1', 'alias': 'customTags*'},
|
||||
{'name': 'field_2', 'alias': 'customTags*'},
|
||||
{'name': 'field_1', 'target': 'customTags*'},
|
||||
{'name': 'field_2', 'target': 'customTags*'},
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -424,11 +424,11 @@ It is also to specify a lang to extract the translation of any given field.</p>
|
|||
<span class="kc">False</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'description'</span><span class="p">},</span>
|
||||
<span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'number'</span><span class="p">,</span> <span class="s1">'resolver'</span><span class="p">:</span> <span class="mi">5</span><span class="p">},</span>
|
||||
<span class="p">({</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'partner_id'</span><span class="p">,</span> <span class="s1">'alias'</span><span class="p">:</span> <span class="s1">'partner'</span><span class="p">},</span> <span class="p">[{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'display_name'</span><span class="p">}])</span>
|
||||
<span class="p">({</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'partner_id'</span><span class="p">,</span> <span class="s1">'target'</span><span class="p">:</span> <span class="s1">'partner'</span><span class="p">},</span> <span class="p">[{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'display_name'</span><span class="p">}])</span>
|
||||
<span class="p">],</span>
|
||||
<span class="s1">'fr_FR'</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'description'</span><span class="p">,</span> <span class="s1">'alias'</span><span class="p">:</span> <span class="s1">'descriptions_fr'</span><span class="p">},</span>
|
||||
<span class="p">({</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'partner_id'</span><span class="p">,</span> <span class="s1">'alias'</span><span class="p">:</span> <span class="s1">'partner'</span><span class="p">},</span> <span class="p">[{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'description'</span><span class="p">,</span> <span class="s1">'alias'</span><span class="p">:</span> <span class="s1">'description_fr'</span><span class="p">}])</span>
|
||||
<span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'description'</span><span class="p">,</span> <span class="s1">'target'</span><span class="p">:</span> <span class="s1">'descriptions_fr'</span><span class="p">},</span>
|
||||
<span class="p">({</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'partner_id'</span><span class="p">,</span> <span class="s1">'target'</span><span class="p">:</span> <span class="s1">'partner'</span><span class="p">},</span> <span class="p">[{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'description'</span><span class="p">,</span> <span class="s1">'target'</span><span class="p">:</span> <span class="s1">'description_fr'</span><span class="p">}])</span>
|
||||
<span class="p">],</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
|
@ -454,7 +454,7 @@ but other features like custom resolvers are:</p>
|
|||
<span class="s2">"fields"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'description'</span><span class="p">},</span>
|
||||
<span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'number'</span><span class="p">,</span> <span class="s1">'resolver'</span><span class="p">:</span> <span class="mi">5</span><span class="p">},</span>
|
||||
<span class="p">({</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'partner_id'</span><span class="p">,</span> <span class="s1">'alias'</span><span class="p">:</span> <span class="s1">'partners'</span><span class="p">},</span> <span class="p">[{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'display_name'</span><span class="p">}]),</span>
|
||||
<span class="p">({</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'partner_id'</span><span class="p">,</span> <span class="s1">'target'</span><span class="p">:</span> <span class="s1">'partners'</span><span class="p">},</span> <span class="p">[{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'display_name'</span><span class="p">}]),</span>
|
||||
<span class="p">],</span>
|
||||
<span class="p">}</span>
|
||||
</pre>
|
||||
|
@ -472,14 +472,14 @@ with the added benefit of being able to use resolvers.</p>
|
|||
</pre>
|
||||
<p>Which allows to add external data from the context or transform the dictionary
|
||||
if necessary. Similarly if given for a field the resolver evaluates the result.</p>
|
||||
<p>It is possible for an alias to end with a ‘*’:
|
||||
<p>It is possible for a target to end with a ‘*’:
|
||||
in that case the result is put into a list.</p>
|
||||
<pre class="code python literal-block">
|
||||
<span class="n">parser</span> <span class="o">=</span> <span class="p">{</span>
|
||||
<span class="n">fields</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'name'</span><span class="p">},</span>
|
||||
<span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'field_1'</span><span class="p">,</span> <span class="s1">'alias'</span><span class="p">:</span> <span class="s1">'customTags*'</span><span class="p">},</span>
|
||||
<span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'field_2'</span><span class="p">,</span> <span class="s1">'alias'</span><span class="p">:</span> <span class="s1">'customTags*'</span><span class="p">},</span>
|
||||
<span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'field_1'</span><span class="p">,</span> <span class="s1">'target'</span><span class="p">:</span> <span class="s1">'customTags*'</span><span class="p">},</span>
|
||||
<span class="p">{</span><span class="s1">'name'</span><span class="p">:</span> <span class="s1">'field_2'</span><span class="p">,</span> <span class="s1">'target'</span><span class="p">:</span> <span class="s1">'customTags*'</span><span class="p">},</span>
|
||||
<span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
</pre>
|
||||
|
|
|
@ -41,7 +41,7 @@ class TestParser(SavepointCase):
|
|||
cls.lang.active = True
|
||||
cls.env["ir.translation"]._load_module_terms(["base"], [cls.lang.code])
|
||||
category = cls.env["res.partner.category"].create({"name": "name"})
|
||||
cls.translated_alias = "name_{}".format(cls.lang.code)
|
||||
cls.translated_target = "name_{}".format(cls.lang.code)
|
||||
cls.env["ir.translation"].create(
|
||||
{
|
||||
"type": "model",
|
||||
|
@ -49,7 +49,7 @@ class TestParser(SavepointCase):
|
|||
"module": "base",
|
||||
"lang": cls.lang.code,
|
||||
"res_id": category.id,
|
||||
"value": cls.translated_alias,
|
||||
"value": cls.translated_target,
|
||||
"state": "translated",
|
||||
}
|
||||
)
|
||||
|
@ -70,7 +70,7 @@ class TestParser(SavepointCase):
|
|||
0,
|
||||
{
|
||||
"name": "name",
|
||||
"alias": "name:{}".format(cls.translated_alias),
|
||||
"target": "name:{}".format(cls.translated_target),
|
||||
"lang_id": cls.lang.id,
|
||||
},
|
||||
),
|
||||
|
@ -79,7 +79,7 @@ class TestParser(SavepointCase):
|
|||
0,
|
||||
{
|
||||
"name": "name",
|
||||
"alias": "name:name_resolved",
|
||||
"target": "name:name_resolved",
|
||||
"resolver_id": cls.resolver.id,
|
||||
},
|
||||
),
|
||||
|
@ -116,9 +116,9 @@ class TestParser(SavepointCase):
|
|||
expected_full_parser = exporter.convert_simple_to_full_parser(expected_parser)
|
||||
self.assertEqual(parser, expected_full_parser)
|
||||
|
||||
# modify an ir.exports_line to put an alias for a field
|
||||
# modify an ir.exports_line to put a target for a field
|
||||
self.env.ref("base_jsonify.category_id_name").write(
|
||||
{"alias": "category_id:category/name"}
|
||||
{"target": "category_id:category/name"}
|
||||
)
|
||||
expected_parser[4] = ("category_id:category", ["name"])
|
||||
parser = exporter.get_json_parser()
|
||||
|
@ -226,7 +226,7 @@ class TestParser(SavepointCase):
|
|||
self.assertEqual(
|
||||
json, json_fr
|
||||
) # starting from different languages should not change anything
|
||||
self.assertEqual(json[self.translated_alias], self.translated_alias)
|
||||
self.assertEqual(json[self.translated_target], self.translated_target)
|
||||
self.assertEqual(json["name_resolved"], "name_pidgin") # field resolver
|
||||
self.assertEqual(json["X"], "X") # added by global resolver
|
||||
|
||||
|
@ -238,9 +238,9 @@ class TestParser(SavepointCase):
|
|||
json_fr = self.category_lang.jsonify(parser)[0]
|
||||
|
||||
self.assertEqual(json["name"], "name")
|
||||
self.assertEqual(json_fr["name"], self.translated_alias)
|
||||
self.assertEqual(json_fr["name"], self.translated_target)
|
||||
|
||||
def test_simple_star_alias_and_field_resolver(self):
|
||||
def test_simple_star_target_and_field_resolver(self):
|
||||
"""The simple parser result should depend on the context language.
|
||||
"""
|
||||
code = (
|
||||
|
@ -251,8 +251,8 @@ class TestParser(SavepointCase):
|
|||
)
|
||||
resolver = self.env["ir.exports.resolver"].create({"python_code": code})
|
||||
lang_parser = [
|
||||
{"alias": "customTags*", "name": "name", "resolver": resolver.id},
|
||||
{"alias": "customTags*", "name": "id", "resolver": resolver.id},
|
||||
{"target": "customTags*", "name": "name", "resolver": resolver.id},
|
||||
{"target": "customTags*", "name": "id", "resolver": resolver.id},
|
||||
]
|
||||
parser = {"language_agnostic": True, "langs": {False: lang_parser}}
|
||||
expected_json = {
|
||||
|
|
|
@ -10,42 +10,42 @@ class TestIrExportsLine(TransactionCase):
|
|||
super(TestIrExportsLine, self).setUp()
|
||||
self.ir_export = self.env.ref("base_jsonify.ir_exp_partner")
|
||||
|
||||
def test_alias_contrains(self):
|
||||
def test_target_contrains(self):
|
||||
ir_export_lines_model = self.env["ir.exports.line"]
|
||||
with self.assertRaises(ValidationError):
|
||||
# The field into the name must be also into the alias
|
||||
# The field into the name must be also into the target
|
||||
ir_export_lines_model.create(
|
||||
{
|
||||
"export_id": self.ir_export.id,
|
||||
"name": "name",
|
||||
"alias": "toto:my_alias",
|
||||
"target": "toto:my_target",
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
# The hierarchy into the alias must be the same as the one into
|
||||
# The hierarchy into the target must be the same as the one into
|
||||
# the name
|
||||
ir_export_lines_model.create(
|
||||
{
|
||||
"export_id": self.ir_export.id,
|
||||
"name": "child_ids/child_ids/name",
|
||||
"alias": "child_ids:children/name",
|
||||
"target": "child_ids:children/name",
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
# The hierarchy into the alias must be the same as the one into
|
||||
# The hierarchy into the target must be the same as the one into
|
||||
# the name and must contains the same fields as into the name
|
||||
ir_export_lines_model.create(
|
||||
{
|
||||
"export_id": self.ir_export.id,
|
||||
"name": "child_ids/child_ids/name",
|
||||
"alias": "child_ids:children/category_id:category/name",
|
||||
"target": "child_ids:children/category_id:category/name",
|
||||
}
|
||||
)
|
||||
line = ir_export_lines_model.create(
|
||||
{
|
||||
"export_id": self.ir_export.id,
|
||||
"name": "child_ids/child_ids/name",
|
||||
"alias": "child_ids:children/child_ids:children/name",
|
||||
"target": "child_ids:children/child_ids:children/name",
|
||||
}
|
||||
)
|
||||
self.assertTrue(line)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<field name="export_fields" nolabel="1">
|
||||
<tree editable="bottom">
|
||||
<field name="name" />
|
||||
<field name="alias" />
|
||||
<field name="target" />
|
||||
<field name="lang_id" />
|
||||
<field name="resolver_id" />
|
||||
<field name="function" />
|
||||
|
|
Loading…
Reference in New Issue