Commit Graph
14 Commits
Author SHA1 Message Date
wan 1656f1a093 [FIX] account_edi: search partner based on VAT with spaces
This solution is not perfect. In order to be, we would need to have a
sanitized function that is used to store the number in the database, and
to use the same function to search in it. This will most likely be done
in master with a refactoring of `base_vat`, on which `account` will
depend one way or another.

In the meantime, we need to support cases that were working before these
fixes:
https://github.com/odoo/odoo/commit/bfb2436b9d99bf9eea29ee44000e18197efa88b6
https://github.com/odoo/odoo/commit/e24c5ba4efef466919735ec4304cfd46be5f0d3f

Since these, it was indeed impossible to detect a partner based on his
VAT for Swiss partners if `base_vat` was installed, which is the
default.

closes odoo/odoo#81263

X-original-commit: 04aa5cd79c6aca1615ba022c351054a390e6c0b5
Signed-off-by: Olivier Colson <oco@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-12-14 13:28:56 +00:00
Laurent Smet ed75307baf [FIX] account_edi: Add missing 'extra_domain' + Fix tests l10n_be_edi
- allow to match a partner having 'BE0477472701' as vat but '477472701' inside the xml.
- code cleanup as suggested in the original PR

Introduced by https://github.com/odoo/odoo/pull/80266

closes odoo/odoo#81237

X-original-commit: 598bfedb540aa81676b957340255aafef85d2823
Signed-off-by: Olivier Colson <oco@odoo.com>
Signed-off-by: Laurent Smet <las@odoo.com>
2021-12-10 15:28:57 +00:00
Laurent Smet 85f2ae03d3 [IMP] account(_edi): Detect when an invoice is ready to be sent
In some flow like subscription, invoices are sent by mail automatically to the customer.
Sometimes, the invoice must be approved by the government before sending the mail like the Mexican EDI.
This commit aims to add a custom method to detect when an invoice is ready to be sent to the customer.

PR (community): https://github.com/odoo/odoo/pull/78714
PR (enterprise): https://github.com/odoo/enterprise/pull/21809

closes odoo/odoo#79504

X-original-commit: 3a29371eb70309f46e3b8938434287fefc23b351
Related: odoo/enterprise#22171
Signed-off-by: William André (wan) <wan@odoo.com>
2021-11-09 14:45:57 +00:00
Benjamin Frantzen (bfr) 5319b71b66 [IMP] account_edi: decouple attachment from the state of the edi_document.
Before this commit, for an EDI to be successfully posted, returning an attachment from 'post_invoice_edi' was required. In some cases this caused problem:
- When an EDI is posted in two steps, sometimes the attachment is generated in the first step and nothing is returned until the second step. This forced to do some hack where the reference to the attachment in a seperate field to be able to return it after the second step.
- When an EDI doesn't have a file to return (maybe we just send data over an API and get a response without any file involved).
Now, the attachment are removed from account_edi flows. When returning from 'post_invoice_edi', it is still possible to return an attachment whose reference will be kept in the edi_document, but will not change the state of the document to 'sent'.
To make the state change to 'sent', 'post_invoice_edi' must return {'success': True}.
Nothing has changed in the 'cancel' flow, meaning that the buttons related to canceling or reseting an invoice to draft are now based on the state and not on the existence of an attachment on the document. Also, when an invoice is successfully cancelled, the reference to the attachment is STILL removed from the document, since the document does not represent an electronic invoice anymore.

closes odoo/odoo#70040

Related: odoo/upgrade#1946
Related: odoo/enterprise#13220
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-07-16 09:08:55 +00:00
Benjamin Frantzen (bfr) 22e04c6d56 [REF] account_edi: remove test_mode from _post_invoice_edi and _cancel_invoice_edi
Before this commit, business logic was mixed with tests. This commit aims to replace the test_mode with mocks for all account_edi tests.

closes odoo/odoo#71650

Related: odoo/enterprise#18709
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-06-03 09:18:24 +00:00
Benjamin Frantzen (bfr) b27614b136 [FIX] account_edi_ubl: extracting the pdf from the imported xml doesn't raise an exception any more when creating a new invoice
Before this commit, when an attachment was present in the xml (pdf) and the import was to create a new invoice, it crashed when trying to post the pdf on the not-yet existant invoice.

This commit also fixes:
- In the tests, `create_invoice_from_file` didn't handle the subfolder parameter correctly
- `create_invoice_from_file` now returns the created invoice

closes odoo/odoo#69722

X-original-commit: e81457501f4815a4d9add7a56a9dfe66a7656269
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: bfr-o <bfr-o@users.noreply.github.com>
2021-04-22 16:57:12 +00:00
Laurent Smet c9f9f859ca [IMP] account_edi: Replace high velocity CRON by CRON triggers
So, instead of waiting for the cron every hour, we create
a cron trigger, which is created/activated every time
we post/cancel an invoice.  When the CRON worker is available,
it can take the job immediately.

To be sure that we don't miss any crons or that events
might be needed that are not triggered, we still launch the
cron every day.

A test was added to check that the crons are correctly
triggered.

closes odoo/odoo#67088

Signed-off-by: Josse Colpaert <jco@openerp.com>
2021-04-01 13:55:48 +00:00
Benjamin Frantzen (bfr) e3bd3fec38 [IMP] account_edi: merge account_edi_extended
TASK ID: 2457873

closes odoo/odoo#65745

Related: odoo/enterprise#16226
Related: odoo/upgrade#2144
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-02-11 08:08:18 +00:00
Benjamin Frantzen (bfr) 7785fcb819 [FIX] account_edi: edi.document are re-send if they are in error
Before the introduction of account_edi_extended and blocking_level, if an edi.document was in error, it was retried each the time the edi.documents were processed. With account_edi_extended a bug was introduced and only the document not in error were processed. This commit aims to restore the previous behavior.

Also fixes tests of account_edi.

See https://github.com/odoo/odoo/commit/a9a46cf09b0c841c7fda95b5ed03033fc6936ca2

X-original-commit: 385fa29322f6dffc7d7d0de96a1cfbddb0cab7f0
2021-02-08 12:20:37 +00:00
Benjamin Frantzen (bfr) fbc77a6ecd [FIX] account_edi: a failed import of an attachment with account_edi now allows OCR to run automatically.
Before this commit, account_invoice_extract and account_edi where independent in parsing files uploaded or added as attachment in an invoice. Some tricks where used to avoid clash, but they were not perfect and some bugs appeared like the OCR not triggering automatically or an attachment being parsed twice by account_edi when parsing failed. The goal of this commit is to unify the import of files between the two features and ensure that they will not clash.

For more information about potential problems that appeared before :
See https://github.com/odoo/odoo/pull/61169
See https://github.com/odoo/enterprise/pull/15124/

closes odoo/odoo#65660

X-original-commit: 8435d0e8990509ee67425977f970ab27bea8133a
Related: odoo/enterprise#16172
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: bfr-o <bfr-o@users.noreply.github.com>
2021-02-05 17:56:12 +00:00
Benjamin Frantzen (bfr) ce674f1b21 [IMP] account_edi: added error_level + better management of Lock on account.move
- Some errors will never get fixed until user intervention, it doesn't make sense to run the CRON when there is such error.
+ some small improvements and esthetic changes
- When we are in a CRON, we need to commit the changes between each call to web-service to avoid loss of data.
- Small refactor of edi.document prepare_jobs and process_jobs
- Added an arbitrary key to create the batches.
2021-02-01 14:41:58 +00:00
Benjamin Frantzen (bfr) 584bcb9025 [IMP] account_edi: Better OCR management in tests
When importing an xml in tests, if the import fails, the OCR will try to parse the file, which will cause an user access error. This polutes the logs and makes it hard to debug the code/test. With this commit a helper is added to create and invoice with OCR deactivated to be used to import the file.

closes odoo/odoo#62817

Related: odoo/enterprise#15134
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: bfr-o <bfr-o@users.noreply.github.com>
2020-12-03 13:32:29 +00:00
oco-odoo 5e89044c92 [IMP] account_edi: improve test helper
Allowing to filter the type of EDI attachments data we want to filter allows finer testing when multiple EDI modules are installed. Wihtout that, we risk to also consider data from other formats than the one we are testing (it actually happened for l10n_mx_edi).

closes odoo/odoo#56824

X-original-commit: 719ffecb58a7e81089427c9e22b5e5f99246980b
Related: odoo/enterprise#12811
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2020-08-31 17:30:51 +00:00
Benjamin Frantzen (bfr) 013936261b [IMP] account_edi: added flows to manage web-services and payments.
Added edi.documents representing an electronic document for a move and an edi.format.
A format can be asynchronous if it needs to call a web-service to generate the document, it will then be generated by the CRON (otherwise it's generated in post).
The formats can support payments if needed (can be generated immediately or by the CRON).
Added support for errors and related views.
Setting defaults format on a journal can be done automatically (based on a hook).
Added tests : xml comparaison with diff and helpers to test a EDI import/export

--task: 2247368
2020-08-17 10:22:01 +00:00