Added Attributes in SALES ORDER is not showing/displaying in INVOICE

Hi Dolibarr Team and Everyone here.

I added attributes or custom fields in SALES ORDER and I want this attributes or custom fields to show up or display also in all INVOICES and in the PDF files. How to do this?

I tried to edit some of .php files and back and forth. I’m not sure if I’m in the right path to edit thou. I am following the documentation and still get confuse.

What path file should i edit? Thank you and looking forward!

this is my added attributes / field in Sales Order module:

and i want to call/display it here automatically in Invoice page but its not showing.

Sales order extrafields would only show in order card and pdfs. You should create same extrafields for invoice then they will appear in invoice creation card.
For pdfs you have to edit dolibarr/htdocs/core/modules/facture/doc/pdf_sponge.modules.php at develop · Dolibarr/dolibarr · GitHub for invoice and dolibarr/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php at develop · Dolibarr/dolibarr · GitHub for orders

code to call the origin extrafield

                $extrafields = new ExtraFields($this->db);
                $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
                $object->fetch($rowid);
                $object->fetch_optionals($rowid,$extralabels);
                $origin = $extrafields->showOutputField('origin', object->array_options['options_origin'], '', $object->table_element);

example code to show the origin extrafield, you should adjust the posx posy values accordingly


                $posy += 4;
                $pdf->SetFont('','', $default_font_size - 1); 				
		$pdf->SetXY($posx +1, $posy + 3);
		$pdf->MultiCell($w, 4, $outputlangs->transnoentities("Origin")." : ".$origin, '', 'L');

You can find more examples in this module I co-develop (code is specific for Greece but you’ll get the idea)

1 Like
2 Likes

I add that, if you use the same name and type for the order and invoice extrafields, the values ​​are transmitted from one document to another

1 Like

Great Help! Thank you so much.