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