From 87c4a3a3b7406cd8bba071846e230f48d7c03da8 Mon Sep 17 00:00:00 2001 From: Anael Closson Date: Mon, 13 Aug 2012 19:04:29 +0200 Subject: initial note push bzr revid: acl@openerp.com-20120813170429-91dibb1dpe32j6w2 --- addons/note/note.py | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 addons/note/note.py (limited to 'addons/note/note.py') diff --git a/addons/note/note.py b/addons/note/note.py new file mode 100644 index 00000000000..a9afad770c4 --- /dev/null +++ b/addons/note/note.py @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +from openerp.osv import osv, fields +from tools.translate import _ + +# +# Todo : + + +# ** fix editable when in form view ** not atm +# fix search +# fix design +# rights + + +class note_stage(osv.Model): + """ Category of Note """ + + _name = "note.stage" + _description = "Note Stage" + _columns = { + 'name': fields.char('Category Name', size=64, 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'), + + } + _sql_constraints = [ + ] + + _order = 'sequence asc' + + _defaults = { + 'fold': 0, + 'user_id': lambda self, cr, uid, ctx: uid, + 'sequence' : 1, + } + + def __init__(self, pool, cr): + osv.Model.__init__(self,pool, cr) + + +# class many2many_filter(fields.many2many) + +# grep many2many_mod dans le code + + + +class note_note(osv.Model): + """ Note """ + _name = 'note.note' + _inherit = ['mail.thread','pad.common'] + _pad_fields = ['note_pad'] + _description = "Note" + + def _get_note_first_line(self, cr, uid, ids, name, args, context=None): + res = {} + for note in self.browse(cr, uid, ids, context=context): + res[note.id] = note.note.split('\n')[0] + return res + + def _set_note_first_line(self, cr, uid, id, name, value, args, context=None): + # + # todo should set the pad first line (as title) + # + return self.write(cr, uid, [id], {'name': value}, context=context) + + _columns = { + 'name': fields.function(_get_note_first_line,_fnct_inv=_set_note_first_line, string='Note Summary', type="text", store=True), + 'note': fields.text('Pad Content'), + 'note_pad': fields.char('Pad Url', size=250), + 'sequence': fields.integer('Sequence'), + 'stage_id': fields.many2one('note.stage', 'Stage'), + 'active': fields.boolean('Active'), + 'color': fields.integer('Color Index'), + #'follower_ids': fields.one2many('mail.subscription', 'res_id', 'Followers', domain=[('res_model','=', 'note.note')]) + 'follower_ids': fields.many2many('res.users', 'mail_subscription', 'res_id', 'user_id', 'Followers', join_filter="mail_subscription.res_model='note.note'") + } + + _sql_constraints = [ + ] + + + def _get_default_stage_id(self,cr,uid,context=None): + id = self.pool.get('note.stage').search(cr,uid,[('sequence','=','1')]) + return id[0] + + _defaults = { + 'active' : 1, + 'stage_id' : _get_default_stage_id, + 'note_pad': lambda self, cr, uid, context: self.pad_generate_url(cr, uid, context), + } + + + _order = 'sequence asc' + + + + def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None): + access_rights_uid = access_rights_uid or uid + stage_obj = self.pool.get('note.stage') + + # only show stage groups not folded and owned by user + search_domain = [('fold', '=', False),('user_id', '=', uid)] + + stage_ids = stage_obj._search(cr, uid, search_domain, order=self._order, access_rights_uid=access_rights_uid, context=context) + result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context) + return result + + _group_by_full = { + 'stage_id' : _read_group_stage_ids, + } + + def stage_set(self,cr,uid,ids,stage_id,context=None): + self.write(cr,uid,ids,{'stage_id': stage_id}) -- cgit v1.2.3 From 876dc272424e78cf45db33dddd23ce994da1ba5e Mon Sep 17 00:00:00 2001 From: Anael Closson Date: Tue, 14 Aug 2012 16:21:51 +0200 Subject: wip bzr revid: acl@openerp.com-20120814142151-uwi6xkdamv623pos --- addons/note/note.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/note/note.py') diff --git a/addons/note/note.py b/addons/note/note.py index a9afad770c4..89049bf6ec8 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -93,7 +93,7 @@ class note_note(osv.Model): 'active': fields.boolean('Active'), 'color': fields.integer('Color Index'), #'follower_ids': fields.one2many('mail.subscription', 'res_id', 'Followers', domain=[('res_model','=', 'note.note')]) - 'follower_ids': fields.many2many('res.users', 'mail_subscription', 'res_id', 'user_id', 'Followers', join_filter="mail_subscription.res_model='note.note'") + #'follower_ids': fields.many2many('res.users', 'mail_subscription', 'res_id', 'user_id', 'Followers', join_filter="mail_subscription.res_model='note.note'") } _sql_constraints = [ -- cgit v1.2.3 From 56666953b38e7ea2c6e8e8bc8391bd6da9b64276 Mon Sep 17 00:00:00 2001 From: Anael Closson Date: Tue, 14 Aug 2012 17:18:00 +0200 Subject: Some fixes bzr revid: acl@openerp.com-20120814151800-e0adyvny6v17c3qr --- addons/note/note.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'addons/note/note.py') diff --git a/addons/note/note.py b/addons/note/note.py index 89049bf6ec8..7d0ff170d79 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -22,16 +22,6 @@ from openerp.osv import osv, fields from tools.translate import _ -# -# Todo : - - -# ** fix editable when in form view ** not atm -# fix search -# fix design -# rights - - class note_stage(osv.Model): """ Category of Note """ @@ -55,9 +45,6 @@ class note_stage(osv.Model): 'sequence' : 1, } - def __init__(self, pool, cr): - osv.Model.__init__(self,pool, cr) - # class many2many_filter(fields.many2many) @@ -93,7 +80,7 @@ class note_note(osv.Model): 'active': fields.boolean('Active'), 'color': fields.integer('Color Index'), #'follower_ids': fields.one2many('mail.subscription', 'res_id', 'Followers', domain=[('res_model','=', 'note.note')]) - #'follower_ids': fields.many2many('res.users', 'mail_subscription', 'res_id', 'user_id', 'Followers', join_filter="mail_subscription.res_model='note.note'") + 'follower_ids': fields.many2many('res.users', 'mail_subscription', 'res_id', 'user_id', 'Followers', join_filter="mail_subscription.res_model='note.note'") } _sql_constraints = [ -- cgit v1.2.3 From 531e077f1bcbbb4d3e45fe1985e6f246132b468e Mon Sep 17 00:00:00 2001 From: Anael Closson Date: Tue, 14 Aug 2012 17:42:40 +0200 Subject: [FIX] some misc fixes bzr revid: acl@openerp.com-20120814154240-on30lw5qfp66xj7q --- addons/note/note.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'addons/note/note.py') diff --git a/addons/note/note.py b/addons/note/note.py index 7d0ff170d79..05c5ea6eadf 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -32,8 +32,8 @@ class note_stage(osv.Model): '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'), - } + _sql_constraints = [ ] @@ -64,13 +64,13 @@ class note_note(osv.Model): for note in self.browse(cr, uid, ids, context=context): res[note.id] = note.note.split('\n')[0] return res - + def _set_note_first_line(self, cr, uid, id, name, value, args, context=None): # # todo should set the pad first line (as title) # return self.write(cr, uid, [id], {'name': value}, context=context) - + _columns = { 'name': fields.function(_get_note_first_line,_fnct_inv=_set_note_first_line, string='Note Summary', type="text", store=True), 'note': fields.text('Pad Content'), @@ -79,8 +79,7 @@ class note_note(osv.Model): 'stage_id': fields.many2one('note.stage', 'Stage'), 'active': fields.boolean('Active'), 'color': fields.integer('Color Index'), - #'follower_ids': fields.one2many('mail.subscription', 'res_id', 'Followers', domain=[('res_model','=', 'note.note')]) - 'follower_ids': fields.many2many('res.users', 'mail_subscription', 'res_id', 'user_id', 'Followers', join_filter="mail_subscription.res_model='note.note'") + 'follower_ids': fields.many2many('res.users', 'mail_subscription', 'res_id', 'user_id', 'Followers', join_filter="mail_subscription.res_model='note.note'") } _sql_constraints = [ @@ -97,18 +96,15 @@ class note_note(osv.Model): 'note_pad': lambda self, cr, uid, context: self.pad_generate_url(cr, uid, context), } - _order = 'sequence asc' - - def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None): access_rights_uid = access_rights_uid or uid stage_obj = self.pool.get('note.stage') - + # only show stage groups not folded and owned by user search_domain = [('fold', '=', False),('user_id', '=', uid)] - + stage_ids = stage_obj._search(cr, uid, search_domain, order=self._order, access_rights_uid=access_rights_uid, context=context) result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context) return result -- cgit v1.2.3 From aa5a055c6d10d60b70abdd365eb6e52f51764555 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Mon, 20 Aug 2012 16:51:38 +0200 Subject: [IMP] note: reorganize code bzr revid: abo@openerp.com-20120820145138-l7a4985im5nua3xq --- addons/note/note.py | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) (limited to 'addons/note/note.py') diff --git a/addons/note/note.py b/addons/note/note.py index 05c5ea6eadf..96c7cea9602 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -22,7 +22,7 @@ from openerp.osv import osv, fields from tools.translate import _ -class note_stage(osv.Model): +class note_stage(osv.osv): """ Category of Note """ _name = "note.stage" @@ -46,13 +46,7 @@ class note_stage(osv.Model): } -# class many2many_filter(fields.many2many) - -# grep many2many_mod dans le code - - - -class note_note(osv.Model): +class note_note(osv.osv): """ Note """ _name = 'note.note' _inherit = ['mail.thread','pad.common'] @@ -71,6 +65,25 @@ class note_note(osv.Model): # return self.write(cr, uid, [id], {'name': value}, context=context) + + def _get_default_stage_id(self,cr,uid,context=None): + id = self.pool.get('note.stage').search(cr,uid,[('sequence','=','1')]) + return id[0] + + def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None): + access_rights_uid = access_rights_uid or uid + stage_obj = self.pool.get('note.stage') + + # only show stage groups not folded and owned by user + search_domain = [('fold', '=', False),('user_id', '=', uid)] + + stage_ids = stage_obj._search(cr, uid, search_domain, order=self._order, access_rights_uid=access_rights_uid, context=context) + result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context) + return result + + def stage_set(self,cr,uid,ids,stage_id,context=None): + self.write(cr,uid,ids,{'stage_id': stage_id}) + _columns = { 'name': fields.function(_get_note_first_line,_fnct_inv=_set_note_first_line, string='Note Summary', type="text", store=True), 'note': fields.text('Pad Content'), @@ -85,11 +98,6 @@ class note_note(osv.Model): _sql_constraints = [ ] - - def _get_default_stage_id(self,cr,uid,context=None): - id = self.pool.get('note.stage').search(cr,uid,[('sequence','=','1')]) - return id[0] - _defaults = { 'active' : 1, 'stage_id' : _get_default_stage_id, @@ -98,20 +106,6 @@ class note_note(osv.Model): _order = 'sequence asc' - def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None): - access_rights_uid = access_rights_uid or uid - stage_obj = self.pool.get('note.stage') - - # only show stage groups not folded and owned by user - search_domain = [('fold', '=', False),('user_id', '=', uid)] - - stage_ids = stage_obj._search(cr, uid, search_domain, order=self._order, access_rights_uid=access_rights_uid, context=context) - result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context) - return result - _group_by_full = { 'stage_id' : _read_group_stage_ids, } - - def stage_set(self,cr,uid,ids,stage_id,context=None): - self.write(cr,uid,ids,{'stage_id': stage_id}) -- cgit v1.2.3 From 6de8c4b8e4f037f5297741e08ab643eada09728d Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Mon, 20 Aug 2012 18:27:48 +0200 Subject: [IMP] note: rename the field 'note_pad' into 'note_pad_url' bzr revid: abo@openerp.com-20120820162748-f92eq99kywwq7vz7 --- addons/note/note.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/note/note.py') diff --git a/addons/note/note.py b/addons/note/note.py index 96c7cea9602..25f6c170f42 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -87,7 +87,7 @@ class note_note(osv.osv): _columns = { 'name': fields.function(_get_note_first_line,_fnct_inv=_set_note_first_line, string='Note Summary', type="text", store=True), 'note': fields.text('Pad Content'), - 'note_pad': fields.char('Pad Url', size=250), + 'note_pad_url': fields.char('Pad Url', size=250), 'sequence': fields.integer('Sequence'), 'stage_id': fields.many2one('note.stage', 'Stage'), 'active': fields.boolean('Active'), @@ -101,7 +101,7 @@ class note_note(osv.osv): _defaults = { 'active' : 1, 'stage_id' : _get_default_stage_id, - 'note_pad': lambda self, cr, uid, context: self.pad_generate_url(cr, uid, context), + 'note_pad_url': lambda self, cr, uid, context: self.pad_generate_url(cr, uid, context), } _order = 'sequence asc' -- cgit v1.2.3 From 2d6829b70ecbac0008aba3c525f9642733c43d82 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 5 Sep 2012 11:54:35 +0200 Subject: [IMP] note name_create ok bzr revid: fp@tinyerp.com-20120905095435-bio3buy24t4sdvze --- addons/note/note.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/note/note.py') diff --git a/addons/note/note.py b/addons/note/note.py index f6a46c72c88..bce54566e64 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -46,6 +46,9 @@ class note_note(osv.osv): _pad_fields = ['note_pad'] _description = "Note" + 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): res = {} for note in self.browse(cr, uid, ids, context=context): @@ -68,7 +71,7 @@ class note_note(osv.osv): return result _columns = { - 'name': fields.function(_get_note_first_line, string='Note Summary', type="text", store=True), + 'name': fields.function(_get_note_first_line, fnct_inv=_set_note_first_line, string='Note Summary', type="text"), 'note': fields.text('Pad Content'), 'note_pad_url': fields.char('Pad Url', size=250), 'sequence': fields.integer('Sequence'), -- cgit v1.2.3 From c07aa9b5da08dfcc6f7ce5cf67ab002ae89b7279 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 6 Sep 2012 18:18:12 +0200 Subject: read_grouop_fold bzr revid: fp@tinyerp.com-20120906161812-5yop3buxhpbuylmm --- addons/note/note.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/note/note.py') diff --git a/addons/note/note.py b/addons/note/note.py index 61b5caeff8d..abc7dca297e 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -64,7 +64,7 @@ class note_note(osv.osv): stage_obj = self.pool.get('note.stage') # only show stage groups not folded and owned by user - search_domain = [('fold', '=', False),('user_id', '=', uid)] + search_domain = [('user_id', '=', uid)] stage_ids = stage_obj._search(cr, uid, search_domain, order=self._order, access_rights_uid=access_rights_uid, context=context) result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context) -- cgit v1.2.3