Browse Source

[ADD] allow to deactivate folders

pull/205/head
Holger Brunn 10 years ago
parent
commit
d26eb82516
  1. 7
      fetchmail_attach_from_folder/model/fetchmail_server.py
  2. 2
      fetchmail_attach_from_folder/model/fetchmail_server_folder.py
  3. 4
      fetchmail_attach_from_folder/view/fetchmail_server.xml

7
fetchmail_attach_from_folder/model/fetchmail_server.py

@ -33,7 +33,8 @@ class fetchmail_server(models.Model):
_inherit = 'fetchmail.server'
folder_ids = fields.One2many(
'fetchmail.server.folder', 'server_id', 'Folders')
'fetchmail.server.folder', 'server_id', 'Folders',
context={'active_test': False})
object_id = fields.Many2one(required=False)
_defaults = {
@ -67,7 +68,7 @@ class fetchmail_server(models.Model):
})
connection = this.connect()
for folder in this.folder_ids:
for folder in this.folder_ids.filtered('active'):
this.handle_folder(connection, folder)
connection.close()
@ -216,7 +217,7 @@ class fetchmail_server(models.Model):
this.write({'state': 'draft'})
connection = this.connect()
connection.select()
for folder in this.folder_ids:
for folder in this.folder_ids.filtered('active'):
if connection.select(folder.path)[0] != 'OK':
raise exceptions.ValidationError(
_('Mailbox %s not found!') % folder.path)

2
fetchmail_attach_from_folder/model/fetchmail_server_folder.py

@ -94,10 +94,12 @@ class fetchmail_server_folder(models.Model):
'Message state',
help='The state messages fetched from this folder should be '
'assigned in Odoo')
active = fields.Boolean('Active')
_defaults = {
'flag_nonmatching': True,
'msg_state': 'received',
'active': True,
}
@api.multi

4
fetchmail_attach_from_folder/view/fetchmail_server.xml

@ -16,7 +16,8 @@
name="folder_ids"
nolabel="1"
on_change="onchange_server_type(type, is_ssl, object_id)">
<tree>
<tree colors="gray:active==False">
<field name="active" invisible="True" />
<field name="sequence" widget="handle" />
<field name="path" />
<field name="model_id" />
@ -37,6 +38,7 @@
<field name="mail_field" placeholder="to,from" />
</group>
<group>
<field name="active" />
<field name="delete_matching" />
<field name="flag_nonmatching" />
<field name="match_first" />

Loading…
Cancel
Save