From 05021bf36062e78f3f8809d4978d6eeacd41f099 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 26 Mar 2013 12:22:16 +0100 Subject: [PATCH] [MRG] lp:~therp-nl/therp-addons/fetchmail_attach_from_folder rev 89 --- .../match_algorithm/email_domain.py | 2 +- .../match_algorithm/email_exact.py | 2 + .../match_algorithm/openerp_standard.py | 3 ++ .../model/fetchmail_server.py | 7 ++-- .../model/fetchmail_server_folder.py | 40 +++++++++++++++---- .../view/fetchmail_server.xml | 17 +++++++- .../wizard/attach_mail_manually.py | 3 +- 7 files changed, 60 insertions(+), 14 deletions(-) diff --git a/fetchmail_attach_from_folder/match_algorithm/email_domain.py b/fetchmail_attach_from_folder/match_algorithm/email_domain.py index ad86faacd..66ab66286 100644 --- a/fetchmail_attach_from_folder/match_algorithm/email_domain.py +++ b/fetchmail_attach_from_folder/match_algorithm/email_domain.py @@ -24,7 +24,7 @@ from email_exact import email_exact class email_domain(email_exact): '''Search objects by domain name of email address. - Beware of match_first here, this is most likely to ge it wrong (gmail...)''' + Beware of match_first here, this is most likely to get it wrong (gmail)''' name = 'Domain of email address' def search_matches(self, cr, uid, conf, mail_message, mail_message_org): diff --git a/fetchmail_attach_from_folder/match_algorithm/email_exact.py b/fetchmail_attach_from_folder/match_algorithm/email_exact.py index 0e67e7222..db4871f65 100644 --- a/fetchmail_attach_from_folder/match_algorithm/email_exact.py +++ b/fetchmail_attach_from_folder/match_algorithm/email_exact.py @@ -25,6 +25,8 @@ from openerp.tools.safe_eval import safe_eval from openerp.addons.mail.mail_message import to_email class email_exact(base): + '''Search for exactly the mailadress as noted in the email''' + name = 'Exact mailadress' required_fields = ['model_field', 'mail_field'] diff --git a/fetchmail_attach_from_folder/match_algorithm/openerp_standard.py b/fetchmail_attach_from_folder/match_algorithm/openerp_standard.py index ae8662ef2..f4efcf89f 100644 --- a/fetchmail_attach_from_folder/match_algorithm/openerp_standard.py +++ b/fetchmail_attach_from_folder/match_algorithm/openerp_standard.py @@ -24,6 +24,9 @@ from base import base from openerp.tools.safe_eval import safe_eval class openerp_standard(base): + '''No search at all. Use OpenERP's standard mechanism to attach mails to + mail.thread objects. Note that this algorithm always matches.''' + name = 'OpenERP standard' readonly_fields = ['model_field', 'mail_field', 'match_first', 'domain', 'model_order', 'flag_nonmatching'] diff --git a/fetchmail_attach_from_folder/model/fetchmail_server.py b/fetchmail_attach_from_folder/model/fetchmail_server.py index e92bde8e9..5f17b5bb0 100644 --- a/fetchmail_attach_from_folder/model/fetchmail_server.py +++ b/fetchmail_attach_from_folder/model/fetchmail_server.py @@ -193,7 +193,7 @@ class fetchmail_server(Model): if view_type == 'form': view = etree.fromstring( - result['fields']['folder_ids']['views']['tree']['arch']) + result['fields']['folder_ids']['views']['form']['arch']) modifiers={} docstr='' for algorithm in self.pool.get('fetchmail.server.folder')\ @@ -206,7 +206,8 @@ class fetchmail_server(Model): modifiers[field][modifier].insert(0, '|') modifiers[field][modifier].append( ("match_algorithm","==",algorithm.__name__)) - docstr+=_(algorithm.__doc__) or '' + docstr += _(algorithm.name) + '\n' + _(algorithm.__doc__) + \ + '\n\n' for field in view: if field.tag == 'field' and field.get('name') in modifiers: @@ -218,7 +219,7 @@ class fetchmail_server(Model): if (field.tag == 'field' and field.get('name') == 'match_algorithm'): field.set('help', docstr) - result['fields']['folder_ids']['views']['tree']['arch'] = \ + result['fields']['folder_ids']['views']['form']['arch'] = \ etree.tostring(view) return result diff --git a/fetchmail_attach_from_folder/model/fetchmail_server_folder.py b/fetchmail_attach_from_folder/model/fetchmail_server_folder.py index 6515b5528..0b8926c9b 100644 --- a/fetchmail_attach_from_folder/model/fetchmail_server_folder.py +++ b/fetchmail_attach_from_folder/model/fetchmail_server_folder.py @@ -48,17 +48,41 @@ class fetchmail_server_folder(Model): 'Path', size=256, help='The path to your mail ' 'folder. Typically would be something like \'INBOX.myfolder\'', required=True), - 'model_id': fields.many2one('ir.model', 'Model', required=True), - 'model_field': fields.char('Field (model)', size=128), - 'model_order': fields.char('Order (model)', size=128), + 'model_id': fields.many2one( + 'ir.model', 'Model', required=True, + help='The model to attach emails to'), + 'model_field': fields.char( + 'Field (model)', size=128, + help='The field in your model that contains the field to match ' + 'against.\n' + 'Examples:\n' + '\'email\' if your model is res.partner, or ' + '\'partner_id.email\' if you\'re matching sale orders'), + 'model_order': fields.char( + 'Order (model)', size=128, + help='Fields to order by, this mostly useful in conjunction ' + 'with \'Use 1st match\''), 'match_algorithm': fields.selection( _get_match_algorithms_sel, - 'Match algorithm', required=True, translate=True), - 'mail_field': fields.char('Field (email)', size=128), + 'Match algorithm', required=True, translate=True, + help='The algorithm used to determine which object an email ' + 'matches.'), + 'mail_field': fields.char( + 'Field (email)', size=128, + help='The field in the email used for matching. Typically ' + 'this is \'to\' or \'from\''), 'server_id': fields.many2one('fetchmail.server', 'Server'), - 'delete_matching': fields.boolean('Delete matches'), - 'flag_nonmatching': fields.boolean('Flag nonmatching'), - 'match_first': fields.boolean('Use 1st match'), + 'delete_matching': fields.boolean( + 'Delete matches', + help='Delete matched emails from server'), + 'flag_nonmatching': fields.boolean( + 'Flag nonmatching', + help='Flag emails in the server that don\'t match any object ' + 'in OpenERP'), + 'match_first': fields.boolean( + 'Use 1st match', + help='If there are multiple matches, use the first one. If ' + 'not checked, multiple matches count as no match at all'), 'domain': fields.char( 'Domain', size=128, help='Fill in a search ' 'filter to narrow down objects to match') diff --git a/fetchmail_attach_from_folder/view/fetchmail_server.xml b/fetchmail_attach_from_folder/view/fetchmail_server.xml index 172166d45..043090cb4 100644 --- a/fetchmail_attach_from_folder/view/fetchmail_server.xml +++ b/fetchmail_attach_from_folder/view/fetchmail_server.xml @@ -19,7 +19,7 @@ nolabel="1" colspan="2" on_change="onchange_server_type(type, is_ssl, object_id)"> - + @@ -38,6 +38,21 @@ string="Attach mail manually" icon="gtk-redo" /> +
+ + + + + + + + + + + +