How to Add the Commercial's Name in Devis, Facture, and BL in Dolibarr**

Hello everyone,

I hope you’re doing well! I’m currently working on a customization for Dolibarr and need some assistance.

I want to add the name of the commercial (salesperson) to the following documents:

  • Devis (Proposal)
  • Facture (Invoice)
  • BL (Delivery Note)

Can anyone guide me on how to achieve this? Specifically, I’m looking for instructions on how to add a custom field or attribute that will display the commercial’s name in these documents.

Any advice or steps to do this will be greatly appreciated!

Thank you in advance for your help.

Hello, maybe try to define this constant to 1 in Setup/Other menu : DOC_SHOW_FIRST_SALES_REP

1. Add a Custom Field for the Commercial (Salesperson):

  • Go to: Setup > Modules/Applications > Other Fields (enable the “Other fields” module if inactive).
  • Select the relevant object (e.g., Proposals, Invoices, Delivery Notes).
  • Click “Add a new personalized field”:
    • Label: “Commercial” (or your preferred name).
    • Type: “Link to User” (to link to the Dolibarr user account of the salesperson).
    • Save and repeat for each document type (Proposals, Invoices, BL).

2. Display the Field in Document Templates:

  • Edit the template for each document (e.g., PDF templates):
    • Go to: Home > Documents > Templates.
    • Open the template (e.g., invoice, proposal, delivery_note) in Word/LibreOffice.
    • Insert the commercial’s name using the Dolibarr tag {commercial} or the custom field variable (e.g., {object->array_options->options_custom_field_name} ).
  • Save and regenerate documents to test.

3. Assign the Commercial to Third Parties (Clients):

  • Ensure the commercial is assigned to the client’s record:
    • Go to: Third Parties > Clients > Edit client.
    • Under the “Sales Representative” field, select the commercial.
    • Save changes.

Troubleshooting Tips:

  • If the field doesn’t display, check template syntax (e.g., {commercial} or your custom field tag).
  • Clear Dolibarr’s cache under Setup > Tools > Clear cache.
  • For advanced needs, consider creating a custom module (PHP/HTML) to automate data linking.