# Computed Field - Shipping Method

**URL:** <https://www.dolibarr.org/forum/t/computed-field-shipping-method/25547>\
**Category:** Using my Dolibarr\
**Tags:** v19, Question, Help\
**Created:** [July 8, 2024, 11:09pm UTC](https://www.dolibarr.org/forum/t/computed-field-shipping-method/25547 "2024-07-08T23:09:54Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![jh482002](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/j/8e7dd6/32.png) [@jh482002](https://www.dolibarr.org/forum/u/jh482002)\
**Post date:** [July 23, 2024, 1:40pm UTC](https://www.dolibarr.org/forum/t/computed-field-shipping-method/25547/21 "2024-07-23T13:40:31Z")

</div>

Hello @DG-Rilling  
To answer your question, I’m using v19.02 and I have worked to develop ODT templates for each module. But in the case of Sales Orders, the normal Shipping method tag (“{object\_shipping\_method}”) does not work. I HAVE TRIED OVER AND OVER again to get it to work.

So, until this bug is fixed, I am trying to make a Complimentary Attribute linked to the same information, which I can successfully load into my templates.

---

<div class="post-metadata">

**Author:** ![DG-Rilling](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@DG-Rilling](https://www.dolibarr.org/forum/u/DG-Rilling)\
**Post date:** [July 23, 2024, 3:16pm UTC](https://www.dolibarr.org/forum/t/computed-field-shipping-method/25547/22 "2024-07-23T15:16:08Z")

</div>

Ok, another approach (QuickAndDirty :wink:).

Insert the following function in ~htdocs/commande/class/commande.class.php

```auto
	public function getLabelOfShipment()
	{
		$description = '';

		$sql = 'SELECT libelle';
		$sql .= ' FROM '.MAIN_DB_PREFIX.'c_shipment_mode';
		$sql .= ' WHERE';
		$sql .= ' rowid = '.((int) $this->shipping_method_id);

		dol_syslog(get_class($this)."::getLabelOfShipment", LOG_DEBUG);
		$resql = $this->db->query($sql);
		if ($resql) {
			$obj = $this->db->fetch_object($resql);
			if ($obj) {
				$description = $obj->libelle;
			}

			$this->db->free($resql);
			return $description;
		} else {
			$this->error = $this->db->lasterror();
			return -1;
		}
	}

```

and add in ~/htdocs/core/modules/doc/doc\_generic\_order\_odt.modules.php in the function “public function write\_file” after  
`$object->fetch_thirdparty();`  
the following line  
`$object->shipping_label = $object->getLabelOfShipment();`

Then you can reference in your \*.odt as  
`object_shipping_label = {object_shipping_label}`

[Previous page](https://www.dolibarr.org/forum/t/computed-field-shipping-method/25547.md?page=1)
