Merge lp://qastaging/~vrt-openerp/domsense-agilebg-addons/6.1-addons into lp://qastaging/domsense-agilebg-addons/6.1

Proposed by Lorenzo Battistini
Status: Merged
Merged at revision: 162
Proposed branch: lp://qastaging/~vrt-openerp/domsense-agilebg-addons/6.1-addons
Merge into: lp://qastaging/domsense-agilebg-addons/6.1
Diff against target: 203 lines (+120/-6)
7 files modified
crm_base_contact/__init__.py (+1/-0)
crm_base_contact/__openerp__.py (+1/-0)
crm_base_contact/crm_lead.py (+90/-0)
crm_base_contact/crm_lead_view.xml (+20/-0)
crm_base_contact/wizard/crm_lead_to_opportunity.py (+3/-2)
crm_base_contact/wizard/crm_lead_to_partner.py (+3/-2)
crm_base_contact/wizard/crm_phonecall_to_partner.py (+2/-2)
To merge this branch: bzr merge lp://qastaging/~vrt-openerp/domsense-agilebg-addons/6.1-addons
Reviewer Review Type Date Requested Status
Lorenzo Battistini Approve
Stuart Longland (community) fixed Needs Resubmitting
Review via email: mp+96202@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Lorenzo Battistini (elbati) wrote :

Hello Stuart,
in your branch you 'import crm_lead' and include 'crm_lead_view.xml' in __openerp__.py but I can't find those files in your branch.
Do they need to be added?

review: Needs Information
Revision history for this message
Stuart Longland (redhatter) wrote :

On 07/03/12 04:28, Lorenzo Battistini - Agile BG - Domsense wrote:
> Review: Needs Information
>
> Hello Stuart,
> in your branch you 'import crm_lead' and include 'crm_lead_view.xml' in __openerp__.py but I can't find those files in your branch.
> Do they need to be added?

Hi,
 I'll check, but yes, they should be there, so if they're absent,
that'll be a blooper on my part. :-)
--
Stuart Longland (aka Redhatter, VK4MSL) .'''.
Gentoo Linux/MIPS Cobalt and Docs Developer '.'` :
. . . . . . . . . . . . . . . . . . . . . . .'.'
http://dev.gentoo.org/~redhatter :.'

I haven't lost my mind...
  ...it's backed up on a tape somewhere.

Revision history for this message
Stuart Longland (redhatter) wrote :

On 07/03/12 06:01, Stuart Longland wrote:
> On 07/03/12 04:28, Lorenzo Battistini - Agile BG - Domsense wrote:
>> in your branch you 'import crm_lead' and include 'crm_lead_view.xml' in __openerp__.py but I can't find those files in your branch.
>> Do they need to be added?
> I'll check, but yes, they should be there, so if they're absent,
> that'll be a blooper on my part. :-)

Okay, they're in now. Apologies for the mixup. :-)
--
Stuart Longland (aka Redhatter, VK4MSL) .'''.
Gentoo Linux/MIPS Cobalt and Docs Developer '.'` :
. . . . . . . . . . . . . . . . . . . . . . .'.'
http://dev.gentoo.org/~redhatter :.'

I haven't lost my mind...
  ...it's backed up on a tape somewhere.

162. By Stuart Longland

Add missing files

Revision history for this message
Stuart Longland (redhatter) wrote :

A heads up with this update; the OpenERP system will drop the contact_name column of the table with potential data loss on application of this update.

One can rescue the data and migrate the schema over ahead of time by running the following SQL against the database:

-- crm improvements; add contact_first_name and contact_last_name --
ALTER TABLE crm_lead ADD COLUMN contact_first_name VARCHAR(64);
ALTER TABLE crm_lead ADD COLUMN contact_last_name VARCHAR(64);
UPDATE crm_lead
SET contact_first_name=TRIM(SUBSTRING(contact_name FROM E'^[^ ]+')),
        contact_last_name=TRIM(SUBSTRING(contact_name FROM E' .+$'));

163. By Stuart Longland

crm_base_contact: Refactor crm.lead._name_get_full

This makes it more resillient to glitches such as having only a first name
entered into the leads database. Prior to conversion to an opportunity, the
lead will need both first and last names filled in, but until then, it should
be possible for the user to enter in only one, or even neither.

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Hello Stuart,

about the '_lead_create_partner_address' method, I think we should use 'super'. Is it possible?

Also, do you want to set your copyright header on 'crm_base_contact/crm_lead.py' ?

review: Needs Information
Revision history for this message
Stuart Longland (redhatter) wrote :

On using super... we can do that, however wouldn't this cause the superclass function to get executed, thus, making the system attempt to insert the partner using the non-base_contact method?

Seems to me calling the superclasses' _lead_create_partner_address method would try to do it the old way, possibly failing and leaving things in an undefined state, before attempting to do things the way it should have done them in the first place.

As for copyright assignment, I can add one. I'll admit that was low on my priorities. :-)

Revision history for this message
Stuart Longland (redhatter) wrote :
Download full text (4.4 KiB)

Okay, just gave it a try, and as I suspected:

Server Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/openerp/addons/web/common/http.py", line 592, in send
    result = openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/usr/lib/pymodules/python2.6/openerp/netsvc.py", line 360, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/usr/lib/pymodules/python2.6/openerp/service/web_services.py", line 572, in dispatch
    res = fn(db, uid, *params)
  File "/usr/lib/pymodules/python2.6/openerp/osv/osv.py", line 167, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/usr/lib/pymodules/python2.6/openerp/osv/osv.py", line 121, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/lib/pymodules/python2.6/openerp/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/lib/pymodules/python2.6/openerp/osv/osv.py", line 164, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/lib/pymodules/python2.6/openerp/addons/crm/wizard/crm_lead_to_opportunity.py", line 140, in action_apply
    self._convert_opportunity(cr, uid, ids, {'lead_ids': lead_ids}, context=context)
  File "/usr/lib/pymodules/python2.6/openerp/addons/crm/wizard/crm_lead_to_opportunity.py", line 111, in _convert_opportunity
    partner_id = self._create_partner(cr, uid, ids, context=context)
  File "/usr/lib/pymodules/python2.6/openerp/addons/crm_base_contact/wizard/crm_lead_to_opportunity.py", line 29, in _create_partner
    partner_ids = super(crm_lead2opportunity_partner, self)._create_partner(cr, uid, ids, context)
  File "/usr/lib/pymodules/python2.6/openerp/addons/crm/wizard/crm_lead_to_partner.py", line 110, in _create_partner
    partner_ids = lead.convert_partner(cr, uid, lead_ids, data.action, partner_id, context=context)
  File "/usr/lib/pymodules/python2.6/openerp/addons/crm/crm_lead.py", line 636, in convert_partner
    self._lead_create_partner_address(cr, uid, lead, partner_id, context=context)
  File "/usr/lib/pymodules/python2.6/openerp/addons/crm_base_contact/crm_lead.py", line 77, in _lead_create_partner_address
    address_id = super(crm_lead, self)._lead_create_partner_address(self, cr, uid, partner_id, context=context)
  File "/usr/lib/pymodules/python2.6/openerp/addons/crm/crm_lead.py", line 608, in _lead_create_partner_address
    'name': lead.contact_name,
AttributeError: 'int' object has no attribute 'contact_name'

So no, calling the superclass _lead_create_partner_address won't help.

The diff:
=== modified file 'crm_base_contact/crm_lead.py'
--- crm_base_contact/crm_lead.py 2012-03-06 23:56:07 +0000
+++ crm_base_contact/crm_lead.py 2012-03-13 00:53:14 +0000
@@ -2,6 +2,7 @@
 ##############################################################################
 #
 # OpenERP, Open Source Management Solution
+# Copyright (C) 2012 VRT Systems (<http://www.vrt.com.au>).
 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
 #
 # This program is free software: you can redistribute it and/or modify
@@ -73,25 +74,16 @@
                 }...

Read more...

164. By Stuart Longland

crm_base_contact:

- Add copyright into crm_lead.py
- Fix missed include for to_email function

165. By Stuart Longland

crm_base_contact: Implement super() suggestion

Seems my prior attempt at this failed due to a typo. Having fixed this, I am
now able to use the superclass _lead_create_partner_address, which creates an
address linked to the partner, but with no location or contact.

Having done this, it is able to go back, edit the created address object, and
add in the location_id and contact_id created.

Revision history for this message
Stuart Longland (redhatter) wrote :

Silly me, I had a closer look at that backtrace, and realised that I hadn't passed in the lead to the superclass, no wonder it failed.

I've updated the class as per your suggestions.

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Hello, I think you have to replace line 77 of crm_lead.py with the following:

address_id = super(crm_lead, self)._lead_create_partner_address(cr, uid, lead, partner_id, context=context)

review: Needs Fixing
Revision history for this message
Stuart Longland (redhatter) wrote :

It took me a double take to spot what had changed, but I have now committed this fix.

Thanks for reviewing. :-)

review: Needs Resubmitting (fixed)
166. By Stuart Longland

crm_base_contact: Drop 'self' argument to superclass function

Revision history for this message
Lorenzo Battistini (elbati) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: