[IMP] note: stage by user, group by stage, access rules
bzr revid: chm@openerp.com-20120913171938-0zmtm2ds5mjdgttj
This commit is contained in:
parent
9ab1f35de5
commit
576d664f88
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
|
@ -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',
|
||||
|
|
|
@ -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,29 +90,36 @@ 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
|
||||
return dict.fromkeys(ids, pid)
|
||||
|
||||
result = {}
|
||||
#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):
|
||||
result[record.id]=pid
|
||||
|
||||
for stage in record.stage_ids:
|
||||
if stage.user_id.id == uid:
|
||||
result[record.id] = stage.id
|
||||
return result
|
||||
|
||||
|
||||
|
||||
_columns = {
|
||||
'name': fields.function(_get_note_first_line,
|
||||
fnct_inv=_set_note_first_line,
|
||||
|
@ -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'),
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
<field name="field_parent"></field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Stages of memos" editable="bottom">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="name"/>
|
||||
<field name="fold"/>
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="name"/>
|
||||
<field name="fold"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -39,8 +39,7 @@
|
|||
<field name="domain">[('user_id','=',uid)]</field>
|
||||
</record>
|
||||
|
||||
<menuitem name="Categories"
|
||||
id="menu_notes_stage" parent="note_my_stuff" action="action_note_stage" sequence="40" groups="base.group_no_one"/>
|
||||
<menuitem name="Categories" id="menu_notes_stage" parent="note_my_stuff" action="action_note_stage" sequence="40" groups="base.group_no_one"/>
|
||||
|
||||
<!-- New memo Kanban View -->
|
||||
<record model="ir.ui.view" id="view_note_note_kanban">
|
||||
|
@ -86,11 +85,8 @@
|
|||
<field name="name"/>
|
||||
</div>
|
||||
|
||||
<div class="oe_left oe_kanban_list_many2many" data-model="note.tag" groups="note.group_note_tags">
|
||||
<t t-foreach="record.tag_ids.raw_value" t-as="tag">
|
||||
<span class="oe_tag" t-att-data-list_id="tag"/>
|
||||
</t>
|
||||
</div>
|
||||
<div widget="many2many_tags" t-att-data="record.tag_ids.raw_value" model="note.tag"/>
|
||||
|
||||
<div class="oe_right">
|
||||
<t t-foreach="record.message_follower_ids.raw_value" t-as="follower">
|
||||
<img t-if="record.current_partner_id.raw_value!=follower" t-att-src="kanban_image('res.partner', 'image_small', follower)" width="24" height="24" class="oe_kanban_avatar" t-att-data-member_id="follower"/>
|
||||
|
@ -104,6 +100,20 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<!-- New memo Form View -->
|
||||
<record model="ir.ui.view" id="view_note_note_tree">
|
||||
<field name="name">note.note.tree</field>
|
||||
<field name="model">note.note</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Stages">
|
||||
<field name="name"/>
|
||||
<field name="active"/>
|
||||
<field name="stage_id"/>
|
||||
<field name="tag_ids" widget="many2many_tags" groups="note.group_note_tags"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- New memo Form View -->
|
||||
<record model="ir.ui.view" id="view_note_note_form">
|
||||
<field name="name">note.note.form</field>
|
||||
|
@ -111,16 +121,16 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Memo" version="7.0">
|
||||
<header>
|
||||
<field name="stage_id" domain="[('user_id','=',uid)]" widget="statusbar" clickable="1"/>
|
||||
<field name="stage_id" domain="[('user_id','=',uid)]"/><!-- widget="statusbar" clickable="1"/-->
|
||||
</header>
|
||||
<field colspan="4" name="memo" widget="html" editor_width="100%%" editor_height="400px" nolabel="1"/>
|
||||
<field colspan="4" name="memo" widget="html" editor_width="100%%" editor_height="100%%" nolabel="1"/>
|
||||
<group groups="note.group_note_tags" col="2">
|
||||
<field name="tag_ids" widget="many2many_tags"/>
|
||||
</group>
|
||||
<div class="oe_chatter" groups="note.group_note_thread">
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
</div>
|
||||
<div class="oe_chatter" groups="note.group_note_thread">
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
</div>
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -180,7 +190,7 @@
|
|||
|
||||
<!-- memo Action -->
|
||||
<record model="ir.actions.act_window" id="action_note_note">
|
||||
<field name="name">note</field>
|
||||
<field name="name">Memos</field>
|
||||
<field name="res_model">note.note</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">kanban,tree,form</field>
|
||||
|
|
|
@ -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
|
||||
|
|
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="note_note_rule_global" model="ir.rule">
|
||||
<field name="name">Only followers can read a memos</field>
|
||||
<field model="ir.model" ref="model_note_note" name="model_id"/>
|
||||
<field name="domain_force">['|',('message_follower_ids.id','=',user.partner_id.id),('message_follower_ids','=',False)]</field>
|
||||
<field eval="True" name="global"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="note_note_global" model="ir.rule">
|
||||
<field name="name">My notes</field>
|
||||
<field ref="model_note_note" name="model_id"/>
|
||||
<field eval="1" name="global"/>
|
||||
<field name="domain_force">[('message_follower_ids','=',user.partner_id.id)]</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
@ -19,5 +19,5 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import memo_pad
|
||||
import note_pad
|
||||
|
||||
|
|
|
@ -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),
|
||||
#}
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
<field name="model">note.note</field>
|
||||
<field name="inherit_id" ref="note.view_note_note_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="note" position="replace">
|
||||
<field name="note_pad_url" invisible="1"/>
|
||||
<field name="name" widget="pad"/>
|
||||
<field name="memo" position="replace">
|
||||
<field name="note_pad_url" widget="pad"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue