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

[FIX] l10n_es_edi_sii: support missing ref #163792

Open
wants to merge 1 commit into
base: 15.0
Choose a base branch
from

Conversation

yajo
Copy link
Contributor

@yajo yajo commented Apr 29, 2024

This field isn't required. However, if not supplied, Odoo fails to notify all invoices in a cron run, without speaking about it. Not good.

The traceback:

2024-04-29 11:43:01,356 29 ERROR odoo odoo.addons.base.models.ir_cron: Call from cron EDI : Perform web services operations for server action #282 failed in Job #15 
Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/tools/safe_eval.py", line 383, in safe_eval
    return unsafe_eval(c, globals_dict, locals_dict)
  File "ir.actions.server(282,)", line 1, in <module>
  File "/opt/odoo/auto/addons/account_edi/models/account_edi_document.py", line 276, in _cron_process_documents_web_services
    nb_remaining_jobs = edi_documents._process_documents_web_services(job_count=job_count)
  File "/opt/odoo/auto/addons/account_edi/models/account_edi_document.py", line 263, in _process_documents_web_services
    self._process_job(job)
  File "/opt/odoo/auto/addons/account_edi/models/account_edi_document.py", line 217, in _process_job
    edi_result = method_to_call(moves)
  File "/opt/odoo/auto/addons/l10n_es_edi_sii/models/account_edi_format.py", line 660, in _l10n_es_edi_sii_post_invoices
    info_list = self._l10n_es_edi_get_invoices_info(invoices)
  File "/opt/odoo/auto/addons/l10n_es_edi_sii/models/account_edi_format.py", line 291, in _l10n_es_edi_get_invoices_info
    info['IDFactura']['NumSerieFacturaEmisor'] = invoice.ref[:60]
TypeError: 'bool' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_cron.py", line 391, in _callback
    self.env['ir.actions.server'].browse(server_action_id).run()
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_actions.py", line 674, in run
    res = runner(run_self, eval_context=eval_context)
  File "/opt/odoo/auto/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 "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_actions.py", line 544, 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 "/opt/odoo/custom/src/odoo/odoo/tools/safe_eval.py", line 397, in safe_eval
    raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))
ValueError: <class 'TypeError'>: "'bool' object is not subscriptable" while evaluating
'model._cron_process_documents_web_services(job_count=20)'

@moduon MT-5819


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

@robodoo
Copy link
Contributor

robodoo commented Apr 29, 2024

@C3POdoo C3POdoo added the Localization about adapting the content to a specify country (usually chart of accounts) label Apr 29, 2024
@yajo yajo changed the title 14.0-l10n_es_edi_sii-fix_missing_ref [FIX] l10n_es_edi_sii: support missing ref Apr 29, 2024
@C3POdoo C3POdoo requested review from a team and casp-odoo and removed request for a team April 29, 2024 12:09
@yajo
Copy link
Contributor Author

yajo commented Apr 29, 2024

FWIW the OCA version of this module requires the ref field for incoming invoices. Do you want me to add such check here too?

@rafaelbn
Copy link
Contributor

@jco-odoo @chklop please could you review here please, or assign an Expert? Thank you! 😄 ❤️

This field isn't required. However, if not supplied, Odoo fails to notify *all* invoices in a cron run, without speaking about it. Not good.

@moduon MT-5819
@yajo yajo changed the base branch from 14.0 to 15.0 April 29, 2024 12:15
@yajo yajo force-pushed the 14.0-l10n_es_edi_sii-fix_missing_ref branch from 675a852 to 8013276 Compare April 29, 2024 12:15
@jco-odoo
Copy link
Contributor

@yajo We do the check for vendor bills in _check_move_configuration.

def _is_compatible_with_journal(self, journal):

@yajo
Copy link
Contributor Author

yajo commented Apr 29, 2024

You probably mean this, right?

if move.move_type in ('in_invoice', 'in_refund'):
if not move.ref:
res.append(_("You should put a vendor reference on this vendor bill. "))

Indeed, that should make this use case impossible to become. I don't know how the error even happened!

I took that faulty invoice, reset it to draft and then validate it again, and I got the error that wouldn't let me continue. 👀

@yajo
Copy link
Contributor Author

yajo commented Apr 30, 2024

It seems like l10n_es_edi_sii was installed after the faulty invoice was installed. In that case, customer was able to validate it, but then the cron would send none of the invoices because the exception happened before sending any of them.

With this fix, only the flaky invoice is failed, and it gets a yellow warning, while the rest of the batch is perfectly sent to SII.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Localization about adapting the content to a specify country (usually chart of accounts)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants