Turkesh Patel (openERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-social-event-kjo into 
lp:~openerp-dev/openobject-addons/trunk-openchatter.

Requested reviews:
  OpenERP R&D Team (openerp-dev)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-social-event-kjo/+merge/103413

                         
                         event
=====================================================

[IMP]: added OpenChatter feature in the event module
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-social-event-kjo/+merge/103413
Your team OpenERP R&D Team is requested to review the proposed merge of 
lp:~openerp-dev/openobject-addons/trunk-social-event-kjo into 
lp:~openerp-dev/openobject-addons/trunk-openchatter.
=== modified file 'event/event.py'
--- event/event.py	2012-03-30 09:08:37 +0000
+++ event/event.py	2012-04-25 06:15:24 +0000
@@ -48,6 +48,7 @@
     _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 @@
         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 @@
         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 @@
             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 @@
         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,56 @@
               '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):
+            # salesman must perform an action when in draft mode
+            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>cancel</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 <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>confirm</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 +338,17 @@
 
 
     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 +440,30 @@
             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):
+            # salesman must perform an action when in draft mode
+            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 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 = _("Event Registration has been <b>draft</b>.")
+            self.message_append_note(cr, uid, [id], body=message, context=context)
+        return True
+
 event_registration()
 
 

=== modified file 'event/event_view.xml'
--- event/event_view.xml	2012-04-02 08:57:18 +0000
+++ event/event_view.xml	2012-04-25 06:15:24 +0000
@@ -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_social" 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_social" colspan="4" widget="ThreadView" nolabel="1"/>
+                    </div>
                 </form>
             </field>
         </record>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to