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

Error when deleting invoice with linked files #14474

Closed
kev-73 opened this issue Aug 13, 2020 · 1 comment
Closed

Error when deleting invoice with linked files #14474

kev-73 opened this issue Aug 13, 2020 · 1 comment
Labels
Bug This is a bug (something does not work as expected)

Comments

@kev-73
Copy link
Contributor

kev-73 commented Aug 13, 2020

Bug

I think would have a bug for invoices (error message appears for customer but not for vendor).
When I delete an invoice which have some linked files, this files are deleted from HDD but not deleted in database (table 'llx_ecm_files').

Environment

  • Version: [12.0.1 (from 11.0.3)]
  • OS: [Local hosting on Windows 10 version 2004 (10.0.19041.388)]
  • Web server: [Apache 2.4.43 (Win64)]
  • PHP: [PHP 7.4.8]
  • Database: [MariaDB 10.5.4]
  • URL(s): [https://localhost/dolibarr/compta/facture/card.php]
  • No external module
  • Tested on Firefox and Chrome
  • Problem replicate on Dolbarr demo website (12.0.0)

Steps to reproduce the behavior

  1. Make a customer draft invoice
  2. Add a linked file (here 'Liste client - 2020-07-26.xlsx')
  3. Add a line in card
  4. Validate invoice (here ref 'FA2008-0001')
  5. Delete invoice
  6. Make a customer draft invoice
  7. Add the same linked file as in step 2
  8. Add a line in card
  9. Validate invoice
    --> If the generated invoice ref is the same as in step 4 (no other customer invoice between time), the validating is canceled by this message error : "Duplicate entry 'facture/FA2008-0001-FA2008-0001-Liste client - 2020-07-26.xlsx-1' for key 'uk_ecm_files'"

Expected and actual behavior

I think than the problem is in step 5, the invoice deleting delete the files in HDD, but in database, just the line of generated PDF file of customer invoice is deleted, but not the line of linked file (same problem with many linked files).
So with the customer invoice validating at the step 9, when the files must be renamed (PROV... to FA2008-0001...), an error appears because the linked file for this customer invoice ref already exist in database, because the 'uk_ecm_files' index wich contains columns 'filepath', 'filename' and 'entity' of 'llx_ecm_files' table must be unique.

Note 1 : I tried with different files and I have the same problem.

Note 2 : When I delete by hand the linked file one by one with the trash icon (in tab Card or in tab Linked file), this is OK, the file is deleted in HDD and in database

Note 3 : For a vendor invoice, there isn't have error message, the validating of invoice in step 9 is OK, but it's because the file path format is different between a customer invoice and a vendor invoice ("facture/FA2008-0001" for customer, "fournisseur/facture/1/0/SI2008-0001" for first invoice vendor, and "fournisseur/facture/2/0/SI2008-0001" for the second).

I looked the Dolibarr php files and I found this :
File 'core\lib\files.lib.php', line 1233, function 'delete' called in file 'ecm\class\ecmfiles.class.php' : $result = $ecmfile->delete($user);
--> bug in 'foreach' loop, or in 'if' ? so the function 'delete' for SQL request DELETE of linked files isn't called ?

Here the part of log for the 'delete' action of customer invoice (step 5). We can see than the SQL request DELETE in table 'llx_ecm_files' is only for one line, that of PDF file generated for the customer invoice), but the linked file is deleted in HDD :
https://textup.fr/475576zp

Sorry for my bad english.

Kevin

Attached files

Error message (step 9) :
Dolibarr message bug facture

@kev-73 kev-73 added the Bug This is a bug (something does not work as expected) label Aug 13, 2020
@dpriskorn
Copy link
Contributor

Big thanks for the very clearly detailed report. 👍

@eldy eldy closed this as completed in bb92e64 Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected)
Projects
None yet
Development

No branches or pull requests

2 participants