[MERGE] merged trunk.
authorVo Minh Thu <vmt@openerp.com>
Mon, 10 Dec 2012 11:16:54 +0000 (12:16 +0100)
committerVo Minh Thu <vmt@openerp.com>
Mon, 10 Dec 2012 11:16:54 +0000 (12:16 +0100)
bzr revid: vmt@openerp.com-20121210111654-0pm3pupnqqeip52n

63 files changed:
1  2 
addons/account/account.py
addons/account/account_invoice.py
addons/account/account_move_line.py
addons/account/partner.py
addons/account/report/account_financial_report.py
addons/account/report/account_report.py
addons/account/wizard/account_invoice_refund.py
addons/account/wizard/account_report_common.py
addons/account_asset/account_asset.py
addons/account_followup/account_followup.py
addons/account_followup/report/account_followup_print.py
addons/account_followup/tests/test_account_followup.py
addons/account_followup/wizard/account_followup_print.py
addons/anonymization/anonymization.py
addons/audittrail/audittrail.py
addons/base_report_designer/wizard/base_report_designer_modify.py
addons/base_setup/res_config.py
addons/crm/crm.py
addons/crm/crm_lead.py
addons/crm/crm_phonecall.py
addons/crm/res_partner.py
addons/crm/wizard/crm_lead_to_opportunity.py
addons/crm/wizard/crm_merge_opportunities.py
addons/crm/wizard/crm_partner_binding.py
addons/delivery/sale.py
addons/document/document_directory.py
addons/document/document_storage.py
addons/event_sale/event_sale.py
addons/fetchmail/fetchmail.py
addons/fleet/fleet.py
addons/google_docs/google_docs.py
addons/hr/hr.py
addons/hr_attendance/hr_attendance.py
addons/hr_evaluation/hr_evaluation.py
addons/hr_holidays/hr_holidays.py
addons/hr_timesheet_invoice/hr_timesheet_invoice.py
addons/hr_timesheet_sheet/hr_timesheet_sheet.py
addons/l10n_be/wizard/l10n_be_vat_intra.py
addons/l10n_be_coda/l10n_be_coda.py
addons/l10n_be_coda/wizard/account_coda_import.py
addons/l10n_ch/report/report_webkit_html.py
addons/mail/wizard/invite.py
addons/membership/membership.py
addons/mrp_byproduct/mrp_byproduct.py
addons/portal/wizard/portal_wizard.py
addons/portal_hr_employees/hr_employee.py
addons/portal_sale/sale.py
addons/product/product.py
addons/product_margin/product_margin.py
addons/project/project.py
addons/project_issue/project_issue.py
addons/project_issue/report/project_issue_report.py
addons/purchase/purchase.py
addons/purchase_double_validation/purchase_double_validation_installer.py
addons/report_webkit/webkit_report.py
addons/resource/resource.py
addons/sale/sale.py
addons/share/wizard/share_wizard.py
addons/stock/stock.py
addons/stock/wizard/stock_partial_picking.py
addons/stock_location/stock_location.py
addons/survey/report/survey_form.py
addons/survey/wizard/survey_answer.py

Simple merge
Simple merge
Simple merge
Simple merge
@@@ -22,8 -22,9 +22,9 @@@
  import time
  from lxml import etree
  
 -from osv import fields, osv
 -from tools.translate import _
 +from openerp.osv import fields, osv
+ from openerp.osv.orm import setup_modifiers
 +from openerp.tools.translate import _
  
  class account_common_report(osv.osv_memory):
      _name = "account.common.report"
Simple merge
  #
  ##############################################################################
  
 -from osv import fields, osv
 +from openerp.osv import fields, osv
  from lxml import etree
  
 -from tools.translate import _
 +from openerp.tools.translate import _
  
  class followup(osv.osv):
      _name = 'account_followup.followup'
      _description = 'Account Follow-up'
  
  import time
  
 -import pooler
 -from report import report_sxw
 +from openerp import pooler
 +from openerp.report import report_sxw
  
  class report_rappel(report_sxw.rml_parse):
+     _name = "account_followup.report.rappel"
      def __init__(self, cr, uid, name, context=None):
          super(report_rappel, self).__init__(cr, uid, name, context=context)
          self.localcontext.update({
Simple merge
Simple merge
  #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  #
  ##############################################################################
++
++import base64
  import time
- from openerp import wizard
- from openerp import osv
- from openerp import pooler
 -import osv
 -import pooler
  import urllib
--import base64
- from openerp import tools
- from openerp.tools.translate import _
 -import tools
 -from tools.translate import _
 -from osv import osv, fields
++
++from openerp import osv, pooler, tools
 +from openerp.osv import fields, osv
++from openerp.tools.translate import _
  
  class base_report_sxw(osv.osv_memory):
      """Base Report sxw """
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
  #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  #
  ##############################################################################
 -from osv import osv, fields
 -from tools.translate import _
 +from openerp.osv import fields, osv
 +from openerp.tools.translate import _
  
  class crm_merge_opportunity(osv.osv_memory):
-     """Merge two Opportunities"""
+     """
+     Merge opportunities together.
+     If we're talking about opportunities, it's just because it makes more sense
+     to merge opps than leads, because the leads are more ephemeral objects.
+     But since opportunities are leads, it's also possible to merge leads
+     together (resulting in a new lead), or leads and opps together (resulting
+     in a new opp).
+     """
  
      _name = 'crm.merge.opportunity'
-     _description = 'Merge two Opportunities'
+     _description = 'Merge opportunities'
+     _columns = {
+         'opportunity_ids': fields.many2many('crm.lead', rel='merge_opportunity_rel', id1='merge_id', id2='opportunity_id', string='Leads/Opportunities'),
+     }
  
      def action_merge(self, cr, uid, ids, context=None):
          if context is None:
index 0000000,bc686db..efef0fa
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,115 +1,115 @@@
+ # -*- coding: utf-8 -*-
+ ##############################################################################
+ #
+ #    OpenERP, Open Source Management Solution
+ #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+ #
+ #    This program is free software: you can redistribute it and/or modify
+ #    it under the terms of the GNU Affero General Public License as
+ #    published by the Free Software Foundation, either version 3 of the
+ #    License, or (at your option) any later version.
+ #
+ #    This program is distributed in the hope that it will be useful,
+ #    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #    GNU Affero General Public License for more details.
+ #
+ #    You should have received a copy of the GNU Affero General Public License
+ #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ #
+ ##############################################################################
 -from osv import osv, fields
 -from tools.translate import _
++from openerp.osv import fields, osv
++from openerp.tools.translate import _
+ class crm_partner_binding(osv.osv_memory):
+     """
+     Handle the partner binding or generation in any CRM wizard that requires
+     such feature, like the lead2opportunity wizard, or the
+     phonecall2opportunity wizard.  Try to find a matching partner from the
+     CRM model's information (name, email, phone number, etc) or create a new
+     one on the fly.
+     Use it like a mixin with the wizard of your choice.
+     """
+     _name = 'crm.partner.binding'
+     _description = 'Handle partner binding or generation in CRM wizards.'
+     _columns = {
+         'action': fields.selection([
+                 ('exist', 'Link to an existing customer'),
+                 ('create', 'Create a new customer'),
+                 ('nothing', 'Do not link to a customer')
+             ], 'Related Customer', required=True),
+         'partner_id': fields.many2one('res.partner', 'Customer'),
+     }
+     def _find_matching_partner(self, cr, uid, context=None):
+         """
+         Try to find a matching partner regarding the active model data, like
+         the customer's name, email, phone number, etc.
+         :return int partner_id if any, False otherwise
+         """
+         if context is None:
+             context = {}
+         partner_id = False
+         partner_obj = self.pool.get('res.partner')
+         # The active model has to be a lead or a phonecall
+         if (context.get('active_model') == 'crm.lead') and context.get('active_id'):
+             active_model = self.pool.get('crm.lead').browse(cr, uid, context.get('active_id'), context=context)
+         elif (context.get('active_model') == 'crm.phonecall') and context.get('active_id'):
+             active_model = self.pool.get('crm.phonecall').browse(cr, uid, context.get('active_id'), context=context)
+         # Find the best matching partner for the active model
+         if (active_model):
+             partner_obj = self.pool.get('res.partner')
+             # A partner is set already
+             if active_model.partner_id:
+                 partner_id = active_model.partner_id.id
+             # Search through the existing partners based on the lead's email
+             elif active_model.email_from:
+                 partner_ids = partner_obj.search(cr, uid, [('email', '=', active_model.email_from)], context=context)
+                 if partner_ids:
+                     partner_id = partner_ids[0]
+             # Search through the existing partners based on the lead's partner or contact name
+             elif active_model.partner_name:
+                 partner_ids = partner_obj.search(cr, uid, [('name', 'ilike', '%'+active_model.partner_name+'%')], context=context)
+                 if partner_ids:
+                     partner_id = partner_ids[0]
+             elif active_model.contact_name:
+                 partner_ids = partner_obj.search(cr, uid, [
+                         ('name', 'ilike', '%'+active_model.contact_name+'%')], context=context)
+                 if partner_ids:
+                     partner_id = partner_ids[0]
+         return partner_id
+     def default_get(self, cr, uid, fields, context=None):
+         res = super(crm_partner_binding, self).default_get(cr, uid, fields, context=context)
+         partner_id = self._find_matching_partner(cr, uid, context=context)
+         if 'action' in fields:
+             res['action'] = partner_id and 'exist' or 'create'
+         if 'partner_id' in fields:
+             res['partner_id'] = partner_id
+         return res
+     def _create_partner(self, cr, uid, ids, context=None):
+         """
+         Create partner based on action.
+         :return dict: dictionary organized as followed: {lead_id: partner_assigned_id}
+         """
+         #TODO this method in only called by crm_lead2opportunity_partner
+         #wizard and would probably diserve to be refactored or at least
+         #moved to a better place
+         if context is None:
+             context = {}
+         lead = self.pool.get('crm.lead')
+         lead_ids = context.get('active_ids', [])
+         data = self.browse(cr, uid, ids, context=context)[0]
+         partner_id = data.partner_id and data.partner_id.id or False
+         return lead.handle_partner_assignation(cr, uid, lead_ids, data.action, partner_id, context=context)
+ # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
  #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  #
  ##############################################################################
+ import logging
  from datetime import datetime
 -from tools import DEFAULT_SERVER_DATETIME_FORMAT
 -from osv import osv, fields
 -from tools.translate import _
 +from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
 +from openerp.osv import fields, osv
 +from openerp.tools.translate import _
+ _logger = logging.getLogger(__name__)
  try:
      import gdata.docs.data
      import gdata.docs.client
diff --cc addons/hr/hr.py
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -29,22 -28,19 +28,20 @@@ from mako.lookup import TemplateLooku
  from mako import exceptions
  
  
 -from report import report_sxw
 -from report_webkit import webkit_report
 -from report_webkit import report_helper
 -from osv import osv
 -from osv.osv import except_osv
++from openerp import addons
++from openerp import pooler
 +from openerp.report import report_sxw
- from report_webkit import webkit_report
- from report_webkit import report_helper
  
 -from tools import mod10r
 -from tools.translate import _
 -from tools.config import config
 +from openerp.osv import osv
 +from openerp.osv.osv import except_osv
  
 -from openerp import addons
 -import pooler
 +from openerp.tools import mod10r
 +from openerp.tools.translate import _
 +from openerp.tools.config import config
 +
- from openerp import wizard
- from openerp import addons
- from openerp import pooler
++from openerp.addons.report_webkit import webkit_report
++from openerp.addons.report_webkit import report_helper
  
  
  class l10n_ch_report_webkit_html(report_sxw.rml_parse):
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge