Merge lp:~vrt-openerp/domsense-agilebg-addons/6.1-addons into lp:domsense-agilebg-addons/6.1
- 6.1-addons
- Merge into 6.1
Status: | Merged |
---|---|
Merged at revision: | 162 |
Proposed branch: | lp:~vrt-openerp/domsense-agilebg-addons/6.1-addons |
Merge into: | lp: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:~vrt-openerp/domsense-agilebg-addons/6.1-addons |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Lorenzo Battistini | Approve | ||
Stuart Longland (community) | fixed | Needs Resubmitting | |
Review via email: mp+96202@code.launchpad.net |
Commit message
Description of the change
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://
I haven't lost my mind...
...it's backed up on a tape somewhere.
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://
I haven't lost my mind...
...it's backed up on a tape somewhere.
- 162. By Stuart Longland
-
Add missing files
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_
- 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.
Lorenzo Battistini (elbati) wrote : | # |
Hello Stuart,
about the '_lead_
Also, do you want to set your copyright header on 'crm_base_
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_
As for copyright assignment, I can add one. I'll admit that was low on my priorities. :-)
Stuart Longland (redhatter) wrote : | # |
Okay, just gave it a try, and as I suspected:
Server Traceback (most recent call last):
File "/usr/lib/
result = openerp.
File "/usr/lib/
result = ExportService.
File "/usr/lib/
res = fn(db, uid, *params)
File "/usr/lib/
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/usr/lib/
return f(self, dbname, *args, **kwargs)
File "/usr/lib/
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/usr/lib/
return getattr(object, method)(cr, uid, *args, **kw)
File "/usr/lib/
self.
File "/usr/lib/
partner_id = self._create_
File "/usr/lib/
partner_ids = super(crm_
File "/usr/lib/
partner_ids = lead.convert_
File "/usr/lib/
self.
File "/usr/lib/
address_id = super(crm_lead, self)._
File "/usr/lib/
'name': lead.contact_name,
AttributeError: 'int' object has no attribute 'contact_name'
So no, calling the superclass _lead_create_
The diff:
=== modified file 'crm_base_
--- crm_base_
+++ crm_base_
@@ -2,6 +2,7 @@
######
#
# OpenERP, Open Source Management Solution
+# Copyright (C) 2012 VRT Systems (<http://
# Copyright (C) 2004-2010 Tiny SPRL (<http://
#
# This program is free software: you can redistribute it and/or modify
@@ -73,25 +74,16 @@
- 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.
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.
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)._
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. :-)
- 166. By Stuart Longland
-
crm_base_contact: Drop 'self' argument to superclass function
Lorenzo Battistini (elbati) : | # |
Preview Diff
1 | === modified file 'crm_base_contact/__init__.py' |
2 | --- crm_base_contact/__init__.py 2011-05-08 16:50:55 +0000 |
3 | +++ crm_base_contact/__init__.py 2012-03-13 20:24:21 +0000 |
4 | @@ -18,4 +18,5 @@ |
5 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
6 | # |
7 | ############################################################################## |
8 | +import crm_lead |
9 | import wizard |
10 | |
11 | === modified file 'crm_base_contact/__openerp__.py' |
12 | --- crm_base_contact/__openerp__.py 2011-05-08 16:50:55 +0000 |
13 | +++ crm_base_contact/__openerp__.py 2012-03-13 20:24:21 +0000 |
14 | @@ -30,6 +30,7 @@ |
15 | 'website': 'http://www.agilebg.com', |
16 | 'init_xml': [], |
17 | 'update_xml': [ |
18 | + 'crm_lead_view.xml' |
19 | ], |
20 | 'demo_xml': [], |
21 | 'installable': True, |
22 | |
23 | === added file 'crm_base_contact/crm_lead.py' |
24 | --- crm_base_contact/crm_lead.py 1970-01-01 00:00:00 +0000 |
25 | +++ crm_base_contact/crm_lead.py 2012-03-13 20:24:21 +0000 |
26 | @@ -0,0 +1,90 @@ |
27 | +# -*- coding: utf-8 -*- |
28 | +############################################################################## |
29 | +# |
30 | +# OpenERP, Open Source Management Solution |
31 | +# Copyright (C) 2012 VRT Systems (<http://www.vrt.com.au>). |
32 | +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). |
33 | +# |
34 | +# This program is free software: you can redistribute it and/or modify |
35 | +# it under the terms of the GNU Affero General Public License as |
36 | +# published by the Free Software Foundation, either version 3 of the |
37 | +# License, or (at your option) any later version. |
38 | +# |
39 | +# This program is distributed in the hope that it will be useful, |
40 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
41 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
42 | +# GNU Affero General Public License for more details. |
43 | +# |
44 | +# You should have received a copy of the GNU Affero General Public License |
45 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
46 | +# |
47 | +############################################################################## |
48 | + |
49 | +from osv import fields, osv |
50 | + |
51 | +class crm_lead(osv.osv): |
52 | + """ CRM Lead Case """ |
53 | + _name = "crm.lead" |
54 | + _inherit = 'crm.lead' |
55 | + |
56 | + def _name_get_full(self, cr, uid, ids, prop, unknow_none, context=None): |
57 | + """ Calculate full name """ |
58 | + result = {} |
59 | + for rec in self.browse(cr, uid, ids, context=context): |
60 | + name_parts = [] |
61 | + |
62 | + if(rec.contact_first_name): |
63 | + name_parts.append(rec.contact_first_name) |
64 | + |
65 | + if(rec.contact_last_name): |
66 | + name_parts.append(rec.contact_last_name) |
67 | + |
68 | + if name_parts: |
69 | + result[rec.id] = ' '.join(name_parts) |
70 | + else: |
71 | + result[rec.id] = False |
72 | + |
73 | + return result |
74 | + |
75 | + _columns = { |
76 | + 'contact_last_name': fields.char('Contact Last Name', size=64), |
77 | + 'contact_first_name': fields.char('Contact First Name', size=64), |
78 | + 'contact_name': fields.function(_name_get_full, string='Contact Name', size=64, |
79 | + type="char", store=False), |
80 | + } |
81 | + |
82 | + def _lead_create_partner_location(self, cr, uid, lead, context=None): |
83 | + location = self.pool.get('res.partner.location') |
84 | + return location.create(cr, uid, { |
85 | + 'street': lead.street, |
86 | + 'street2': lead.street2, |
87 | + 'zip': lead.zip, |
88 | + 'city': lead.city, |
89 | + 'state_id': lead.state_id and lead.state_id.id or False, |
90 | + 'country_id': lead.country_id and lead.country_id.id or False, |
91 | + }) |
92 | + |
93 | + def _lead_create_partner_contact(self, cr, uid, lead, context=None): |
94 | + location = self.pool.get('res.partner.contact') |
95 | + return location.create(cr, uid, { |
96 | + 'first_name': lead.contact_first_name, |
97 | + 'last_name': lead.contact_last_name, |
98 | + 'mobile': lead.mobile, |
99 | + 'title': lead.title and lead.title.id or False, |
100 | + }) |
101 | + |
102 | + def _lead_create_partner_address(self, cr, uid, lead, partner_id, context=None): |
103 | + address_id = super(crm_lead, self)._lead_create_partner_address(cr, uid, lead, partner_id, context=context) |
104 | + location_id = self._lead_create_partner_location(cr, uid, lead, context=context) |
105 | + contact_id = self._lead_create_partner_contact(cr, uid, lead, context=context) |
106 | + |
107 | + address = self.pool.get('res.partner.address') |
108 | + address.write(cr, uid, [address_id], { |
109 | + 'location_id': location_id, |
110 | + 'contact_id': contact_id, |
111 | + }) |
112 | + return address_id |
113 | + |
114 | +crm_lead() |
115 | + |
116 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
117 | |
118 | === added file 'crm_base_contact/crm_lead_view.xml' |
119 | --- crm_base_contact/crm_lead_view.xml 1970-01-01 00:00:00 +0000 |
120 | +++ crm_base_contact/crm_lead_view.xml 2012-03-13 20:24:21 +0000 |
121 | @@ -0,0 +1,20 @@ |
122 | +<?xml version="1.0"?> |
123 | +<openerp> |
124 | +<data> |
125 | + |
126 | + <!-- CRM Lead Form View --> |
127 | + <record model="ir.ui.view" id="crm_case_form_view_leads"> |
128 | + <field name="name">crm.lead.form.inherited</field> |
129 | + <field name="inherit_id" ref="crm.crm_case_form_view_leads" /> |
130 | + <field name="model">crm.lead</field> |
131 | + <field name="type">form</field> |
132 | + <field name="arch" type="xml"> |
133 | + <xpath expr="/form/notebook/page[@string='Lead']/group/field[@name='contact_name']" position="replace"> |
134 | + <field name="contact_last_name"/> |
135 | + <field name="contact_first_name"/> |
136 | + </xpath> |
137 | + </field> |
138 | + </record> |
139 | + |
140 | +</data> |
141 | +</openerp> |
142 | |
143 | === modified file 'crm_base_contact/wizard/crm_lead_to_opportunity.py' |
144 | --- crm_base_contact/wizard/crm_lead_to_opportunity.py 2011-05-08 16:50:55 +0000 |
145 | +++ crm_base_contact/wizard/crm_lead_to_opportunity.py 2012-03-13 20:24:21 +0000 |
146 | @@ -30,13 +30,14 @@ |
147 | rec_ids = context and context.get('active_ids', []) |
148 | lead_obj = self.pool.get('crm.lead') |
149 | contact_obj = self.pool.get('res.partner.contact') |
150 | - job_obj = self.pool.get('res.partner.job') |
151 | + job_obj = self.pool.get('res.partner.address') |
152 | for data in self.browse(cr, uid, ids, context=context): |
153 | for lead in lead_obj.browse(cr, uid, rec_ids, context=context): |
154 | if data.action == 'create': |
155 | if lead.partner_address_id: |
156 | contact_id = contact_obj.create(cr, uid, { |
157 | - 'name': lead.contact_name, |
158 | + 'last_name': lead.contact_last_name, |
159 | + 'first_name': lead.contact_first_name, |
160 | 'mobile': lead.mobile, |
161 | 'title': lead.title and lead.title.id or False, |
162 | 'email': lead.email_from, |
163 | |
164 | === modified file 'crm_base_contact/wizard/crm_lead_to_partner.py' |
165 | --- crm_base_contact/wizard/crm_lead_to_partner.py 2011-05-08 16:50:55 +0000 |
166 | +++ crm_base_contact/wizard/crm_lead_to_partner.py 2012-03-13 20:24:21 +0000 |
167 | @@ -30,13 +30,14 @@ |
168 | rec_ids = context and context.get('active_ids', []) |
169 | lead_obj = self.pool.get('crm.lead') |
170 | contact_obj = self.pool.get('res.partner.contact') |
171 | - job_obj = self.pool.get('res.partner.job') |
172 | + job_obj = self.pool.get('res.partner.address') |
173 | for data in self.browse(cr, uid, ids, context=context): |
174 | for lead in lead_obj.browse(cr, uid, rec_ids, context=context): |
175 | if data.action == 'create': |
176 | if lead.partner_address_id: |
177 | contact_id = contact_obj.create(cr, uid, { |
178 | - 'name': lead.contact_name, |
179 | + 'first_name': lead.contact_last_name, |
180 | + 'last_name': lead.contact_first_name, |
181 | 'mobile': lead.mobile, |
182 | 'title': lead.title and lead.title.id or False, |
183 | 'email': lead.email_from, |
184 | |
185 | === modified file 'crm_base_contact/wizard/crm_phonecall_to_partner.py' |
186 | --- crm_base_contact/wizard/crm_phonecall_to_partner.py 2011-05-08 16:50:55 +0000 |
187 | +++ crm_base_contact/wizard/crm_phonecall_to_partner.py 2012-03-13 20:24:21 +0000 |
188 | @@ -30,13 +30,13 @@ |
189 | rec_ids = context and context.get('active_ids', []) |
190 | phonecall_obj = self.pool.get('crm.phonecall') |
191 | contact_obj = self.pool.get('res.partner.contact') |
192 | - job_obj = self.pool.get('res.partner.job') |
193 | + job_obj = self.pool.get('res.partner.address') |
194 | for data in self.browse(cr, uid, ids, context=context): |
195 | for phonecall in phonecall_obj.browse(cr, uid, rec_ids, context=context): |
196 | if data.action == 'create': |
197 | if phonecall.partner_address_id: |
198 | contact_id = contact_obj.create(cr, uid, { |
199 | - 'name': phonecall.name, |
200 | + 'last_name': phonecall.name, |
201 | }) |
202 | job_id = job_obj.create(cr, uid, { |
203 | 'address_id': phonecall.partner_address_id.id, |
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?