Merge lp:~camptocamp/department-mgmt/7.0-port-crm_department into lp:~department-core-editors/department-mgmt/7.0

Proposed by Yannick Vaucher @ Camptocamp
Status: Merged
Merged at revision: 13
Proposed branch: lp:~camptocamp/department-mgmt/7.0-port-crm_department
Merge into: lp:~department-core-editors/department-mgmt/7.0
Diff against target: 394 lines (+151/-159)
4 files modified
crm_department/__init__.py (+3/-2)
crm_department/__openerp__.py (+17/-22)
crm_department/crm.py (+30/-25)
crm_department/crm_view.xml (+101/-110)
To merge this branch: bzr merge lp:~camptocamp/department-mgmt/7.0-port-crm_department
Reviewer Review Type Date Requested Status
Maxime Chambreuil (http://www.savoirfairelinux.com) Approve
Guewen Baconnier @ Camptocamp Approve
Alexandre Fayolle - camptocamp code review, no test Needs Fixing
Review via email: mp+162131@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

line 156: add space after ":"

apart from that LGTM

review: Needs Fixing (code review, no test)
16. By Yannick Vaucher @ Camptocamp

[IMP] crm_department - add a space

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Thanks for the review.

Space add

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

LGTM

review: Approve
Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'crm_department/__init__.py'
2--- crm_department/__init__.py 2012-05-29 07:06:32 +0000
3+++ crm_department/__init__.py 2013-05-13 08:36:26 +0000
4@@ -1,10 +1,9 @@
5 # -*- coding: utf-8 -*-
6 ##############################################################################
7 #
8-# Author: Joël Grand-guillaume (Camptocamp)
9+# Author: Joël Grand-guillaume (Camptocamp)
10 # Contributor: Yannick Vaucher (Camptocamp)
11 # Copyright 2011 Camptocamp SA
12-# Donors:
13 #
14 # This program is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU Affero General Public License as
16@@ -21,3 +20,5 @@
17 #
18 ##############################################################################
19 import crm
20+
21+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
22
23=== modified file 'crm_department/__openerp__.py'
24--- crm_department/__openerp__.py 2013-01-04 10:32:58 +0000
25+++ crm_department/__openerp__.py 2013-05-13 08:36:26 +0000
26@@ -1,10 +1,9 @@
27 # -*- coding: utf-8 -*-
28 ##############################################################################
29 #
30-# Author: Joël Grand-guillaume (Camptocamp)
31+# Author: Joël Grand-guillaume (Camptocamp)
32 # Contributor: Yannick Vaucher (Camptocamp)
33 # Copyright 2011 Camptocamp SA
34-# Donors:
35 #
36 # This program is free software: you can redistribute it and/or modify
37 # it under the terms of the GNU Affero General Public License as
38@@ -21,27 +20,23 @@
39 #
40 ##############################################################################
41 {
42- "name" : "CRM with Department Categorization",
43- "version" : "1.0",
44- "author" : "Camptocamp",
45- "category" : "Generic Modules/CRM & SRM",
46- "description": """
47-
48+ 'name' : 'CRM with Department Categorization',
49+ 'version' : '1.0',
50+ 'category' : 'Generic Modules/CRM & SRM',
51+ 'description': '''
52+
53 Add the department on Sales Team (with related field on Lead & Opportunities)
54 as well as the related filter and button in the search form.
55
56-
57-""",
58- "website": "http://camptocamp.com",
59- "depends" : [
60- "crm",
61- "hr"
62- ],
63- "init_xml" : [],
64- "demo_xml" : [],
65- "update_xml" : [
66- "crm_view.xml",
67- ],
68- "active": False,
69- 'installable': False
70+''',
71+ 'author' : 'Camptocamp',
72+ 'website': 'http://camptocamp.com',
73+ 'depends' : ['crm', 'hr'],
74+ 'data' : ['crm_view.xml'],
75+ 'demo_xml' : [],
76+ 'installable': True,
77+ 'auto_install': False,
78+ 'application': True,
79 }
80+
81+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
82
83=== modified file 'crm_department/crm.py'
84--- crm_department/crm.py 2012-05-29 07:06:32 +0000
85+++ crm_department/crm.py 2013-05-13 08:36:26 +0000
86@@ -1,10 +1,9 @@
87 # -*- coding: utf-8 -*-
88 ##############################################################################
89 #
90-# Author: Joël Grand-guillaume (Camptocamp)
91+# Author: Joël Grand-guillaume (Camptocamp)
92 # Contributor: Yannick Vaucher (Camptocamp)
93 # Copyright 2011 Camptocamp SA
94-# Donors:
95 #
96 # This program is free software: you can redistribute it and/or modify
97 # it under the terms of the GNU Affero General Public License as
98@@ -20,40 +19,46 @@
99 # along with this program. If not, see <http://www.gnu.org/licenses/>.
100 #
101 ##############################################################################
102-from osv import osv
103-from osv import fields
104+from openerp.osv import orm, fields
105
106-class crm_sales_team(osv.osv):
107+class CrmSalesTeam(orm.Model):
108 _inherit = "crm.case.section"
109-
110 _columns = {
111 'department_id': fields.many2one('hr.department', 'Department'),
112- }
113+ }
114+
115+ def _get_department(self, cr, uid, ids, context=None):
116+ employee_obj = self.pool.get('hr.employee')
117+ department_id = False
118+ employee_ids = employee_obj.search(cr, uid, [('user_id','=', uid)])
119+ if employee_ids:
120+ department_id = employee_obj.browse(cr, uid, employee_ids[0], context=context).department_id.id
121+ return department_id
122+
123 _defaults = {
124- 'department_id': lambda s,cr,uid,c: s.pool.get('res.users').browse(cr,uid,uid).context_department_id.id,
125- }
126-
127-crm_sales_team()
128-
129-class crm_lead(osv.osv):
130+ 'department_id': _get_department,
131+ }
132+
133+
134+class CrmLead(orm.Model):
135 _inherit = "crm.lead"
136-
137+
138 def onchange_section_id(self, cr, uid, ids, section_id=False, context=None):
139- """ Updates res dictionary with the department corresponding to the section
140- """
141+ print "onchange_section_id"
142+ """ Updates res dictionary with the department corresponding to the section """
143+ if context is None:
144+ context = {}
145 res = {}
146 if section_id:
147 section = self.pool.get('crm.case.section').browse(cr, uid, section_id, context=context)
148 if section.department_id.id:
149 res.update({'department_id': section.department_id.id})
150- return {
151- 'value':res
152- }
153-
154-
155+
156+ return {'value': res}
157+
158 _columns = {
159 'department_id': fields.many2one('hr.department', 'Department'),
160- }
161-
162-crm_lead()
163-
164+ }
165+
166+
167+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
168
169=== modified file 'crm_department/crm_view.xml'
170--- crm_department/crm_view.xml 2011-09-01 13:46:50 +0000
171+++ crm_department/crm_view.xml 2013-05-13 08:36:26 +0000
172@@ -1,121 +1,112 @@
173+<?xml version="1.0" encoding="utf-8"?>
174 <openerp>
175- <data>
176-
177- <record id="crm_case_section_view_form" model="ir.ui.view">
178- <field name="name">crm.case.section.form</field>
179- <field name="model">crm.case.section</field>
180- <field name="inherit_id" ref="crm.crm_case_section_view_form" />
181- <field name="type">form</field>
182- <field name="arch" type="xml">
183- <xpath expr="/form/group/field[@name='active']" position="after">
184- <field name="department_id" select="1" widget="selection"/>
185- </xpath>
186- </field>
187- </record>
188-
189- <record id="crm_case_section_view_tree" model="ir.ui.view">
190- <field name="name">crm.case.section.tree</field>
191- <field name="model">crm.case.section</field>
192- <field name="type">tree</field>
193- <field name="inherit_id" ref="crm.crm_case_section_view_tree" />
194- <field name="arch" type="xml">
195- <xpath expr="/tree/field[@name='user_id']" position="after">
196- <field name="department_id" select="1"/>
197- </xpath>
198- </field>
199- </record>
200-
201-
202- <!-- CRM Lead Form View -->
203- <record model="ir.ui.view" id="crm_case_form_view_leads">
204- <field name="name">CRM - Leads Form</field>
205- <field name="model">crm.lead</field>
206- <field name="type">form</field>
207- <field name="inherit_id" ref="crm.crm_case_form_view_leads" />
208- <field name="arch" type="xml">
209- <xpath expr="/form/group/field[@name='type']" position="after">
210- <field name="department_id" widget="selection"/>
211- </xpath>
212- </field>
213- </record>
214-
215- <!-- CRM Lead Tree View -->
216+ <data>
217+
218+ <record id="crm_case_section_view_form" model="ir.ui.view">
219+ <field name="name">crm.case.section.form</field>
220+ <field name="model">crm.case.section</field>
221+ <field name="inherit_id" ref="crm.crm_case_section_view_form" />
222+ <field name="arch" type="xml">
223+ <xpath expr="/form/group//group[2]/field[@name='active']" position="after">
224+ <field name="department_id" widget="selection"/>
225+ </xpath>
226+ </field>
227+ </record>
228+
229+ <record id="crm_case_section_view_tree" model="ir.ui.view">
230+ <field name="name">crm.case.section.tree</field>
231+ <field name="model">crm.case.section</field>
232+ <field name="inherit_id" ref="crm.crm_case_section_view_tree" />
233+ <field name="arch" type="xml">
234+ <xpath expr="/tree/field[@name='user_id']" position="after">
235+ <field name="department_id"/>
236+ </xpath>
237+ </field>
238+ </record>
239+
240+
241+ <!-- CRM Lead Form View -->
242+ <record model="ir.ui.view" id="crm_case_form_view_leads">
243+ <field name="name">CRM - Leads Form</field>
244+ <field name="model">crm.lead</field>
245+ <field name="inherit_id" ref="crm.crm_case_form_view_leads" />
246+ <field name="arch" type="xml">
247+ <xpath expr="/form/sheet/group/group[3]/field[@name='type']" position="after">
248+ <field name="department_id" widget="selection"/>
249+ </xpath>
250+ </field>
251+ </record>
252+
253+ <!-- CRM Lead Tree View -->
254
255 <record model="ir.ui.view" id="crm_case_tree_view_leads">
256- <field name="name">Leads</field>
257- <field name="model">crm.lead</field>
258- <field name="type">tree</field>
259- <field name="inherit_id" ref="crm.crm_case_tree_view_leads" />
260- <field name="arch" type="xml">
261- <xpath expr="/tree/field[@name='user_id']" position="after">
262- <field name="department_id" />
263- </xpath>
264- </field>
265+ <field name="name">Leads</field>
266+ <field name="model">crm.lead</field>
267+ <field name="inherit_id" ref="crm.crm_case_tree_view_leads" />
268+ <field name="arch" type="xml">
269+ <xpath expr="/tree/field[@name='user_id']" position="after">
270+ <field name="department_id" />
271+ </xpath>
272+ </field>
273 </record>
274-
275-
276+
277 <record id="view_crm_case_leads_filter" model="ir.ui.view">
278- <field name="name">CRM - Leads Search</field>
279- <field name="model">crm.lead</field>
280- <field name="type">search</field>
281- <field name="inherit_id" ref="crm.view_crm_case_leads_filter" />
282- <field name="arch" type="xml">
283- <xpath expr="/search/group/field[@name='company_id']" position="before">
284- <field name="department_id" widget="selection"/>
285- </xpath>
286- <xpath expr="/search/group/filter[@string='Salesman']" position="after">
287- <filter string="Department" icon="terp-folder-orange" domain="[]" context="{'group_by':'department_id'}"/>
288- </xpath>
289- </field>
290+ <field name="name">CRM - Leads Search</field>
291+ <field name="model">crm.lead</field>
292+ <field name="inherit_id" ref="crm.view_crm_case_leads_filter" />
293+ <field name="arch" type="xml">
294+ <xpath expr="/search/field[@name='section_id']" position="before">
295+ <field name="department_id" widget="selection"/>
296+ </xpath>
297+ <xpath expr="/search/group/filter[@string='Salesperson']" position="after">
298+ <filter string="Department" domain="[]" context="{'group_by':'department_id'}"/>
299+ </xpath>
300+ </field>
301 </record>
302-
303+
304 <!-- Opportunities Form View -->
305- <record model="ir.ui.view" id="crm_case_form_view_oppor">
306- <field name="name">Opportunities</field>
307- <field name="model">crm.lead</field>
308- <field name="type">form</field>
309- <field name="inherit_id" ref="crm.crm_case_form_view_oppor" />
310- <field name="arch" type="xml">
311- <xpath expr="/form/notebook/page/group/field[@name='section_id']" position="attributes">
312- <attribute name="on_change">onchange_section_id(section_id)</attribute>
313- </xpath>
314- <xpath expr="/form/notebook/page/group/field[@name='section_id']" position="after">
315- <field name="department_id" widget="selection"/>
316- </xpath>
317- </field>
318- </record>
319+ <record model="ir.ui.view" id="crm_case_form_view_oppor">
320+ <field name="name">Opportunities</field>
321+ <field name="model">crm.lead</field>
322+ <field name="inherit_id" ref="crm.crm_case_form_view_oppor" />
323+ <field name="arch" type="xml">
324+ <xpath expr="/form/sheet/group/group[3]/div/field[@name='section_id']" position="attributes">
325+ <attribute name="on_change">onchange_section_id(section_id)</attribute>
326+ </xpath>
327+ <xpath expr="/form/sheet/group/group[3]/div" position="after">
328+ <field name="department_id" widget="selection"/>
329+ </xpath>
330+ </field>
331+ </record>
332
333 <!-- Opportunities Tree View -->
334
335- <record model="ir.ui.view" id="crm_case_tree_view_oppor">
336- <field name="name">Opportunities Tree</field>
337- <field name="model">crm.lead</field>
338- <field name="type">tree</field>
339- <field name="inherit_id" ref="crm.crm_case_tree_view_oppor" />
340- <field name="arch" type="xml">
341- <xpath expr="/tree/field[@name='user_id']" position="after">
342- <field name="department_id" />
343- </xpath>
344- </field>
345- </record>
346- <!-- Opportunities Search View -->
347-
348- <record id="view_crm_case_opportunities_filter" model="ir.ui.view">
349- <field name="name">CRM - Opportunities Search</field>
350- <field name="model">crm.lead</field>
351- <field name="type">search</field>
352- <field name="inherit_id" ref="crm.view_crm_case_opportunities_filter" />
353- <field name="arch" type="xml">
354- <xpath expr="/search/group/field[@name='company_id']" position="before">
355- <field name="department_id" widget="selection"/>
356- </xpath>
357- <xpath expr="/search/group/filter[@string='Salesman']" position="after">
358- <filter string="Department" icon="terp-folder-orange" domain="[]" context="{'group_by':'department_id'}"/>
359- </xpath>
360- </field>
361- </record>
362-
363-
364-
365- </data>
366+ <record model="ir.ui.view" id="crm_case_tree_view_oppor">
367+ <field name="name">Opportunities Tree</field>
368+ <field name="model">crm.lead</field>
369+ <field name="inherit_id" ref="crm.crm_case_tree_view_oppor" />
370+ <field name="arch" type="xml">
371+ <xpath expr="/tree/field[@name='user_id']" position="after">
372+ <field name="department_id" />
373+ </xpath>
374+ </field>
375+ </record>
376+
377+ <!-- Opportunities Search View -->
378+
379+ <record id="view_crm_case_opportunities_filter" model="ir.ui.view">
380+ <field name="name">CRM - Opportunities Search</field>
381+ <field name="model">crm.lead</field>
382+ <field name="inherit_id" ref="crm.view_crm_case_opportunities_filter" />
383+ <field name="arch" type="xml">
384+ <xpath expr="/search/field[@name='section_id']" position="before">
385+ <field name="department_id" widget="selection"/>
386+ </xpath>
387+ <xpath expr="/search/group/filter[@string='Salesperson']" position="after">
388+ <filter string="Department" domain="[]" context="{'group_by':'department_id'}"/>
389+ </xpath>
390+ </field>
391+ </record>
392+
393+ </data>
394 </openerp>

Subscribers

People subscribed via source and target branches