Computed Field - Shipping Method

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.

Ok, another approach (QuickAndDirty :wink:).

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

	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}