diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py
index e4862ca9fb9..e7b6df7f05f 100644
--- a/addons/mail/mail_message.py
+++ b/addons/mail/mail_message.py
@@ -57,7 +57,7 @@ class mail_message(osv.Model):
for message in self.browse(cr, uid, ids, context=context):
if not message.model or not message.res_id:
continue
- result[message.id] = self._shorten_name(self.pool.get(message.model).name_get(cr, uid, [message.res_id], context=context)[0][1])
+ result[message.id] = self._shorten_name(self.pool.get(message.model).name_get(cr, 1, [message.res_id], context=context)[0][1])
return result
def _get_unread(self, cr, uid, ids, name, arg, context=None):
diff --git a/addons/mail/security/ir.model.access.csv b/addons/mail/security/ir.model.access.csv
index 1979e2fec05..efd600400ad 100644
--- a/addons/mail/security/ir.model.access.csv
+++ b/addons/mail/security/ir.model.access.csv
@@ -1,4 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_mail_global,mail.mail,model_mail_mail,base.group_system,1,1,1,1
access_mail_message_all,mail.message.all,model_mail_message,,1,0,0,0
access_mail_message_group_user,mail.message.group.user,model_mail_message,base.group_user,1,1,1,1
access_mail_thread,mail.thread,model_mail_thread,base.group_user,1,1,1,0
diff --git a/addons/note/__openerp__.py b/addons/note/__openerp__.py
index c0c05c4cdb9..02e4653031c 100644
--- a/addons/note/__openerp__.py
+++ b/addons/note/__openerp__.py
@@ -44,7 +44,7 @@ Memos can be found in the 'Home' menu.
],
'data': [
'security/res.groups.csv',
- 'security/note_security.xml',
+ 'security/ir.rule.xml',
'security/ir.model.access.csv',
'note_data.xml',
'note_view.xml',
diff --git a/addons/note/note.py b/addons/note/note.py
index ed69214f97d..c600c54b162 100644
--- a/addons/note/note.py
+++ b/addons/note/note.py
@@ -70,11 +70,6 @@ class note_note(osv.osv):
return res
- #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)])
- return ids and ids[0] or False
-
#unactivate a memo and record the date
def onclick_note_is_done(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, { 'active' : False, 'date_done' : fields.date.today() })
@@ -95,27 +90,34 @@ class note_note(osv.osv):
#look that the title (first line of the memo) 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)
-
- for note in self.browse(cr, uid, ids, context=context):
- if len(res[note.id])<1 :
- return False
-
- return True
-
+ 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)
pid = user.partner_id and user.partner_id.id or False
-
- result = {}
- for record in self.browse(cr, uid, ids, context=context):
- result[record.id]=pid
-
- return result
+ return dict.fromkeys(ids, pid)
+ #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
+
+ 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)
+
+ #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):
+ for stage in record.stage_ids:
+ if stage.user_id.id == uid:
+ result[record.id] = stage.id
+ return result
_columns = {
@@ -126,13 +128,18 @@ class note_note(osv.osv):
store=True),
'memo': fields.html('Pad Content'),
'sequence': fields.integer('Sequence'),
- # the stage_id depending on the uid
- 'stage_id': fields.many2one('note.stage', 'Stage'),
- # ERROR for related & stage_ids => group_by for kanban
- #'stage_id': fields.related('stage_ids', 'id', string='Stage', type="many2one", relation="note.stage"),
+ #'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',
+ 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','Linked stages users'),
'active': fields.boolean('Active'),
# when the user unactivate the memo, record de date for un display memo after 1 days
@@ -144,10 +151,6 @@ class note_note(osv.osv):
'current_partner_id' : fields.function(_get_my_current_partner),
}
- _constraints = [
- (_constraints_min_len,'The title (first line on the memo) must have at least one character.',['memo']),
- ]
-
_defaults = {
'active' : 1,
'stage_id' : _get_default_stage_id,
@@ -156,6 +159,44 @@ class note_note(osv.osv):
_order = 'sequence asc'
+ def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
+ if groupby and groupby[0]=="stage_id":
+
+ #search all stages
+ stage_ids = self.pool.get('note.stage').search(cr,uid,[('user_id','=',uid)], context=context)
+ stage_name = dict(self.pool.get('note.stage').name_get(cr, uid, stage_ids, context=context)) #dict: map l'id sur le nom
+
+ result = [{ #notes by stage for stages user
+ '__context': {'group_by': groupby[1:]},
+ '__domain': domain + [('stage_ids.id', '=', stage_id)],
+ 'stage_id': (stage_id, stage_name[stage_id]),
+ 'stage_id_count': len(self.search(cr,uid, domain+[('stage_ids', '=', stage_id)], context=context ))
+ } for stage_id in stage_ids]
+
+ nb_notes_ws = len(self.search(cr,uid, domain+[('stage_ids', 'not in', stage_ids)], context=context ))
+
+ if nb_notes_ws>0:
+ result += [{ #notes for unknown stage
+ '__context': {'group_by': groupby[1:]},
+ '__domain': domain + [('stage_ids', 'not in', stage_ids)],
+ 'stage_id': (0, 'Unknown'),
+ 'stage_id_count':nb_notes_ws
+ }]
+
+ return result
+
+ else:
+ return super(note_note, self).read_group(self, cr, uid, domain, fields, groupby,
+ offset=offset, limit=limit, context=context, orderby=orderby)
+
+ # object.execute_kw time:0.017s [{'__context': {'group_by': []},
+ # '__domain': [('author', '=', u'OpenERP SA'), ['application', '=', 1]],
+ # 'author': u'OpenERP SA',
+ # 'author_count': 20L}]
+
+
+
+
#upgrade config setting page to configure pad, fancy and tags mode
class note_base_config_settings(osv.osv_memory):
_inherit = 'base.config.settings'
@@ -165,5 +206,5 @@ class note_base_config_settings(osv.osv_memory):
#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 memo', implied_group='note.group_note_tags'),
- 'group_note_thread': fields.boolean('Use mail thread and follower', implied_group='note.group_note_thread'),
+ 'group_note_thread': fields.boolean('Use mail thread', implied_group='note.group_note_thread'),
}
diff --git a/addons/note/note_view.xml b/addons/note/note_view.xml
index 763489b0fd7..9381489a8d9 100644
--- a/addons/note/note_view.xml
+++ b/addons/note/note_view.xml
@@ -24,9 +24,9 @@
-
-
-
+
+
+
@@ -39,8 +39,7 @@
[('user_id','=',uid)]
-
+
@@ -86,11 +85,8 @@
-
-
-
-
-
+
+
@@ -104,6 +100,20 @@
+
+
+ note.note.tree
+ note.note
+
+
+
+
+
+
+
+
+
+
note.note.form
@@ -111,16 +121,16 @@
@@ -180,7 +190,7 @@
- note
+ Memos
note.note
form
kanban,tree,form
diff --git a/addons/note/security/ir.model.access.csv b/addons/note/security/ir.model.access.csv
index fe523cdd2ee..6c5ea823d96 100644
--- a/addons/note/security/ir.model.access.csv
+++ b/addons/note/security/ir.model.access.csv
@@ -1,3 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_note_stage_user,note.stage,model_note_stage,base.group_user,1,1,1,1
-access_note_note_user,note.note,model_note_note,base.group_user,1,1,1,1
+access_note_stage,note.stage,model_note_stage,,1,1,1,1
+access_note_note,note.note,model_note_note,,1,1,1,1
+access_note_tag,note.tag,model_note_tag,,1,1,1,1
diff --git a/addons/note/security/ir.rule.xml b/addons/note/security/ir.rule.xml
new file mode 100644
index 00000000000..4eab169519f
--- /dev/null
+++ b/addons/note/security/ir.rule.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ Only followers can read a memos
+
+ ['|',('message_follower_ids.id','=',user.partner_id.id),('message_follower_ids','=',False)]
+
+
+
+
+
diff --git a/addons/note/security/note_security.xml b/addons/note/security/note_security.xml
deleted file mode 100644
index 3710d79839e..00000000000
--- a/addons/note/security/note_security.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
- My notes
-
-
- [('message_follower_ids','=',user.partner_id.id)]
-
-
-
-
diff --git a/addons/note_pad/__init__.py b/addons/note_pad/__init__.py
index 75aae47f772..44a484adac4 100644
--- a/addons/note_pad/__init__.py
+++ b/addons/note_pad/__init__.py
@@ -19,5 +19,5 @@
#
##############################################################################
-import memo_pad
+import note_pad
diff --git a/addons/note_pad/note_pad.py b/addons/note_pad/note_pad.py
index 673867afd53..9864f0ae14f 100644
--- a/addons/note_pad/note_pad.py
+++ b/addons/note_pad/note_pad.py
@@ -29,12 +29,13 @@ class note_pad_note(osv.osv):
_inherit = ['pad.common','note.note']
_pad_fields = ['note_pad']
- _description = "Memo pad"
_columns = {
- 'note_pad_url': fields.char('Pad Url', size=250),
+ 'note_pad_url': fields.char('Pad Url',
+ pad_content_field='memo',
+ size=250 ),
}
- _defaults = {
- 'note_pad_url': lambda self, cr, uid, context: self.pad_generate_url(cr, uid, context),
- }
+ #_defaults = {
+ # 'note_pad_url': lambda self, cr, uid, context: self.pad_generate_url(cr, uid, context),
+ #}
diff --git a/addons/note_pad/note_pad_view.xml b/addons/note_pad/note_pad_view.xml
index eec7735d488..9e45a3952f1 100644
--- a/addons/note_pad/note_pad_view.xml
+++ b/addons/note_pad/note_pad_view.xml
@@ -6,9 +6,8 @@
note.note
-
-
-
+
+