OCA / l10n-netherlands

Odoo Dutch Localization
GNU Affero General Public License v3.0
21 stars 55 forks source link

[13.0] nl tax statement - Error since upgrade from 12 to 13 #318

Closed E4eqRL0yw0yajQJ433QL closed 2 years ago

E4eqRL0yw0yajQJ433QL commented 3 years ago

Problem summary Since I had my database upgraded from Odoo12 CE to Odoo13 CE, the nl tax statement report (BTW aangifte rapport) leads to an error when I hit the "update" button in the report: File "/var/lib/odoo/addons/13.0/l10n_nl_tax_statement/models/l10n_nl_vat_statement.py", line 408, in _get_tags_map matching.update({tag.id: (res_code.group(0), "omzet")}) AttributeError: 'NoneType' object has no attribute 'group'

I am not sure if this is a program issue, a setup issue or a migration issue.

Things I already tried unsuccesfully Updating the module Uninstalling and reinstalling the module Regenerate asset bundles Checking the VAT setup and the Chart of Account setup (this is probably where my knowledge fails and maybe someone can give some pointers where to look)

Full error log: Odoo Server Error Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/http.py", line 624, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/usr/lib/python3/dist-packages/odoo/http.py", line 310, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 14, in reraise raise value File "/usr/lib/python3/dist-packages/odoo/http.py", line 669, in dispatch result = self._call_function(self.params) File "/usr/lib/python3/dist-packages/odoo/http.py", line 350, in _call_function return checked_call(self.db, *args, *kwargs) File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper return f(dbname, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/http.py", line 339, in checked_call result = self.endpoint(*a, kw) File "/usr/lib/python3/dist-packages/odoo/http.py", line 915, in call return self.method(*args, *kw) File "/usr/lib/python3/dist-packages/odoo/http.py", line 515, in response_wrap response = f(args, kw) File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1343, in call_button action = self._call_kw(model, method, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1331, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/api.py", line 387, in call_kw result = _call_kw_multi(method, model, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/api.py", line 374, in _call_kw_multi result = method(recs, *args, **kwargs) File "/var/lib/odoo/addons/13.0/l10n_nl_tax_statement/models/l10n_nl_vat_statement.py", line 430, in statement_update self._set_statement_lines(lines, move_lines) File "/var/lib/odoo/addons/13.0/l10n_nl_tax_statement/models/l10n_nl_vat_statement.py", line 457, in _set_statement_lines tags_map = self._get_tags_map() File "/var/lib/odoo/addons/13.0/l10n_nl_tax_statement/models/l10n_nl_vat_statement.py", line 408, in _get_tags_map matching.update({tag.id: (res_code.group(0), "omzet")}) AttributeError: 'NoneType' object has no attribute 'group'

CasVissers-360ERP commented 3 years ago

@E4eqRL0yw0yajQJ433QL

You can fix this by updating def _get_tags_map(self): with:

        for tag in nl_tags:
            res_code = pattern_code.match(tag.name)
            if res_code and re.search("omzet", tag.name, re.IGNORECASE):
                matching.update({tag.id: (res_code.group(0), "omzet")})
            elif res_code and re.search("btw", tag.name, re.IGNORECASE):
                matching.update({tag.id: (res_code.group(0), "btw")})
            elif res_code:
                matching.update({tag.id: (res_code.group(0), False)})

@astirpe what do you think of the fix?

E4eqRL0yw0yajQJ433QL commented 3 years ago

@CasVissers-360ERP Thanks for your superfast reply Cas. It is well-appreciated. I applied the fix that you proposed and did some quick testing:

CasVissers-360ERP commented 3 years ago

You might need to correct the account tags set on the taxes and then recompute the tax_tag_ids of account move lines to fix the incorrect amounts.

E4eqRL0yw0yajQJ433QL commented 3 years ago

Thx Cas. You are right. Correcting the account tags set on the taxes was something I indeed already did yesterday. So for any new purchases/invoices the VAT report shows the right figures (just tested that and things are fine). As for Q1, I already posted the VAT reports, so there also I am OK. However I am now struggling with the (both customer and supplier) invoices that I posted in the first three weeks of this month. These were posted with the old tags and the effect is that VAT amount equals the total amount of the invoice. Not really sure how I can correct these already posted invoices.

CasVissers-360ERP commented 3 years ago

I have a script te re-create them, will share tomorrow.

CasVissers-360ERP commented 3 years ago

@E4eqRL0yw0yajQJ433QL

I created a server action running a custom method based on Odoo's base mechanism to calculate this (use at own risk :) ).

code incorrect

E4eqRL0yw0yajQJ433QL commented 3 years ago

Hi Cas. Just to make sure that I am doing the right thing: which "model" should I choose when creating this server action. I tried to include it in model "nederlandse btw aangifte", but that leads to an odoo server error when running the action. Hence I think, I am probably doing something wrong in the server action (sorry for not being an odoo expert - pretty new at this).

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 354, in safe_eval return unsafe_eval(c, globals_dict, locals_dict) File "", line 19, in AttributeError: 'account.move' object has no attribute '_compute_base_line_taxes'

After this, I tried a whole bunch of different models (account.move, account.move.lines, account.tax, account.tax.report, account.tax.report.line, ....) but in virtually all cases it gives a comparable message as given above.

CasVissers-360ERP commented 3 years ago

@E4eqRL0yw0yajQJ433QL The script was not correct, I am working on something new will let you know if I find something.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.