Complementary Lines (products) to show in Sales order

Hello,

I have tried so many things but it’s still not working.

about 4000 items have a location as complementary attributes products

i want/need them to be shown in the sales order module.

in the sales order management is have added complementary attribute (lines)

i have tried so many samples from all over the internet haha, but nothing seems to work
Please help me with this.

regards,

Hello,

$objectoffiled->id is the line id, and you need product id
Try :

(($reloadedobj = new Product($db)) && ($reloadedobj->fetch($objectoffield->fk_product))) ? $reloadedobj->array_options['options_l1948'] : 'Not found'

Also, what is your Dolibarr version ? objectoffield is newly introduced in V18

You are not showing the entire width of your Complementary attributes.

please show the contents including these 2 columns:

  • Visibility
  • On PDF

Hello Jonbendtsen,

As you can see it is visible in photo 2, besides that it has nothing to do with the PDF, thanks anyway.

Mr. Ksar had the correct answer thank you very much.
had been looking for this for a long time.

another question if you want to extract data from the product, for example the current stock (not the virtual one)

I expected it to be possible with the following code

(($reloadedobj = new Product($db)) && ($reloadedobj->fetch($objectoffield->fk_product))) ? $reloadedobj->array_options[‘reel’] : ‘Not found’
or
(($reloadedobj = new Product($db)) && ($reloadedobj->fetch($objectoffield->fk_product_stock))) ? $reloadedobj->array_options[‘reel’] : ‘Not found’

but unfortunately this doesn’t work.

Could you also give an example of this?
thank you very much in advance

and maybe a tip :), adding this to the wiki in a simple way, I understand that everything works in PHP. but for people with less knowledge “like me” it is really a great idea (I think)

Oh yes, I use 18.0.01

Hello,

Does the extrafield “reel” exist on Product module ?

you can try to do a print_r() to see all the properties of the product object and find the one related to stock

(($reloadedobj = new Product($db)) && ($reloadedobj->fetch($objectoffield->fk_product))) ? print_r($reloadedobj) : 'Not found'

I agree, but due to lack of time, I only copy/past some of the formula here : Extrafield Champ Calculé - Dolibarr ERP CRM Wiki

Hello Looking in the data i tought reel was linked to the amount that was in the warehouse, i know now that its

Product > warehouse > amount in physicle stock.
i checked you print_r()

was thinking that did the trick, but i know the actual link to the product amount in stock is not there.

(($reloadedobj = new Product($db)) && ($reloadedobj->fetch($objectoffield->fk_product))) ? $reloadedobj->array_options[stock_warehouse] : ‘Not found’

the idea is that


shows
6

the 11 pcs of the stock onto “voorraad”
5

if you could add a sample on how to link this, i would be really greatfull.

Hello,

Can you post the result of this ?

image

Stock (voorraad) should show 4 pcs

62

Product Object ( [module] => [db] => DoliDBMysqli Object ( [db] => mysqli Object ( [affected_rows] => 1 [client_info] => mysqlnd 8.1.25 [client_version] => 80125 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 4[_results:DoliDBMysqli:private] => mysqli_result Object ( [current_field] => 0 [field_count] => 4 [lengths] => [num_rows] => 1 [type] => 0 ) ) [id] => 152501 [entity] => 1 [error] => [errorhidden] => [errors] => Array ( ) [validateFieldsErrors:CommonObject:private] => Array ( ) [element] => product [fk_element] => fk_product [element_for_permission] => [table_element] => product [table_element_line] => [ismultientitymanaged] => 1 [import_key] => 20221227134140 [array_options] => Array ( [options_l9948] => S5.08.07 [options_binnenmaat] => [options_buitenmaat] => [options_hoogte] => [options_categorie] => [options_afdtoepassing] => [options_brandselection] => 8 [options_materiaal] => 2 [options_descwebsite] => [[Oringproductdesc]] [options_z1254] => MOR-180x3 [options_aantallev] => +400 [options_mvw] => ) [fields] => Array ( [rowid] => Array ( [type] => integer [label] => TechnicalID [enabled] => 1 [visible] => -2 [notnull] => 1 [index] => 1 [position] => 1 [comment] => Id ) [ref] => Array ( [type] => varchar(128) [label] => Ref [enabled] => 1 [visible] => 1 [notnull] => 1 [showoncombobox] => 1 [index] => 1 [position] => 10 [searchall] => 1 [comment] => Reference of object ) [entity] => Array ( [type] => integer [label] => Entity [enabled] => 1 [visible] => 0 [default] => 1 [notnull] => 1 [index] => 1 [position] => 5 ) [label] => Array ( [type] => varchar(255) [label] => Label [enabled] => 1 [visible] => 1 [notnull] => 1 [showoncombobox] => 2 [position] => 15 [csslist] => tdoverflowmax250 ) [barcode] => Array ( [type] => varchar(255) [label] => Barcode [enabled] => isModEnabled(“barcode”) [position] => 20 [visible] => -1 [showoncombobox] => 3 ) [fk_barcode_type] => Array ( [type] => integer [label] => BarcodeType [enabled] => 1 [position] => 21 [notnull] => 0 [visible] => -1 ) [note_public] => Array ( [type] => html [label] => NotePublic [enabled] => 1 [visible] => 0 [position] => 61 ) [note] => Array ( [type] => html [label] => NotePrivate [enabled] => 1 [visible] => 0 [position] => 62 ) [datec] => Array ( [type] => datetime [label] => DateCreation [enabled] => 1 [visible] => -2 [notnull] => 1 [position] => 500 ) [tms] => Array ( [type] => timestamp [label] => DateModification [enabled] => 1 [visible] => -2 [notnull] => 1 [position] => 501 ) [fk_user_author] => Array ( [type] => integer [label] => UserAuthor [enabled] => 1 [visible] => -2 [notnull] => 1 [position] => 510 [foreignkey] => llx_user.rowid ) [fk_user_modif] => Array ( [type] => integer [label] => UserModif [enabled] => 1 [visible] => -2 [notnull] => -1 [position] => 511 ) [localtax1_tx] => Array ( [type] => double(6,3) [label] => Localtax1tx [enabled] => 1 [position] => 150 [notnull] => 0 [visible] => -1 ) [localtax1_type] => Array ( [type] => varchar(10) [label] => Localtax1type [enabled] => 1 [position] => 155 [notnull] => 1 [visible] => -1 ) [localtax2_tx] => Array ( [type] => double(6,3) [label] => Localtax2tx [enabled] => 1 [position] => 160 [notnull] => 0 [visible] => -1 ) [localtax2_type] => Array ( [type] => varchar(10) [label] => Localtax2type [enabled] => 1 [position] => 165 [notnull] => 1 [visible] => -1 ) [import_key] => Array ( [type] => varchar(14) [label] => ImportId [enabled] => 1 [visible] => -2 [notnull] => -1 [index] => 0 [position] => 1000 ) [mandatory_period] => Array ( [type] => integer [label] => mandatory_period [enabled] => 1 [visible] => 1 [notnull] => 1 [default] => 0 [index] => 1 [position] => 1000 ) ) [array_languages] => [contacts_ids] => [linked_objects] => [linkedObjectsIds] => [linkedObjects] => [linkedObjectsFullLoaded:CommonObject:private] => Array ( ) [oldref] => [table_ref_field:protected] => ref [restrictiononfksoc] => 0 [context] => Array ( ) [canvas] => [project] => [fk_project] => [projet] => [fk_projet] => [contact] => [contact_id] => [thirdparty] => [user] => [origin] => [origin_id] => [ref] => HS-3283 [ref_ext] => [ref_previous] => [ref_next] => [newref] => [statut] => [status] => 1 [country] => [country_id] => [country_code] => [state] => [state_id] => [state_code] => [region_id] => [region_code] => [region] => [barcode_type] => 8 [barcode_type_code] => [barcode_type_label] => [barcode_type_coder] => [mode_reglement_id] => [cond_reglement_id] => [demand_reason_id] => [transport_mode_id] => [cond_reglement] => [fk_delivery_address] => [shipping_method_id] => [shipping_method] => [multicurrency_code] => [multicurrency_tx] => [model_pdf] => [modelpdf] => [last_main_doc] => [fk_bank] => [fk_account] => [openid] => [note_public] => [note_private] => [note] => [total_ht] => [total_tva] => [total_localtax1] => [total_localtax2] => [total_ttc] => [lines] => [comments] => Array ( ) [name] => [lastname] => [firstname] => [civility_id] => [date_creation] => [date_validation] => [date_modification] => 2023-10-29 12:47:00 [date_update] => [date_cloture] => [user_author] => [user_creation] => [user_creation_id] => [user_valid] => [user_validation] => [user_validation_id] => [user_closing_id] => [user_modification] => [user_modification_id] => [next_prev_filter] => [specimen] => 0 [sendtoid] => [alreadypaid] => [labelStatus] => [labelStatusShort:protected] => [showphoto_on_popup] => [nb] => Array ( ) [output] => [extraparams] => Array ( ) [childtables:protected] => Array ( [supplier_proposaldet] => Array ( [name] => SupplierProposal [parent] => supplier_proposal [parentkey] => fk_supplier_proposal ) [propaldet] => Array ( [name] => Proposal [parent] => propal [parentkey] => fk_propal ) [commandedet] => Array ( [name] => Order [parent] => commande [parentkey] => fk_commande ) [facturedet] => Array ( [name] => Invoice [parent] => facture [parentkey] => fk_facture ) [contratdet] => Array ( [name] => Contract [parent] => contrat [parentkey] => fk_contrat ) [facture_fourn_det] => Array ( [name] => SupplierInvoice [parent] => facture_fourn [parentkey] => fk_facture_fourn ) [commande_fournisseurdet] => Array ( [name] => SupplierOrder [parent] => commande_fournisseur [parentkey] => fk_commande ) ) [childtablesoncascade:protected] => Array ( ) [isextrafieldmanaged] => 1 [picto] => product [regeximgext] => .gif|.jpg|.jpeg|.png|.bmp|.webp|.xpm|.xbm [libelle] => [label] => OR70-180x3 [description] => [other] => [type] => 0 [price] => 1.81000000 [price_formated] => [price_ttc] => 2.19000000 [price_ttc_formated] => [price_min] => 0.00000000 [price_min_ttc] => 0.00000000 [price_base_type] => HT [multiprices] => Array ( ) [multiprices_ttc] => Array ( ) [multiprices_base_type] => Array ( ) [multiprices_min] => Array ( ) [multiprices_min_ttc] => Array ( ) [multiprices_tva_tx] => Array ( ) [multiprices_recuperableonly] => Array ( ) [price_by_qty] => [prices_by_qty] => Array ( ) [prices_by_qty_id] => Array ( ) [prices_by_qty_list] => Array ( ) [multilangs] => Array ( [nl_NL] => Array ( [label] => OR70-180x3 [description] => [other] => ) ) [default_vat_code] => [tva_tx] => 21.0000 [tva_npr] => 0 [recuperableonly] => 0 [remise_percent] => [localtax1_tx] => 0.0000 [localtax2_tx] => 0.0000 [localtax1_type] => 0 [localtax2_type] => 0 [desc_supplier] => [vatrate_supplier] => [default_vat_code_supplier] => [fourn_multicurrency_price] => [fourn_multicurrency_unitprice] => [fourn_multicurrency_tx] => [fourn_multicurrency_id] => [fourn_multicurrency_code] => [packaging] => [lifetime] => [qc_frequency] => [stock_reel] => 7 [stock_theorique] => [cost_price] => [pmp] => 0.36120000 [seuil_stock_alerte] => [desiredstock] => 0 [duration_value] => [duration_unit] => [duration] => [fk_default_workstation] => [tosell] => [status_buy] => 1 [tobuy] => [finished] => 1 [fk_default_bom] => [status_batch] => 0 [batch_mask] => [customcode] => [url] => [weight] => [weight_units] => 3 [length] => [length_units] => 0 [width] => [width_units] => 0 [height] => [height_units] => 0 [surface] => [surface_units] => 0 [volume] => [volume_units] => 0 [net_measure] => [net_measure_units] => [accountancy_code_sell] => [accountancy_code_sell_intra] => [accountancy_code_sell_export] => [accountancy_code_buy] => [accountancy_code_buy_intra] => [accountancy_code_buy_export] => [barcode] => 020000001639 [stats_propale] => Array ( ) [stats_commande] => Array ( ) [stats_contrat] => Array ( ) [stats_facture] => Array ( ) [stats_proposal_supplier] => Array ( ) [stats_commande_fournisseur] => Array ( ) [stats_expedition] => Array ( ) [stats_reception] => Array ( ) [stats_mo] => Array ( ) [stats_bom] => Array ( ) [stats_mrptoconsume] => Array ( ) [stats_mrptoproduce] => Array ( ) [stats_facturerec] => Array ( ) [stats_facture_fournisseur] => Array ( ) [imgWidth] => [imgHeight] => [product_fourn_id] => [product_id_already_linked] => [nbphoto] => 0 [stock_warehouse] => Array ( ) [fk_default_warehouse] => 1 [fk_price_expression] => [fourn_qty] => [fourn_pu] => [fourn_price_base_type] => [fourn_socid] => [ref_fourn] => [ref_supplier] => [fk_unit] => [price_autogen] => 0 [supplierprices] => [sousprods] => [res] => [is_object_used] => [mandatory_period] => 0 ) Product Object ( [module] => [db] => DoliDBMysqli Object ( [db] => mysqli Object ( [affected_rows] => 1 [client_info] => mysqlnd 8.1.25 [client_version] => 80125 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 4 [host_info] => database-5013303390.webspace-host.com via TCP/IP [info] => [insert_id] => 0 [protocol_version] => 10 [thread_id] => 63192878 [transaction_opened] => 0 [lastquery] => SELECT lang, label, description, note as other FROM llx_product_lang WHERE fk_product = 162631 [lastqueryerror] => [lasterror] => [lasterrno] => [prefix_db] => [ok] => 1 [error] => [_results:DoliDBMysqli:private] => mysqli_result Object ( [current_field] => 0 [field_count] => 4 [lengths] => [num_rows] => 1 [type] => 0 ) ) [id] => 162631 [entity] => 1 [error] => [errorhidden] => [errors] => Array ( ) [validateFieldsErrors:CommonObject:private] => Array ( ) [element] => product [fk_element] => fk_product [element_for_permission] => [table_element] => product [table_element_line] => [ismultientitymanaged] => 1 [import_key] => 20221227134140 [array_options] => Array ( [options_l9948] => S4.08.01 [options_binnenmaat] => [options_buitenmaat] => [options_hoogte] => [options_categorie] => [options_afdtoepassing] => [options_brandselection] => 8 [options_materiaal] => 2 [options_descwebsite] => [[Oringproductdesc]] [options_z1254] => MOR-230x7 [options_aantallev] => [options_mvw] => ) [fields] => Array ( [rowid] => Array ( [type] => integer [label] => TechnicalID [enabled] => 1 [visible] => -2 [notnull] => 1 [index] => 1 [position] => 1 [comment] => Id ) [ref] => Array ( [type] => varchar(128) [label] => Ref [enabled] => 1 [visible] => 1 [notnull] => 1 [showoncombobox] => 1 [index] => 1 [position] => 10 [searchall] => 1 [comment] => Reference of object ) [entity] => Array ( [type] => integer [label] => Entity [enabled] => 1 [visible] => 0 [default] => 1 [notnull] => 1 [index] => 1 [position] => 5 ) [label] => Array ( [type] => varchar(255) [label] => Label [enabled] => 1 [visible] => 1 [notnull] => 1 [showoncombobox] => 2 [position] => 15 [csslist] => tdoverflowmax250 ) [barcode] => Array ( [type] => varchar(255) [label] => Barcode [enabled] => isModEnabled(“barcode”) [position] => 20 [visible] => -1 [showoncombobox] => 3 ) [fk_barcode_type] => Array ( [type] => integer [label] => BarcodeType [enabled] => 1 [position] => 21 [notnull] => 0 [visible] => -1 ) [note_public] => Array ( [type] => html [label] => NotePublic [enabled] => 1 [visible] => 0 [position] => 61 ) [note] => Array ( [type] => html [label] => NotePrivate [enabled] => 1 [visible] => 0 [position] => 62 ) [datec] => Array ( [type] => datetime [label] => DateCreation [enabled] => 1 [visible] => -2 [notnull] => 1 [position] => 500 ) [tms] => Array ( [type] => timestamp [label] => DateModification [enabled] => 1 [visible] => -2 [notnull] => 1 [position] => 501 ) [fk_user_author] => Array ( [type] => integer [label] => UserAuthor [enabled] => 1 [visible] => -2 [notnull] => 1 [position] => 510 [foreignkey] => llx_user.rowid ) [fk_user_modif] => Array ( [type] => integer [label] => UserModif [enabled] => 1 [visible] => -2 [notnull] => -1 [position] => 511 ) [localtax1_tx] => Array ( [type] => double(6,3) [label] => Localtax1tx [enabled] => 1 [position] => 150 [notnull] => 0 [visible] => -1 ) [localtax1_type] => Array ( [type] => varchar(10) [label] => Localtax1type [enabled] => 1 [position] => 155 [notnull] => 1 [visible] => -1 ) [localtax2_tx] => Array ( [type] => double(6,3) [label] => Localtax2tx [enabled] => 1 [position] => 160 [notnull] => 0 [visible] => -1 ) [localtax2_type] => Array ( [type] => varchar(10) [label] => Localtax2type [enabled] => 1 [position] => 165 [notnull] => 1 [visible] => -1 ) [import_key] => Array ( [type] => varchar(14) [label] => ImportId [enabled] => 1 [visible] => -2 [notnull] => -1 [index] => 0 [position] => 1000 ) [mandatory_period] => Array ( [type] => integer [label] => mandatory_period [enabled] => 1 [visible] => 1 [notnull] => 1 [default] => 0 [index] => 1 [position] => 1000 ) ) [array_languages] => [contacts_ids] => [linked_objects] => [linkedObjectsIds] => [linkedObjects] => [linkedObjectsFullLoaded:CommonObject:private] => Array ( ) [oldref] => [table_ref_field:protected] => ref [restrictiononfksoc] => 0 [context] => Array ( ) [canvas] => [project] => [fk_project] => [projet] => [fk_projet] => [contact] => [contact_id] => [thirdparty] => [user] => [origin] => [origin_id] => [ref] => HS-1926 [ref_ext] => [ref_previous] => [ref_next] => [newref] => [statut] => [status] => 1 [country] => [country_id] => [country_code] => [state] => [state_id] => [state_code] => [region_id] => [region_code] => [region] => [barcode_type] => 8 [barcode_type_code] => [barcode_type_label] => [barcode_type_coder] => [mode_reglement_id] => [cond_reglement_id] => [demand_reason_id] => [transport_mode_id] => [cond_reglement] => [fk_delivery_address] => [shipping_method_id] => [shipping_method] => [multicurrency_code] => [multicurrency_tx] => [model_pdf] => [modelpdf] => [last_main_doc] => [fk_bank] => [fk_account] => [openid] => [note_public] => [note_private] => [note] => [total_ht] => [total_tva] => [total_localtax1] => [total_localtax2] => [total_ttc] => [lines] => [comments] => Array ( ) [name] => [lastname] => [firstname] => [civility_id] => [date_creation] => [date_validation] => [date_modification] => 2023-10-29 12:47:25 [date_update] => [date_cloture] => [user_author] => [user_creation] => [user_creation_id] => [user_valid] => [user_validation] => [user_validation_id] => [user_closing_id] => [user_modification] => [user_modification_id] => [next_prev_filter] => [specimen] => 0 [sendtoid] => [alreadypaid] => [labelStatus] => [labelStatusShort:protected] => [showphoto_on_popup] => [nb] => Array ( ) [output] => [extraparams] => Array ( ) [childtables:protected] => Array ( [supplier_proposaldet] => Array ( [name] => SupplierProposal [parent] => supplier_proposal [parentkey] => fk_supplier_proposal ) [propaldet] => Array ( [name] => Proposal [parent] => propal [parentkey] => fk_propal ) [commandedet] => Array ( [name] => Order [parent] => commande [parentkey] => fk_commande ) [facturedet] => Array ( [name] => Invoice [parent] => facture [parentkey] => fk_facture ) [contratdet] => Array ( [name] => Contract [parent] => contrat [parentkey] => fk_contrat ) [facture_fourn_det] => Array ( [name] => SupplierInvoice [parent] => facture_fourn [parentkey] => fk_facture_fourn ) [commande_fournisseurdet] => Array ( [name] => SupplierOrder [parent] => commande_fournisseur [parentkey] => fk_commande ) ) [childtablesoncascade:protected] => Array ( ) [isextrafieldmanaged] => 1 [picto] => product [regeximgext] => .gif|.jpg|.jpeg|.png|.bmp|.webp|.xpm|.xbm [libelle] => [label] => OR70-230x3 [description] => [other] => [type] => 0 [price] => 3.20000000 [price_formated] => [price_ttc] => 3.88000000 [price_ttc_formated] => [price_min] => 0.00000000 [price_min_ttc] => 0.00000000 [price_base_type] => HT [multiprices] => Array ( ) [multiprices_ttc] => Array ( ) [multiprices_base_type] => Array ( ) [multiprices_min] => Array ( ) [multiprices_min_ttc] => Array ( ) [multiprices_tva_tx] => Array ( ) [multiprices_recuperableonly] => Array ( ) [price_by_qty] => [prices_by_qty] => Array ( ) [prices_by_qty_id] => Array ( ) [prices_by_qty_list] => Array ( ) [multilangs] => Array ( [nl_NL] => Array ( [label] => OR70-230x3 [description] => [other] => ) ) [default_vat_code] => [tva_tx] => 21.0000 [tva_npr] => 0 [recuperableonly] => 0 [remise_percent] => [localtax1_tx] => 0.0000 [localtax2_tx] => 0.0000 [localtax1_type] => 0 [localtax2_type] => 0 [desc_supplier] => [vatrate_supplier] => [default_vat_code_supplier] => [fourn_multicurrency_price] => [fourn_multicurrency_unitprice] => [fourn_multicurrency_tx] => [fourn_multicurrency_id] => [fourn_multicurrency_code] => [packaging] => [lifetime] => [qc_frequency] => [stock_reel] => 4 [stock_theorique] => [cost_price] => [pmp] => 0.64050000 [seuil_stock_alerte] => [desiredstock] => 0 [duration_value] => [duration_unit] => [duration] => [fk_default_workstation] => [tosell] => [status_buy] => 1 [tobuy] => [finished] => 1 [fk_default_bom] => [status_batch] => 0 [batch_mask] => [customcode] => [url] => [weight] => [weight_units] => 3 [length] => [length_units] => 0 [width] => [width_units] => 0 [height] => [height_units] => 0 [surface] => [surface_units] => 0 [volume] => [volume_units] => 0 [net_measure] => [net_measure_units] => [accountancy_code_sell] => [accountancy_code_sell_intra] => [accountancy_code_sell_export] => [accountancy_code_buy] => [accountancy_code_buy_intra] => [accountancy_code_buy_export] => [barcode] => 020000001768 [stats_propale] => Array ( ) [stats_commande] => Array ( ) [stats_contrat] => Array ( ) [stats_facture] => Array ( ) [stats_proposal_supplier] => Array ( ) [stats_commande_fournisseur] => Array ( ) [stats_expedition] => Array ( ) [stats_reception] => Array ( ) [stats_mo] => Array ( ) [stats_bom] => Array ( ) [stats_mrptoconsume] => Array ( ) [stats_mrptoproduce] => Array ( ) [stats_facturerec] => Array ( ) [stats_facture_fournisseur] => Array ( ) [imgWidth] => [imgHeight] => [product_fourn_id] => [product_id_already_linked] => [nbphoto] => 0 [stock_warehouse] => Array ( ) [fk_default_warehouse] => 1 [fk_price_expression] => [fourn_qty] => [fourn_pu] => [fourn_price_base_type] => [fourn_socid] => [ref_fourn] => [ref_supplier] => [fk_unit] => [price_autogen] => 0 [supplierprices] => [sousprods] => [res] => [is_object_used] => [mandatory_period] => 0 )

Hi Ksar,

found it!

(($reloadedobj = new Product($db)) && ($reloadedobj->fetch($objectoffield->fk_product))) ? $reloadedobj-> stock_reel : ‘Not found’

no need to add “Option or Array” as it is directly linked in the part itself

Maybe add this in the Wiki

noticed on forum people were asking for the reel_stock to be shown “incl me”

Many thanks for the help!

2 Likes