[MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 9885 revid:dle@openerp.com...
authorDenis Ledoux <dle@openerp.com>
Mon, 10 Mar 2014 12:21:01 +0000 (13:21 +0100)
committerDenis Ledoux <dle@openerp.com>
Mon, 10 Mar 2014 12:21:01 +0000 (13:21 +0100)
bzr revid: dle@openerp.com-20140310122101-gicombyc5ii0yz6a

18 files changed:
1  2 
addons/account/account_view.xml
addons/base_calendar/base_calendar.py
addons/base_calendar/base_calendar_view.xml
addons/base_import/static/src/js/import.js
addons/crm/crm_lead.py
addons/crm/crm_phonecall_view.xml
addons/event/report/report_event_registration.py
addons/hr_expense/hr_expense.py
addons/hr_payroll_account/hr_payroll_account.py
addons/l10n_multilang/l10n_multilang.py
addons/mrp/mrp.py
addons/mrp_repair/__openerp__.py
addons/mrp_repair/mrp_repair.py
addons/product/pricelist.py
addons/product/product.py
addons/product/product_view.xml
addons/product_margin/product_margin.py
addons/sale/sale.py

Simple merge
Simple merge
@@@ -388,66 -423,38 +388,66 @@@ class crm_lead(format_address, osv.osv)
              return stage_ids[0]
          return False
  
 -    def case_cancel(self, cr, uid, ids, context=None):
 -        """ Overrides case_cancel from base_stage to set probability """
 -        res = super(crm_lead, self).case_cancel(cr, uid, ids, context=context)
 -        self.write(cr, uid, ids, {'probability' : 0.0}, context=context)
 -        return res
 -
 -    def case_reset(self, cr, uid, ids, context=None):
 -        """ Overrides case_reset from base_stage to set probability """
 -        res = super(crm_lead, self).case_reset(cr, uid, ids, context=context)
 -        self.write(cr, uid, ids, {'probability': 0.0}, context=context)
 -        return res
 -
      def case_mark_lost(self, cr, uid, ids, context=None):
 -        """ Mark the case as lost: state=cancel and probability=0 """
 -        for lead in self.browse(cr, uid, ids):
 -            stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 0.0),('on_change','=',True)], context=context)
 +        """ Mark the case as lost: state=cancel and probability=0
 +            :deprecated: this method will be removed in OpenERP v8.
 +        """
 +        stages_leads = {}
 +        for lead in self.browse(cr, uid, ids, context=context):
 +            stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 0.0), ('fold', '=', True), ('sequence', '>', 1)], context=context)
              if stage_id:
 -                self.case_set(cr, uid, [lead.id], values_to_update={'probability': 0.0, 'date_closed': fields.datetime.now()}, new_stage_id=stage_id, context=context)
 +                if stages_leads.get(stage_id):
 +                    stages_leads[stage_id].append(lead.id)
 +                else:
 +                    stages_leads[stage_id] = [lead.id]
 +            else:
 +                raise osv.except_osv(_('Warning!'),
 +                    _('To relieve your sales pipe and group all Lost opportunities, configure one of your sales stage as follow:\n'
 +                        'probability = 0 %, select "Change Probability Automatically".\n'
 +                        'Create a specific stage or edit an existing one by editing columns of your opportunity pipe.'))
 +        for stage_id, lead_ids in stages_leads.items():
-             self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context)
++            self.write(cr, uid, lead_ids, {'stage_id': stage_id, 'date_closed': fields.datetime.now()}, context=context)
          return True
  
      def case_mark_won(self, cr, uid, ids, context=None):
 -        """ Mark the case as won: state=done and probability=100 """
 -        for lead in self.browse(cr, uid, ids):
 -            stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 100.0),('on_change','=',True)], context=context)
 +        """ Mark the case as won: state=done and probability=100
 +            :deprecated: this method will be removed in OpenERP v8.
 +        """
 +        stages_leads = {}
 +        for lead in self.browse(cr, uid, ids, context=context):
 +            stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 100.0), ('fold', '=', True)], context=context)
              if stage_id:
 -                self.case_set(cr, uid, [lead.id], values_to_update={'probability': 100.0, 'date_closed': fields.datetime.now()}, new_stage_id=stage_id, context=context)
 +                if stages_leads.get(stage_id):
 +                    stages_leads[stage_id].append(lead.id)
 +                else:
 +                    stages_leads[stage_id] = [lead.id]
 +            else:
 +                raise osv.except_osv(_('Warning!'),
 +                    _('To relieve your sales pipe and group all Won opportunities, configure one of your sales stage as follow:\n'
 +                        'probability = 100 % and select "Change Probability Automatically".\n'
 +                        'Create a specific stage or edit an existing one by editing columns of your opportunity pipe.'))
 +        for stage_id, lead_ids in stages_leads.items():
-             self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context)
++            self.write(cr, uid, lead_ids, {'stage_id': stage_id, 'date_closed': fields.datetime.now()}, context=context)
 +        return True
 +
 +    def case_escalate(self, cr, uid, ids, context=None):
 +        """ Escalates case to parent level """
 +        for case in self.browse(cr, uid, ids, context=context):
 +            data = {'active': True}
 +            if case.section_id.parent_id:
 +                data['section_id'] = case.section_id.parent_id.id
 +                if case.section_id.parent_id.change_responsible:
 +                    if case.section_id.parent_id.user_id:
 +                        data['user_id'] = case.section_id.parent_id.user_id.id
 +            else:
 +                raise osv.except_osv(_('Error!'), _("You are already at the top level of your sales-team category.\nTherefore you cannot escalate furthermore."))
 +            self.write(cr, uid, [case.id], data, context=context)
          return True
  
 -    def set_priority(self, cr, uid, ids, priority):
 +    def set_priority(self, cr, uid, ids, priority, context=None):
          """ Set lead priority
          """
 -        return self.write(cr, uid, ids, {'priority' : priority})
 +        return self.write(cr, uid, ids, {'priority': priority}, context=context)
  
      def set_high_priority(self, cr, uid, ids, context=None):
          """ Set lead priority to high
Simple merge
Simple merge
@@@ -27,8 -27,10 +27,9 @@@ from openerp.osv import fields, osv, or
  from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP
  from openerp.tools import float_compare
  from openerp.tools.translate import _
 -from openerp import netsvc
 -from openerp import tools
 +from openerp import tools, SUPERUSER_ID
  from openerp import SUPERUSER_ID
+ from openerp.addons.product import _common
  
  #----------------------------------------------------------
  # Work Centers
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge