Choose BILL TO and DELIVER TO addresses for Sales Order

It appears that Dolibarr does not allow me to print “Bill To” and “Deliver To” (alternate addresses) on my Sales Orders. I have tried setting of ODT templates to add this type of information, but I don’t have enough background to make the necessary changes.

First approach: Is there any way to link the ODT ‘tag’ for Sales Order “Customer invoice contact” or “Customer shipping contact” or “Customer contact following-up order”?

Second approach: If there is no way to accomplish the First approach, can I setup Complimentary fields to select a new Contact, and then load the Contact Address automatically? For instance, 1 field called “Delivery Contact” and 2 field called “Delivery Address”.

Any help would be greatly appreciated!
I don’t understand how to set up Dolibarr so that I can sell goods to a Customer who has multiple warehouse locations???

Thanks

Does anyone know how to ‘link to an object’ to pull up Contact Address?

Any help is appreciated!

do you mean an Complementary Attribute?

@jonbendtsen
Yes.

Specifically, I would really like to select a Contact and have a Complimentary Attrribute pull up the Address (and City, State, Zip).

Okay, I’ll reply at a later time or date with more details. I am using something a little similar - though I link to other Thirdparties, but I expect it to be trivial to change to contacts.

I am not sure it can bring up the address though :-/

I have 2 fields on my proposal, one links to another thirdparty and the other links to proposal on that other thirdparty.

I use it for a dance class registration system, where the other thirdparty is their dance partner and the proposal link is to the dance partners registration. (the last linke I haven’t coded yet, just prepared.

You need to create the link using a Value like this_

Societe:societe/class/societe.class.php

So you wanted it for a Contact, I think this is what you want to link to Contact:contact/class/contact.class.php

you can of course give it a Label like “Delivery Contact” or “Delivery Address”.

For me it shows up on a Proposal like the smallest picture below
links_on_proposals

I don’t 100% know what you mean with “pull up the Address” but if I click the link inside Dolibarr I’ll be taken to the other Thirdparty or Proposal. So surely clicking a link for you could take you to a Contact.


Thanks @jonbendtsen
I have that set up the same as you explanation. Now I just need to ‘compute’ the contact Address (in another Complimentary attribute) in order to display it on the Sales Order.

Any ideas?

I have never done that, but there is that “On PDF” field which I do use for some complementary lines on the proposal

I have tried many variations of the following code, but it does not appear to work:

(($reloadedobj = new socpeople($db)) && ($reloadedobj->fetch(8) > 0)) ? $reloadedobj->address : ‘not found’

(I’m trying to compute the ‘address’ field for record 8 in the Contacts table.)

Can anyone help?

@ksar @pcbleu @eldy @DG-Rilling
Can either of you help me? I see that you have experience with this sort of thing.

I need to generate a Contact Address string for a Sales Order (to be included in my doc template).

How to setup Complimentary fields to select a new Contact, and then load the Contact Address automatically? For instance, 1 field called “Delivery Contact” and 2 field called “Delivery Address”.

I have already figured out how to use the ‘Select from table’ option. But when I include it on my .ODT, it only displays the rowid (for instance: “8”). Maybe there is a way to convert to a string?

If not, if anyone has an idea how to do this, please help!

I would solve this as follows:

  • Add one or more contact types under “Dictionary setup - Contact/Address types”.

  • Possibly also an third party extra field (checkbox/combolist/…) for the selection of the contact (checkbox: checked = use contact address, not checked = use company address)

  • Store the contact with the new contact type under the third party contacts.

  • Create a new function in the ODT module with a corresponding database query for the contact with this contact type and store the result in the tags “object_delivery_contact” and/or “object_delivery_address”

  • Then use these tags in your odt template

Thank you for your response @DG-Rilling

Is there no way without changing source code? Your solution makes perfect sense, but I’m not a very accomplished programmer (don’t get me wrong, I’m willing to learn). It seems like this could be done without source code???

If I may ask you some questions:

  • Should Dolibarr not already do this on some level? (It’s a very common business practice to show this information on a Sales Order. How are others using this module?)
  • Why when I use “select from table” field to select a “Contact”, does it only result in “8” (rowid) on my ODT doc? Any way to produce a string?
  • Using Complimentary field::: (($reloadedobj = new socpeople($db)) && ($reloadedobj->fetch(8) > 0)) ? $reloadedobj->address : ‘not found’ ::: does not work for me. How can I pull “address” string from “Contacts” table?
  • I would think that some combination of the Complimentary Attributes: “Link to an object”, “Select from table”, and “String/Computed field” could accomplish this goal. Where is the err in my logic?

Thank You very much for your help!

Hi @jh482002
I started with odt as well because at first glance seemed easier to customize and style but i soon realized that functionality wise is underdeveloped and i had to jump through hoops every time i wanted to add sth and finally all this just to generate a pdf!

Process description for v. 20.0.0 with pdf models
From a purchase order or a signed proposal(cyan) with billing and shipping contacts info entered, you can generate a sales order(eratosthene) which is usually an internal use document.
Employee that process it has no use for billing or shipping info and that is why there is no billing and shipping contacts in pdf.
After it is processed shipping sheet(espadon) contains shipping info and finally invoice(sponge) contains both billing and shipping contact info.

Ok, look at this complementary field:

The classname is wrong. There is no object “socpeople”.
Exchange that with the correct classname “Contact” and you will get the address for the record with the rowid 8 from the db-table “llx_socpeople”.

(($reloadedobj = new Contact($db)) && ($reloadedobj->fetch(8) > 0)) ? $reloadedobj->address : 'not found'

But this is the manual way, I think that you want to exchange the “8” with the right value for different customers automatically?

Therefore you have to nest the commands for at least 3 levels.

  1. pull the fk_soc from the commande → result: id of customer
  2. pull fk_socpeople with correct fk_c_type_contact and 1. result from societe_contacts → result: id of contact
  3. pull adress with 2. result from socpeople → result: address of contact

Here is a example with 2 levels to pull out the IBAN of the customer:

(($reloadedobj = new Contact($db)) && ($reloadedobj->fetchNoCompute($obj->id) > 0)) ? ((($rdobj = new Account($db)) && ($rdobj->fetchNoCompute($reloadedobj->fk_account) > 0)) ? $rdobj->iban: 'no iban'):''

And it gets even more complicated with different selectable addresses :wink:.
My previous method is perhaps more suitable here, but it requires a change to the source code.
But perhaps someone else has an even better, more suitable method

1 Like

Not only for 20.0.0, also for the older versions.
We are at 17.x.x and use this PDF as confirmation for the customer.

Sure, we are on 19.0.3 right now(i always wait for .1 release) but i test on a 20.0.0 instance and process is already better streamlined(automation wise) from 19 at this point!

Hi @jh482002
I submitted code to add functionality you need, for pdf though, in core and will be available from next v. 21