'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),
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):