← Back to team overview

openerp-india team mailing list archive

[Bug 938256] [NEW] base_contact wrong creation of res.partner.address record

 

Public bug reported:

In V6.1, with crm and base_contact installed: when you convert a lead
into an opportunity, the contact information is lost, and the created
res.partner.address has no associated res.partner.contact (name, mobile
and title info is lost)

The reason is an error on module base_contact, not creating the record
on create method overwrite

For sure is impacting on any module thats creates partner addresses not
aware of base_contact.

Correction is attached:

=== modified file 'base_contact/base_contact.py'
--- base_contact/base_contact.py	2012-02-15 13:22:13 +0000
+++ base_contact/base_contact.py	2012-02-21 22:22:13 +0000
@@ -220,6 +220,30 @@
                 'state_id': data.get('state_id',False)
             }, context=context)
             data['location_id'] = loc_id
+        if not data.get('contact_id', False):
+            first_name = ''
+            last_name = ''
+            if data.get('name', False):
+                name = data.get('name','').strip()
+                words = name.split(",")
+                if len(words) > 1:
+                    last_name = words[0].strip()
+                    first_name = ",".join(words[1:]).strip()
+                else:
+                    words = name.split(" ")
+                    if len(words) == 1:
+                        last_name = words[0].strip()
+                        first_name = ''
+                    else:
+                        first_name = words[0].strip()
+                        last_name = " ".join(words[1:]).strip()
+            contact_id = self.pool.get('res.partner.contact').create(cr, uid, {
+                'mobile': data.get('mobile',''),
+                'title': data.get('title',''),
+                'first_name': first_name,
+                'last_name': last_name,
+            }, context=context)
+            data['contact_id'] = contact_id
         result = super(res_partner_address, self).create(cr, uid, data, context=context)
         return result

** Affects: openobject-addons
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/938256

Title:
  base_contact wrong creation of res.partner.address record

Status in OpenERP Addons (modules):
  New

Bug description:
  In V6.1, with crm and base_contact installed: when you convert a lead
  into an opportunity, the contact information is lost, and the created
  res.partner.address has no associated res.partner.contact (name,
  mobile and title info is lost)

  The reason is an error on module base_contact, not creating the record
  on create method overwrite

  For sure is impacting on any module thats creates partner addresses
  not aware of base_contact.

  Correction is attached:

  === modified file 'base_contact/base_contact.py'
  --- base_contact/base_contact.py	2012-02-15 13:22:13 +0000
  +++ base_contact/base_contact.py	2012-02-21 22:22:13 +0000
  @@ -220,6 +220,30 @@
                   'state_id': data.get('state_id',False)
               }, context=context)
               data['location_id'] = loc_id
  +        if not data.get('contact_id', False):
  +            first_name = ''
  +            last_name = ''
  +            if data.get('name', False):
  +                name = data.get('name','').strip()
  +                words = name.split(",")
  +                if len(words) > 1:
  +                    last_name = words[0].strip()
  +                    first_name = ",".join(words[1:]).strip()
  +                else:
  +                    words = name.split(" ")
  +                    if len(words) == 1:
  +                        last_name = words[0].strip()
  +                        first_name = ''
  +                    else:
  +                        first_name = words[0].strip()
  +                        last_name = " ".join(words[1:]).strip()
  +            contact_id = self.pool.get('res.partner.contact').create(cr, uid, {
  +                'mobile': data.get('mobile',''),
  +                'title': data.get('title',''),
  +                'first_name': first_name,
  +                'last_name': last_name,
  +            }, context=context)
  +            data['contact_id'] = contact_id
           result = super(res_partner_address, self).create(cr, uid, data, context=context)
           return result

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/938256/+subscriptions


Follow ups

References