[IMP]improve view of contract and open chatter notification added when state changed
authorSanjay Gohel (Open ERP) <sgo@tinyerp.com>
Fri, 22 Jun 2012 09:10:08 +0000 (14:40 +0530)
committerSanjay Gohel (Open ERP) <sgo@tinyerp.com>
Fri, 22 Jun 2012 09:10:08 +0000 (14:40 +0530)
bzr revid: sgo@tinyerp.com-20120622091008-uy805uph0hz4vk0h

addons/account_analytic_analysis/account_analytic_analysis.py
addons/account_analytic_analysis/account_analytic_analysis_view.xml
addons/analytic/analytic.py
addons/analytic/analytic_view.xml
addons/hr_timesheet_invoice/hr_timesheet_invoice.py

index c4ae080..0ac783a 100644 (file)
@@ -494,7 +494,6 @@ class account_analytic_account(osv.osv):
         res['value']['pricelist_id'] = template.pricelist_id.id
         res['value']['description'] = template.description
         return res
-
 account_analytic_account()
 
 class account_analytic_account_summary_user(osv.osv):
index a607643..70f4d49 100644 (file)
@@ -23,7 +23,7 @@
                 <xpath expr='//field[@name="type"]' position='after'>
                     <field name="template_id" on_change="on_change_template(template_id,context)"  domain="[('type','=','template')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/>
                 </xpath>
-                <xpath expr='//field[@name="date"]' position="after" version="7.0">
+                <xpath expr='//div[@name="duration"]' position="after" version="7.0">
                     <label for="quantity_max"/>
                     <div>
                         <field name="quantity_max" class="oe_form_inline"/> / Remaining:
index cb5ab3e..35acc4a 100644 (file)
@@ -272,7 +272,20 @@ class account_analytic_account(osv.osv):
         else:
             account = self.search(cr, uid, args, limit=limit, context=context)
         return self.name_get(cr, uid, account, context=context)
-
+    
+    def create(self, cr, uid, vals, context=None):
+        contract =  super(account_analytic_account, self).create(cr, uid, vals, context=context)
+        if contract:
+            self.create_send_note(cr, uid, [contract], context=context)
+        return contract
+    # ------------------------------------------------
+    # OpenChatter methods and notifications
+    # ------------------------------------------------
+    def create_send_note(self, cr, uid, ids, context=None):
+        for obj in self.browse(cr, uid, ids, context=context):
+            self.message_subscribe(cr, uid, [obj.id], [obj.user_id.id], context=context)
+            self.message_append_note(cr, uid, [obj.id], body=_("Contract for <em>%s</em> has been <b>created</b>.") % (obj.partner_id.name), context=context)
+            
 account_analytic_account()
 
 
index f19eaf1..4fa01a9 100644 (file)
                             <page string="Contract Information" name="contract_page" attrs="{'invisible':[('type','not in',['contract', 'template'])]}">
                                 <group name="master">
                                     <group string="Validity" name="contract">
-                                        <field name="date_start"/>
-                                        <field name="date"/>
+                                        <label string="Duration"/>
+                                        <div name="duration">
+                                            <field name="date_start"/> - <field name="date"/>
+                                        </div>
                                     </group>
                                     <group name="project">
                                         <separator string="Project Management" name="project_sep" invisible="1"/>
index 48282a8..8701210 100644 (file)
@@ -94,16 +94,40 @@ class account_analytic_account(osv.osv):
         return res
 
     def set_close(self, cr, uid, ids, context=None):
-        return self.write(cr, uid, ids, {'state':'close'}, context=context)
+        self.write(cr, uid, ids, {'state':'close'}, context=context)
+        self.set_close_send_note(cr, uid, ids, context)
+        return True
 
     def set_cancel(self, cr, uid, ids, context=None):
-        return self.write(cr, uid, ids, {'state':'cancelled'}, context=context)
+        self.write(cr, uid, ids, {'state':'cancelled'}, context=context)
+        self.set_cancel_send_note(cr, uid, ids, context)
+        return True
 
     def set_open(self, cr, uid, ids, context=None):
-        return self.write(cr, uid, ids, {'state':'open'}, context=context)
+        self.write(cr, uid, ids, {'state':'open'}, context=context)
+        self.set_open_send_note(cr, uid, ids, context)
+        return True
 
     def set_pending(self, cr, uid, ids, context=None):
-        return self.write(cr, uid, ids, {'state':'pending'}, context=context)
+        self.write(cr, uid, ids, {'state':'pending'}, context=context)
+        self.set_pending_send_note(cr, uid, ids, context)
+        return True
+    
+    def set_open_send_note(self, cr, uid, ids, context=None):
+        message = _("Contract has been <b>opened</b>.")
+        return self.message_append_note(cr, uid, ids, body=message, context=context)
+    
+    def set_close_send_note(self, cr, uid, ids, context=None):
+        message = _("Contract has been <b>closed</b>.")
+        return self.message_append_note(cr, uid, ids, body=message, context=context)
+    
+    def set_cancel_send_note(self, cr, uid, ids, context=None):
+        message = _("Contract has been <b>cancelled</b>.")
+        return self.message_append_note(cr, uid, ids, body=message, context=context)
+
+    def set_pending_send_note(self, cr, uid, ids, context=None):
+        message = _("Contract has been <b>pending</b>.")
+        return self.message_append_note(cr, uid, ids, body=message, context=context)
 
 account_analytic_account()