this is the fonction :
@api.one
def importation_automatique(self):
# connexion avec la base statagris
conn_stat = psycopg2.connect(database="db_statagris", user="openpg", password="openpgpwd", host="localhost", port="5432")
print ("Opened database statistic1 successfully")
cursor = conn_stat.cursor(cursor_factory=psycopg2.extras.DictCursor)
cursor.execute("SELECT * FROM statistic")
rows = cursor.fetchall()
conn_stat.commit()
# connexion avec la base odoo
con_odoo = psycopg2.connect(database="frma", user="openpg", password="openpgpwd", host="localhost", port="5432")
curr_stat = con_odoo.cursor()
print ("Opened database odoo successfully")
#fout = open('tempo', 'w')
#cur.copy_to(fout, 'tempo', sep="|")
#print ("file created successfully")
curr_stat.execute("TRUNCATE TABLE ml_stat ")
for row in rows:
curr_stat.execute("""insert into ml_stat values (%s,%s,%s,%s)""",( row["unid"],"2016-05-13 15:15:20.264",row["occurrence"], row["variante2_valeur"]))
print( '%s' % ( row["unid"]))
con_odoo.commit()
and here's the form I want the data to be loaded:
<record id="view_mlstat_form" model="ir.ui.view">
<field name="name">ml.stat.form</field>
<field name="model">ml.stat</field>
<field name="priority">4</field>
<field name="arch" type="xml">
<form string="Plan Maroc vert stat">
<group>
<group>
<field name="annee_reference"/>
<field name="periodicite"/>
<field name="occurrence"/>
<field name="sous_region_type"/>
<field name="region_name"/>
<field name="province_name"/>
<field name="sous_region_name"/>
<field name="zone_name"/>
</group> <group>
<field name="produit_name"/>
<field name="variante1_name"/>
<field name="variante1_valeur"/>
<field name="variante2_name"/>
<field name="variante2_valeur"/>
<field name="variante3_name"/>
<field name="variante3_valeur"/>
<field name="indicateur_name"/>
<field name="valeur"/>
</group>
</group>
</form>
</field>
</record>
This is an english forum, please use english language.