mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-26 18:38:41 -06:00
FIx bugs and tweak view
This commit is contained in:
parent
16ca5d51a2
commit
da3e3adb2c
@ -28,7 +28,7 @@
|
|||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'Generic Modules',
|
'category': 'Generic Modules',
|
||||||
'depends': [
|
'depends': [
|
||||||
'ir_attachment_metadata',
|
'attachment_metadata',
|
||||||
],
|
],
|
||||||
'external_dependencies': {
|
'external_dependencies': {
|
||||||
'python': [
|
'python': [
|
||||||
|
@ -10,6 +10,9 @@ class AbstractTask(object):
|
|||||||
_key = None
|
_key = None
|
||||||
_synchronize_type = None
|
_synchronize_type = None
|
||||||
_default_port = None
|
_default_port = None
|
||||||
|
_hide_login = False
|
||||||
|
_hide_password = False
|
||||||
|
_hide_port = False
|
||||||
|
|
||||||
def create_file(self, filename, data):
|
def create_file(self, filename, data):
|
||||||
ir_attachment_id = self.env['ir.attachment.metadata'].create({
|
ir_attachment_id = self.env['ir.attachment.metadata'].create({
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<record id="view_attachment_improved_form" model="ir.ui.view">
|
<record id="view_attachment_improved_form" model="ir.ui.view">
|
||||||
<field name="model">ir.attachment.metadata</field>
|
<field name="model">ir.attachment.metadata</field>
|
||||||
<field name="inherit_id" ref="ir_attachment_metadata.view_attachment_improved_form" />
|
<field name="inherit_id" ref="attachment_metadata.view_attachment_improved_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="url" position="after">
|
<field name="url" position="after">
|
||||||
<field name="sync_date"/>
|
<field name="sync_date"/>
|
||||||
|
@ -32,10 +32,13 @@ class Location(models.Model):
|
|||||||
name = fields.Char(string='Name', required=True)
|
name = fields.Char(string='Name', required=True)
|
||||||
protocol = fields.Selection(selection='_get_protocol', required=True)
|
protocol = fields.Selection(selection='_get_protocol', required=True)
|
||||||
address = fields.Char(string='Address', required=True)
|
address = fields.Char(string='Address', required=True)
|
||||||
port = fields.Integer(required=True)
|
port = fields.Integer()
|
||||||
login = fields.Char(required=True)
|
login = fields.Char()
|
||||||
password = fields.Char()
|
password = fields.Char()
|
||||||
task_ids = fields.One2many('external.file.task', 'location_id')
|
task_ids = fields.One2many('external.file.task', 'location_id')
|
||||||
|
hide_login = fields.Boolean()
|
||||||
|
hide_password = fields.Boolean()
|
||||||
|
hide_port = fields.Boolean()
|
||||||
|
|
||||||
def _get_protocol(self):
|
def _get_protocol(self):
|
||||||
res = []
|
res = []
|
||||||
@ -48,7 +51,19 @@ class Location(models.Model):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
@api.onchange('protocol')
|
@api.onchange('protocol')
|
||||||
def get_default_port(self):
|
def onchange_protocol(self):
|
||||||
for cls in itersubclasses(AbstractTask):
|
for cls in itersubclasses(AbstractTask):
|
||||||
if cls._key == self.protocol:
|
if cls._key == self.protocol:
|
||||||
self.port = cls._default_port
|
self.port = cls._default_port
|
||||||
|
if cls._hide_login:
|
||||||
|
self.hide_login = True
|
||||||
|
else:
|
||||||
|
self.hide_login = False
|
||||||
|
if cls._hide_password:
|
||||||
|
self.hide_password = True
|
||||||
|
else:
|
||||||
|
self.hide_password = False
|
||||||
|
if cls._hide_port:
|
||||||
|
self.hide_port = True
|
||||||
|
else:
|
||||||
|
self.hide_port = False
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
<field name="protocol" colspan="2"/>
|
<field name="protocol" colspan="2"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="address" colspan="2"/>
|
<field name="address" colspan="2"/>
|
||||||
<field name="port" colspan="2"/>
|
<field name="port" colspan="2" attrs="{'invisible': [('hide_port', '=', True)], 'required': [('hide_port', '=', False)]}"/>
|
||||||
<field name="login" colspan="2"/>
|
<field name="login" colspan="2" attrs="{'invisible': [('hide_login', '=', True)], 'required': [('hide_login', '=', False)]}"/>
|
||||||
<field name="password" password="1" colspan="2"/>
|
<field name="password" password="1" colspan="2" attrs="{'invisible': [('hide_password', '=', True)]}"/>
|
||||||
<separator string="Tasks" colspan="4"/>
|
<separator string="Tasks" colspan="4"/>
|
||||||
<field name="task_ids" colspan="4" nolabel="1" context="{'hide_location': True, 'protocol': protocol}">
|
<field name="task_ids" colspan="4" nolabel="1" context="{'hide_location': True, 'protocol': protocol}">
|
||||||
<tree>
|
<tree>
|
||||||
@ -30,6 +30,9 @@
|
|||||||
<button name="run" type="object" string="Run" icon="gtk-execute"/>
|
<button name="run" type="object" string="Run" icon="gtk-execute"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="hide_login" invisible="1"/>
|
||||||
|
<field name="hide_password" invisible="1"/>
|
||||||
|
<field name="hide_port" invisible="1"/>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
|
@ -52,8 +52,9 @@ class Task(models.Model):
|
|||||||
def _get_method(self):
|
def _get_method(self):
|
||||||
res = []
|
res = []
|
||||||
for cls in itersubclasses(AbstractTask):
|
for cls in itersubclasses(AbstractTask):
|
||||||
if cls._synchronize_type: # \
|
if cls._synchronize_type \
|
||||||
# and cls._key == self._context.get('protocol'):
|
and ('protocol' not in self._context
|
||||||
|
or cls._key == self._context['protocol']):
|
||||||
cls_info = (cls._key + '_' + cls._synchronize_type,
|
cls_info = (cls._key + '_' + cls._synchronize_type,
|
||||||
cls._name + ' ' + cls._synchronize_type)
|
cls._name + ' ' + cls._synchronize_type)
|
||||||
res.append(cls_info)
|
res.append(cls_info)
|
||||||
|
@ -102,8 +102,8 @@ class AbstractFSTask(AbstractTask):
|
|||||||
if self.after_import == 'delete':
|
if self.after_import == 'delete':
|
||||||
self._delete_file(conn, file_to_process[1])
|
self._delete_file(conn, file_to_process[1])
|
||||||
elif self.after_import == 'move':
|
elif self.after_import == 'move':
|
||||||
if not conn.path.exists(self.move_path):
|
if not conn.exists(self.move_path):
|
||||||
conn.mkdir(self.move_path)
|
conn.makedir(self.move_path)
|
||||||
self._move_file(
|
self._move_file(
|
||||||
conn,
|
conn,
|
||||||
file_to_process[1],
|
file_to_process[1],
|
||||||
|
@ -32,6 +32,9 @@ class FileStoreTask(AbstractFSTask):
|
|||||||
_name = 'File Store'
|
_name = 'File Store'
|
||||||
_synchronize_type = None
|
_synchronize_type = None
|
||||||
_default_port = None
|
_default_port = None
|
||||||
|
_hide_login = True
|
||||||
|
_hide_password = True
|
||||||
|
_hide_port = True
|
||||||
|
|
||||||
|
|
||||||
class FileStoreImportTask(FileStoreTask):
|
class FileStoreImportTask(FileStoreTask):
|
||||||
|
@ -32,6 +32,9 @@ class FtpTask(AbstractFSTask):
|
|||||||
_name = 'FTP'
|
_name = 'FTP'
|
||||||
_synchronize_type = None
|
_synchronize_type = None
|
||||||
_default_port = 21
|
_default_port = 21
|
||||||
|
_hide_login = False
|
||||||
|
_hide_password = False
|
||||||
|
_hide_port = False
|
||||||
|
|
||||||
|
|
||||||
class FtpImportTask(FtpTask):
|
class FtpImportTask(FtpTask):
|
||||||
|
@ -32,6 +32,9 @@ class SftpTask(AbstractFSTask):
|
|||||||
_name = 'SFTP'
|
_name = 'SFTP'
|
||||||
_synchronize_type = None
|
_synchronize_type = None
|
||||||
_default_port = 22
|
_default_port = 22
|
||||||
|
_hide_login = False
|
||||||
|
_hide_password = False
|
||||||
|
_hide_port = False
|
||||||
|
|
||||||
|
|
||||||
class SftpImportTask(SftpTask):
|
class SftpImportTask(SftpTask):
|
||||||
|
Loading…
Reference in New Issue
Block a user