Amit Patel (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-stages-clickable-apa-improve-sgo into 
lp:~openerp-dev/openobject-addons/trunk-stages-clickable-apa.

Requested reviews:
  Amit Patel (OpenERP) (apa-tiny)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-stages-clickable-apa-improve-sgo/+merge/117007

hello sir,

  I have made status bar clickable which are with stages not with states.
Remove all unnecessary button from project_task,project_issue,hr_recruitment 
and 
crm opprtunities. remove next previous button and do work all this on stage 
click.

Thank You.
Sanjay Gohel

-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-stages-clickable-apa-improve-sgo/+merge/117007
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-stages-clickable-apa.
=== modified file 'crm/crm_lead.py'
--- crm/crm_lead.py	2012-07-26 13:00:23 +0000
+++ crm/crm_lead.py	2012-07-27 05:33:09 +0000
@@ -282,9 +282,21 @@
         if not stage_id:
             return {'value':{}}
         stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context)
+        if stage.state == "draft":
+            return {'value':{'probability': 0.0}}
+        if stage.state == "open":
+            cases = self.browse(cr, uid, ids, context=context)
+            data = {'active': True}
+            for case in cases:
+                if case.stage_id and case.stage_id.state == 'draft':
+                    data['date_open'] = fields.datetime.now()
+                if not case.user_id:
+                    data['user_id'] = uid
+            return {'value':data}
         if not stage.on_change:
             return {'value':{}}
-        return {'value':{'probability': stage.probability}}
+        else:
+            return {'value':{'probability': stage.probability}}
 
     def _check(self, cr, uid, ids=False, context=None):
         """ Override of the base.stage method.

=== modified file 'crm/crm_lead_view.xml'
--- crm/crm_lead_view.xml	2012-07-26 13:00:23 +0000
+++ crm/crm_lead_view.xml	2012-07-27 05:33:09 +0000
@@ -428,26 +428,25 @@
         <field name="arch" type="xml">
             <form string="Opportunities" version="7.0">
                 <header>
+<<<<<<< TREE
                     <button name="stage_previous" string="Previous" type="object"
                             states="open" context="{'stage_type': 'opportunity'}"/>
                     <button name="stage_next" string="Next" type="object"  
                             states="open" context="{'stage_type': 'opportunity'}"/>
+=======
+>>>>>>> MERGE-SOURCE
                     <button name="case_mark_won" string="Mark Won" type="object"
                             states="open" class="oe_highlight"/>
                     <button name="case_mark_won" string="Mark Won" type="object"
                             states="draft,pending"/>
-                    <button name="case_open" string="Open" type="object" class="oe_highlight"
-                            states="draft,pending"/>
                     <button name="case_escalate" string="Escalate" type="object"
                             states="open" />
                     <button name="case_mark_lost" string="Mark Lost" type="object"
                             states="draft,open"/>
-                    <button name="case_reset" string="Reset to Draft" type="object"
-                            states="done,cancel" />
                     <button name="case_cancel" string="Cancel" type="object"
                             states="draft"/>
                     <field name="stage_id" widget="statusbar"
-                            on_change="onchange_stage_id(stage_id)"/>
+                            on_change="onchange_stage_id(stage_id)" clickable="1"/>
                 </header>
                 <sheet>
                     <div class="oe_right oe_button_box">

=== modified file 'hr_recruitment/hr_recruitment.py'
--- hr_recruitment/hr_recruitment.py	2012-07-25 15:27:34 +0000
+++ hr_recruitment/hr_recruitment.py	2012-07-27 05:33:09 +0000
@@ -242,6 +242,28 @@
     _group_by_full = {
         'stage_id': _read_group_stage_ids
     }
+    
+    def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
+        if context is None:
+            context = {}
+        if not stage_id:
+            return {'value':{}}
+        stage = self.pool.get('hr.recruitment.stage').browse(cr, uid, stage_id, context)
+        if stage.state == 'done':
+            context['onchange'] = True
+            self.case_close_with_emp(cr, uid, ids, context)
+        if stage.state == "draft":
+            return {'value':{'active': True,'date_open': False, 'date_closed': False}}
+        if stage.state == "open":
+            cases = self.browse(cr, uid, ids, context=context)
+            data = {'active': True}
+            for case in cases:
+                if case.stage_id and case.stage_id.state == 'draft':
+                    data['date_open'] = fields.datetime.now()
+                if not case.user_id:
+                    data['user_id'] = uid
+            return {'value':data}
+        return {'value':{}}
 
     def onchange_job(self,cr, uid, ids, job, context=None):
         result = {}
@@ -407,8 +429,11 @@
                                                      'address_home_id': address_id,
                                                      'department_id': applicant.department_id.id
                                                      })
-                self.write(cr, uid, [applicant.id], {'emp_id': emp_id}, context=context)
-                self.case_close(cr, uid, [applicant.id], context)
+                if context.get('onchange') == True:
+                    return {'value':{'emp_id': emp_id,'active': True, 'date_closed': fields.datetime.now()}}
+                else:
+                    self.write(cr, uid, [applicant.id], {'emp_id': emp_id}, context=context)
+                    self.case_close(cr, uid, [applicant.id], context)
             else:
                 raise osv.except_osv(_('Warning!'),_('You must define Applied Job for this applicant.'))
 

=== modified file 'hr_recruitment/hr_recruitment_view.xml'
--- hr_recruitment/hr_recruitment_view.xml	2012-07-24 06:01:14 +0000
+++ hr_recruitment/hr_recruitment_view.xml	2012-07-27 05:33:09 +0000
@@ -105,21 +105,28 @@
         <field name="arch" type="xml">
           <form string="Jobs - Recruitment Form" version="7.0">
             <header>
-                <button name="%(action_hr_recruitment_hired_employee)d" string="Hire" type="action"
+                <button name="case_close_with_emp" string="Hire" type="object"
                         states="open,pending" class="oe_highlight"/>
+<<<<<<< TREE
                 <button name="case_open" string="Open" type="object"
                         states="draft,pending" class="oe_highlight"/>
                 <button name="case_pending" string="Pending" type="object" invisible="1"
                         states="open"/>
                 <button name="case_reset" string="Reset to New" type="object"
                         states="done,cancel"/>
+=======
+>>>>>>> MERGE-SOURCE
                 <button name="case_cancel" string="Refuse" type="object"
                         states="draft,open,pending" class="oe_highlight"/>
+<<<<<<< TREE
                 <button name="stage_previous" string="Previous" type="object"
                         states="open"/>
                 <button name="stage_next" string="Next" type="object"
                         states="open"/>
                 <field name="stage_id" widget="statusbar"/>
+=======
+                <field name="stage_id" widget="statusbar" clickable="True" on_change="onchange_stage_id(stage_id)"/>
+>>>>>>> MERGE-SOURCE
             </header>
             <sheet>
                 <div class="oe_right oe_button_box">

=== modified file 'project/project_view.xml'
--- project/project_view.xml	2012-07-21 18:23:18 +0000
+++ project/project_view.xml	2012-07-27 05:33:09 +0000
@@ -402,18 +402,12 @@
                                     states="cancelled,done" context="{'button_reactivate':True}"/>
                             <button name="action_close" string="Done" type="object"
                                     states="draft,open,pending" class="oe_highlight"/>
-                            <button name="do_pending" string="Pending" type="object"
-                                    states="open"/>
                             <button name="%(action_project_task_delegate)d" string="Delegate" type="action"
                                     states="pending,open,draft" groups="project.group_delegate_task"/>
                             <button name="do_cancel" string="Cancel" type="object"
                                     states="draft,open,pending"/>
-                            <button name="stage_previous" string="Previous Stage" type="object"
-                                    states="open,pending" icon="gtk-go-back" attrs="{'invisible': [('stage_id','=', False)]}"/>
-                            <button name="stage_next" string="Next Stage" type="object" class="oe_highlight"
-                                    states="open,pending" icon="gtk-go-forward" attrs="{'invisible': [('stage_id','=', False)]}"/>
                         </span>
-                        <field name="stage_id" widget="statusbar"/>
+                        <field name="stage_id" widget="statusbar" clickable="True"/>
                     </header>
                     <sheet string="Task">
                     <label for="name" class="oe_edit_only"/>

=== modified file 'project_issue/project_issue.py'
--- project_issue/project_issue.py	2012-07-23 12:09:07 +0000
+++ project_issue/project_issue.py	2012-07-27 05:33:09 +0000
@@ -397,6 +397,25 @@
         res = super(project_issue, self).case_reset(cr, uid, ids, context)
         self.write(cr, uid, ids, {'date_open': False, 'date_closed': False})
         return res
+    
+    def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
+        if context is None:
+            context = {}
+        if not stage_id:
+            return {'value':{}}
+        stage = self.pool.get('project.task.type').browse(cr, uid, stage_id, context)
+        if stage.state == "draft":
+            return {'value':{'active': True,'date_open': False, 'date_closed': False}}
+        if stage.state == "open":
+            cases = self.browse(cr, uid, ids, context=context)
+            data = {'active': True}
+            for case in cases:
+                if case.stage_id and case.stage_id.state == 'draft':
+                    data['date_open'] = fields.datetime.now()
+                if not case.user_id:
+                    data['user_id'] = uid
+            return {'value':data}
+        return {'value':{}}
 
     def create(self, cr, uid, vals, context=None):
         obj_id = super(project_issue, self).create(cr, uid, vals, context=context)

=== modified file 'project_issue/project_issue_view.xml'
--- project_issue/project_issue_view.xml	2012-07-13 14:26:22 +0000
+++ project_issue/project_issue_view.xml	2012-07-27 05:33:09 +0000
@@ -93,28 +93,16 @@
                 <form version="7.0">
                 <header>
                     <span groups="base.group_user">
-                        <button name="case_open" string="Open" type="object"
-                                states="draft,pending" class="oe_highlight"/>
                         <button name="case_close" string="Done" type="object"
                                 states="open"/>
                          <button name="case_close" string="Done" type="object"
                                 states="draft,pending"/>
-                        <button name="case_pending" string="Pending" type="object"
-                                states="draft,open"/>
                         <button name="case_escalate" string="Escalate" type="object"
                                 states="draft,open,pending"/>
-                        <button name="case_reset" string="Reset to New" type="object"
-                                states="cancelled,done"/>
-                        <button name="stage_previous" string="Previous Stage" type="object"
-                                states="open,pending" icon="gtk-go-back"
-                                attrs="{'invisible': [('stage_id','=', False)]}"/>
-                        <button name="stage_next" string="Next Stage" type="object"
-                                states="open,pending" icon="gtk-go-forward"
-                                attrs="{'invisible': [('stage_id','=', False)]}"/>
                         <button name="case_cancel" string="Cancel" type="object"
                                 states="draft,open,pending"/>
                     </span>
-                    <field name="stage_id" widget="statusbar"/>
+                    <field name="stage_id" widget="statusbar" on_change="onchange_stage_id(stage_id)" clickable="1"/>
                 </header>
                 <sheet string="Issue">
                     <label for="name" class="oe_edit_only"/>

_______________________________________________
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