Sunday, May 22, 2022
2 changes · master
Miscellaneous changes
When a subtest fails, the failure or error is taken into account and even if the subtest was silenced the test itself logs an ERROR with the count of failures. With this commit, at the first try, the subtest result is not taken into account. Here is an [example](https://runbot.odoo.com/runbot/batch/767455/build/15399520) of such an issue Forward-Port-Of: odoo/odoo#91054
Original PR description
When a subtest fails, the failure or error is taken into account and even if the subtest was silenced the test itself logs an ERROR with the count of failures. With this commit, at the first try, the subtest result is not taken into account. Here is an [example](https://runbot.odoo.com/runbot/batch/767455/build/15399520) of such an issue Forward-Port-Of: odoo/odoo#91054
The name of taxes is computed by merging the name of all parent taxes together, based on the code: ```py tax_name = " ".join([treelib[x] for x in [rec.get('TREELEVEL')[:i] for i in range(2, len(rec.get('TREELEVEL')) + 1, 2)]]) ``` This leads to an exception when the parent tax is after its childs within the files holding the taxes. ``` File "/home/odoo/src/enterprise/saas-15.1/account_winbooks_import/wizard/import_wizard.py", line 700, in import_winbooks_file vatcode_data = se
Original PR description
The name of taxes is computed by merging the name of all parent taxes together, based on the code: ```py tax_name = " ".join([treelib[x] for x in [rec.get('TREELEVEL')[:i] for i in range(2,…
The name of taxes is computed by merging the name of all
parent taxes together, based on the code:
```py
tax_name = " ".join([treelib[x] for x in [rec.get('TREELEVEL')[:i] for i in range(2, len(rec.get('TREELEVEL')) + 1, 2)]])
```
This leads to an exception when the parent tax is after its childs
within the files holding the taxes.
```
File "/home/odoo/src/enterprise/saas-15.1/account_winbooks_import/wizard/import_wizard.py", line 700, in import_winbooks_file
vatcode_data = self.import_vat(file_dir, vatfile, account_central)
File "/home/odoo/src/enterprise/saas-15.1/account_winbooks_import/wizard/import_wizard.py", line 599, in import_vat
tax_name = " ".join([treelib[x] for x in [rec.get('TREELEVEL')[:i] for i in range(2, len(rec.get('TREELEVEL')) + 1, 2)]])
File "/home/odoo/src/enterprise/saas-15.1/account_winbooks_import/wizard/import_wizard.py", line 599, in <listcomp>
tax_name = " ".join([treelib[x] for x in [rec.get('TREELEVEL')[:i] for i in range(2, len(rec.get('TREELEVEL')) + 1, 2)]])
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/odoo/src/odoo/saas-15.1/odoo/http.py", line 644, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odoo/src/odoo/saas-15.1/odoo/http.py", line 302, in _handle_exception
raise exception.with_traceback(None) from new_cause
KeyError: '23040203'
```
In the winbooks import files of the customer, in the support ticket,
the parent `23040203` is clearly after its childs
`2304020301`, `2304020302`, `2304020303`:
```py
In [7]: from dbfread import DBF; [r.get('TREELEVEL') for r in DBF('PROFILE_codevat.dbf', encoding='latin').records if '23040203' in r.get('TREELEVEL')]
Out[7]: ['2304020301', '2304020302', '2304020303', '23040203']
```
The goal of this revision is to sort the taxes record on their
`treelevel` length, so parents are always before their childs.
opw-2716479
Forward-Port-Of: odoo/enterprise#27560
Forward-Port-Of: odoo/enterprise#27530