Browse Source

[FIX]base_jsonify: Preserve initial order on ir.export.line

We can't change the order on ir.export.line since it's used to preserve the order speicifed by the user when creating a export filter into the UI
12.0
Laurent Mignon (ACSONE) 5 years ago
parent
commit
482ec3acfe
  1. 1
      base_jsonify/models/ir_exports_line.py
  2. 27
      base_jsonify/tests/test_get_parser.py

1
base_jsonify/models/ir_exports_line.py

@ -7,7 +7,6 @@ from odoo import api, fields, models, _
class IrExportsLine(models.Model): class IrExportsLine(models.Model):
_inherit = 'ir.exports.line' _inherit = 'ir.exports.line'
_order = 'name'
alias = fields.Char( alias = fields.Char(
'Alias', 'Alias',

27
base_jsonify/tests/test_get_parser.py

@ -8,30 +8,33 @@ class TestParser(TransactionCase):
def test_getting_parser(self): def test_getting_parser(self):
expected_parser = [ expected_parser = [
'name',
'active', 'active',
'credit_limit',
'color',
('category_id', ['name']), ('category_id', ['name']),
('child_ids', [(
'child_ids', ['name']),
('country_id', ['code', 'name']),
'email', 'id',
'name'
('country_id', ['name', 'code']),
('child_ids', [
'name',
'id',
'email',
('country_id', ['name', 'code']),
('child_ids', ['name']),
]), ]),
'color',
'comment',
('country_id', ['code', 'name']),
'credit_limit',
'lang', 'lang',
'name']
'comment'
]
exporter = self.env.ref('base_jsonify.ir_exp_partner') exporter = self.env.ref('base_jsonify.ir_exp_partner')
parser = exporter.get_json_parser() parser = exporter.get_json_parser()
self.assertEqual(parser, expected_parser)
self.assertListEqual(parser, expected_parser)
# modify an ir.exports_line to put an alias for a field # modify an ir.exports_line to put an alias for a field
self.env.ref('base_jsonify.category_id_name').write({ self.env.ref('base_jsonify.category_id_name').write({
'alias': 'category_id:category/name' 'alias': 'category_id:category/name'
}) })
expected_parser[1] = ('category_id:category', ['name'])
expected_parser[4] = ('category_id:category', ['name'])
parser = exporter.get_json_parser() parser = exporter.get_json_parser()
self.assertEqual(parser, expected_parser) self.assertEqual(parser, expected_parser)

Loading…
Cancel
Save