7 changed files with 143 additions and 137 deletions
-
13base_jsonify/__manifest__.py
-
11base_jsonify/models/ir_export.py
-
28base_jsonify/models/ir_exports_line.py
-
17base_jsonify/models/models.py
-
156base_jsonify/tests/test_get_parser.py
-
53base_jsonify/tests/test_ir_exports_line.py
-
2base_jsonify/views/ir_exports_view.xml
@ -1,33 +1,37 @@ |
|||
# Copyright 2017 ACSONE SA/NV |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from odoo import _, api, fields, models |
|||
from odoo.exceptions import ValidationError |
|||
from odoo import api, fields, models, _ |
|||
|
|||
|
|||
class IrExportsLine(models.Model): |
|||
_inherit = 'ir.exports.line' |
|||
_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' |
|||
"Alias", |
|||
help="The complete path to the field where you can specify an " |
|||
"alias on the a step as field:alias", |
|||
) |
|||
|
|||
@api.constrains('alias', 'name') |
|||
@api.constrains("alias", "name") |
|||
def _check_alias(self): |
|||
for rec in self: |
|||
if not rec.alias: |
|||
continue |
|||
names = rec.name.split('/') |
|||
names_with_alias = rec.alias.split('/') |
|||
names = rec.name.split("/") |
|||
names_with_alias = rec.alias.split("/") |
|||
if len(names) != len(names_with_alias): |
|||
raise ValidationError( |
|||
_("Name and Alias must have the same hierarchy depth")) |
|||
_("Name and Alias must have the same hierarchy depth") |
|||
) |
|||
for name, name_with_alias in zip(names, names_with_alias): |
|||
field_name = name_with_alias.split(':')[0] |
|||
field_name = name_with_alias.split(":")[0] |
|||
if name != field_name: |
|||
raise ValidationError( |
|||
_("The alias must reference the same field as in " |
|||
"name '%s' not in '%s'") % (name, name_with_alias) |
|||
_( |
|||
"The alias must reference the same field as in " |
|||
"name '%s' not in '%s'" |
|||
) |
|||
% (name, name_with_alias) |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue