sesn-odoo f8ffd62aa2 [FIX] l10n_sa_edi: skip QR code generation on invoices without signature
Steps to reproduce
------------------
* install `l10n_sa_edi`
* switch to a Saudi company
* deactivate the "EDI : Perform web services operations" scheduled
  action. (this will help ease the reproduction process)
* create and post two invoices for a partner that's an individual (not a
  company)
* manually run that scheduled action.

You should be met with a traceback.

Cause
-----
When a ZATCA document is submitted, the system performs several
operations, two of which are important for this issue:
1. Generating a signature (`l10n_sa_invoice_signature`)
2. Using this signature to generate a QR code (`l10n_sa_qr_code_str`)

The QR code generation relies on the assumption that the signature
(`l10n_sa_invoice_signature`) already exists, which is a reasonable
expectation as the signature is typically created prior to the QR code.

However, complications arise when multiple documents are submitted
simultaneously in a batch process. During batch processing, each
document in the batch undergoes the same two operations mentioned above.
The issue emerges due to the behavior of non-stored computed fields .

In Odoo, computed fields are evaluated in batches, meaning that if you
access a computed field for one record, Odoo may also compute the same
field for other records fetched in the same operation. For example, if
you have two records, `A` and `B` such that `B.id in A._prefetch_ids`,
and you access a computed field on `A`, Odoo will also compute this
field for `B` at the same time.

This behavior leads to an issue when submitting two documents (`D1` and
`D2`) together. The system will generate a signature and then compute
the QR code for `D1`. However, when computing the QR code for `D1`, it
inadvertently attempts to also compute the QR code for `D2` due to the
batch computation behavior. Since `D2`'s signature has not yet been
generated at this point, this results in an error.

opw-3696146

closes odoo/odoo#155269

X-original-commit: 97e67514c0e72730882cc093b36cb5477eba496d
Signed-off-by: William André (wan) <wan@odoo.com>
2024-02-23 19:27:36 +00:00
2024-02-21 11:28:04 +00:00
…
…
…
…
…

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%