Holger Brunn
10 years ago
18 changed files with 250 additions and 243 deletions
-
131__unported__/fetchmail_attach_from_folder/model/fetchmail_server_folder.py
-
46fetchmail_attach_from_folder/README.rst
-
5fetchmail_attach_from_folder/__init__.py
-
18fetchmail_attach_from_folder/__openerp__.py
-
8fetchmail_attach_from_folder/match_algorithm/__init__.py
-
4fetchmail_attach_from_folder/match_algorithm/base.py
-
4fetchmail_attach_from_folder/match_algorithm/email_domain.py
-
2fetchmail_attach_from_folder/match_algorithm/email_exact.py
-
2fetchmail_attach_from_folder/match_algorithm/openerp_standard.py
-
5fetchmail_attach_from_folder/model/__init__.py
-
147fetchmail_attach_from_folder/model/fetchmail_server.py
-
115fetchmail_attach_from_folder/model/fetchmail_server_folder.py
-
0fetchmail_attach_from_folder/security/ir.model.access.csv
-
BINfetchmail_attach_from_folder/static/description/icon.png
-
0fetchmail_attach_from_folder/view/fetchmail_server.xml
-
2fetchmail_attach_from_folder/wizard/__init__.py
-
4fetchmail_attach_from_folder/wizard/attach_mail_manually.py
-
0fetchmail_attach_from_folder/wizard/attach_mail_manually.xml
@ -1,131 +0,0 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>) |
|||
# All Rights Reserved |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
######################################################################## |
|||
|
|||
from openerp.osv import fields |
|||
from openerp.osv.orm import Model |
|||
from .. import match_algorithm |
|||
|
|||
|
|||
class fetchmail_server_folder(Model): |
|||
_name = 'fetchmail.server.folder' |
|||
_rec_name = 'path' |
|||
|
|||
def _get_match_algorithms(self): |
|||
def get_all_subclasses(cls): |
|||
return cls.__subclasses__() + [subsub |
|||
for sub in cls.__subclasses__() |
|||
for subsub in get_all_subclasses(sub)] |
|||
return dict([(cls.__name__, cls) for cls in get_all_subclasses( |
|||
match_algorithm.base.base)]) |
|||
|
|||
def _get_match_algorithms_sel(self, cr, uid, context=None): |
|||
algorithms = [] |
|||
for cls in self._get_match_algorithms().itervalues(): |
|||
algorithms.append((cls.__name__, cls.name)) |
|||
algorithms.sort() |
|||
return algorithms |
|||
|
|||
_columns = { |
|||
'sequence': fields.integer('Sequence'), |
|||
'path': fields.char( |
|||
'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, |
|||
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, |
|||
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', |
|||
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' |
|||
), |
|||
'msg_state': fields.selection( |
|||
[ |
|||
('sent', 'Sent'), |
|||
('received', 'Received'), |
|||
], |
|||
'Message state', |
|||
help='The state messages fetched from this folder should be ' |
|||
'assigned in OpenERP' |
|||
), |
|||
} |
|||
|
|||
_defaults = { |
|||
'flag_nonmatching': True, |
|||
'msg_state': 'received', |
|||
} |
|||
|
|||
def get_algorithm(self, cr, uid, ids, context=None): |
|||
for this in self.browse(cr, uid, ids, context): |
|||
return self._get_match_algorithms()[this.match_algorithm]() |
|||
|
|||
def button_attach_mail_manually(self, cr, uid, ids, context=None): |
|||
for this in self.browse(cr, uid, ids, context): |
|||
context.update({'default_folder_id': this.id}) |
|||
return { |
|||
'type': 'ir.actions.act_window', |
|||
'res_model': 'fetchmail.attach.mail.manually', |
|||
'target': 'new', |
|||
'context': context, |
|||
'view_type': 'form', |
|||
'view_mode': 'form', |
|||
} |
@ -0,0 +1,46 @@ |
|||
Email gateway - folders |
|||
======================= |
|||
|
|||
Adds the possibility to attach emails from a certain IMAP folder to objects, |
|||
ie partners. Matching is done via several algorithms, ie email address, email |
|||
address's domain or the original Odoo algorithm. |
|||
|
|||
This gives a simple possibility to archive emails in Odoo without a mail |
|||
client integration. |
|||
|
|||
Configuration |
|||
============= |
|||
|
|||
In your fetchmail configuration, you'll find a new field `folders`. Add your |
|||
folders here in IMAP notation [TODO] |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
A widespread configuration is to have a shared mailbox with several folders [TODO] |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Holger Brunn <hbrunn@therp.nl> |
|||
|
|||
Icon |
|||
---- |
|||
|
|||
http://commons.wikimedia.org/wiki/File:Crystal_Clear_filesystem_folder_favorites.png |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: http://odoo-community.org/logo.png |
|||
:alt: Odoo Community Association |
|||
:target: http://odoo-community.org |
|||
|
|||
This module is maintained by the OCA. |
|||
|
|||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. |
|||
|
|||
To contribute to this module, please visit http://odoo-community.org. |
@ -0,0 +1,115 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>) |
|||
# All Rights Reserved |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
######################################################################## |
|||
from openerp import api, models, fields |
|||
from .. import match_algorithm |
|||
|
|||
|
|||
class fetchmail_server_folder(models.Model): |
|||
_name = 'fetchmail.server.folder' |
|||
_rec_name = 'path' |
|||
|
|||
def _get_match_algorithms(self): |
|||
def get_all_subclasses(cls): |
|||
return (cls.__subclasses__() + |
|||
[subsub |
|||
for sub in cls.__subclasses__() |
|||
for subsub in get_all_subclasses(sub)]) |
|||
return dict([(cls.__name__, cls) |
|||
for cls in get_all_subclasses( |
|||
match_algorithm.base.base)]) |
|||
|
|||
def _get_match_algorithms_sel(self): |
|||
algorithms = [] |
|||
for cls in self._get_match_algorithms().itervalues(): |
|||
algorithms.append((cls.__name__, cls.name)) |
|||
algorithms.sort() |
|||
return algorithms |
|||
|
|||
sequence = fields.Integer('Sequence') |
|||
path = fields.Char( |
|||
'Path', |
|||
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, |
|||
help='The model to attach emails to') |
|||
model_field = fields.Char( |
|||
'Field (model)', |
|||
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)', |
|||
help='Field(s) to order by, this mostly useful in conjunction ' |
|||
"with 'Use 1st match'") |
|||
match_algorithm = fields.Selection( |
|||
_get_match_algorithms_sel, |
|||
'Match algorithm', required=True, |
|||
help='The algorithm used to determine which object an email matches.') |
|||
mail_field = fields.Char( |
|||
'Field (email)', |
|||
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', |
|||
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 Odoo") |
|||
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', |
|||
help='Fill in a search filter to narrow down objects to match') |
|||
msg_state = fields.Selection( |
|||
[ |
|||
('sent', 'Sent'), |
|||
('received', 'Received'), |
|||
], |
|||
'Message state', |
|||
help='The state messages fetched from this folder should be ' |
|||
'assigned in Odoo') |
|||
|
|||
_defaults = { |
|||
'flag_nonmatching': True, |
|||
'msg_state': 'received', |
|||
} |
|||
|
|||
@api.multi |
|||
def get_algorithm(self): |
|||
return self._get_match_algorithms()[self.match_algorithm]() |
|||
|
|||
@api.multi |
|||
def button_attach_mail_manually(self): |
|||
return { |
|||
'type': 'ir.actions.act_window', |
|||
'res_model': 'fetchmail.attach.mail.manually', |
|||
'target': 'new', |
|||
'context': dict(self.env.context, default_folder_id=self.id), |
|||
'view_type': 'form', |
|||
'view_mode': 'form', |
|||
} |
After Width: 128 | Height: 128 | Size: 12 KiB |
Write
Preview
Loading…
Cancel
Save
Reference in new issue