Merge lp:~openerp-dev/openobject-addons/trunk-kanban-column-vme into lp:openobject-addons
- trunk-kanban-column-vme
- Merge into trunk
Proposed by
Vidhin Mehta (OpenERP)
Status: | Work in progress |
---|---|
Proposed branch: | lp:~openerp-dev/openobject-addons/trunk-kanban-column-vme |
Merge into: | lp:openobject-addons |
Diff against target: |
503 lines (+274/-33) 11 files modified
crm/crm.py (+56/-0) crm/crm_lead.py (+1/-1) crm/crm_lead_view.xml (+1/-1) hr/hr_demo.xml (+1/-1) hr/hr_view.xml (+2/-0) hr_recruitment/hr_recruitment.py (+107/-26) hr_recruitment/hr_recruitment_demo.xml (+30/-1) hr_recruitment/hr_recruitment_menu.xml (+18/-1) hr_recruitment/hr_recruitment_view.xml (+3/-1) project/project.py (+53/-0) project/security/ir.model.access.csv (+2/-1) |
To merge this branch: | bzr merge lp:~openerp-dev/openobject-addons/trunk-kanban-column-vme |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+171049@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 8781. By Vidhin Mehta (OpenERP)
-
[IMP]project.py fixes and improvements.
- 8782. By Vidhin Mehta (OpenERP)
-
[IMP]improvement in view
- 8783. By Vidhin Mehta (OpenERP)
-
[IMP]Improvements in hr module (P1).
- 8784. By Vidhin Mehta (OpenERP)
-
[IMP]Improvement in project csv
- 8785. By Vidhin Mehta (OpenERP)
-
[IMP] Improvements in crm.
- 8786. By Vidhin Mehta (OpenERP)
-
[MERGE]Trunk.
- 8787. By Vidhin Mehta (OpenERP)
-
[IMP]give proper name of methods.
- 8788. By Vidhin Mehta (OpenERP)
-
[IMP]IMprovements in hr_recuriment
- 8789. By Vidhin Mehta (OpenERP)
-
[IMP]misspel.
- 8790. By Vidhin Mehta (OpenERP)
-
[IMP]Add some demo data.
- 8791. By Vidhin Mehta (OpenERP)
-
[IMP]
- 8792. By Vidhin Mehta (OpenERP)
-
[IMP]
- 8793. By Vidhin Mehta (OpenERP)
-
[IMP]FIX
- 8794. By Vidhin Mehta (OpenERP)
-
[IMP]
- 8795. By Vidhin Mehta (OpenERP)
-
[IMP]
- 8796. By Vidhin Mehta (OpenERP)
-
[Imp]
- 8797. By Vidhin Mehta (OpenERP)
-
[IMP]
- 8798. By Vidhin Mehta (OpenERP)
-
[IMP]Change condition in crm_lead def stage_modify
- 8799. By Vidhin Mehta (OpenERP)
-
[MERGE]Trunk.
- 8800. By Vidhin Mehta (OpenERP)
-
[IMP]add demo data.
- 8801. By RGA(OpenERP)
-
Merge with trunk
Unmerged revisions
- 8801. By RGA(OpenERP)
-
Merge with trunk
- 8800. By Vidhin Mehta (OpenERP)
-
[IMP]add demo data.
- 8799. By Vidhin Mehta (OpenERP)
-
[MERGE]Trunk.
- 8798. By Vidhin Mehta (OpenERP)
-
[IMP]Change condition in crm_lead def stage_modify
- 8797. By Vidhin Mehta (OpenERP)
-
[IMP]
- 8796. By Vidhin Mehta (OpenERP)
-
[Imp]
- 8795. By Vidhin Mehta (OpenERP)
-
[IMP]
- 8794. By Vidhin Mehta (OpenERP)
-
[IMP]
- 8793. By Vidhin Mehta (OpenERP)
-
[IMP]FIX
- 8792. By Vidhin Mehta (OpenERP)
-
[IMP]
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'crm/crm.py' | |||
2 | --- crm/crm.py 2013-07-16 15:15:13 +0000 | |||
3 | +++ crm/crm.py 2013-08-13 11:44:00 +0000 | |||
4 | @@ -84,7 +84,63 @@ | |||
5 | 84 | 'type': 'both', | 84 | 'type': 'both', |
6 | 85 | 'case_default': True, | 85 | 'case_default': True, |
7 | 86 | } | 86 | } |
8 | 87 | def create(self, cr, uid, value, context=None): | ||
9 | 88 | if context is None: context = {} | ||
10 | 89 | stage_id = self.search(cr, uid, [('name','=', value.get('name'))], context=context, limit=1) | ||
11 | 90 | section_id = context.get('default_section_id', False) | ||
12 | 91 | if section_id and stage_id: | ||
13 | 92 | create_return = self._stage_modify(cr, uid, stage_id[0], section_id, value, context=context) | ||
14 | 93 | return create_return.get('id') | ||
15 | 94 | |||
16 | 95 | create_return = super(crm_case_stage, self).create(cr, uid, value, context=context) | ||
17 | 96 | if section_id: | ||
18 | 97 | self.pool.get('crm.case.section').write(cr ,uid, section_id, {'stage_ids': [(4, create_return)]}, context=context) | ||
19 | 98 | return create_return | ||
20 | 99 | |||
21 | 100 | def _stage_modify(self, cr, uid, stage_id, section_id, value, context=None): | ||
22 | 101 | crm_lead = self.pool.get('crm.lead') | ||
23 | 102 | section_browse = self.pool.get('crm.case.section').browse(cr, uid, section_id, context=context) | ||
24 | 103 | crm_lead_ids = crm_lead.search(cr, uid, [('stage_id','=', stage_id),('section_id','=', section_id)], context=context) | ||
25 | 104 | stage_ids = self.search(cr, uid, [('name','=', value.get('name'))], context=context, limit=1) | ||
26 | 105 | |||
27 | 106 | if not stage_ids: | ||
28 | 107 | value['state'] = self.browse(cr, uid, stage_id, context=context).state | ||
29 | 108 | value['section_ids'] = [(6, 0, [section_id])] | ||
30 | 109 | new_stage_id = self.copy(cr, uid, stage_id, default=value, context=context) | ||
31 | 110 | else: | ||
32 | 111 | new_stage_id = stage_ids[0] | ||
33 | 112 | |||
34 | 113 | if new_stage_id: | ||
35 | 114 | section_write = section_browse.write({'stage_ids': [(3, stage_id),(4, new_stage_id)]}, context=context) | ||
36 | 115 | crm_write = crm_lead.write(cr, uid, crm_lead_ids, {'stage_id': new_stage_id} , context=context) | ||
37 | 116 | if section_write and crm_write: | ||
38 | 117 | return {'boolean':True, 'id': new_stage_id} | ||
39 | 118 | return {'boolean': False, 'id' : Null} | ||
40 | 87 | 119 | ||
41 | 120 | def write(self, cr, uid, ids, value, context=None): | ||
42 | 121 | if context is None: context = {} | ||
43 | 122 | section_id = context.get('default_section_id', False) | ||
44 | 123 | if value.get('name') and section_id: | ||
45 | 124 | for stage_id in ids: | ||
46 | 125 | write_return = self._stage_modify(cr, uid, stage_id, section_id, value, context=context) | ||
47 | 126 | if not write_return.get('boolean'): | ||
48 | 127 | return False | ||
49 | 128 | return True | ||
50 | 129 | return super(crm_case_stage, self).write(cr, uid, ids, value, context=context) | ||
51 | 130 | |||
52 | 131 | def unlink(self, cr, uid, ids, context=None): | ||
53 | 132 | if context is None: context = {} | ||
54 | 133 | section_id = context.get('default_section_id', False) | ||
55 | 134 | if section_id: | ||
56 | 135 | crm_lead = self.pool.get('crm.lead') | ||
57 | 136 | for stage_id in ids: | ||
58 | 137 | crm_lead_ids = crm_lead.search(cr, uid, [('stage_id','=',stage_id),('section_id','=', section_id)]) | ||
59 | 138 | crm_write = crm_lead.write(cr, uid, crm_lead_ids, {'stage_id': False} , context=context) | ||
60 | 139 | section_write = self.pool.get('crm.case.section').write(cr, uid, section_id, {'stage_ids': [(3, stage_id)]}, context=context) | ||
61 | 140 | if not crm_write or not section_write: | ||
62 | 141 | return False | ||
63 | 142 | return True | ||
64 | 143 | return super(crm_case_stage,self).unlink(cr, uid, ids, context) | ||
65 | 88 | 144 | ||
66 | 89 | class crm_case_section(osv.osv): | 145 | class crm_case_section(osv.osv): |
67 | 90 | """ Model for sales teams. """ | 146 | """ Model for sales teams. """ |
68 | 91 | 147 | ||
69 | === modified file 'crm/crm_lead.py' | |||
70 | --- crm/crm_lead.py 2013-08-05 14:19:05 +0000 | |||
71 | +++ crm/crm_lead.py 2013-08-13 11:44:00 +0000 | |||
72 | @@ -365,7 +365,7 @@ | |||
73 | 365 | # OR all section_ids and OR with case_default | 365 | # OR all section_ids and OR with case_default |
74 | 366 | search_domain = [] | 366 | search_domain = [] |
75 | 367 | if section_ids: | 367 | if section_ids: |
77 | 368 | search_domain += [('|')] * len(section_ids) | 368 | search_domain += [('&')] * len(section_ids) |
78 | 369 | for section_id in section_ids: | 369 | for section_id in section_ids: |
79 | 370 | search_domain.append(('section_ids', '=', section_id)) | 370 | search_domain.append(('section_ids', '=', section_id)) |
80 | 371 | search_domain.append(('case_default', '=', True)) | 371 | search_domain.append(('case_default', '=', True)) |
81 | 372 | 372 | ||
82 | === modified file 'crm/crm_lead_view.xml' | |||
83 | --- crm/crm_lead_view.xml 2013-08-09 07:52:28 +0000 | |||
84 | +++ crm/crm_lead_view.xml 2013-08-13 11:44:00 +0000 | |||
85 | @@ -543,7 +543,7 @@ | |||
86 | 543 | <search string="Search Opportunities"> | 543 | <search string="Search Opportunities"> |
87 | 544 | <field name="name" string="Opportunity" filter_domain="['|','|','|',('partner_id','ilike',self),('partner_name','ilike',self),('email_from','ilike',self),('name', 'ilike', self)]"/> | 544 | <field name="name" string="Opportunity" filter_domain="['|','|','|',('partner_id','ilike',self),('partner_name','ilike',self),('email_from','ilike',self),('name', 'ilike', self)]"/> |
88 | 545 | <field name="categ_ids" string="Category" filter_domain="[('categ_ids','ilike', self)]"/> | 545 | <field name="categ_ids" string="Category" filter_domain="[('categ_ids','ilike', self)]"/> |
90 | 546 | <field name="section_id" context="{'invisible_section': False}" groups="base.group_multi_salesteams"/> | 546 | <field name="section_id" groups="base.group_multi_salesteams"/> |
91 | 547 | <field name="user_id"/> | 547 | <field name="user_id"/> |
92 | 548 | <field name="partner_id" filter_domain="[('partner_id','child_of',self)]"/> | 548 | <field name="partner_id" filter_domain="[('partner_id','child_of',self)]"/> |
93 | 549 | <field name="stage_id" domain="[]"/> | 549 | <field name="stage_id" domain="[]"/> |
94 | 550 | 550 | ||
95 | === modified file 'hr/hr_demo.xml' | |||
96 | --- hr/hr_demo.xml 2013-04-11 12:44:46 +0000 | |||
97 | +++ hr/hr_demo.xml 2013-08-13 11:44:00 +0000 | |||
98 | @@ -25,7 +25,7 @@ | |||
99 | 25 | <record id="dep_sales" model="hr.department"> | 25 | <record id="dep_sales" model="hr.department"> |
100 | 26 | <field name="name">Sales</field> | 26 | <field name="name">Sales</field> |
101 | 27 | </record> | 27 | </record> |
103 | 28 | 28 | ||
104 | 29 | <!--Jobs--> | 29 | <!--Jobs--> |
105 | 30 | 30 | ||
106 | 31 | <record id="job_ceo" model="hr.job"> | 31 | <record id="job_ceo" model="hr.job"> |
107 | 32 | 32 | ||
108 | === modified file 'hr/hr_view.xml' | |||
109 | --- hr/hr_view.xml 2013-06-21 11:03:44 +0000 | |||
110 | +++ hr/hr_view.xml 2013-08-13 11:44:00 +0000 | |||
111 | @@ -343,6 +343,8 @@ | |||
112 | 343 | <field name="state" widget="statusbar" statusbar_visible="recruit,open"/> | 343 | <field name="state" widget="statusbar" statusbar_visible="recruit,open"/> |
113 | 344 | </header> | 344 | </header> |
114 | 345 | <sheet> | 345 | <sheet> |
115 | 346 | <div name="hr_applicant_button" class="oe_right oe_button_box"> | ||
116 | 347 | </div> | ||
117 | 346 | <div class="oe_title"> | 348 | <div class="oe_title"> |
118 | 347 | <label for="name" class="oe_edit_only"/> | 349 | <label for="name" class="oe_edit_only"/> |
119 | 348 | <h1><field name="name" class="oe_inline"/></h1> | 350 | <h1><field name="name" class="oe_inline"/></h1> |
120 | 349 | 351 | ||
121 | === modified file 'hr_recruitment/hr_recruitment.py' | |||
122 | --- hr_recruitment/hr_recruitment.py 2013-07-24 07:22:13 +0000 | |||
123 | +++ hr_recruitment/hr_recruitment.py 2013-08-13 11:44:00 +0000 | |||
124 | @@ -44,7 +44,7 @@ | |||
125 | 44 | } | 44 | } |
126 | 45 | 45 | ||
127 | 46 | class hr_recruitment_stage(osv.osv): | 46 | class hr_recruitment_stage(osv.osv): |
129 | 47 | """ Stage of HR Recruitment """ | 47 | """ Stage of HR Recruitment """ |
130 | 48 | _name = "hr.recruitment.stage" | 48 | _name = "hr.recruitment.stage" |
131 | 49 | _description = "Stage of Recruitment" | 49 | _description = "Stage of Recruitment" |
132 | 50 | _order = 'sequence' | 50 | _order = 'sequence' |
133 | @@ -54,12 +54,83 @@ | |||
134 | 54 | 'department_id':fields.many2one('hr.department', 'Specific to a Department', help="Stages of the recruitment process may be different per department. If this stage is common to all departments, keep this field empty."), | 54 | 'department_id':fields.many2one('hr.department', 'Specific to a Department', help="Stages of the recruitment process may be different per department. If this stage is common to all departments, keep this field empty."), |
135 | 55 | 'fold': fields.boolean('Hide in views if empty', help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."), | 55 | 'fold': fields.boolean('Hide in views if empty', help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."), |
136 | 56 | 'requirements': fields.text('Requirements'), | 56 | 'requirements': fields.text('Requirements'), |
137 | 57 | 'case_default': fields.boolean('Default to New Job'), | ||
138 | 57 | } | 58 | } |
139 | 59 | |||
140 | 60 | def _get_default_job_id(self, cr, uid, ctx={}): | ||
141 | 61 | job = ctx.get('default_job_id', False) | ||
142 | 62 | if type(job) is int: | ||
143 | 63 | return [job] | ||
144 | 64 | return job | ||
145 | 65 | |||
146 | 58 | _defaults = { | 66 | _defaults = { |
147 | 59 | 'sequence': 1, | 67 | 'sequence': 1, |
148 | 60 | 'fold': False, | 68 | 'fold': False, |
149 | 69 | 'job_ids': _get_default_job_id, | ||
150 | 70 | 'case_default': True | ||
151 | 61 | } | 71 | } |
152 | 62 | 72 | ||
153 | 73 | def _stage_modify(self, cr, uid, stage_id, job_id, vals, context=None): | ||
154 | 74 | hr_applicant = self.pool.get('hr.applicant') | ||
155 | 75 | hr_job = self.pool.get('hr.job').browse(cr, uid, job_id, context=context) | ||
156 | 76 | hr_applicant_ids = hr_applicant.search(cr, uid, [('stage_id','=', stage_id),('job_id','=', job_id)], context=context) | ||
157 | 77 | stage_ids = self.search(cr, uid, [('name','=', vals['name'])], context=context) | ||
158 | 78 | if not stage_ids: | ||
159 | 79 | vals['state'] = self.browse(cr, uid, stage_id, context=context).state | ||
160 | 80 | vals['job_ids'] = [(6, 0, [job_id])] | ||
161 | 81 | new_stage_id = self.copy(cr, uid, stage_id, default=vals, context=context) | ||
162 | 82 | else: | ||
163 | 83 | new_stage_id = stage_ids[0] | ||
164 | 84 | |||
165 | 85 | if new_stage_id: | ||
166 | 86 | hr_job_write = hr_job.write({'stage_ids': [(4, new_stage_id),(3, stage_id)]}, context=context) | ||
167 | 87 | hr_applicant_write = hr_applicant.write(cr, uid, hr_applicant_ids, {'stage_id': new_stage_id} , context=context) | ||
168 | 88 | if hr_job_write and hr_applicant_write: | ||
169 | 89 | return {'boolean': True,'id': new_stage_id} | ||
170 | 90 | return {'boolean': False,'id': Null} | ||
171 | 91 | |||
172 | 92 | def create(self, cr, uid, vals, context=None): | ||
173 | 93 | if context is None: | ||
174 | 94 | context = {} | ||
175 | 95 | stage_ids = self.search(cr, uid, [('name','=', vals.get('name'))], context=context, limit=1) | ||
176 | 96 | job_id = context.get('default_job_id') | ||
177 | 97 | |||
178 | 98 | if job_id and stage_ids: | ||
179 | 99 | create_return = self._stage_modify(cr, uid, stage_ids[0], job_id, vals, context=context) | ||
180 | 100 | return create_return.get('id') | ||
181 | 101 | |||
182 | 102 | create_return = super(hr_recruitment_stage, self).create(cr, uid, vals, context=context) | ||
183 | 103 | if job_id: | ||
184 | 104 | self.pool.get('hr.job').write(cr, uid, job_id, {'stage_ids': [(4, create_return)]}, context=context) | ||
185 | 105 | return create_return | ||
186 | 106 | |||
187 | 107 | def write(self, cr, uid, ids, vals, context=None): | ||
188 | 108 | if context is None: | ||
189 | 109 | context = {} | ||
190 | 110 | job_id = context.get('default_job_id') | ||
191 | 111 | if vals.get('name') and job_id: | ||
192 | 112 | for stage_id in ids: | ||
193 | 113 | write_return = self._stage_modify(cr, uid, stage_id, job_id, vals, context=context) | ||
194 | 114 | if not write_return.get('boolean'): | ||
195 | 115 | return False | ||
196 | 116 | return True | ||
197 | 117 | return super(hr_recruitment_stage, self).write(cr, uid, ids, vals, context=context) | ||
198 | 118 | |||
199 | 119 | def unlink(self, cr, uid, ids, context=None): | ||
200 | 120 | if context is None: | ||
201 | 121 | context = {} | ||
202 | 122 | job_id = context.get('default_job_id', False) | ||
203 | 123 | if job_id: | ||
204 | 124 | hr_application = self.pool.get('hr.applicant') | ||
205 | 125 | for stage_id in ids: | ||
206 | 126 | applicant_ids = hr_application.search(cr, uid, [('stage_id','=',stage_id),('job_id','=',job_id)]) | ||
207 | 127 | hr_app_write = hr_application.write(cr, uid, applicant_ids, {'stage_id': False} , context=context) | ||
208 | 128 | hr_job_write = self.pool.get('hr.job').write(cr, uid, job_id, {'stage_ids': [(3, stage_id)]}, context=context) | ||
209 | 129 | if not hr_app_write or not hr_job_write: | ||
210 | 130 | return False | ||
211 | 131 | return True | ||
212 | 132 | return super(hr_recruitment_stage,self).unlink(cr, uid, ids, context) | ||
213 | 133 | |||
214 | 63 | class hr_recruitment_degree(osv.osv): | 134 | class hr_recruitment_degree(osv.osv): |
215 | 64 | """ Degree of HR Recruitment """ | 135 | """ Degree of HR Recruitment """ |
216 | 65 | _name = "hr.recruitment.degree" | 136 | _name = "hr.recruitment.degree" |
217 | @@ -87,29 +158,29 @@ | |||
218 | 87 | }, | 158 | }, |
219 | 88 | } | 159 | } |
220 | 89 | 160 | ||
222 | 90 | def _get_default_department_id(self, cr, uid, context=None): | 161 | def _get_default_job_id(self, cr, uid, context=None): |
223 | 91 | """ Gives default department by checking if present in the context """ | 162 | """ Gives default department by checking if present in the context """ |
225 | 92 | return (self._resolve_department_id_from_context(cr, uid, context=context) or False) | 163 | return (self._resolve_job_id_from_context(cr, uid, context=context) or False) |
226 | 93 | 164 | ||
227 | 94 | def _get_default_stage_id(self, cr, uid, context=None): | 165 | def _get_default_stage_id(self, cr, uid, context=None): |
228 | 95 | """ Gives default stage_id """ | 166 | """ Gives default stage_id """ |
229 | 96 | department_id = self._get_default_department_id(cr, uid, context=context) | 167 | department_id = self._get_default_department_id(cr, uid, context=context) |
230 | 97 | return self.stage_find(cr, uid, [], department_id, [('sequence', '=', '1')], context=context) | 168 | return self.stage_find(cr, uid, [], department_id, [('sequence', '=', '1')], context=context) |
231 | 98 | 169 | ||
234 | 99 | def _resolve_department_id_from_context(self, cr, uid, context=None): | 170 | def _resolve_job_id_from_context(self, cr, uid, context=None): |
235 | 100 | """ Returns ID of department based on the value of 'default_department_id' | 171 | """ Returns ID of job based on the value of 'default_job_id' |
236 | 101 | context key, or None if it cannot be resolved to a single | 172 | context key, or None if it cannot be resolved to a single |
237 | 102 | department. | 173 | department. |
238 | 103 | """ | 174 | """ |
239 | 104 | if context is None: | 175 | if context is None: |
240 | 105 | context = {} | 176 | context = {} |
248 | 106 | if type(context.get('default_department_id')) in (int, long): | 177 | if type(context.get('default_job_id')) in (int, long): |
249 | 107 | return context.get('default_department_id') | 178 | return context.get('default_job_id') |
250 | 108 | if isinstance(context.get('default_department_id'), basestring): | 179 | if isinstance(context.get('default_job_id'), basestring): |
251 | 109 | department_name = context['default_department_id'] | 180 | job_name = context['default_job_id'] |
252 | 110 | department_ids = self.pool.get('hr.department').name_search(cr, uid, name=department_name, context=context) | 181 | job_ids = self.pool.get('hr.job').name_search(cr, uid, name=job_name, context=context) |
253 | 111 | if len(department_ids) == 1: | 182 | if len(job_ids) == 1: |
254 | 112 | return int(department_ids[0][0]) | 183 | return int(job_ids[0][0]) |
255 | 113 | return None | 184 | return None |
256 | 114 | 185 | ||
257 | 115 | def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None): | 186 | def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None): |
258 | @@ -121,13 +192,14 @@ | |||
259 | 121 | order = "%s desc" % order | 192 | order = "%s desc" % order |
260 | 122 | # retrieve section_id from the context and write the domain | 193 | # retrieve section_id from the context and write the domain |
261 | 123 | # - ('id', 'in', 'ids'): add columns that should be present | 194 | # - ('id', 'in', 'ids'): add columns that should be present |
265 | 124 | # - OR ('department_id', '=', False), ('fold', '=', False): add default columns that are not folded | 195 | # - OR ('job_id', '=', False), ('fold', '=', False): add default columns that are not folded |
266 | 125 | # - OR ('department_id', 'in', department_id), ('fold', '=', False) if department_id: add department columns that are not folded | 196 | # - OR ('job_id', 'in', job_id), ('fold', '=', False) if job_id: add department columns that are not folded |
267 | 126 | department_id = self._resolve_department_id_from_context(cr, uid, context=context) | 197 | job_id = self._resolve_job_id_from_context(cr, uid, context=context) |
268 | 127 | search_domain = [] | 198 | search_domain = [] |
272 | 128 | if department_id: | 199 | if job_id: |
273 | 129 | search_domain += ['|', ('department_id', '=', department_id)] | 200 | search_domain += ['|', ('job_ids', '=', job_id)] |
274 | 130 | search_domain += ['|', ('id', 'in', ids), ('department_id', '=', False)] | 201 | search_domain += [('id', 'in', ids)] |
275 | 202 | search_domain += ['|', '|', ('id', 'in', ids), ('job_ids', '=', False), ('case_default', '=', True)] | ||
276 | 131 | stage_ids = stage_obj._search(cr, uid, search_domain, order=order, access_rights_uid=access_rights_uid, context=context) | 203 | stage_ids = stage_obj._search(cr, uid, search_domain, order=order, access_rights_uid=access_rights_uid, context=context) |
277 | 132 | result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context) | 204 | result = stage_obj.name_get(cr, access_rights_uid, stage_ids, context=context) |
278 | 133 | # restore order of the search | 205 | # restore order of the search |
279 | @@ -220,7 +292,7 @@ | |||
280 | 220 | 'active': lambda *a: 1, | 292 | 'active': lambda *a: 1, |
281 | 221 | 'user_id': lambda s, cr, uid, c: uid, | 293 | 'user_id': lambda s, cr, uid, c: uid, |
282 | 222 | 'stage_id': lambda s, cr, uid, c: s._get_default_stage_id(cr, uid, c), | 294 | 'stage_id': lambda s, cr, uid, c: s._get_default_stage_id(cr, uid, c), |
284 | 223 | 'department_id': lambda s, cr, uid, c: s._get_default_department_id(cr, uid, c), | 295 | 'job_id': lambda s, cr, uid, c: s._get_default_job_id(cr, uid, c), |
285 | 224 | 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'hr.applicant', context=c), | 296 | 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'hr.applicant', context=c), |
286 | 225 | 'color': 0, | 297 | 'color': 0, |
287 | 226 | 'date_last_stage_update': fields.datetime.now(), | 298 | 'date_last_stage_update': fields.datetime.now(), |
288 | @@ -262,17 +334,16 @@ | |||
289 | 262 | if isinstance(cases, (int, long)): | 334 | if isinstance(cases, (int, long)): |
290 | 263 | cases = self.browse(cr, uid, cases, context=context) | 335 | cases = self.browse(cr, uid, cases, context=context) |
291 | 264 | # collect all section_ids | 336 | # collect all section_ids |
293 | 265 | department_ids = [] | 337 | job_ids = [] |
294 | 266 | if section_id: | 338 | if section_id: |
296 | 267 | department_ids.append(section_id) | 339 | job_ids.append(section_id) |
297 | 268 | for case in cases: | 340 | for case in cases: |
300 | 269 | if case.department_id: | 341 | if case.job_id: |
301 | 270 | department_ids.append(case.department_id.id) | 342 | job_ids.append(case.job_id.id) |
302 | 271 | # OR all section_ids and OR with case_default | 343 | # OR all section_ids and OR with case_default |
303 | 272 | search_domain = [] | 344 | search_domain = [] |
307 | 273 | if department_ids: | 345 | if job_ids: |
308 | 274 | search_domain += ['|', ('department_id', 'in', department_ids)] | 346 | search_domain += [('job_ids', 'in', job_ids)] |
306 | 275 | search_domain.append(('department_id', '=', False)) | ||
309 | 276 | # AND with the domain in parameter | 347 | # AND with the domain in parameter |
310 | 277 | search_domain += list(domain) | 348 | search_domain += list(domain) |
311 | 278 | # perform search, return the first found | 349 | # perform search, return the first found |
312 | @@ -463,8 +534,18 @@ | |||
313 | 463 | 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True, | 534 | 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True, |
314 | 464 | help="Email alias for this job position. New emails will automatically " | 535 | help="Email alias for this job position. New emails will automatically " |
315 | 465 | "create new applicants for this job position."), | 536 | "create new applicants for this job position."), |
316 | 537 | 'stage_ids':fields.many2many('hr.recruitment.stage', 'job_stage_rel','job_id', 'stage_id', 'Stages') | ||
317 | 466 | } | 538 | } |
318 | 467 | 539 | ||
319 | 540 | def _get_stage_common(self, cr, uid, context): | ||
320 | 541 | ids = self.pool.get('hr.recruitment.stage').search(cr, uid, [('case_default','=',1)], context=context) | ||
321 | 542 | return ids | ||
322 | 543 | |||
323 | 544 | _defaults = { | ||
324 | 545 | 'alias_domain': False, # always hide alias during creation | ||
325 | 546 | 'stage_ids': _get_stage_common, | ||
326 | 547 | } | ||
327 | 548 | |||
328 | 468 | def _auto_init(self, cr, context=None): | 549 | def _auto_init(self, cr, context=None): |
329 | 469 | """Installation hook to create aliases for all jobs and avoid constraint errors.""" | 550 | """Installation hook to create aliases for all jobs and avoid constraint errors.""" |
330 | 470 | return self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(hr_job, self)._auto_init, | 551 | return self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(hr_job, self)._auto_init, |
331 | 471 | 552 | ||
332 | === modified file 'hr_recruitment/hr_recruitment_demo.xml' | |||
333 | --- hr_recruitment/hr_recruitment_demo.xml 2013-03-13 09:37:09 +0000 | |||
334 | +++ hr_recruitment/hr_recruitment_demo.xml 2013-08-13 11:44:00 +0000 | |||
335 | @@ -124,6 +124,35 @@ | |||
336 | 124 | 124 | ||
337 | 125 | <record id="hr.job_developer" model="hr.job"> | 125 | <record id="hr.job_developer" model="hr.job"> |
338 | 126 | <field name="survey_id" ref="survey_job_0"/> | 126 | <field name="survey_id" ref="survey_job_0"/> |
340 | 127 | </record> | 127 | <field name= "stage_ids" eval="[(4, stage_job1),(4, stage_job2),(4, stage_job3),(4, stage_job4),(4, stage_job5),(4, stage_job6)]" /> |
341 | 128 | </record> | ||
342 | 129 | <record id="hr.job_ceo" model="hr.job"> | ||
343 | 130 | <field name="survey_id" ref="survey_job_0"/> | ||
344 | 131 | <field name= "stage_ids" eval="[(4, stage_job3),(4, stage_job4),(4, stage_job5),(4, stage_job6)]" /> | ||
345 | 132 | </record> | ||
346 | 133 | <record id="hr.job_cto" model="hr.job"> | ||
347 | 134 | <field name="survey_id" ref="survey_job_0"/> | ||
348 | 135 | <field name= "stage_ids" eval="[(4, stage_job1),(4, stage_job4),(4, stage_job5),(4, stage_job6)]" /> | ||
349 | 136 | </record> | ||
350 | 137 | <record id="hr.job_hrm" model="hr.job"> | ||
351 | 138 | <field name="survey_id" ref="survey_job_0"/> | ||
352 | 139 | <field name= "stage_ids" eval="[(4, stage_job1),(4, stage_job2),(4, stage_job3),(4, stage_job4)]" /> | ||
353 | 140 | </record> | ||
354 | 141 | <record id="hr.job_consultant" model="hr.job"> | ||
355 | 142 | <field name="survey_id" ref="survey_job_0"/> | ||
356 | 143 | <field name= "stage_ids" eval="[(4, stage_job1),(4, stage_job2),(4, stage_job3),(4, stage_job4)]" /> | ||
357 | 144 | </record> | ||
358 | 145 | |||
359 | 146 | <record id="hr.job_marketing" model="hr.job"> | ||
360 | 147 | <field name="survey_id" ref="survey_job_0"/> | ||
361 | 148 | <field name= "stage_ids" eval="[(4, stage_job1),(4, stage_job2),(4, stage_job3),(4, stage_job4)]" /> | ||
362 | 149 | </record> | ||
363 | 150 | |||
364 | 151 | <record id="hr.job_trainee" model="hr.job"> | ||
365 | 152 | <field name="survey_id" ref="survey_job_0"/> | ||
366 | 153 | <field name= "stage_ids" eval="[(4, stage_job1),(4, stage_job2),(4, stage_job3),(4, stage_job4)]" /> | ||
367 | 154 | </record> | ||
368 | 155 | |||
369 | 156 | |||
370 | 128 | </data> | 157 | </data> |
371 | 129 | </openerp> | 158 | </openerp> |
372 | 130 | \ No newline at end of file | 159 | \ No newline at end of file |
373 | 131 | 160 | ||
374 | === modified file 'hr_recruitment/hr_recruitment_menu.xml' | |||
375 | --- hr_recruitment/hr_recruitment_menu.xml 2013-03-04 15:13:55 +0000 | |||
376 | +++ hr_recruitment/hr_recruitment_menu.xml 2013-08-13 11:44:00 +0000 | |||
377 | @@ -63,7 +63,24 @@ | |||
378 | 63 | id="menu_crm_case_categ0_act_job" action="crm_case_categ0_act_job" sequence="1"/> | 63 | id="menu_crm_case_categ0_act_job" action="crm_case_categ0_act_job" sequence="1"/> |
379 | 64 | 64 | ||
380 | 65 | <menuitem parent="hr.menu_hr_configuration" id="hr.menu_hr_job" action="hr.action_hr_job" sequence="2"/> | 65 | <menuitem parent="hr.menu_hr_configuration" id="hr.menu_hr_job" action="hr.action_hr_job" sequence="2"/> |
382 | 66 | 66 | ||
383 | 67 | <!-- Add new Button(Application) in department Form --> | ||
384 | 68 | |||
385 | 69 | <record id="view_job_form_inherit" model="ir.ui.view"> | ||
386 | 70 | <field name="name">hr.job.form.inherit</field> | ||
387 | 71 | <field name="model">hr.job</field> | ||
388 | 72 | <field name="inherit_id" ref="hr.view_hr_job_form"/> | ||
389 | 73 | <field name="arch" type="xml"> | ||
390 | 74 | <xpath expr="//div[@name='hr_applicant_button']" position="inside"> | ||
391 | 75 | <button name="%(crm_case_categ0_act_job)d" string="Applications" type="action" | ||
392 | 76 | context="{'search_default_job_id': active_id, 'default_job_id': active_id}"/> | ||
393 | 77 | </xpath> | ||
394 | 78 | <xpath expr="//field[@name='requirements']" position="after"> | ||
395 | 79 | <separator string="Recruitment Stages" /> | ||
396 | 80 | <field name="stage_ids" nolabel="1"/> | ||
397 | 81 | </xpath> | ||
398 | 82 | </field> | ||
399 | 83 | </record> | ||
400 | 67 | 84 | ||
401 | 68 | </data> | 85 | </data> |
402 | 69 | </openerp> | 86 | </openerp> |
403 | 70 | 87 | ||
404 | === modified file 'hr_recruitment/hr_recruitment_view.xml' | |||
405 | --- hr_recruitment/hr_recruitment_view.xml 2013-07-16 15:15:13 +0000 | |||
406 | +++ hr_recruitment/hr_recruitment_view.xml 2013-08-13 11:44:00 +0000 | |||
407 | @@ -354,15 +354,17 @@ | |||
408 | 354 | <group string="Stage Definition"> | 354 | <group string="Stage Definition"> |
409 | 355 | <group> | 355 | <group> |
410 | 356 | <field name="name"/> | 356 | <field name="name"/> |
411 | 357 | <field name="fold"/> | ||
412 | 358 | <field name="case_default"/> | ||
413 | 357 | <field name="department_id"/> | 359 | <field name="department_id"/> |
414 | 358 | </group> | 360 | </group> |
415 | 359 | <group> | 361 | <group> |
416 | 360 | <field name="sequence"/> | 362 | <field name="sequence"/> |
417 | 361 | <field name="fold"/> | ||
418 | 362 | </group> | 363 | </group> |
419 | 363 | </group> | 364 | </group> |
420 | 364 | <separator string="Requirements"/> | 365 | <separator string="Requirements"/> |
421 | 365 | <field name="requirements"/> | 366 | <field name="requirements"/> |
422 | 367 | <field name="job_ids" invisible="1"/> | ||
423 | 366 | </sheet> | 368 | </sheet> |
424 | 367 | </form> | 369 | </form> |
425 | 368 | </field> | 370 | </field> |
426 | 369 | 371 | ||
427 | === modified file 'project/project.py' | |||
428 | --- project/project.py 2013-07-24 07:22:13 +0000 | |||
429 | +++ project/project.py 2013-08-13 11:44:00 +0000 | |||
430 | @@ -52,6 +52,59 @@ | |||
431 | 52 | 'project_ids': lambda self, cr, uid, ctx=None: self.pool['project.task']._get_default_project_id(cr, uid, context=ctx), | 52 | 'project_ids': lambda self, cr, uid, ctx=None: self.pool['project.task']._get_default_project_id(cr, uid, context=ctx), |
432 | 53 | } | 53 | } |
433 | 54 | _order = 'sequence' | 54 | _order = 'sequence' |
434 | 55 | def write(self, cr, uid, ids, value, context=None): | ||
435 | 56 | if context is None:context = {} | ||
436 | 57 | project_id = context.get('default_project_id', False) | ||
437 | 58 | if value.get('name') and project_id: | ||
438 | 59 | for id in ids: | ||
439 | 60 | write_return = self._stage_modify(cr, uid, id, project_id, value, context=context) | ||
440 | 61 | if not write_return.get('boolean'): | ||
441 | 62 | return False | ||
442 | 63 | return True | ||
443 | 64 | return super(project_task_type, self).write(cr, uid, ids, value, context=context) | ||
444 | 65 | |||
445 | 66 | def _stage_modify(self, cr, uid, stage_id, project_id, vals, context=None): | ||
446 | 67 | project = self.pool.get('project.project').browse(cr, uid, project_id, context=context) | ||
447 | 68 | project_task = self.pool.get('project.task') | ||
448 | 69 | stage_ids = self.search(cr, uid, [('name','=', vals.get('name'))], context=context, limit=1) | ||
449 | 70 | task_ids = project_task.search(cr, uid, [('stage_id','=', stage_id),('project_id','=', project_id)], context=context) | ||
450 | 71 | |||
451 | 72 | if not stage_ids: | ||
452 | 73 | vals['state'] = self.browse(cr, uid, stage_id, context=context).state | ||
453 | 74 | vals['project_ids'] = [(6, 0, [project_id])] | ||
454 | 75 | new_stage_id = self.copy(cr, uid, stage_id, default=vals, context=context) | ||
455 | 76 | else: | ||
456 | 77 | new_stage_id = stage_ids[0] | ||
457 | 78 | |||
458 | 79 | if new_stage_id: | ||
459 | 80 | project_write = project.write({'type_ids': [(3, stage_id),(4, new_stage_id),]}, context=context) | ||
460 | 81 | task_write = project_task.write(cr, uid, task_ids, {'stage_id': new_stage_id} , context=context) | ||
461 | 82 | if project_write and task_write: | ||
462 | 83 | return {'boolean':True, 'id': new_stage_id} | ||
463 | 84 | return {'boolean': False, 'id': Null} | ||
464 | 85 | |||
465 | 86 | def create(self, cr, uid, value, context=None): | ||
466 | 87 | if context is None:context = {} | ||
467 | 88 | stage_id = self.search(cr, uid, [('name','=', value.get('name'))], context=context, limit=1) | ||
468 | 89 | project_id = context.get('default_project_id', False) | ||
469 | 90 | if project_id and stage_id: | ||
470 | 91 | create_return = self._stage_modify(cr, uid, stage_id[0], project_id, value, context=context) | ||
471 | 92 | return create_return.get('id') | ||
472 | 93 | return super(project_task_type, self).create(cr, uid, value, context=context) | ||
473 | 94 | |||
474 | 95 | def unlink(self, cr, uid, ids, context=None): | ||
475 | 96 | if context is None: context = {} | ||
476 | 97 | project_id = context.get('default_project_id') | ||
477 | 98 | if project_id: | ||
478 | 99 | project_task = self.pool.get('project.task') | ||
479 | 100 | for stage_id in ids: | ||
480 | 101 | task_ids = project_task.search(cr, uid, [('stage_id','=', stage_id),('project_id','=', project_id)]) | ||
481 | 102 | task_write = project_task.write(cr, uid, task_ids, {'stage_id': False} , context=context) | ||
482 | 103 | project_write = self.pool.get('project.project').write({'type_ids': [cr, uid, project_id, (3, stage_id)]}, context=context) | ||
483 | 104 | if not project_write or not task_write: | ||
484 | 105 | return False | ||
485 | 106 | return True | ||
486 | 107 | return super(project_task_type,self).unlink(cr, uid, ids, context) | ||
487 | 55 | 108 | ||
488 | 56 | 109 | ||
489 | 57 | class project(osv.osv): | 110 | class project(osv.osv): |
490 | 58 | 111 | ||
491 | === modified file 'project/security/ir.model.access.csv' | |||
492 | --- project/security/ir.model.access.csv 2013-07-10 10:15:08 +0000 | |||
493 | +++ project/security/ir.model.access.csv 2013-08-13 11:44:00 +0000 | |||
494 | @@ -3,7 +3,8 @@ | |||
495 | 3 | access_project_project_manager,project.project,model_project_project,project.group_project_manager,1,1,1,1 | 3 | access_project_project_manager,project.project,model_project_project,project.group_project_manager,1,1,1,1 |
496 | 4 | access_account_analytic_account_user,account.analytic.account,analytic.model_account_analytic_account,project.group_project_user,1,0,0,0 | 4 | access_account_analytic_account_user,account.analytic.account,analytic.model_account_analytic_account,project.group_project_user,1,0,0,0 |
497 | 5 | access_account_analytic_account,account.analytic.account,analytic.model_account_analytic_account,project.group_project_manager,1,1,1,1 | 5 | access_account_analytic_account,account.analytic.account,analytic.model_account_analytic_account,project.group_project_manager,1,1,1,1 |
499 | 6 | access_project_task_type_user,project.task.type user,model_project_task_type,project.group_project_user,1,1,1,1 | 6 | access_project_task_type_manager,project.task.type manager,model_project_task_type,project.group_project_manager,1,1,1,1 |
500 | 7 | access_project_task_type_user,project.task.type user,model_project_task_type,project.group_project_user,1,0,0,0 | ||
501 | 7 | access_project_task,project.task,model_project_task,project.group_project_user,1,1,1,1 | 8 | access_project_task,project.task,model_project_task,project.group_project_user,1,1,1,1 |
502 | 8 | access_project_task_work,project.task.work,model_project_task_work,project.group_project_user,1,1,1,1 | 9 | access_project_task_work,project.task.work,model_project_task_work,project.group_project_user,1,1,1,1 |
503 | 9 | access_report_project_task_user,report.project.task.user,model_report_project_task_user,project.group_project_manager,1,1,1,1 | 10 | access_report_project_task_user,report.project.task.user,model_report_project_task_user,project.group_project_manager,1,1,1,1 |