summaryrefslogtreecommitdiff
path: root/addons/note/note.py
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@openerp.com>2012-09-07 14:25:06 +0200
committerChristophe Matthieu <chm@openerp.com>2012-09-07 14:25:06 +0200
commit7dd65a0f9ba6ca0c59addc22f2b3fed6e9f56504 (patch)
tree83d97f087a2dd394fe8df1f2977b1f1297c20385 /addons/note/note.py
parentb49b72f00ec2d818338aa8af008ac8337ba990df (diff)
note : constraint for note min len
bzr revid: chm@openerp.com-20120907122506-fs6d3vvqowr2m6yk
Diffstat (limited to 'addons/note/note.py')
-rw-r--r--addons/note/note.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/addons/note/note.py b/addons/note/note.py
index 985cacd3404..1b5704eb601 100644
--- a/addons/note/note.py
+++ b/addons/note/note.py
@@ -55,10 +55,10 @@ class note_note(osv.osv):
_inherit = ['mail.thread']
_description = "Note"
- def _set_note_first_line(self, cr, uid, id, name, value, args, context=None):
+ def _set_note_first_line(self, cr, uid, id, name, value, args={}, context=None):
return self.write(cr, uid, [id], {'note': value}, context=context)
- def _get_note_first_line(self, cr, uid, ids, name, args, context=None):
+ def _get_note_first_line(self, cr, uid, ids, name="", args={}, context=None):
res = {}
for note in self.browse(cr, uid, ids, context=context):
text_note = (note.note or '').strip().split('\n')[0]
@@ -99,6 +99,16 @@ class note_note(osv.osv):
return False
+ def _constraints_min_len(self, cr, uid, ids, context=None):
+
+ res = self._get_note_first_line(cr, uid, ids, context=context)
+
+ for note in self.browse(cr, uid, ids, context=context):
+ if len(res[note.id])<1 :
+ return False
+
+ return True
+
_columns = {
'name': fields.function(_get_note_first_line, fnct_inv=_set_note_first_line, string='Note Summary', type='text'),
@@ -120,9 +130,14 @@ class note_note(osv.osv):
'tag_ids' : fields.many2many('note.tag','note_tags_rel','note_id','tag_id','Tags'),
}
+ _constraints = [
+ (_constraints_min_len,'The title (first line on the note) must have at least one character.',['note']),
+ ]
+
_defaults = {
'active' : 1,
'stage_id' : _get_default_stage_id,
+ 'note': " "
}
_order = 'sequence asc'
_group_by_full = {