Merge lp:~openerp-dev/openobject-addons/trunk-imp-crm-salesteam-another-amb into lp:openobject-addons

Proposed by Thibault Delavallée (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-imp-crm-salesteam-another-amb
Merge into: lp:openobject-addons
Diff against target: 229 lines (+60/-67)
7 files modified
crm/crm_lead.py (+27/-8)
crm/crm_lead_view.xml (+28/-0)
crm/crm_phonecall.py (+2/-1)
crm/res_partner.py (+1/-1)
crm_helpdesk/crm_helpdesk.py (+1/-0)
sale_crm/sale_crm.py (+1/-29)
sale_crm/sale_crm_view.xml (+0/-28)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-imp-crm-salesteam-another-amb
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+206218@code.launchpad.net
To post a comment you must log in.
9087. By Niko (OpenERP)

[IMP] Add some video to manisfest ( website, website_blog, website_event, website_ecommerce)

9137. By Amit Vora(OpenERP)

[MERGE] merge with main branch

9138. By Amit Vora(OpenERP)

[MERGE] merge with main branch

9139. By Amit Vora(OpenERP)

[IMP] improve code

9140. By Amit Vora(OpenERP)

[MERGE] merge with main branch

9141. By Amit Vora(OpenERP)

[IMP] improve code

9142. By Amit Vora(OpenERP)

[IMP] give default value to section_id

9143. By Amit Vora(OpenERP)

[IMP] improve code

Unmerged revisions

9143. By Amit Vora(OpenERP)

[IMP] improve code

9142. By Amit Vora(OpenERP)

[IMP] give default value to section_id

9141. By Amit Vora(OpenERP)

[IMP] improve code

9140. By Amit Vora(OpenERP)

[MERGE] merge with main branch

9139. By Amit Vora(OpenERP)

[IMP] improve code

9138. By Amit Vora(OpenERP)

[MERGE] merge with main branch

9137. By Amit Vora(OpenERP)

[MERGE] merge with main branch

9136. By Amit Bhavsar (Open ERP)

[merge] lp:~openerp-dev/openobject-addons/trunk-imp-crm-salesteam-amb

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'crm/crm_lead.py'
2--- crm/crm_lead.py 2014-03-18 13:27:41 +0000
3+++ crm/crm_lead.py 2014-03-19 09:31:19 +0000
4@@ -63,6 +63,19 @@
5 'partner_name']
6
7
8+class res_users(osv.Model):
9+ _inherit = 'res.users'
10+ _columns = {
11+ 'default_section_id': fields.many2one('crm.case.section', 'Default Sales Team'),
12+ }
13+
14+ def __init__(self, pool, cr):
15+ init_res = super(res_users, self).__init__(pool, cr)
16+ # duplicate list to avoid modifying the original reference
17+ self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
18+ self.SELF_WRITEABLE_FIELDS.extend(['default_section_id'])
19+ return init_res
20+
21 class crm_lead(format_address, osv.osv):
22 """ CRM Lead Case """
23 _name = "crm.lead"
24@@ -103,13 +116,19 @@
25 """
26 if context is None:
27 context = {}
28- if type(context.get('default_section_id')) in (int, long):
29- return context.get('default_section_id')
30- if isinstance(context.get('default_section_id'), basestring):
31- section_ids = self.pool.get('crm.case.section').name_search(cr, uid, name=context['default_section_id'], context=context)
32- if len(section_ids) == 1:
33- return int(section_ids[0][0])
34- return None
35+ section_id = context.get('default_section_id', False)
36+ if section_id and isinstance(section_id, basestring):
37+ section_ids = self.pool.get('crm.case.section').name_search(cr, uid, name=section_id, context=context)
38+ if section_ids and len(section_ids):
39+ section_id = int(section_ids[0][0])
40+ else:
41+ section_id = False
42+ if not section_id:
43+ user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
44+ section_id = user.default_section_id and user.default_section_id.id or False
45+ if not section_id:
46+ model, section_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'crm', 'section_sales_department')
47+ return section_id
48
49 def _resolve_type_from_context(self, cr, uid, context=None):
50 """ Returns the type (lead or opportunity) from the type context
51@@ -945,7 +964,7 @@
52 lead = self.browse(cr, uid, id, context=context)
53 local_context = dict(context)
54 local_context.setdefault('default_type', lead.type)
55- local_context.setdefault('default_section_id', lead.section_id)
56+ local_context.setdefault('default_section_id', lead.section_id and lead.section_id.id)
57 if lead.type == 'opportunity':
58 default['date_open'] = fields.datetime.now()
59 else:
60
61=== modified file 'crm/crm_lead_view.xml'
62--- crm/crm_lead_view.xml 2014-03-18 13:27:41 +0000
63+++ crm/crm_lead_view.xml 2014-03-19 09:31:19 +0000
64@@ -631,5 +631,33 @@
65 <field eval="'ir.actions.server,%d'%action_mark_as_lost" name="value"/>
66 </record>
67
68+ <!-- Update user form !-->
69+ <record model="ir.ui.view" id="res_user_form">
70+ <field name="name">Users Preferences</field>
71+ <field name="model">res.users</field>
72+ <field name="inherit_id" ref="base.view_users_form"/>
73+ <field name="arch" type="xml">
74+ <data>
75+ <xpath expr="//field[@name='tz']" position="after">
76+ <field name="default_section_id"/>
77+ </xpath>
78+ </data>
79+ </field>
80+ </record>
81+
82+ <!-- Update Preferences form !-->
83+ <record id="view_users_form_preferences" model="ir.ui.view">
84+ <field name="name">res.users.preferences.form</field>
85+ <field name="model">res.users</field>
86+ <field name="inherit_id" ref="base.view_users_form_simple_modif"/>
87+ <field name="arch" type="xml">
88+ <data>
89+ <xpath expr="//field[@name='company_id']" position="before">
90+ <field name="default_section_id" readonly="0"/>
91+ </xpath>
92+ </data>
93+ </field>
94+ </record>
95+
96 </data>
97 </openerp>
98
99=== modified file 'crm/crm_phonecall.py'
100--- crm/crm_phonecall.py 2014-02-10 06:46:42 +0000
101+++ crm/crm_phonecall.py 2014-03-19 09:31:19 +0000
102@@ -77,7 +77,8 @@
103 'priority': crm.AVAILABLE_PRIORITIES[2][0],
104 'state': _get_default_state,
105 'user_id': lambda self, cr, uid, ctx: uid,
106- 'active': 1
107+ 'active': 1,
108+ 'section_id': lambda self, cr, uid, c=None: self.pool.get('crm.lead')._get_default_section_id(cr, uid, c),
109 }
110
111 def on_change_partner_id(self, cr, uid, ids, partner_id, context=None):
112
113=== modified file 'crm/res_partner.py'
114--- crm/res_partner.py 2014-01-15 09:38:05 +0000
115+++ crm/res_partner.py 2014-03-19 09:31:19 +0000
116@@ -49,7 +49,7 @@
117 'opportunity_count': fields.function(_opportunity_meeting_count, string="Opportunity", type='integer', multi='opp_meet'),
118 'meeting_count': fields.function(_opportunity_meeting_count, string="# Meetings", type='integer', multi='opp_meet'),
119 }
120-
121+
122 def copy(self, cr, uid, record_id, default=None, context=None):
123 if default is None:
124 default = {}
125
126=== modified file 'crm_helpdesk/crm_helpdesk.py'
127--- crm_helpdesk/crm_helpdesk.py 2013-11-27 15:32:57 +0000
128+++ crm_helpdesk/crm_helpdesk.py 2014-03-19 09:31:19 +0000
129@@ -80,6 +80,7 @@
130 _defaults = {
131 'active': lambda *a: 1,
132 'user_id': lambda s, cr, uid, c: uid,
133+ 'section_id': lambda self, cr, uid, c=None: self.pool.get('crm.lead')._get_default_section_id(cr, uid, c),
134 'state': lambda *a: 'draft',
135 'date': fields.datetime.now,
136 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c),
137
138=== modified file 'sale_crm/sale_crm.py'
139--- sale_crm/sale_crm.py 2013-12-18 15:57:15 +0000
140+++ sale_crm/sale_crm.py 2014-03-19 09:31:19 +0000
141@@ -26,19 +26,6 @@
142 from openerp import tools
143 from openerp.osv import osv, fields
144
145-class res_users(osv.Model):
146- _inherit = 'res.users'
147- _columns = {
148- 'default_section_id': fields.many2one('crm.case.section', 'Default Sales Team'),
149- }
150-
151- def __init__(self, pool, cr):
152- init_res = super(res_users, self).__init__(pool, cr)
153- # duplicate list to avoid modifying the original reference
154- self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
155- self.SELF_WRITEABLE_FIELDS.extend(['default_section_id'])
156- return init_res
157-
158 class sale_order(osv.osv):
159 _inherit = 'sale.order'
160 _columns = {
161@@ -115,28 +102,13 @@
162 def action_forecast(self, cr, uid, id, value, context=None):
163 return self.write(cr, uid, [id], {'invoiced_forecast': round(float(value))}, context=context)
164
165-class sale_crm_lead(osv.Model):
166- _inherit = 'crm.lead'
167-
168- def on_change_user(self, cr, uid, ids, user_id, context=None):
169- """ Override of on change user_id on lead/opportunity; when having sale
170- the new logic is :
171- - use user.default_section_id
172- - or fallback on previous behavior """
173- if user_id:
174- user = self.pool.get('res.users').browse(cr, uid, user_id, context=context)
175- if user.default_section_id and user.default_section_id.id:
176- return {'value': {'section_id': user.default_section_id.id}}
177- return super(sale_crm_lead, self).on_change_user(cr, uid, ids, user_id, context=context)
178-
179-
180 class account_invoice(osv.osv):
181 _inherit = 'account.invoice'
182 _columns = {
183 'section_id': fields.many2one('crm.case.section', 'Sales Team'),
184 }
185 _defaults = {
186- 'section_id': lambda self, cr, uid, c=None: self.pool.get('res.users').browse(cr, uid, uid, c).default_section_id.id or False,
187+ 'section_id': lambda self, cr, uid, c=None: self.pool.get('crm.lead')._get_default_section_id(cr, uid, c),
188 }
189
190 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
191
192=== modified file 'sale_crm/sale_crm_view.xml'
193--- sale_crm/sale_crm_view.xml 2014-03-11 14:52:05 +0000
194+++ sale_crm/sale_crm_view.xml 2014-03-19 09:31:19 +0000
195@@ -94,34 +94,6 @@
196 </field>
197 </record>
198
199- <!-- Update user form !-->
200- <record model="ir.ui.view" id="res_user_form">
201- <field name="name">Users Preferences</field>
202- <field name="model">res.users</field>
203- <field name="inherit_id" ref="base.view_users_form"/>
204- <field name="arch" type="xml">
205- <data>
206- <xpath expr="//field[@name='tz']" position="after">
207- <field name="default_section_id"/>
208- </xpath>
209- </data>
210- </field>
211- </record>
212-
213- <!-- Update Preferences form !-->
214- <record id="view_users_form_preferences" model="ir.ui.view">
215- <field name="name">res.users.preferences.form</field>
216- <field name="model">res.users</field>
217- <field name="inherit_id" ref="base.view_users_form_simple_modif"/>
218- <field name="arch" type="xml">
219- <data>
220- <xpath expr="//field[@name='company_id']" position="before">
221- <field name="default_section_id" readonly="0"/>
222- </xpath>
223- </data>
224- </field>
225- </record>
226-
227 <!-- search by Salesteams -->
228
229 <record id="action_orders_salesteams" model="ir.actions.act_window">

Subscribers

People subscribed via source and target branches

to all changes: