diff options
| author | amoyaux <arm@odoo.com> | 2017-10-10 14:01:41 +0200 |
|---|---|---|
| committer | amoyaux <arm@odoo.com> | 2017-10-13 09:43:11 +0200 |
| commit | e1769cbea9dc9b13453f507321b4de2e86de2d36 (patch) | |
| tree | ee98aed67969c3d05daa7f212555200ea7b65b64 /addons/base_import/tests | |
| parent | ba519bde84de89280632cb05dca59d342d3bea0d (diff) | |
[FIX] base_import: parse date and float for relational fields
Use case to reproduce:
-> Import a file with a float using a coma related to the model
(for example the product.supplierinfo/price)
It happens because the method that parse the date and float field
only compare them to the main imported model.
This commit complete the method by using a recursion on relational
model in order to also parse the relational subfields.
Diffstat (limited to 'addons/base_import/tests')
| -rw-r--r-- | addons/base_import/tests/test_base_import.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/addons/base_import/tests/test_base_import.py b/addons/base_import/tests/test_base_import.py index 891fc3e7671..f858101fef3 100644 --- a/addons/base_import/tests/test_base_import.py +++ b/addons/base_import/tests/test_base_import.py @@ -402,7 +402,33 @@ class test_convert_import_data(TransactionCase): # if results empty, no errors self.assertItemsEqual(results, []) + def test_parse_relational_fields(self): + """ Ensure that relational fields float and date are correctly + parsed during the import call. + """ + import_wizard = self.env['base_import.import'].create({ + 'res_model': 'res.partner', + 'file': 'name,parent_id/id,parent_id/date,parent_id/credit_limit\n' + '"foo","__export__.res_partner_1","2017年10月12日","5,69"\n', + 'file_type': 'text/csv' + }) + options = { + 'date_format': '%Y年%m月%d日', + 'quoting': '"', + 'separator': ',', + 'float_decimal_separator': ',', + 'float_thousand_separator': '.', + 'headers': True + } + data, import_fields = import_wizard._convert_import_data( + ['name', 'parent_id/.id', 'parent_id/date', 'parent_id/credit_limit'], + options + ) + result = import_wizard._parse_import_data(data, import_fields, options) + # Check if the data 5,69 as been correctly parsed. + self.assertEqual(float(result[0][-1]), 5.69) + self.assertEqual(str(result[0][-2]), '2017-10-12') def test_filtered(self): """ If ``False`` is provided as field mapping for a column, |
