[IMP] mail.group: improved kanban view. Also added a joined calculated field, calling message_is_subscriber, used to display available options in kanban view.
bzr revid: tde@openerp.com-20120307170254-p18c95iv804cjcim
This commit is contained in:
parent
4e60bfccc5
commit
4031396f47
|
@ -38,18 +38,10 @@ class mail_group(osv.osv):
|
|||
_inherit = ['mail.thread']
|
||||
|
||||
def action_group_join(self, cr, uid, ids, context={}):
|
||||
sub_obj = self.pool.get('mail.subscription')
|
||||
menu_values = {'res_model': 'mail.group', 'user_id': uid}
|
||||
for id in ids:
|
||||
menu_values['res_id'] = id
|
||||
sub_id = sub_obj.create(cr, uid, menu_values, context=context)
|
||||
|
||||
for group in self.browse(cr, uid, ids, context):
|
||||
self.write(cr, uid, group.id, {
|
||||
'users': [(4, uid)]
|
||||
})
|
||||
|
||||
return True
|
||||
return self.message_subscribe(cr, uid, ids, context=context);
|
||||
|
||||
def action_group_leave(self, cr, uid, ids, context={}):
|
||||
return self.message_unsubscribe(cr, uid, ids, context=context);
|
||||
|
||||
def _get_photo_mini(self, cr, uid, ids, name, args, context=None):
|
||||
result = {}
|
||||
|
@ -70,6 +62,12 @@ class mail_group(osv.osv):
|
|||
self.write(cr, uid, [id], {'photo': value}, context=context)
|
||||
return True
|
||||
|
||||
def is_subscriber(self, cr, uid, ids, name, args, context=None):
|
||||
result = {}
|
||||
for id in ids:
|
||||
result[id] = self.message_is_subscriber(cr, uid, [id], context=context)
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True),
|
||||
'description': fields.text('Description'),
|
||||
|
@ -81,6 +79,7 @@ class mail_group(osv.osv):
|
|||
store = {
|
||||
'mail.group': (lambda self, cr, uid, ids, c={}: ids, ['photo'], 10),
|
||||
}),
|
||||
'joined': fields.function(is_subscriber, type='boolean'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
|
|
@ -11,19 +11,29 @@
|
|||
<field name="arch" type="xml">
|
||||
<kanban>
|
||||
<templates>
|
||||
<t t-name="kanban-description">
|
||||
<div class="oe_group_description" t-if="record.description.raw_value">
|
||||
<field name="description"/>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="kanban-box">
|
||||
<div class="oe_group_vignette">
|
||||
<div t-attf-class="{record.joined.raw_value} oe_group_vignette">
|
||||
<div class="oe_group_image">
|
||||
Image
|
||||
<a type="edit"><img t-att-src="kanban_image('mail.group', 'photo', record.id.value)" class="oe_group_photo" tooltip="kanban-description"/></a>
|
||||
</div>
|
||||
<div class="oe_group_details">
|
||||
<h4><a type="edit"><field name="name"/></a></h4>
|
||||
<span style="display: none;"><field name="joined"/></span>
|
||||
<ul>
|
||||
<li><a name="action_group_join" string="Join" type="object">Join</a></li>
|
||||
<li>Joined</li>
|
||||
<li t-if="record.joined.raw_value"><b>Joined</b></li>
|
||||
<li t-if="! record.joined.raw_value"><a name="action_group_join" string="Join" type="object">Join</a></li>
|
||||
<li t-if="record.joined.raw_value"><a name="action_group_leave" string="Join" type="object">Leave</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$('.oe_group_photo').load(function() { if($(this).width() > $(this).height()) { $(this).addClass('oe_group_photo_wide') } });
|
||||
</script>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.oe_group_picture {
|
||||
.oe_group_photo {
|
||||
width: 100px;
|
||||
height: auto;
|
||||
clip: rect(10px, 100px, 110px, 0px);
|
||||
}
|
||||
|
||||
.oe_group_picture_wide {
|
||||
.oe_group_photo_wide {
|
||||
height: 100px;
|
||||
width: auto;
|
||||
clip: rect(0px, 115px, 100px, 15px);
|
||||
|
@ -66,3 +66,9 @@
|
|||
.oe_group_details li {
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
.oe_group_description {
|
||||
}
|
||||
|
||||
.oe_kanban_record div.true {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue