Troubles creating a socity from a csv file called by script launched by a cron

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Troubles creating a socity from a csv file called by script launched by a cron

Gilles Lengy
Hello,

I don't if this is the right place to post that kind of stuff...

Sorry for any inconvenience.


We use a cran that call a script to handle the socities and the contacts
from a distant csv file.

The socities are not created.

Dolibarr 4.0.1.

Here is an extract of the logs :

2017-10-20 12:47:45 INFO    83.152.44.246   Societe::create Ambassade de
France à Oman
2017-10-20 12:47:45 DEBUG   83.152.44.246   BEGIN Transaction
2017-10-20 12:47:45 DEBUG   83.152.44.246    Societe::create
2017-10-20 12:47:45 DEBUG   83.152.44.246    sql=INSERT INTO llx_societe
(nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int,
ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key,
fk_multicurrency, multicurrency_code) VALUES ('Ambassade de France à
Oman', '', 1, '20171020124745', null, null, 1, null, null, 0, 0, '',
null, 0, '')
2017-10-20 12:47:45 INFO    83.152.44.246    Societe::Update id=15680
call_trigger=0 allowmodcodeclient=1 allowmodcodefournisseur=1
2017-10-20 12:47:45 INFO    83.152.44.246     Societe::update verify ok
or not done
2017-10-20 12:47:45 DEBUG   83.152.44.246     Societe::Update
2017-10-20 12:47:45 DEBUG   83.152.44.246     sql=UPDATE llx_societe SET
nom = 'Ambassade de France à Oman',name_alias = '',ref_ext =
null,address = 'PO Box 208',zip = null,town = 'Mascate',fk_departement =
'0',fk_pays = '174',phone = '[968]24681800',fax = '[968]24681882',email
= null,skype = null,url = null,siren   = '',siret   = '',ape     =
'',idprof4 = '',idprof5 = '',idprof6 = '',tva_assuj = '1',tva_intra =
'',status = 1,localtax1_assuj = null,localtax2_assuj =
null,localtax1_value =0.000,localtax2_value =0.000,capital =
null,prefix_comm = null,fk_effectif = null,fk_typent =
0,fk_forme_juridique = null,mode_reglement = null,cond_reglement =
null,mode_reglement_supplier = null,cond_reglement_supplier =
null,fk_shipping_method = null,client = 0,fournisseur = 0,barcode =
null,default_lang = null,logo = null,outstanding_limit=
null,fk_prospectlevel='',webservices_url = null,webservices_key = null,
fk_incoterms = 0, location_incoterms = null, fk_user_modif = null,
fk_multicurrency = 0, multicurrency_code = '' WHERE rowid = '15680'
2017-10-20 12:47:45 INFO    83.152.44.246     Loading
hook:actions_supportparutioncontact.class.php
2017-10-20 12:47:45 INFO    83.152.44.246 HookManager::executeHooks
method=insertExtraFields action=update context=thirdpartydao
2017-10-20 12:47:45 WARNING 83.152.44.246     Warning: The hook
'insertExtraFields' is deprecated and must not be used. Use instead
trigger on CRUD event (ask it to dev team if not implemented)
2017-10-20 12:47:45 DEBUG   83.152.44.246
ExtraFields::fetch_name_optionals_label
2017-10-20 12:47:45 DEBUG   83.152.44.246     sql=SELECT
rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,list,ishidden
FROM llx_extrafields WHERE entity IN (0,1) AND elementtype = 'societe'
ORDER BY pos
2017-10-20 12:47:45 DEBUG   83.152.44.246 Societe::insertExtraFields delete
2017-10-20 12:47:45 DEBUG   83.152.44.246      sql=DELETE FROM
llx_societe_extrafields WHERE fk_object = 15680
2017-10-20 12:47:45 DEBUG   83.152.44.246 Societe::insertExtraFields insert
2017-10-20 12:47:45 DEBUG   83.152.44.246      sql=INSERT INTO
llx_societe_extrafields (fk_object,adresse2,cedex,id_yoocan) VALUES
(15680,'MSQ pc 115',null,'AMBAS.FRA.OMAN')
2017-10-20 12:47:45 INFO    83.152.44.246     Societe::Update success
2017-10-20 12:47:45 DEBUG   83.152.44.246 Interfaces::run_triggers
action=COMPANY_CREATE Triggers for file
'interface_20_modPaypal_PaypalWorkflow.class.php' need module to be enabled
2017-10-20 12:47:45 DEBUG   83.152.44.246 Interfaces::run_triggers
action=COMPANY_CREATE Triggers for file
'interface_20_modWorkflow_WorkflowManager.class.php' need module to be
enabled
2017-10-20 12:47:45 DEBUG   83.152.44.246 Interfaces::run_triggers
action=COMPANY_CREATE Triggers for file
'interface_50_modNotification_Notification.class.php' need module to be
enabled
2017-10-20 12:47:45 DEBUG   83.152.44.246 Interfaces::run_triggers
action=COMPANY_CREATE Triggers for file
'interface_50_modLdap_Ldapsynchro.class.php' need module to be enabled
2017-10-20 12:47:45 DEBUG   83.152.44.246 Interfaces::run_triggers
action=COMPANY_CREATE Triggers for file
'interface_50_modMailmanspip_Mailmanspipsynchro.class.php' need module
to be enabled
2017-10-20 12:47:45 INFO    83.152.44.246 Interfaces::run_triggers
action=COMPANY_CREATE Launch runTrigger for file
'interface_20_all_Logevents.class.php'
2017-10-20 12:47:45 INFO    83.152.44.246 Interfaces::run_triggers
action=COMPANY_CREATE Launch runTrigger for file
'interface_50_modAgenda_ActionsAuto.class.php'
2017-10-20 12:47:45 INFO    83.152.44.246    Trigger 'ActionsAuto' for
action 'COMPANY_CREATE' launched by
/home/yadlapoire/public_html/ird_prod/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php.
id=15680
2017-10-20 12:47:45 DEBUG   83.152.44.246    sql=SELECT s.rowid, s.nom
as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address,
s.datec as date_creation, s.prefix_comm, s.status, s.price_level, s.tms
as date_modification, s.phone, s.fax, s.email, s.skype, s.url, s.zip,
s.town, s.note_private, s.note_public, s.model_pdf, s.client,
s.fournisseur, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3,
s.idprof4, s.idprof5, s.idprof6, s.capital, s.tva_intra, s.fk_typent as
typent_id, s.fk_effectif as effectif_id, s.fk_forme_juridique as
forme_juridique_code, s.webservices_url, s.webservices_key,
s.code_client, s.code_fournisseur, s.code_compta,
s.code_compta_fournisseur, s.parent, s.barcode, s.fk_departement,
s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement,
s.cond_reglement, s.tva_assuj, s.mode_reglement_supplier,
s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value,
s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel,
s.default_lang, s.logo, s.fk_shipping_method, s.outstanding_limit,
s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms,
s.fk_multicurrency, s.multicurrency_code, fj.libelle as forme_juridique,
e.libelle as effectif, c.code as country_code, c.label as country,
d.code_departement as state_code, d.nom as state, st.libelle as stcomm,
te.code as typent_code, i.libelle as libelle_incoterms FROM llx_societe
as s LEFT JOIN llx_c_effectif as e ON s.fk_effectif = e.id LEFT JOIN
llx_c_country as c ON s.fk_pays = c.rowid LEFT JOIN llx_c_stcomm as st
ON s.fk_stcomm = st.id LEFT JOIN llx_c_forme_juridique as fj ON
s.fk_forme_juridique = fj.code LEFT JOIN llx_c_departements as d ON
s.fk_departement = d.rowid LEFT JOIN llx_c_typent as te ON s.fk_typent =
te.id LEFT JOIN llx_c_incoterms as i ON s.fk_incoterms = i.rowid WHERE
s.rowid = 15680
2017-10-20 12:47:45 INFO    83.152.44.246    Societe::fetch SELECT
s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int,
s.address, s.datec as date_creation, s.prefix_comm, s.status,
s.price_level, s.tms as date_modification, s.phone, s.fax, s.email,
s.skype, s.url, s.zip, s.town, s.note_private, s.note_public,
s.model_pdf, s.client, s.fournisseur, s.siren as idprof1, s.siret as
idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6, s.capital,
s.tva_intra, s.fk_typent as typent_id, s.fk_effectif as effectif_id,
s.fk_forme_juridique as forme_juridique_code, s.webservices_url,
s.webservices_key, s.code_client, s.code_fournisseur, s.code_compta,
s.code_compta_fournisseur, s.parent, s.barcode, s.fk_departement,
s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement,
s.cond_reglement, s.tva_assuj, s.mode_reglement_supplier,
s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value,
s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel,
s.default_lang, s.logo, s.fk_shipping_method, s.outstanding_limit,
s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms,
s.fk_multicurrency, s.multicurrency_code, fj.libelle as forme_juridique,
e.libelle as effectif, c.code as country_code, c.label as country,
d.code_departement as state_code, d.nom as state, st.libelle as stcomm,
te.code as typent_code, i.libelle as libelle_incoterms FROM llx_societe
as s LEFT JOIN llx_c_effectif as e ON s.fk_effectif = e.id LEFT JOIN
llx_c_country as c ON s.fk_pays = c.rowid LEFT JOIN llx_c_stcomm as st
ON s.fk_stcomm = st.id LEFT JOIN llx_c_forme_juridique as fj ON
s.fk_forme_juridique = fj.code LEFT JOIN llx_c_departements as d ON
s.fk_departement = d.rowid LEFT JOIN llx_c_typent as te ON s.fk_typent =
te.id LEFT JOIN llx_c_incoterms as i ON s.fk_incoterms = i.rowid WHERE
s.rowid = 15680
2017-10-20 12:47:45 DEBUG   83.152.44.246
ExtraFields::fetch_name_optionals_label
2017-10-20 12:47:45 DEBUG   83.152.44.246    sql=SELECT
rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,list,ishidden
FROM llx_extrafields WHERE entity IN (0,1) AND elementtype = 'societe'
ORDER BY pos
2017-10-20 12:47:45 DEBUG   83.152.44.246 Societe::fetch_optionals
2017-10-20 12:47:45 DEBUG   83.152.44.246    sql=SELECT rowid, adresse2,
cedex, code_region, email2, date_maj_yoocan, id_yoocan FROM
llx_societe_extrafields WHERE fk_object = 15680
2017-10-20 12:47:45 WARNING 83.152.44.246    You tried to create an
event but mandatory property ownerid was not defined
2017-10-20 12:47:45 ERR     83.152.44.246
interface_modAgenda_ActionsAuto.class.php: Failed to insert event : 
ErrorPropertyUserowneridNotDefined
2017-10-20 12:47:45 ERR     83.152.44.246 Interfaces::run_triggers
action=COMPANY_CREATE Files found: 7, Files launched: 2, Done: 0,
Failed: 1 - Nb of error string returned in this->errors = 1
2017-10-20 12:47:45 ERR     83.152.44.246    Societe::Create echec update
2017-10-20 12:47:45 DEBUG   83.152.44.246   ROLLBACK Transaction


The function that is supposed to create the socity :

[code]
function creation_organisme($organisme, $status, $user) {
     global $conf, $db;
     if ($status == 'ACTIF' || $status == 'ETAT CONTACT') {
         $organisme->statut = 1;
     } else {
         $organisme->statut = 0;
     }

     $result_creation_organisme = $organisme->create($user);

     return $result_creation_organisme;
}


We will be delight by any help.

Best regards.

--
Gilles Lengy

Artaban Communication
33 (0)1 40 09 18 18
www.artaban.fr
spip.artaban.fr

Adhérent de l'April (www.april.org)


_______________________________________________
Dolibarr-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev
Reply | Threaded
Open this post in threaded view
|

Re: Troubles creating a socity from a csv file called by script launched by a cron

Laurent Destailleur (aka Eldy)
Are you sure the variable "$user" is defined correcty to an existing user ?

2017-10-20 14:19 GMT+02:00 Gilles Lengy <[hidden email]>:
Hello,

I don't if this is the right place to post that kind of stuff...

Sorry for any inconvenience.


We use a cran that call a script to handle the socities and the contacts from a distant csv file.

The socities are not created.

Dolibarr 4.0.1.

Here is an extract of the logs :

2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246   Societe::create Ambassade de France à Oman
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246   BEGIN Transaction
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246    Societe::create
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246    sql=INSERT INTO llx_societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code) VALUES ('Ambassade de France à Oman', '', 1, '20171020124745', null, null, 1, null, null, 0, 0, '', null, 0, '')
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246    Societe::Update id=15680 call_trigger=0 allowmodcodeclient=1 allowmodcodefournisseur=1
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246     Societe::update verify ok or not done
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246     Societe::Update
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246     sql=UPDATE llx_societe SET nom = 'Ambassade de France à Oman',name_alias = '',ref_ext = null,address = 'PO Box 208',zip = null,town = 'Mascate',fk_departement = '0',fk_pays = '174',phone = '[968]24681800',fax = '[968]24681882',email = null,skype = null,url = null,siren   = '',siret   = '',ape     = '',idprof4 = '',idprof5 = '',idprof6 = '',tva_assuj = '1',tva_intra = '',status = 1,localtax1_assuj = null,localtax2_assuj = null,localtax1_value =0.000,localtax2_value =0.000,capital = null,prefix_comm = null,fk_effectif = null,fk_typent = 0,fk_forme_juridique = null,mode_reglement = null,cond_reglement = null,mode_reglement_supplier = null,cond_reglement_supplier = null,fk_shipping_method = null,client = 0,fournisseur = 0,barcode = null,default_lang = null,logo = null,outstanding_limit= null,fk_prospectlevel='',webservices_url = null,webservices_key = null, fk_incoterms = 0, location_incoterms = null, fk_user_modif = null, fk_multicurrency = 0, multicurrency_code = '' WHERE rowid = '15680'
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246     Loading hook:actions_supportparutioncontact.class.php
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 HookManager::executeHooks method=insertExtraFields action=update context=thirdpartydao
2017-10-20 12:47:45 WARNING <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246     Warning: The hook 'insertExtraFields' is deprecated and must not be used. Use instead trigger on CRUD event (ask it to dev team if not implemented)
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 ExtraFields::fetch_name_optionals_label
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246     sql=SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,list,ishidden FROM llx_extrafields WHERE entity IN (0,1) AND elementtype = 'societe' ORDER BY pos
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 Societe::insertExtraFields delete
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246      sql=DELETE FROM llx_societe_extrafields WHERE fk_object = 15680
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 Societe::insertExtraFields insert
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246      sql=INSERT INTO llx_societe_extrafields (fk_object,adresse2,cedex,id_yoocan) VALUES (15680,'MSQ pc 115',null,'AMBAS.FRA.OMAN')
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246     Societe::Update success
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Triggers for file 'interface_20_modPaypal_PaypalWorkflow.class.php' need module to be enabled
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Triggers for file 'interface_20_modWorkflow_WorkflowManager.class.php' need module to be enabled
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Triggers for file 'interface_50_modNotification_Notification.class.php' need module to be enabled
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Triggers for file 'interface_50_modLdap_Ldapsynchro.class.php' need module to be enabled
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Triggers for file 'interface_50_modMailmanspip_Mailmanspipsynchro.class.php' need module to be enabled
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Launch runTrigger for file 'interface_20_all_Logevents.class.php'
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Launch runTrigger for file 'interface_50_modAgenda_ActionsAuto.class.php'
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246    Trigger 'ActionsAuto' for action 'COMPANY_CREATE' launched by /home/yadlapoire/public_html/ird_prod/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php. id=15680
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246    sql=SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm, s.status, s.price_level, s.tms as date_modification, s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6, s.capital, s.tva_intra, s.fk_typent as typent_id, s.fk_effectif as effectif_id, s.fk_forme_juridique as forme_juridique_code, s.webservices_url, s.webservices_key, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode, s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj, s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.fk_shipping_method, s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms, s.fk_multicurrency, s.multicurrency_code, fj.libelle as forme_juridique, e.libelle as effectif, c.code as country_code, c.label as country, d.code_departement as state_code, d.nom as state, st.libelle as stcomm, te.code as typent_code, i.libelle as libelle_incoterms FROM llx_societe as s LEFT JOIN llx_c_effectif as e ON s.fk_effectif = e.id LEFT JOIN llx_c_country as c ON s.fk_pays = c.rowid LEFT JOIN llx_c_stcomm as st ON s.fk_stcomm = st.id LEFT JOIN llx_c_forme_juridique as fj ON s.fk_forme_juridique = fj.code LEFT JOIN llx_c_departements as d ON s.fk_departement = d.rowid LEFT JOIN llx_c_typent as te ON s.fk_typent = te.id LEFT JOIN llx_c_incoterms as i ON s.fk_incoterms = i.rowid WHERE s.rowid = 15680
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246    Societe::fetch SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm, s.status, s.price_level, s.tms as date_modification, s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6, s.capital, s.tva_intra, s.fk_typent as typent_id, s.fk_effectif as effectif_id, s.fk_forme_juridique as forme_juridique_code, s.webservices_url, s.webservices_key, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode, s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj, s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.fk_shipping_method, s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms, s.fk_multicurrency, s.multicurrency_code, fj.libelle as forme_juridique, e.libelle as effectif, c.code as country_code, c.label as country, d.code_departement as state_code, d.nom as state, st.libelle as stcomm, te.code as typent_code, i.libelle as libelle_incoterms FROM llx_societe as s LEFT JOIN llx_c_effectif as e ON s.fk_effectif = e.id LEFT JOIN llx_c_country as c ON s.fk_pays = c.rowid LEFT JOIN llx_c_stcomm as st ON s.fk_stcomm = st.id LEFT JOIN llx_c_forme_juridique as fj ON s.fk_forme_juridique = fj.code LEFT JOIN llx_c_departements as d ON s.fk_departement = d.rowid LEFT JOIN llx_c_typent as te ON s.fk_typent = te.id LEFT JOIN llx_c_incoterms as i ON s.fk_incoterms = i.rowid WHERE s.rowid = 15680
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 ExtraFields::fetch_name_optionals_label
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246    sql=SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,list,ishidden FROM llx_extrafields WHERE entity IN (0,1) AND elementtype = 'societe' ORDER BY pos
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 Societe::fetch_optionals
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246    sql=SELECT rowid, adresse2, cedex, code_region, email2, date_maj_yoocan, id_yoocan FROM llx_societe_extrafields WHERE fk_object = 15680
2017-10-20 12:47:45 WARNING <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246    You tried to create an event but mandatory property ownerid was not defined
2017-10-20 12:47:45 ERR     <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 interface_modAgenda_ActionsAuto.class.php: Failed to insert event :  ErrorPropertyUserowneridNotDefined
2017-10-20 12:47:45 ERR     <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Files found: 7, Files launched: 2, Done: 0, Failed: 1 - Nb of error string returned in this->errors = 1
2017-10-20 12:47:45 ERR     <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246    Societe::Create echec update
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank">83.152.44.246   ROLLBACK Transaction


The function that is supposed to create the socity :

[code]
function creation_organisme($organisme, $status, $user) {
    global $conf, $db;
    if ($status == 'ACTIF' || $status == 'ETAT CONTACT') {
        $organisme->statut = 1;
    } else {
        $organisme->statut = 0;
    }

    $result_creation_organisme = $organisme->create($user);

    return $result_creation_organisme;
}


We will be delight by any help.

Best regards.

--
Gilles Lengy

Artaban Communication
33 (0)1 40 09 18 18
www.artaban.fr
spip.artaban.fr

Adhérent de l'April (www.april.org)


_______________________________________________
Dolibarr-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev



--
------------------------------------------------------------------------------------
Google+: https://plus.google.com/+LaurentDestailleur-Open-Source-Expert/
Facebook: https://www.facebook.com/Destailleur.Laurent
------------------------------------------------------------------------------------
* Dolibarr (Project leader): https://www.dolibarr.org (make a donation for Dolibarr project via Paypal: [hidden email])
* AWStats (Author) : http://awstats.sourceforge.net (make a donation for AWStats project via Paypal: [hidden email])
* AWBot (Author) : http://awbot.sourceforge.net
* CVSChangeLogBuilder (Author) : http://cvschangelogb.sourceforge.net



_______________________________________________
Dolibarr-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev
Reply | Threaded
Open this post in threaded view
|

Re: Troubles creating a socity from a csv file called by script launched by a cron

Gilles Lengy

Thank you !

As the updating worked, I thought the $user was ok. But while updating, it seems that de user can be NULL.

Here is what I've done :

.....

require_once(DOL_DOCUMENT_ROOT . "/user/class/user.class.php");
....
// Init
....
global $conf, $db;
$user = new User($db);
$user->fetch($conf->global->TFDE_ID_USER);

.........

I used a constant since it's easier to change user if we want to do so later on.

Thank you again


Le 20/10/2017 à 15:04, Laurent Destailleur (aka Eldy) a écrit :
Are you sure the variable "$user" is defined correcty to an existing user ?

2017-10-20 14:19 GMT+02:00 Gilles Lengy <[hidden email]>:
Hello,

I don't if this is the right place to post that kind of stuff...

Sorry for any inconvenience.


We use a cran that call a script to handle the socities and the contacts from a distant csv file.

The socities are not created.

Dolibarr 4.0.1.

Here is an extract of the logs :

2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246   Societe::create Ambassade de France à Oman
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246   BEGIN Transaction
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246    Societe::create
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246    sql=INSERT INTO llx_societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code) VALUES ('Ambassade de France à Oman', '', 1, '20171020124745', null, null, 1, null, null, 0, 0, '', null, 0, '')
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246    Societe::Update id=15680 call_trigger=0 allowmodcodeclient=1 allowmodcodefournisseur=1
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246     Societe::update verify ok or not done
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246     Societe::Update
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246     sql=UPDATE llx_societe SET nom = 'Ambassade de France à Oman',name_alias = '',ref_ext = null,address = 'PO Box 208',zip = null,town = 'Mascate',fk_departement = '0',fk_pays = '174',phone = '[968]24681800',fax = '[968]24681882',email = null,skype = null,url = null,siren   = '',siret   = '',ape     = '',idprof4 = '',idprof5 = '',idprof6 = '',tva_assuj = '1',tva_intra = '',status = 1,localtax1_assuj = null,localtax2_assuj = null,localtax1_value =0.000,localtax2_value =0.000,capital = null,prefix_comm = null,fk_effectif = null,fk_typent = 0,fk_forme_juridique = null,mode_reglement = null,cond_reglement = null,mode_reglement_supplier = null,cond_reglement_supplier = null,fk_shipping_method = null,client = 0,fournisseur = 0,barcode = null,default_lang = null,logo = null,outstanding_limit= null,fk_prospectlevel='',webservices_url = null,webservices_key = null, fk_incoterms = 0, location_incoterms = null, fk_user_modif = null, fk_multicurrency = 0, multicurrency_code = '' WHERE rowid = '15680'
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246     Loading hook:actions_supportparutioncontact.class.php
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 HookManager::executeHooks method=insertExtraFields action=update context=thirdpartydao
2017-10-20 12:47:45 WARNING <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246     Warning: The hook 'insertExtraFields' is deprecated and must not be used. Use instead trigger on CRUD event (ask it to dev team if not implemented)
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 ExtraFields::fetch_name_optionals_label
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246     sql=SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,list,ishidden FROM llx_extrafields WHERE entity IN (0,1) AND elementtype = 'societe' ORDER BY pos
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 Societe::insertExtraFields delete
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246      sql=DELETE FROM llx_societe_extrafields WHERE fk_object = 15680
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 Societe::insertExtraFields insert
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246      sql=INSERT INTO llx_societe_extrafields (fk_object,adresse2,cedex,id_yoocan) VALUES (15680,'MSQ pc 115',null,'AMBAS.FRA.OMAN')
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246     Societe::Update success
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Triggers for file 'interface_20_modPaypal_PaypalWorkflow.class.php' need module to be enabled
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Triggers for file 'interface_20_modWorkflow_WorkflowManager.class.php' need module to be enabled
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Triggers for file 'interface_50_modNotification_Notification.class.php' need module to be enabled
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Triggers for file 'interface_50_modLdap_Ldapsynchro.class.php' need module to be enabled
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Triggers for file 'interface_50_modMailmanspip_Mailmanspipsynchro.class.php' need module to be enabled
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Launch runTrigger for file 'interface_20_all_Logevents.class.php'
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Launch runTrigger for file 'interface_50_modAgenda_ActionsAuto.class.php'
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246    Trigger 'ActionsAuto' for action 'COMPANY_CREATE' launched by /home/yadlapoire/public_html/ird_prod/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php. id=15680
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246    sql=SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm, s.status, s.price_level, s.tms as date_modification, s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6, s.capital, s.tva_intra, s.fk_typent as typent_id, s.fk_effectif as effectif_id, s.fk_forme_juridique as forme_juridique_code, s.webservices_url, s.webservices_key, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode, s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj, s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.fk_shipping_method, s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms, s.fk_multicurrency, s.multicurrency_code, fj.libelle as forme_juridique, e.libelle as effectif, c.code as country_code, c.label as country, d.code_departement as state_code, d.nom as state, st.libelle as stcomm, te.code as typent_code, i.libelle as libelle_incoterms FROM llx_societe as s LEFT JOIN llx_c_effectif as e ON s.fk_effectif = e.id LEFT JOIN llx_c_country as c ON s.fk_pays = c.rowid LEFT JOIN llx_c_stcomm as st ON s.fk_stcomm = st.id LEFT JOIN llx_c_forme_juridique as fj ON s.fk_forme_juridique = fj.code LEFT JOIN llx_c_departements as d ON s.fk_departement = d.rowid LEFT JOIN llx_c_typent as te ON s.fk_typent = te.id LEFT JOIN llx_c_incoterms as i ON s.fk_incoterms = i.rowid WHERE s.rowid = 15680
2017-10-20 12:47:45 INFO    <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246    Societe::fetch SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm, s.status, s.price_level, s.tms as date_modification, s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6, s.capital, s.tva_intra, s.fk_typent as typent_id, s.fk_effectif as effectif_id, s.fk_forme_juridique as forme_juridique_code, s.webservices_url, s.webservices_key, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode, s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj, s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo, s.fk_shipping_method, s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms, s.fk_multicurrency, s.multicurrency_code, fj.libelle as forme_juridique, e.libelle as effectif, c.code as country_code, c.label as country, d.code_departement as state_code, d.nom as state, st.libelle as stcomm, te.code as typent_code, i.libelle as libelle_incoterms FROM llx_societe as s LEFT JOIN llx_c_effectif as e ON s.fk_effectif = e.id LEFT JOIN llx_c_country as c ON s.fk_pays = c.rowid LEFT JOIN llx_c_stcomm as st ON s.fk_stcomm = st.id LEFT JOIN llx_c_forme_juridique as fj ON s.fk_forme_juridique = fj.code LEFT JOIN llx_c_departements as d ON s.fk_departement = d.rowid LEFT JOIN llx_c_typent as te ON s.fk_typent = te.id LEFT JOIN llx_c_incoterms as i ON s.fk_incoterms = i.rowid WHERE s.rowid = 15680
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 ExtraFields::fetch_name_optionals_label
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246    sql=SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,list,ishidden FROM llx_extrafields WHERE entity IN (0,1) AND elementtype = 'societe' ORDER BY pos
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 Societe::fetch_optionals
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246    sql=SELECT rowid, adresse2, cedex, code_region, email2, date_maj_yoocan, id_yoocan FROM llx_societe_extrafields WHERE fk_object = 15680
2017-10-20 12:47:45 WARNING <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246    You tried to create an event but mandatory property ownerid was not defined
2017-10-20 12:47:45 ERR     <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 interface_modAgenda_ActionsAuto.class.php: Failed to insert event :  ErrorPropertyUserowneridNotDefined
2017-10-20 12:47:45 ERR     <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246 Interfaces::run_triggers action=COMPANY_CREATE Files found: 7, Files launched: 2, Done: 0, Failed: 1 - Nb of error string returned in this->errors = 1
2017-10-20 12:47:45 ERR     <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246    Societe::Create echec update
2017-10-20 12:47:45 DEBUG   <a href="tel:83.152.44.246" value="+18315244246" target="_blank" moz-do-not-send="true">83.152.44.246   ROLLBACK Transaction


The function that is supposed to create the socity :

[code]
function creation_organisme($organisme, $status, $user) {
    global $conf, $db;
    if ($status == 'ACTIF' || $status == 'ETAT CONTACT') {
        $organisme->statut = 1;
    } else {
        $organisme->statut = 0;
    }

    $result_creation_organisme = $organisme->create($user);

    return $result_creation_organisme;
}


We will be delight by any help.

Best regards.

--
Gilles Lengy

Artaban Communication
33 (0)1 40 09 18 18
www.artaban.fr
spip.artaban.fr

Adhérent de l'April (www.april.org)


_______________________________________________
Dolibarr-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev



--
------------------------------------------------------------------------------------
Google+: https://plus.google.com/+LaurentDestailleur-Open-Source-Expert/
Facebook: https://www.facebook.com/Destailleur.Laurent
------------------------------------------------------------------------------------
* Dolibarr (Project leader): https://www.dolibarr.org (make a donation for Dolibarr project via Paypal: [hidden email])
* AWStats (Author) : http://awstats.sourceforge.net (make a donation for AWStats project via Paypal: [hidden email])
* AWBot (Author) : http://awbot.sourceforge.net
* CVSChangeLogBuilder (Author) : http://cvschangelogb.sourceforge.net




_______________________________________________
Dolibarr-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev

-- 
Gilles Lengy 

Artaban Communication
33 (0)1 40 09 18 18
www.artaban.fr
spip.artaban.fr

Adhérent de l'April (www.april.org)

_______________________________________________
Dolibarr-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev