[ADD]:event:added kanban view for event and realted changes for that.

bzr revid: apa@tinyerp.com-20120306064902-rdx250ihctkpjph8
This commit is contained in:
Amit (OpenERP) 2012-03-06 12:19:02 +05:30
parent 79ff7b620a
commit 8085156454
4 changed files with 207 additions and 2 deletions

View File

@ -53,6 +53,7 @@ Note that:
],
'demo_xml': ['event_demo.xml'],
'test': ['test/process/event_draft2done.yml'],
'css': ['static/src/css/event.css'],
'installable': True,
'application': True,
'auto_install': False,

View File

@ -148,8 +148,30 @@ class event_event(osv.osv):
number = reg_done
elif field == 'register_prospect':
number = reg_draft
elif field == 'register_avail':
number = event.register_max-reg_open
res[event.id][field] = number
return res
def _subscribe_fnc(self, cr, uid, ids, fields, args, context=None):
"""Get Confirm or uncofirm register value.
@param ids: List of Event registration type's id
@param fields: List of function fields(register_current and register_prospect).
@param context: A standard dictionary for contextual values
@return: Dictionary of function fields value.
"""
register_pool = self.pool.get('event.registration')
res = {}
for event in self.browse(cr, uid, ids, context=context):
curr_reg_id = register_pool.search(cr,uid,[('user_id','=',uid),('event_id','=',event.id)])
if not curr_reg_id:res[event.id] = False
if curr_reg_id:
for reg in register_pool.browse(cr,uid,curr_reg_id,context=context):
if not reg.subscribe:
res[event.id]=False
else:
res[event.id]=True
return res
_columns = {
'name': fields.char('Name', size=64, required=True, translate=True, readonly=False, states={'done': [('readonly', True)]}),
@ -158,6 +180,7 @@ class event_event(osv.osv):
'register_max': fields.integer('Maximum Registrations', help="You can for each event define a maximum registration level. If you have too much registrations you are not able to confirm your event. (put 0 to ignore this rule )", readonly=True, states={'draft': [('readonly', False)]}),
'register_min': fields.integer('Minimum Registrations', help="You can for each event define a minimum registration level. If you do not enough registrations you are not able to confirm your event. (put 0 to ignore this rule )", readonly=True, states={'draft': [('readonly', False)]}),
'register_current': fields.function(_get_register, string='Confirmed Registrations', multi='register_numbers'),
'register_avail': fields.function(_get_register, string='Available Registrations', multi='register_numbers',type='integer'),
'register_prospect': fields.function(_get_register, string='Unconfirmed Registrations', multi='register_numbers'),
'register_attended': fields.function(_get_register, string='Attended Registrations', multi='register_numbers'),
'registration_ids': fields.one2many('event.registration', 'event_id', 'Registrations', readonly=False, states={'done': [('readonly', True)]}),
@ -182,6 +205,7 @@ class event_event(osv.osv):
type='many2one', relation='res.country', string='Country', readonly=False, states={'done': [('readonly', True)]}),
'note': fields.text('Description', readonly=False, states={'done': [('readonly', True)]}),
'company_id': fields.many2one('res.company', 'Company', required=False, change_default=True, readonly=False, states={'done': [('readonly', True)]}),
'subscribe' : fields.function(_subscribe_fnc, type="boolean", string='Subscribe'),
}
_defaults = {
@ -189,6 +213,33 @@ class event_event(osv.osv):
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'event.event', context=c),
'user_id': lambda obj, cr, uid, context: uid,
}
def subscribe_to_event(self,cr,uid,ids,context=None):
register_pool = self.pool.get('event.registration')
curr_reg_id = register_pool.search(cr,uid,[('user_id','=',uid),('event_id','=',ids[0])])
if not curr_reg_id:
register_pool.create(cr, uid, {'state':'open',
'event_id':ids[0],
'subscribe':True,
})
else:
register_pool.write(cr, uid, curr_reg_id,{'state':'open','subscribe':True,
'event_id':ids[0],
})
self.write(cr,uid,ids,{'subscribe':True})
return True
def unsubscribe_to_event(self,cr,uid,ids,context=None):
register_pool = self.pool.get('event.registration')
curr_reg_id = register_pool.search(cr,uid,[('user_id','=',uid),('event_id','=',ids[0])])
if curr_reg_id:
register_pool.write(cr, uid, curr_reg_id,{'state':'draft',
'event_id':ids[0],
'subscribe':False
})
self.write(cr,uid,ids,{'subscribe':False})
return True
def _check_closing_date(self, cr, uid, ids, context=None):
for event in self.browse(cr, uid, ids, context=context):
@ -239,7 +290,8 @@ class event_registration(osv.osv):
('open', 'Confirmed'),
('cancel', 'Cancelled'),
('done', 'Attended')], 'State',
size=16, readonly=True)
size=16, readonly=True),
'subscribe': fields.boolean('Subscribe'),
}
_defaults = {

View File

@ -156,6 +156,70 @@
</tree>
</field>
</record>
<!-- Event Kanban View -->
<record model="ir.ui.view" id="view_event_kanban">
<field name="name">event.event.kanban</field>
<field name="model">event.event</field>
<field name="type">kanban</field>
<field name="arch" type="xml">
<kanban>
<field name="register_max"/>
<field name="type"/>
<field name="user_id"/>
<field name="register_current"/>
<field name="subscribe"/>
<field name="country_id"/>
<field name="date_begin"/>
<field name="register_avail"/>
<templates>
<t t-name="kanban-box">
<div class="oe_module_vignette">
<a type="edit" class="oe_module_icon">
<div class="oe_event_date "><t t-esc="record.date_begin.raw_value.getDate()"/></div>
<div class="oe_event_month_year">
<t t-esc="record.date_begin.raw_value.toString('MMM')"/>
<t t-esc="record.date_begin.raw_value.getFullYear()"/>
</div>
<div class="oe_event_time"><t t-esc="record.date_begin.raw_value.toString('hh:mm tt')"/></div>
</a>
<div class="oe_module_desc">
<h4><a type="edit"><field name="name"/></a></h4>
<p>
<t t-if="record.country_id.raw_value">@<field name="country_id"/><br/></t>
<t t-if="record.user_id.raw_value">Organized by <field name="user_id"/><br/></t>
<t t-if="record.register_avail.raw_value lte 10">
<t t-if="record.register_avail.raw_value != 0">
<i><b><field name="register_avail"/></b></i>
<i>
<t t-if="record.register_avail.raw_value > 1">seats </t>
<t t-if="record.register_avail.raw_value == 1 || !record.register_avail.raw_value > 1">seat </t>available.
</i>
</t>
</t>
</p>
<t t-if="record.register_avail.raw_value != 0">
<t t-if="!record.subscribe.raw_value">
<button type="object" name="subscribe_to_event" class="subscribe_button oe_event_button_subscribe">
<span>Subscribe</span>
<span class="subscribe">UnSubscribe</span>
</button>
</t>
</t>
<t t-if="record.subscribe.raw_value">
<button type="object" name="unsubscribe_to_event" class="unsubscribe_button oe_event_button_unsubscribe">
<span>UnSubscribe</span>
<span class="unsubscribe">Subscribe</span>
</button>
</t>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<!-- Events Calendar View -->
@ -199,6 +263,10 @@
<filter icon="terp-check" string="Unconfirmed" name="draft" domain="[('state','=','draft')]" help="Events in New state"/>
<filter icon="terp-camera_test" string="Confirmed" domain="[('state','=','confirm')]" help="Confirmed events"/>
<separator orientation="vertical"/>
<filter icon="terp-go-today" string="Up Coming"
name="upcoming"
domain="[('date_begin','&gt;=', time.strftime('%%Y-%%m-%%d 00:00:00'))]"
help="Up Coming Events" />
<field name="name"/>
<field name="type" widget="selection"/>
<field name="user_id" widget="selection">
@ -229,7 +297,8 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">event.event</field>
<field name="view_type">form</field>
<field name="view_mode">calendar,tree,form,graph</field>
<field name="view_mode">kanban,calendar,tree,form,graph</field>
<field name="context">{"search_default_upcoming":1}</field>
<field name="search_view_id" ref="view_event_search"/>
<field name="help">Event is the low level object used by meeting and others documents that should be synchronized with mobile devices or calendar applications through caldav. Most of the users should work in the Calendar menu, and not in the list of events.</field>
</record>

View File

@ -0,0 +1,83 @@
.oe_event_date{
border-top-left-radius:3px;
border-top-right-radius:3px;
font-size: 48px;
height: auto;
font-weight: bold;
text-align: center;
margin-bottom:-7px;
color: #FFFFFF;
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
background-color: #8A89BA;
}
.oe_event_time{
border-bottom-left-radius:3px;
border-bottom-right-radius:3px;
font-size: 12px;
text-align: center;
font-weight: bold;
color: #8A89BA;
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
background-color: #FFFFFF;
}
.oe_event_month_year{
border-bottom-left-radius:3px;
border-bottom-right-radius:3px;
font-size: 12px;
text-align: center;
font-weight: bold;
color: #FFFFFF;
background-color: #8A89BA;
}
div.oe_fold_column{
padding:0px !important;
}
.oe_event_button_subscribe{
display: block;
border: 1px solid #404040;
color: #404040;
font-size: 10px;
text-align: center;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-ms-border-radius: 3px;
border-radius: 3px;
}
.oe_event_button_unsubscribe{
display: block;
border: 1px solid #404040;
color: #FFFFFF;
background-color:#DC5F59;
font-size: 10px;
text-align: center;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-ms-border-radius: 3px;
border-radius: 3px;
}
.oe_event_button_subscribe:hover {
cursor: pointer;
background-color: #DC5F59;
}
.oe_event_button_unsubscribe:hover {
cursor: pointer;
background-color: #404040;
}
.subscribe, .subscribe_button:hover span {
display: none;
background-color: #DC5F59;
}
.subscribe_button:hover .subscribe {
display: inline;
background-color: #DC5F59;
}
.unsubscribe, .unsubscribe_button:hover span {
display: none;
}
.unsubscribe_button:hover .unsubscribe {
display: inline;
background-color: #404040;
}