Skip to content
Snippets Groups Projects
Commit 71be10ee authored by Benjamin's avatar Benjamin
Browse files

modification channel

parent 00b4c84c
Branches
No related tags found
No related merge requests found
......@@ -41,6 +41,9 @@ class CgscopRigaFilesMatching(models.Model):
trim=False)
day = fields.Integer("Décalage jour", default=False)
params_active = fields.Boolean('Extra params actifs')
ftp_channel_id = fields.Many2one(
comodel_name='riga.ftp.channel',
string="Canal FTP")
def sync_data(self):
odoo_import = self.env['riga.odoo.import'].sudo()
......
......@@ -13,13 +13,4 @@ class CgscopRigaFtpChannel(models.Model):
password = fields.Char('Password')
url = fields.Char('URL')
path = fields.Char('Path')
active = fields.Boolean('Actif', default=False)
def toogle_active_config(self):
""" Active la connexion sélectionnée et désactive
toutes les autres connexions
"""
for item in self.env['riga.ftp.channel'].search([]):
item.active = False
self.active = True
active = fields.Boolean('Actif', default=True)
......@@ -32,7 +32,7 @@ class CgscopRigaOdooImport(models.Model):
# ------------------------------------------------------
# Fonctions génériques
# ------------------------------------------------------
def _get_ftp_file(self, filename):
def _get_ftp_file(self, filename, ftp_channel):
""" Fonction de récupértion d'ufichier sur un FTP.
Cette fonction prend en paramètre un nom de fichier et recherche
......@@ -44,9 +44,7 @@ class CgscopRigaOdooImport(models.Model):
@return csv_file: (binary) fichier binaire à traiter
"""
param = self.env['riga.ftp.channel'].sudo().search([
['active', '=', True]])
param.ensure_one()
param = ftp_channel
ftp_login = param.login
ftp_pass = param.password
# Connexion FTP
......@@ -67,7 +65,6 @@ class CgscopRigaOdooImport(models.Model):
)
return csv_file
except Exception as e:
ftp.quit()
raise exceptions.Warning(e)
def _read_file(self, model, file, table, primary_key, header_key):
......@@ -229,7 +226,7 @@ class CgscopRigaOdooImport(models.Model):
table.append([header.name, header.riga_name, header.relation])
self._read_file(
model=model.model_id,
file=self._get_ftp_file(model.riga_filename),
file=self._get_ftp_file(model.riga_filename, model.ftp_channel_id),
table=table,
primary_key=model.primary_key,
header_key=model.header_key)
......
......@@ -15,6 +15,7 @@
<field name="riga_filename"/>
<field name="primary_key"/>
<field name="header_key"/>
<field name="ftp_channel_id"/>
<field name="is_active"/>
</tree>
</field>
......@@ -31,13 +32,14 @@
<sheet>
<group>
<group>
<field name="model_id" />
<field name="riga_filename"/>
<field name="riga_extension"/>
<field name="model_id" required="True" />
<field name="riga_filename" required="True" />
<field name="riga_extension" required="True" />
<field name="ftp_channel_id" required="True" />
</group>
<group>
<field name="primary_key"/>
<field name="header_key"/>
<field name="primary_key" required="True" />
<field name="header_key" required="True" />
<field name="is_active" widget="boolean_toggle"/>
</group>
</group>
......
......@@ -24,9 +24,6 @@
<field name="model">riga.ftp.channel</field>
<field name="arch" type="xml">
<form>
<header>
<button name="toogle_active_config" type="object" string="Activer" />
</header>
<sheet>
<group>
<group>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment