Insertion Incoterms dans un modele ODT

Bonjour à tous,

Je viens de faire la mise à jour pour la version 3.8, et souhaite intégrer les incoterms dans mes modèles de factures/commandes/propales odt.
Les balises {object_incoterm} et {object_incoterms} ne semblent pas fonctionner. Y a-t-il une manip à effectuer afin de pouvoir extraire les incoterms dans les modèles odt ?

Merci par avance pour votre aide.

Romain

Bonjour,

Je réponds en partie à ma question, les balises que j’ai trouvées sont :

{object_libelle_incoterms} : renvoie le libellé de l’incoterm type : « Ex Works, au départ non chargé, non dédouané sortie d’'usine (uniquement adapté aux flux domestiques, nationaux) »

{object_location_incoterms} : renvoie le lieu indiqué

{object_fk_incoterms} : renvoie un nombre, mais je ne sais pas à quoi il correspond.

Donc j’ai en partie résolu mon problème, maintenant je n’arrive pas à renvoyer simplement le code de l’incoterm, type « EXW », « FOB »… Une solution consisterait à renommer dans le dictionnaire tous les libellés, mais je doute que ce soit la meilleure manière de faire.

Merci pour votre aide.

1 « J'aime »

Hi Romain,

nice you found the new tags, but for me aren’t working on dollibar 3.8.3 under ubuntu.

Can you tell me how did you find them? They work on invoices?

Thanks for your attention, and happy new year.

Hi Romain,

nice you found the new tags, but for me aren’t working on dollibar 3.8.3 under ubuntu.

Can you tell me how did you find them? They work on invoices?

Thanks for your attention, and happy new year.

Hi Romain,

nice you found the new tags, but for me aren’t working on dollibar 3.8.3 under ubuntu.

Can you tell me how did you find them? They work on invoices?

Thanks for your attention, and happy new year.

Bonjour
Je pense que cela correspond à la colonne rowid de la table llx_c_incoterms
Il faudrait qu’il y ai {object_code_incoterms}

Fred

1 « J'aime »

Bonjour
Essaye de rajouter par exemple pour les commandes, dans la classe commande.class.php, dans la fonction fetch
$sql.= ‹ , c.fk_incoterms, c.location_incoterms ›;
devient
$sql.= ‹ , c.code_incoterms, c.fk_incoterms, c.location_incoterms ›;

et un peu plus bas après
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
tu ajoutes
$this->code_incoterms=$obj->code_incoterms

Ainsi tu récupère le code incoterm dans l’objet commande
reste à voir pour {object_code_incoterms}
Fred

1 « J'aime »

Thanks for your reply, with the modifications on the class now I see this, testing with DAP incoterm

For

{object_libelle_incoterms} : Delivered At Place, marchandises (non déchargées) mises à disposition de l’acheteur dans le pays d’importation au lieu précisé dans le contrat (déchargement, dédouanement import payé par l’acheteur)
{object_location_incoterms}: 6 ( A number a I added to the incoterm form )
{object:_fk_incoterms}: 10
{object_code_incoterms}: « blank » The one I really need :unhappy:

Much appreciated your help, I need to find the way to show up only the code (DAP, CIF, etc)

Bonjour
Je me suis trompé…
$sql.= ‹ , c.fk_incoterms, c.location_incoterms ›;
$sql.= « , i.libelle as libelle_incoterms »;
devient
$sql.= ‹ , c.fk_incoterms, c.location_incoterms ›;
$sql.= « , i.code as code_incoterms, i.libelle as libelle_incoterms »;

Le reste est bon, enfin je pense…
Fred

1 « J'aime »

Thanks for your effort, but still not working the tag, thanks to your guidance I know how to start messing with the sql table to show up what I need on my odt templates.

For now {object_code_incoterms} it isn’t replaced, I restarted the server also and no luck.

Tomorrow I’ll will do some more tries.

Thank you very much!

STEPS DONE (Thanks to Fredereic34)

edit /htdocs/commande/class/commande.class.php

line 1498/9 replace
$sql.= ‹ , c.fk_incoterms, c.location_incoterms ›;
$sql.= « , i.libelle as libelle_incoterms »;

with

$sql.= ‹ , c.fk_incoterms, c.location_incoterms ›;
$sql.= « , i.code as code_incoterms, i.libelle as libelle_incoterms »;

new line after line 1569 add $this->code_incoterms = $obj->code_incoterms;

Bonjour
Essayez d’ajouter dans htdocs/core/class/commondocgenerator.class.php
dans le fonction function get_substitutionarray_object($object,$outputlangs,$array_key=‹ object ›)
dans $resarray=array(
au milieu des lignes existantes:
$array_key.’_code_incoterms’=>$object->code_incoterms,

Fred

I added this onto coomondocgenerator.class.php

// Incoterms
$array_key.’_code_incoterms’=>$object->code_incoterms,
$array_key.’_libelle_incoterms’=>$object->libelle_incoterms,
$array_key.’_location_incoterms’=>$object->location_incoterms,
$array_key.’_fk_incoterms’=>$object->fk_incoterms,

{object_libelle_incoterms} : Replaced properly
{object_location_incoterms}: Replaced properly
{object_fk_incoterms}: Replaced properly (It’s row id)
{object_code_incoterms}: Replaced with empty

I think the SQL query isn’t taking anything

If I use $array_key.’_code_incoterms’=>$object->getIncotermsForPDF(), I got

« Incoterm : CIF - location »

f I use $array_key.’_code_incoterms’=>$object->display_incoterms(), I got
« CIF - location »

I recycled display_incoterms function on coomonobject.class.php file to make exactly what I want, but for me this solution feels dirty.

function display_incotermsODT() { $out = ''; $this->libelle_incoterms = ''; if (!empty($this->fk_incoterms)) { $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; $result = $this->db->query($sql); if ($result) { $res = $this->db->fetch_object($result); $out .= $res->code; } } return $out; }

Maybe this code can give as a clue. coomonobject.class.php file

[code]
/**
* Return incoterms informations
*
* @return string incoterms info
*/
function display_incoterms()
{
$out = ‹  ›;
$this->libelle_incoterms = ‹  ›;
if (!empty($this->fk_incoterms))
{
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$result = $this->db->query($sql);
if ($result)
{
$res = $this->db->fetch_object($result);
$out .= $res->code;
}
}

	$out .= ' - '.$this->location_incoterms;

	return $out;
}

/**
 *    Return incoterms informations for pdf display
 *
 *    @return	string		incoterms info
 */
function getIncotermsForPDF()
{
	$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
	$resql = $this->db->query($sql);
	if ($resql)
	{
		$res = $this->db->fetch_object($resql);
		return 'Incoterm : '.$res->code.' - '.$this->location_incoterms;
	}
	else
	{
		return false;
	}
}

/**
 *    Define incoterms values of current object
 *
 *    @param	int		$id_incoterm     Id of incoterm to set or '' to remove
 * 	  @param 	string  $location		 location of incoterm
 *    @return	int     		<0 if KO, >0 if OK
 */
function setIncoterms($id_incoterm, $location)
{
    if ($this->id && $this->table_element)
    {
        $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
        $sql.= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null");
		$sql.= ", location_incoterms = '".($id_incoterm > 0 ? $this->db->escape($location) : "null")."'";
        $sql.= " WHERE rowid = " . $this->id;
		dol_syslog(get_class($this).'::setIncoterms', LOG_DEBUG);
        $resql=$this->db->query($sql);
        if ($resql)
        {
        	$this->fk_incoterms = $id_incoterm;
			$this->location_incoterms = $location;

			$sql = 'SELECT libelle FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
			$res = $this->db->query($sql);
			if ($res)
			{
				$obj = $this->db->fetch_object($res);
				$this->libelle_incoterms = $obj->libelle;
			}
            return 1;
        }
        else
		{
            return -1;
        }
    }
    else return -1;
}[/code]

Bonjour,

Je créé actuellement un modèle ODT de propale.
Je suis sur la version Dolibarr 3.9.

Je m’excuse à l’avance si la réponse est évoquée dans les messages plus hauts de frederic34 et vinclar (je me logge en admin mais tout ce qui est gestion du serveur, intégration de nouveau modules etc … sont gérés par mon directeur informatique, donc je n’ai pas tous les tenants et aboutissants)

Je souhaite intégrer à ce modèle ODT le code incoterm ICC 2010 et le lieu de prise d’effet de l’incoterm (informations que j’ai bien renseignées dans mon devis Dolibarr qui me sert de test)

J’ai donc intégrer les balises mentionnées ci-dessus - qui semblaient fonctionner pour romaingh - à savoir :
{object_code_incoterms}
{object_location_incoterms}

Cela ne fonctionne pas : les balises ressortent telles quelles dans le document généré.

L’étape évoquée par frederic34 est-elle donc nécessaire (auquel cas, je devrais missionner mon directeur technique :happy: ) :

Merci par avance de vos lumières

Bonne journée

Bonjour,

Pour ma part, j’ai finalement utilisé les balises
{object_libelle_incoterms}
{object_location_incoterms}

Je confirme que cela fonctionne sur mes modèles odt, je suis également en version 3.9

De mémoire, j’avais bidouillé pour modifier les libellés pour passer de « Ex Works, au départ non chargé, non dédouané sortie d’'usine (uniquement adapté aux flux domestiques, nationaux » a simplement « EXW », et ce pour chaque Incoterm. Je n’ai plus la procédure en tête, mais peux m’y repencher si besoin.

Romain

1 « J'aime »

Merci de ton retour rapide Romain.
Pour info complémentaire : j’ai créé et modifié mon odt avec Openoffice.

Je viens de réessayer avec les balises que tu mentionnes (que j’avais déjà testées) mais en vain.
Je n’ai pas fait de copier/coller : je l’ai fait à la mano.

La balise ressort telle quelle à la génération du document …

Si je prends l’exemple de la balise {object_location_incoterms}
Cela ne fonctionne pas avec ma configuration actuelle, bien que ma propale contienne bien cette information.

Pour ce qui est de modifier le libellé : je comprends que tu as été dans Accueil < Configuration < Dictionnaire < Incoterms et que ensuite tu as créé de nouvelles lignes d’incoterms en indiquant dans la case « Libellé » l’acronyme à 3 lettres de l’incoterm (en lieu et place de la description précise de l’incoterm). Et que tu as ensuite utilisé la balise {object_libelle_incoterms}, au lieu donc de {object_code_incoterm}, dans tes documents.

Je viens de tenter la même manip’ … en vain.

Il doit me manquer quelque chose dans ma config … Mais quoi ?

Pièces jointes :

Bonjour,

Je viens de faire des essais, et il se trouve qui’l faut activer le module Customfileds ou Champs personnalisés pour que les champs apparaissent bien dans les modèles odt.

Ce qui me paraît étrange car je n’ai aucun paramètre lié aux incoterms configuré dans customfields.

Si vous n’avez pas ce module installé, voici ou le trouver : https://www.dolistore.com/fr/modules/221-Champs-Personnalis--s.html

Romain

1 « J'aime »

Bonjour Romain,

J’avais ce module Customfield installé mais non activé.

Et en effet, oh miracle ! désormais, cela fonctionne.

Merci beaucoup d’avoir pris le temps de te pencher à nouveau sur la problématique.

Bonne journée