diff options
| author | Christophe Matthieu <chm@openerp.com> | 2012-09-18 17:25:50 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@openerp.com> | 2012-09-18 17:25:50 +0200 |
| commit | 4290c35f065d1d4943f5dc99fb8428a6f01372a6 (patch) | |
| tree | d8a8f0199f838a8b484e35ef466d3bb6425e97e8 /addons/note/note.py | |
| parent | 8cb1f558a0f7d0c5eb43b75f153e2b374351999d (diff) | |
| parent | 4ab0705aca414f9745bd1adaafadf2e20cb7824f (diff) | |
[MERGE] from trunk
bzr revid: chm@openerp.com-20120918152550-zdo1b9gtc3r3v6xc
Diffstat (limited to 'addons/note/note.py')
| -rw-r--r-- | addons/note/note.py | 77 |
1 files changed, 23 insertions, 54 deletions
diff --git a/addons/note/note.py b/addons/note/note.py index 33d138de641..7df56e234ed 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -27,12 +27,12 @@ from openerp.tools.misc import html2plaintext class note_stage(osv.osv): """ Category of Note """ _name = "note.stage" - _description = "Sticky note Stage" + _description = "Note Stage" _columns = { - 'name': fields.char('Category Name', size=64, required=True), + 'name': fields.char('Stage Name', required=True), 'sequence': fields.integer('Sequence', help="Used to order the note stages"), - 'user_id': fields.many2one('res.users', 'Owner', help="Owner of the note stage.", required=True, readonly=True), - 'fold': fields.boolean('Folded'), + 'user_id': fields.many2one('res.users', 'Owner', help="Owner of the note stage.", required=True), + 'fold': fields.boolean('Folded by Default'), } _order = 'sequence asc' _defaults = { @@ -42,19 +42,17 @@ class note_stage(osv.osv): } class note_tag(osv.osv): - _name = "note.tag" - _description = "User can make tags on his note." - + _description = "Note Tag" _columns = { - 'name' : fields.char('Tag name', size=64, required=True), + 'name' : fields.char('Tag Name', required=True), } class note_note(osv.osv): """ Note """ _name = 'note.note' _inherit = ['mail.thread'] - _description = "Sticky note" + _description = "Note" #writing method (no modification of values) def name_create(self, cr, uid, name, context=None): @@ -74,32 +72,22 @@ class note_note(osv.osv): text_note = re.sub(r'<[^>]+>','',text_note) text_note = html2plaintext(text_note) res[note.id] = text_note - return res #unactivate a sticky note and record the date def onclick_note_is_done(self, cr, uid, ids, context=None): self.write(cr, uid, ids, { 'open' : False, 'date_done' : fields.date.today() }) - - self.message_post(cr, uid, ids[0], body='This sticky note is active', subject=False, + self.message_post(cr, uid, ids[0], body='Note is done.', subject=False, type='notification', parent_id=False, attachments=None, context=context) - return False - #activate a Sticky note + #activate a note def onclick_note_not_done(self, cr, uid, ids, context=None): - self.write(cr, uid, ids, { 'open' : True }) - - self.message_post(cr, uid, ids[0], body='This sticky note is close', subject=False, + self.write(cr, uid, ids, {'open' : True}) + self.message_post(cr, uid, ids[0], body='Note has been activated.', subject=False, type='notification', parent_id=False, attachments=None, context=context) - return False - - #look that the title (first line of the Sticky note) have more of one caracter - def _constraints_min_len(self, cr, uid, ids, context=None): - res = self._get_note_first_line(cr, uid, ids, context=context) - return dict.fromkeys(ids, (len(res[ids])>0) ) - + #used for undisplay the follower if it's the current user def _get_my_current_partner(self, cr, uid, ids, name, args, context=None): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) @@ -109,15 +97,13 @@ class note_note(osv.osv): #return the default stage for the uid user def _get_default_stage_id(self,cr,uid,context=None): ids = self.pool.get('note.stage').search(cr,uid,[('user_id','=',uid)], context=context) - return ids and ids[0] or 0 + return ids and ids[0] or False def _set_stage_per_user(self, cr, uid, id, name, value, args=None, context=None): note = self.browse(cr, uid, id, context=context) if not value: return False - stage_ids = [value] + [stage.id for stage in note.stage_ids if stage.user_id.id != uid ] - return self.write(cr, uid, [id], {'stage_ids': [(6, 0, stage_ids)]}, context=context) + return self.write(cr, uid, [id], {'stage_ids': [(4, value)]}, context=context) - #used for undisplay the follower if it's the current user def _get_stage_per_user(self, cr, uid, ids, name, args, context=None): result = dict.fromkeys(ids, False) for record in self.browse(cr, uid, ids, context=context): @@ -129,41 +115,27 @@ class note_note(osv.osv): _columns = { 'name': fields.function(_get_note_first_line, - string='Sticky note Summary', - type='text', - store=True), - 'memo': fields.html('Pad Content'), + string='Note Summary', + type='text', store=True), + 'memo': fields.html('Note Content'), 'sequence': fields.integer('Sequence'), - - #'stage_id': fields.many2one('note.stage', 'Stage'), - - # the stage_id depending on the uid 'stage_id': fields.function(_get_stage_per_user, fnct_inv=_set_stage_per_user, - string='Stages', + string='Stage', type='many2one', relation='note.stage'), - - # stage per user - 'stage_ids': fields.many2many('note.stage','note_stage_rel','note_id','stage_id','Linked stages users'), - + 'stage_ids': fields.many2many('note.stage','note_stage_rel','note_id','stage_id','Stages of Users'), 'open': fields.boolean('Active'), - # when the user unactivate the Sticky note, record de date for un display Sticky note after 1 days 'date_done': fields.date('Date done'), 'color': fields.integer('Color Index'), - # put tags on the note (optional) 'tag_ids' : fields.many2many('note.tag','note_tags_rel','note_id','tag_id','Tags'), - 'current_partner_id' : fields.function(_get_my_current_partner), } - _defaults = { 'open' : 1, 'stage_id' : _get_default_stage_id, - 'memo': " " } - _order = 'sequence asc' - + _order = 'sequence' def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False): if groupby and groupby[0]=="stage_id": @@ -206,7 +178,6 @@ class note_note(osv.osv): }] else: result = [] - return result else: @@ -218,9 +189,7 @@ class note_note(osv.osv): class note_base_config_settings(osv.osv_memory): _inherit = 'base.config.settings' _columns = { - #install of the note_pad module => automatic with "module_" - 'module_note_pad': fields.boolean('Use an etherpad'), - #auto group user => automatic with "group_" - 'group_note_fancy': fields.boolean('Use fancy render', implied_group='note.group_note_fancy'), - 'group_note_tags': fields.boolean('Use tags for sticky note', implied_group='note.group_note_tags'), + 'module_note_pad': fields.boolean('Use collaborative pads (etherpad)'), + 'group_note_fancy': fields.boolean('Use fancy layouts for notes', implied_group='note.group_note_fancy'), + 'group_note_tags': fields.boolean('Allow setting tags on notes', implied_group='note.group_note_tags'), } |
