Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] l10n_id_efaktur: prevent error when download e-Faktur without tax number #162746

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Apr 20, 2024

Currently, the error arises when downloading e-Faktur without a 'Tax Number'.

Steps to reproduce:

  • Install a 'l10n_id_efaktur' module (with demo data).
  • Navigate to Invoicing -> Customers -> Invoices and open any invoice with an empty 'Tax Number' field.
  • Click on the action button to download e-Faktur.

Stack Trace :

TypeError: 'bool' object is not subscriptable
  File "odoo/tools/safe_eval.py", line 365, in safe_eval
    return unsafe_eval(c, globals_dict, locals_dict)
  File "ir.actions.server(801,)", line 1, in <module>
  File "addons/l10n_id_efaktur/models/account_move.py", line 143, in download_efaktur
    self._generate_efaktur(',')
  File "addons/l10n_id_efaktur/models/account_move.py", line 338, in _generate_efaktur
    output_head = self._generate_efaktur_invoice(delimiter)
  File "addons/l10n_id_efaktur/models/account_move.py", line 178, in _generate_efaktur_invoice
    eTax['KD_JENIS_TRANSAKSI'] = move.l10n_id_tax_number[0:2] or 0
ValueError: <class 'TypeError'>: "'bool' object is not subscriptable" while evaluating
'action = records.download_efaktur()'
  File "odoo/http.py", line 2251, in __call__
    response = request._serve_db()
  File "odoo/http.py", line 1826, in _serve_db
    return self._transactioning(_serve_ir_http, readonly=ro)
  File "odoo/http.py", line 1847, in _transactioning
    return service_model.retrying(func, env=self.env)
  File "odoo/service/model.py", line 134, in retrying
    result = func()
  File "odoo/http.py", line 1824, in _serve_ir_http
    return self._serve_ir_http(rule, args)
  File "odoo/http.py", line 1832, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "odoo/http.py", line 2057, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "odoo/addons/base/models/ir_http.py", line 222, in _dispatch
    result = endpoint(**request.params)
  File "odoo/http.py", line 740, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "addons/web/controllers/action.py", line 46, in run
    result = action.run()
  File "home/odoo/src/custom/trial/saas_trial/models/sentry.py", line 33, in run
    res = super().run()
  File "odoo/addons/base/models/ir_actions.py", line 938, in run
    res = runner(run_self, eval_context=eval_context)
  File "addons/website/models/ir_actions_server.py", line 61, in _run_action_code_multi
    res = super(ServerAction, self)._run_action_code_multi(eval_context)
  File "odoo/addons/base/models/ir_actions.py", line 770, in _run_action_code_multi
    safe_eval(self.code.strip(), eval_context, mode="exec", nocopy=True, filename=str(self))  # nocopy allows to return 'action'
  File "odoo/tools/safe_eval.py", line 379, in safe_eval
    raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))

When downloading e-Faktur, There's an issue at [1], Where the system tries to access elements of 'l10n_id_tax_number', but 'Tax Number' is empty, So 'l10n_id_tax_number' is considered as a 'False'.

[1] :

eTax['KD_JENIS_TRANSAKSI'] = move.l10n_id_tax_number[0:2] or 0
eTax['FG_PENGGANTI'] = move.l10n_id_tax_number[2:3] or 0
eTax['NOMOR_FAKTUR'] = move.l10n_id_tax_number[3:] or 0

This commit fixes the above issue by adding a condition to ensure that the system only accesses an 'l10n_id_tax_number' if it is available.

sentry-5001664034


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #162096
Forward-Port-Of: #155196

…ax number

Currently, the error arises when downloading e-Faktur without a 'Tax Number'.

Steps to reproduce:

- Install a 'l10n_id_efaktur' module (with demo data).
- Navigate to Invoicing -> Customers -> Invoices and open any invoice with
an empty 'Tax Number' field.
- Click on the action button to download e-Faktur.

Error:   'bool' object is not subscriptable while evaluating
'action = records.download_efaktur()'

When downloading e-Faktur, There's an issue at [1], Where
the system tries to access elements of 'l10n_id_tax_number', but
'Tax Number' is empty, So 'l10n_id_tax_number' is considered as a 'False'.

[1]: https://github.com/odoo/odoo/blob/9c4194ad3387c55d39ec7bbef1c6414893098c6e/addons/l10n_id_efaktur/models/account_move.py#L168-L170

This commit fixes the above issue by adding a condition to ensure that
the system only accesses an 'l10n_id_tax_number' if it is available.

sentry-5001664034

X-original-commit: 24e65c2
@robodoo robodoo added the forwardport This PR was created by @fw-bot label Apr 20, 2024
@robodoo
Copy link
Contributor

robodoo commented Apr 20, 2024

@fw-bot
Copy link
Contributor Author

fw-bot commented Apr 20, 2024

This PR targets saas-16.3 and is part of the forward-port chain. Further PRs will be created up to master.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@C3POdoo C3POdoo added the RD research & development, internal work label Apr 20, 2024
robodoo pushed a commit that referenced this pull request Apr 21, 2024
…ax number

Currently, the error arises when downloading e-Faktur without a 'Tax Number'.

Steps to reproduce:

- Install a 'l10n_id_efaktur' module (with demo data).
- Navigate to Invoicing -> Customers -> Invoices and open any invoice with
an empty 'Tax Number' field.
- Click on the action button to download e-Faktur.

Error:   'bool' object is not subscriptable while evaluating
'action = records.download_efaktur()'

When downloading e-Faktur, There's an issue at [1], Where
the system tries to access elements of 'l10n_id_tax_number', but
'Tax Number' is empty, So 'l10n_id_tax_number' is considered as a 'False'.

[1]: https://github.com/odoo/odoo/blob/9c4194ad3387c55d39ec7bbef1c6414893098c6e/addons/l10n_id_efaktur/models/account_move.py#L168-L170

This commit fixes the above issue by adding a condition to ensure that
the system only accesses an 'l10n_id_tax_number' if it is available.

sentry-5001664034

closes #162746

X-original-commit: 24e65c2
Signed-off-by: William André (wan) <wan@odoo.com>
@robodoo robodoo closed this Apr 21, 2024
@fw-bot fw-bot deleted the saas-16.3-15.0-sentry-5001664034-l10n-id-efaktur-typeerror-mega-OtC5-fw branch May 5, 2024 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwardport This PR was created by @fw-bot RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants