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

Serious Bug: When creating an invoice from a sales order, the content of the extrafields is not fetched from the database #14649

Closed
Fred-Zweig opened this issue Sep 7, 2020 · 12 comments
Labels
Bug This is a bug (something does not work as expected)

Comments

@Fred-Zweig
Copy link
Contributor

Fred-Zweig commented Sep 7, 2020

Bug

When I try to create an invoice from a sales order that has an extrafield, the content of the extrafield is not fetched from the database:

invoice_from_order_not_working png

Environment

  • Version: Dolibarr 12.0.0, 12.0.1, 12.0.2
  • OS: Debian 10
  • Web server: Nginx 1.14.2
  • PHP: PHP 7.3
  • Database: MariaDB 15.1

Expected behavior

When clicking on the 'Create invoice' button below the product lines of a sales order, the 'New invoice' form should fetch the content of the order's etrafield, to insert it in the corresponding invoice extrafield. This works in Dolibarr version 11 as seen below, but not in versions 12.0.0, 12.0.1, 12.0.2.

invoice_from_order_working

I created the extrafield correctly for sales orders and for invoices and it has nothing special: Position: 100, Type: long text, Size: 2000, Computed field: No, Unique: No, Required: No, Can always be edited: Yes, Visible: 3, Display on PDF: 1, Totalizable: No.

Please note that if I replace the core/class/commonobject.class.php of Dolibarr version 12 with the corresponding file of Dolibarr version 11, the extrafield content is fetched correctly. On the other hand, the old commonobject.class.php file creates another problem in Dolibarr 12 when saving third parties, so I can't use the old commonobject.class.php file as a temporary workaround.

Actual behavior

When creating an invoice from a sales order the extrafield content is not fetched from the database, so, when saving the draft invoice, an empty string is inserted in the corresponding invoice extrafield. If when I create the invoice from the order, I add manually some content in the extrafield, the content is inserted correctly in the extrafield of the invoice.

The same thing happens when trying to create a shipment from an order with an extrafield: the extrafield's content is not fetched from the database.

Steps to reproduce the behavior

Add an extrafield to the sales orders, then add the same extrafield to the invoices. Then try to create an invoice from an order that has content in that extrafield. The new invoice will be created with an empty extrafield.

This problem deeply affects my activities. Please try to find a fix or a workaround.

@Fred-Zweig Fred-Zweig added the Bug This is a bug (something does not work as expected) label Sep 7, 2020
@BebZ
Copy link

BebZ commented Sep 7, 2020

Hello,

Maybe you missed :

https://wiki.dolibarr.org/index.php/Setup_Other

THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER => Copy also extrafields from thirdparty to order (if name match). ► (v11.0+)

@Fred-Zweig
Copy link
Contributor Author

Fred-Zweig commented Sep 7, 2020

Thank you BebZ for your suggestion. I tried adding the THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER parameter, but it didn't work. As mentioned above, my problem is not with copying extrafields from third parties to orders, but with fetching the content of the order's extrafield, when creating an invoice from the order.

@BebZ
Copy link

BebZ commented Sep 7, 2020

i will ask my dev to know how we do it... he's back on 16th of september... we never had this problem and we are fetching extrafields from orders to shipments but I don't know if it works for extrafields between orders and invoices :)

@Fred-Zweig
Copy link
Contributor Author

Fred-Zweig commented Sep 8, 2020

@atm-maxime
Is anybody working on this bug ? As mentioned, the problem is in the core/class/commonobject.class.php file of Dolibarr version 12. When that file is replaced with the old one from version 11, it works.

@atm-maxime
Copy link
Member

?
Why requesting me ?
Be patient, you opened your issue 3 days ago... Surely someone on the community will deal with it.

@simnandez
Copy link
Member

With the branch 12 (future 12.0.3), it works for me fine.

@Fred-Zweig
Copy link
Contributor Author

simnandez, thank you for your info. So, you say that the current development version of Dolibarr doesn't have this bug ? I have Dolibarr 12.0.2 installed and it has the bug. Version 12.0.2 is currently the latest 'stable' version. Are you sure that in the current development version, which will be the future 12.0.3 version, the extrafield content is fetched correctly from the database when creating an invoice from a sales order ? Because I tried copying the core/class/commonobject.class.php file from the development version into version 12.0.2, and it didn't work.

@dolibit-ut
Copy link
Contributor

Thank you and hope that works for future,

but my statement: this is really not a serious bug
if you create an extrafield and something with it want work like you want
and you can even work on (maybe with a work around).

@Fred-Zweig
Copy link
Contributor Author

dolibit-ut, for me it's a serious bug, because it's very inefficient to copy the content of the extrafield from the sales order manually and insert it in the empty extrafield of the new invoice. It should be fetched automatically. This bug also affects shipments. When I create a shipment from a sales order having an extrafield, the new shipment is created with an empty extrafield. Also, there is no workaround for this bug, as I explained. I lost 2 days trying to find a solution to this bug and I couldn't. It's very frustrating, since it worked so well in version 11 but it doesn't work in version 12.0.2, and it seems to me that it doesn't work in 12.0.1 and 12.0.0 either.

@Fred-Zweig
Copy link
Contributor Author

Fred-Zweig commented Oct 19, 2020

@simnandez It doesn't work in 12.0.3 either. I installed 12.0.3 from scratch, yet it doesn't work.

It's a nightmare. I lost so much time trying to solve this in vain.

Once again: When you try to create an invoice from a sales order that has an extrafield, the content of the extrafield is not fetched from the database.

Why it worked in version 11 and in version 12.0.0, 12.0.1, 12.0.2 and 12.0.3 it doesn't work ?

Are you all happy with entering the content of extrafields manually when you make invoices from orders ?

FHenry added a commit to FHenry/dolibarr that referenced this issue Oct 19, 2020
@FHenry FHenry mentioned this issue Oct 19, 2020
@FHenry
Copy link
Member

FHenry commented Oct 19, 2020

@Fred-Zweig , bug occurs only for extrafields of type html, text, select, int.
If this PR #15063 is accepted, it will correct it. After that, what is wanted, dafault value of extrafields over value comming from origin object, I'm not sure for all cases, but, at least if it's filled on HTML form, it will be easier to set it manually

@Fred-Zweig
Copy link
Contributor Author

@FHenry thank you so much for your fix. You are a hero.

I tried to apply your modification to the core/class/commonobject.class.php file and indeed, it worked. With your fix applied, the content of the extrafields is fetched from the database both for invoices made from orders and for shipments made from orders.

What can I do to have your pull request merged more quickly ? Should I ping eldy ? Who else has the right to merge pull requests ?

@FHenry FHenry mentioned this issue Oct 20, 2020
eldy added a commit that referenced this issue Oct 22, 2020
@eldy eldy closed this as completed in d4fd71d Oct 22, 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

Successfully merging a pull request may close this issue.

6 participants