[MERGE] Merge event changes for openchatter

bzr revid: sbh@tinyerp.com-20120514113218-4026sf5jlu5cx0fx
This commit is contained in:
Sbh (Openerp) 2012-05-14 17:02:18 +05:30
commit cc2570dc05
2 changed files with 93 additions and 3 deletions

View File

@ -48,6 +48,7 @@ class event_event(osv.osv):
_name = 'event.event'
_description = __doc__
_order = 'date_begin'
_inherit = ['ir.needaction_mixin','mail.thread']
def name_get(self, cr, uid, ids, context=None):
if not ids:
@ -70,6 +71,11 @@ class event_event(osv.osv):
res = self.name_get(cr, uid, ids, context=context)
return dict(res)
def create(self, cr, uid, vals, context=None):
obj_id = super(event_event, self).create(cr, uid, vals, context)
self.create_send_note(cr, uid, [obj_id], context=context)
return obj_id
def copy(self, cr, uid, id, default=None, context=None):
""" Reset the state and the registrations while copying an event
"""
@ -82,6 +88,7 @@ class event_event(osv.osv):
return super(event_event, self).copy(cr, uid, id, default=default, context=context)
def button_draft(self, cr, uid, ids, context=None):
self.button_draft_send_note(cr, uid, ids, context=context)
return self.write(cr, uid, ids, {'state': 'draft'}, context=context)
def button_cancel(self, cr, uid, ids, context=None):
@ -91,9 +98,11 @@ class event_event(osv.osv):
if event_reg.state == 'done':
raise osv.except_osv(_('Error!'),_("You have already set a registration for this event as 'Attended'. Please reset it to draft if you want to cancel this event.") )
registration.write(cr, uid, reg_ids, {'state': 'cancel'}, context=context)
self.button_cancel_send_note(cr, uid, ids, context=context)
return self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
def button_done(self, cr, uid, ids, context=None):
self.button_done_send_note(cr, uid, ids, context=context)
return self.write(cr, uid, ids, {'state': 'done'}, context=context)
def check_registration_limits(self, cr, uid, ids, context=None):
@ -119,6 +128,7 @@ class event_event(osv.osv):
if isinstance(ids, (int, long)):
ids = [ids]
self.check_registration_limits(cr, uid, ids, context=context)
self.button_confirm_send_note(cr, uid, ids, context=context)
return self.confirm_event(cr, uid, ids, context=context)
def _get_register(self, cr, uid, ids, fields, args, context=None):
@ -248,13 +258,55 @@ class event_event(osv.osv):
'register_max': type_info.default_registration_max,
}
return {'value': dic}
# ----------------------------------------
# OpenChatter methods and notifications
# ----------------------------------------
def get_needaction_user_ids(self, cr, uid, ids, context=None):
result = dict.fromkeys(ids, [])
for obj in self.browse(cr, uid, ids, context=context):
if obj.state == 'draft' and obj.user_id:
result[obj.id] = [obj.user_id.id]
return result
def create_send_note(self, cr, uid, ids, context=None):
for id in ids:
message = _("Event has been <b>created</b>.")
self.message_append_note(cr, uid, [id], body=message, context=context)
return True
def button_cancel_send_note(self, cr, uid, ids, context=None):
for id in ids:
message = _("Event has been <b>cancelled</b>.")
self.message_append_note(cr, uid, [id], body=message, context=context)
return True
def button_draft_send_note(self, cr, uid, ids, context=None):
for id in ids:
message = _("Event has been set to <b>draft</b>.")
self.message_append_note(cr, uid, [id], body=message, context=context)
return True
def button_done_send_note(self, cr, uid, ids, context=None):
for id in ids:
message = _("Event has been <b>done</b>.")
self.message_append_note(cr, uid, [id], body=message, context=context)
return True
def button_confirm_send_note(self, cr, uid, ids, context=None):
for id in ids:
message = _("Event has been <b>confirmed</b>.")
self.message_append_note(cr, uid, [id], body=message, context=context)
return True
event_event()
class event_registration(osv.osv):
"""Event Registration"""
_name= 'event.registration'
_description = __doc__
_inherit = ['mail.thread','res.partner']
_inherit = ['ir.needaction_mixin','mail.thread','res.partner']
_columns = {
'id': fields.integer('ID'),
'origin': fields.char('Origin', size=124,readonly=True,help="Name of the sale order which create the registration"),
@ -285,12 +337,17 @@ class event_registration(osv.osv):
def do_draft(self, cr, uid, ids, context=None):
self.do_draft_send_note(cr, uid, ids, context=context)
return self.write(cr, uid, ids, {'state': 'draft'}, context=context)
def confirm_registration(self, cr, uid, ids, context=None):
self.message_append(cr, uid, ids,_('State set to open'),body_text= _('Open'))
return self.write(cr, uid, ids, {'state': 'open'}, context=context)
def create(self, cr, uid, vals, context=None):
obj_id = super(event_registration, self).create(cr, uid, vals, context)
self.create_send_note(cr, uid, [obj_id], context=context)
return obj_id
def registration_open(self, cr, uid, ids, context=None):
""" Open Registration
@ -382,6 +439,29 @@ class event_registration(osv.osv):
data.update(d['value'])
return {'value': data}
# ----------------------------------------
# OpenChatter methods and notifications
# ----------------------------------------
def get_needaction_user_ids(self, cr, uid, ids, context=None):
result = dict.fromkeys(ids, [])
for obj in self.browse(cr, uid, ids, context=context):
if obj.state == 'draft' and obj.user_id:
result[obj.id] = [obj.user_id.id]
return result
def create_send_note(self, cr, uid, ids, context=None):
for id in ids:
message = _("Registration has been <b>created</b>.")
self.message_append_note(cr, uid, [id], body=message, context=context)
return True
def do_draft_send_note(self, cr, uid, ids, context=None):
for id in ids:
message = _("Registration has been <b>draft</b>.")
self.message_append_note(cr, uid, [id], body=message, context=context)
return True
event_registration()

View File

@ -50,7 +50,8 @@
<field name="model">event.event</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Events">
<form string="Events" layout="manual">
<sheet layout="auto">
<group col="6" colspan="4">
<field name="name"/>
<field name="date_begin"/>
@ -127,6 +128,10 @@
</group>
</page>
</notebook>
</sheet>
<div class="oe_form_sheet_width">
<field name="message_ids" colspan="4" widget="ThreadView" nolabel="1"/>
</div>
</form>
</field>
</record>
@ -353,7 +358,8 @@
<field name="model">event.registration</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Registration">
<form string="Registration" layout="manual">
<sheet layout="auto">
<group col="6" colspan="4">
<field name="event_id" on_change="onchange_event(event_id, context)" domain="[('state','in',('draft','confirm'))]"/>
<field name="partner_id" attrs="{'readonly':[('state','!=', 'draft')]}" on_change="onchange_partner_id(partner_id, context)"/>
@ -406,6 +412,10 @@
</page>
</notebook>
</sheet>
<div class="oe_form_sheet_width">
<field name="message_ids" colspan="4" widget="ThreadView" nolabel="1"/>
</div>
</form>
</field>
</record>