summaryrefslogtreecommitdiff
path: root/addons/fetchmail
diff options
context:
space:
mode:
authorjam-openerp <jam@tinyerp.com>2010-12-07 11:41:50 +0530
committerjam-openerp <jam@tinyerp.com>2010-12-07 11:41:50 +0530
commit42d6b54c2dff0fbdd8f86ba5da92ab8e8e1c41e4 (patch)
tree6ba0cf1010f804c44d047e8c35fe54492d263a12 /addons/fetchmail
parent241da980f97bc654c0ab3fd86974ea2dd343c7de (diff)
[BUG-FIX] lp:680704
bzr revid: jam@tinyerp.com-20101207061150-swi023vg3fvb63y2
Diffstat (limited to 'addons/fetchmail')
-rw-r--r--addons/fetchmail/fetchmail.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py
index 84490de2b53..2308598a551 100644
--- a/addons/fetchmail/fetchmail.py
+++ b/addons/fetchmail/fetchmail.py
@@ -57,9 +57,8 @@ class email_server(osv.osv):
'user' : fields.char('User Name', size=256, required=True, readonly=True, states={'draft':[('readonly', False)]}),
'password' : fields.char('Password', size=1024, invisible=True, required=True, readonly=True, states={'draft':[('readonly', False)]}),
'note': fields.text('Description'),
- 'action_id':fields.many2one('ir.actions.server', 'Reply Email', required=False, domain="[('state','=','email')]",
- help="An Email Server Action. It will be run whenever an e-mail is fetched from server."),
- 'object_id': fields.many2one('ir.model', "Model", required=True, help="OpenObject Model. Generates a record of this model."),
+ 'action_id':fields.many2one('ir.actions.server', 'Email Server Action', required=False, domain="[('state','=','email')]", help="An Email Server Action. It will be run whenever an e-mail is fetched from server."),
+ 'object_id': fields.many2one('ir.model', "Model", required=True, help="OpenObject Model. Generates a record of this model.\nSelect Object with message_new attrbutes."),
'priority': fields.integer('Server Priority', readonly=True, states={'draft':[('readonly', False)]}, help="Priority between 0 to 10, select define the order of Processing"),
'user_id':fields.many2one('res.users', 'User', required=False),
'message_ids': fields.one2many('mailgate.message', 'server_id', 'Messages', readonly=True),
@@ -82,8 +81,19 @@ class email_server(osv.osv):
return False
return True
+ def check_model(self, cr, uid, ids, context = None):
+ if not context:
+ context = {}
+ current_rec = self.read(cr, uid, ids, context)[0]
+ if current_rec:
+ model = self.pool.get(current_rec.get('object_id')[1])
+ if hasattr(model, 'message_new'):
+ return True
+ return False
+
_constraints = [
- (check_duplicate, 'Warning! Can\'t have duplicate server configuration!', ['user', 'password'])
+ (check_duplicate, 'Warning! Can\'t have duplicate server configuration!', ['user', 'password']),
+ (check_model, 'Warning! Record for slected Model can not be created\nPlease choose valid Model', ['object_id'])
]
def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False):