Merge lp:~savoirfairelinux-openerp/openerp-isp/contract_isp_package_configurator into lp:openerp-isp
- contract_isp_package_configurator
- Merge into 7.0
Proposed by
Mathieu Benoit
Status: | Needs review |
---|---|
Proposed branch: | lp:~savoirfairelinux-openerp/openerp-isp/contract_isp_package_configurator |
Merge into: | lp:openerp-isp |
Diff against target: |
1231 lines (+592/-383) 6 files modified
contract_isp_package_configurator/__openerp__.py (+3/-1) contract_isp_package_configurator/company.py (+2/-1) contract_isp_package_configurator/contract_isp_package_configurator_view.xml (+10/-11) contract_isp_package_configurator/i18n/contract_isp_package_configurator.pot (+263/-0) contract_isp_package_configurator/wizard/package_configurator.py (+188/-244) contract_isp_package_configurator/wizard/package_configurator.xml (+126/-126) |
To merge this branch: | bzr merge lp:~savoirfairelinux-openerp/openerp-isp/contract_isp_package_configurator |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Joao Alfredo Gama Batista | Pending | ||
Review via email: mp+214056@code.launchpad.net |
Commit message
Description of the change
Clean code contract_
- pep8
- Remove dupplication code
- Add .pot
To post a comment you must log in.
- 27. By Mathieu Benoit
-
[FIX] wizard package_
configurator: inverse state product and dependency, for logical workflow. - 28. By Mathieu Benoit
-
[IMP] format package_
configurator. xml
Unmerged revisions
- 28. By Mathieu Benoit
-
[IMP] format package_
configurator. xml - 27. By Mathieu Benoit
-
[FIX] wizard package_
configurator: inverse state product and dependency, for logical workflow. - 26. By Mathieu Benoit
-
[FIX] contract_
isp_package_ configurator: fix last clean - missing variable - 25. By Mathieu Benoit
-
[IMP] contract_
isp_package_ configurator: add .pot and clean code.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'contract_isp_package_configurator/__openerp__.py' | |||
2 | --- contract_isp_package_configurator/__openerp__.py 2013-09-16 17:59:01 +0000 | |||
3 | +++ contract_isp_package_configurator/__openerp__.py 2014-04-07 19:36:16 +0000 | |||
4 | @@ -28,7 +28,9 @@ | |||
5 | 28 | Contract ISP Package Configurator | 28 | Contract ISP Package Configurator |
6 | 29 | ================================= | 29 | ================================= |
7 | 30 | 30 | ||
9 | 31 | This module provides a wizard to help create service packages based on product inter-dependencies. It uses the dependency tree provided by the product_dependencies module.""", | 31 | This module provides a wizard to help create service packages based on product\ |
10 | 32 | inter-dependencies. It uses the dependency tree provided by the\ | ||
11 | 33 | product_dependencies module.""", | ||
12 | 32 | 'author': 'Savoirfaire-Linux Inc', | 34 | 'author': 'Savoirfaire-Linux Inc', |
13 | 33 | 'website': 'www.savoirfairelinux.com', | 35 | 'website': 'www.savoirfairelinux.com', |
14 | 34 | 'license': 'AGPL-3', | 36 | 'license': 'AGPL-3', |
15 | 35 | 37 | ||
16 | === modified file 'contract_isp_package_configurator/company.py' | |||
17 | --- contract_isp_package_configurator/company.py 2013-09-16 17:59:01 +0000 | |||
18 | +++ contract_isp_package_configurator/company.py 2014-04-07 19:36:16 +0000 | |||
19 | @@ -30,5 +30,6 @@ | |||
20 | 30 | 'product.category', | 30 | 'product.category', |
21 | 31 | 'Default Product Category', | 31 | 'Default Product Category', |
22 | 32 | required=True, | 32 | required=True, |
24 | 33 | help='''Set the default starting point for the package configuration wizard'''), | 33 | help='''Set the default starting point for the package \ |
25 | 34 | configuration wizard'''), | ||
26 | 34 | } | 35 | } |
27 | 35 | 36 | ||
28 | === modified file 'contract_isp_package_configurator/contract_isp_package_configurator_view.xml' | |||
29 | --- contract_isp_package_configurator/contract_isp_package_configurator_view.xml 2013-09-16 17:59:01 +0000 | |||
30 | +++ contract_isp_package_configurator/contract_isp_package_configurator_view.xml 2014-04-07 19:36:16 +0000 | |||
31 | @@ -13,17 +13,16 @@ | |||
32 | 13 | </xpath> | 13 | </xpath> |
33 | 14 | </field> | 14 | </field> |
34 | 15 | </record> | 15 | </record> |
46 | 16 | <record id="view_company_form_package_configurator" model="ir.ui.view"> | 16 | <record id="view_company_form_package_configurator" model="ir.ui.view"> |
47 | 17 | <field name="name">company.form.package.configurator</field> | 17 | <field name="name">company.form.package.configurator</field> |
48 | 18 | <field name="model">res.company</field> | 18 | <field name="model">res.company</field> |
49 | 19 | <field name="inherit_id" ref="contract_isp.view_company_contract_isp_form"/> | 19 | <field name="inherit_id" ref="contract_isp.view_company_contract_isp_form"/> |
50 | 20 | <field name="arch" type="xml"> | 20 | <field name="arch" type="xml"> |
51 | 21 | <field name="parent_account_id" position="before"> | 21 | <field name="parent_account_id" position="before"> |
52 | 22 | <field name="default_product_category" /> | 22 | <field name="default_product_category" /> |
53 | 23 | </field> | 23 | </field> |
54 | 24 | </field> | 24 | </field> |
55 | 25 | </record> | 25 | </record> |
45 | 26 | |||
56 | 27 | </data> | 26 | </data> |
57 | 28 | </openerp> | 27 | </openerp> |
58 | 29 | 28 | ||
59 | 30 | 29 | ||
60 | === modified file 'contract_isp_package_configurator/i18n/contract_isp_package_configurator.pot' | |||
61 | --- contract_isp_package_configurator/i18n/contract_isp_package_configurator.pot 2013-09-16 17:59:01 +0000 | |||
62 | +++ contract_isp_package_configurator/i18n/contract_isp_package_configurator.pot 2014-04-07 19:36:16 +0000 | |||
63 | @@ -0,0 +1,263 @@ | |||
64 | 1 | # Translation of OpenERP Server. | ||
65 | 2 | # This file contains the translation of the following modules: | ||
66 | 3 | # * contract_isp_package_configurator | ||
67 | 4 | # | ||
68 | 5 | msgid "" | ||
69 | 6 | msgstr "" | ||
70 | 7 | "Project-Id-Version: OpenERP Server 7.0\n" | ||
71 | 8 | "Report-Msgid-Bugs-To: \n" | ||
72 | 9 | "POT-Creation-Date: 2014-04-02 19:06+0000\n" | ||
73 | 10 | "PO-Revision-Date: 2014-04-02 19:06+0000\n" | ||
74 | 11 | "Last-Translator: <>\n" | ||
75 | 12 | "Language-Team: \n" | ||
76 | 13 | "MIME-Version: 1.0\n" | ||
77 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
78 | 15 | "Content-Transfer-Encoding: \n" | ||
79 | 16 | "Plural-Forms: \n" | ||
80 | 17 | |||
81 | 18 | #. module: contract_isp_package_configurator | ||
82 | 19 | #: view:contract.service.configurator:0 | ||
83 | 20 | #: field:contract.service.configurator,product_category_id:0 | ||
84 | 21 | #: field:contract.service.configurator,root_category_id:0 | ||
85 | 22 | msgid "Category" | ||
86 | 23 | msgstr "" | ||
87 | 24 | |||
88 | 25 | #. module: contract_isp_package_configurator | ||
89 | 26 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:42 | ||
90 | 27 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:114 | ||
91 | 28 | #: selection:contract.service.configurator.dependency.line,state:0 | ||
92 | 29 | #: selection:contract.service.configurator.line,state:0 | ||
93 | 30 | #, python-format | ||
94 | 31 | msgid "Information" | ||
95 | 32 | msgstr "" | ||
96 | 33 | |||
97 | 34 | #. module: contract_isp_package_configurator | ||
98 | 35 | #: field:contract.service.configurator,is_level2:0 | ||
99 | 36 | msgid "Is level 2" | ||
100 | 37 | msgstr "" | ||
101 | 38 | |||
102 | 39 | #. module: contract_isp_package_configurator | ||
103 | 40 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:149 | ||
104 | 41 | #: selection:contract.service.configurator,state:0 | ||
105 | 42 | #, python-format | ||
106 | 43 | msgid "Select product" | ||
107 | 44 | msgstr "" | ||
108 | 45 | |||
109 | 46 | #. module: contract_isp_package_configurator | ||
110 | 47 | #: field:contract.service.configurator.dependency.line,handle_dependency:0 | ||
111 | 48 | #: field:contract.service.configurator.line,handle_dependency:0 | ||
112 | 49 | msgid "Handle dependencies" | ||
113 | 50 | msgstr "" | ||
114 | 51 | |||
115 | 52 | #. module: contract_isp_package_configurator | ||
116 | 53 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:44 | ||
117 | 54 | #: selection:contract.service.configurator.dependency.line,state:0 | ||
118 | 55 | #: selection:contract.service.configurator.line,state:0 | ||
119 | 56 | #, python-format | ||
120 | 57 | msgid "No Stock" | ||
121 | 58 | msgstr "" | ||
122 | 59 | |||
123 | 60 | #. module: contract_isp_package_configurator | ||
124 | 61 | #: model:ir.model,name:contract_isp_package_configurator.model_contract_service_configurator_dependency_line | ||
125 | 62 | msgid "contract.service.configurator.dependency.line" | ||
126 | 63 | msgstr "" | ||
127 | 64 | |||
128 | 65 | #. module: contract_isp_package_configurator | ||
129 | 66 | #: view:contract.service.configurator:0 | ||
130 | 67 | msgid "Next" | ||
131 | 68 | msgstr "" | ||
132 | 69 | |||
133 | 70 | #. module: contract_isp_package_configurator | ||
134 | 71 | #: help:res.company,default_product_category:0 | ||
135 | 72 | msgid "Set the default starting point for the package configuration wizard" | ||
136 | 73 | msgstr "" | ||
137 | 74 | |||
138 | 75 | #. module: contract_isp_package_configurator | ||
139 | 76 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:148 | ||
140 | 77 | #: selection:contract.service.configurator,state:0 | ||
141 | 78 | #, python-format | ||
142 | 79 | msgid "Start" | ||
143 | 80 | msgstr "" | ||
144 | 81 | |||
145 | 82 | #. module: contract_isp_package_configurator | ||
146 | 83 | #: view:contract.service.configurator:0 | ||
147 | 84 | msgid "Add" | ||
148 | 85 | msgstr "" | ||
149 | 86 | |||
150 | 87 | #. module: contract_isp_package_configurator | ||
151 | 88 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:43 | ||
152 | 89 | #: selection:contract.service.configurator.dependency.line,state:0 | ||
153 | 90 | #: selection:contract.service.configurator.line,state:0 | ||
154 | 91 | #, python-format | ||
155 | 92 | msgid "Select serial number" | ||
156 | 93 | msgstr "" | ||
157 | 94 | |||
158 | 95 | #. module: contract_isp_package_configurator | ||
159 | 96 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:150 | ||
160 | 97 | #: selection:contract.service.configurator,state:0 | ||
161 | 98 | #, python-format | ||
162 | 99 | msgid "Select components" | ||
163 | 100 | msgstr "" | ||
164 | 101 | |||
165 | 102 | #. module: contract_isp_package_configurator | ||
166 | 103 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:356 | ||
167 | 104 | #, python-format | ||
168 | 105 | msgid "Product not found!" | ||
169 | 106 | msgstr "" | ||
170 | 107 | |||
171 | 108 | #. module: contract_isp_package_configurator | ||
172 | 109 | #: view:contract.service.configurator:0 | ||
173 | 110 | #: field:contract.service.configurator.dependency.line,product_id:0 | ||
174 | 111 | #: field:contract.service.configurator.line,product_id:0 | ||
175 | 112 | msgid "Product" | ||
176 | 113 | msgstr "" | ||
177 | 114 | |||
178 | 115 | #. module: contract_isp_package_configurator | ||
179 | 116 | #: field:contract.service.configurator,current_product_id:0 | ||
180 | 117 | msgid "Add Product" | ||
181 | 118 | msgstr "" | ||
182 | 119 | |||
183 | 120 | #. module: contract_isp_package_configurator | ||
184 | 121 | #: field:contract.service.configurator.dependency.line,parent_id:0 | ||
185 | 122 | #: field:contract.service.configurator.line,parent_id:0 | ||
186 | 123 | msgid "Parent" | ||
187 | 124 | msgstr "" | ||
188 | 125 | |||
189 | 126 | #. module: contract_isp_package_configurator | ||
190 | 127 | #: field:contract.service.configurator.dependency.line,serial:0 | ||
191 | 128 | #: view:contract.service.configurator.line:0 | ||
192 | 129 | #: field:contract.service.configurator.line,serial:0 | ||
193 | 130 | msgid "Serial Number" | ||
194 | 131 | msgstr "" | ||
195 | 132 | |||
196 | 133 | #. module: contract_isp_package_configurator | ||
197 | 134 | #: field:contract.service.configurator,dependency_ids:0 | ||
198 | 135 | msgid "Dependencies" | ||
199 | 136 | msgstr "" | ||
200 | 137 | |||
201 | 138 | #. module: contract_isp_package_configurator | ||
202 | 139 | #: field:res.company,default_product_category:0 | ||
203 | 140 | msgid "Default Product Category" | ||
204 | 141 | msgstr "" | ||
205 | 142 | |||
206 | 143 | #. module: contract_isp_package_configurator | ||
207 | 144 | #: field:contract.service.configurator,line_ids:0 | ||
208 | 145 | msgid "Line" | ||
209 | 146 | msgstr "" | ||
210 | 147 | |||
211 | 148 | #. module: contract_isp_package_configurator | ||
212 | 149 | #: model:ir.model,name:contract_isp_package_configurator.model_contract_service_configurator_line | ||
213 | 150 | msgid "contract.service.configurator.line" | ||
214 | 151 | msgstr "" | ||
215 | 152 | |||
216 | 153 | #. module: contract_isp_package_configurator | ||
217 | 154 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:414 | ||
218 | 155 | #, python-format | ||
219 | 156 | msgid "Product Details" | ||
220 | 157 | msgstr "" | ||
221 | 158 | |||
222 | 159 | #. module: contract_isp_package_configurator | ||
223 | 160 | #: view:contract.service.configurator.line:0 | ||
224 | 161 | msgid "Ok" | ||
225 | 162 | msgstr "" | ||
226 | 163 | |||
227 | 164 | #. module: contract_isp_package_configurator | ||
228 | 165 | #: field:contract.service.configurator.dependency.line,name:0 | ||
229 | 166 | #: field:contract.service.configurator.line,name:0 | ||
230 | 167 | msgid "Name" | ||
231 | 168 | msgstr "" | ||
232 | 169 | |||
233 | 170 | #. module: contract_isp_package_configurator | ||
234 | 171 | #: model:ir.model,name:contract_isp_package_configurator.model_contract_service_configurator | ||
235 | 172 | msgid "contract.service.configurator" | ||
236 | 173 | msgstr "" | ||
237 | 174 | |||
238 | 175 | #. module: contract_isp_package_configurator | ||
239 | 176 | #: model:ir.model,name:contract_isp_package_configurator.model_res_company | ||
240 | 177 | msgid "Companies" | ||
241 | 178 | msgstr "" | ||
242 | 179 | |||
243 | 180 | #. module: contract_isp_package_configurator | ||
244 | 181 | #: field:contract.service.configurator,contract_id:0 | ||
245 | 182 | msgid "Contract" | ||
246 | 183 | msgstr "" | ||
247 | 184 | |||
248 | 185 | #. module: contract_isp_package_configurator | ||
249 | 186 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:41 | ||
250 | 187 | #: selection:contract.service.configurator.dependency.line,state:0 | ||
251 | 188 | #: selection:contract.service.configurator.line,state:0 | ||
252 | 189 | #, python-format | ||
253 | 190 | msgid "Added" | ||
254 | 191 | msgstr "" | ||
255 | 192 | |||
256 | 193 | #. module: contract_isp_package_configurator | ||
257 | 194 | #: view:contract.service.configurator:0 | ||
258 | 195 | #: view:contract.service.configurator.line:0 | ||
259 | 196 | msgid "Products" | ||
260 | 197 | msgstr "" | ||
261 | 198 | |||
262 | 199 | #. module: contract_isp_package_configurator | ||
263 | 200 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:356 | ||
264 | 201 | #, python-format | ||
265 | 202 | msgid "Error" | ||
266 | 203 | msgstr "" | ||
267 | 204 | |||
268 | 205 | #. module: contract_isp_package_configurator | ||
269 | 206 | #: view:account.analytic.account:0 | ||
270 | 207 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:426 | ||
271 | 208 | #: view:contract.service.configurator:0 | ||
272 | 209 | #: field:contract.service.configurator.dependency.line,configurator_id:0 | ||
273 | 210 | #: view:contract.service.configurator.line:0 | ||
274 | 211 | #: field:contract.service.configurator.line,configurator_id:0 | ||
275 | 212 | #: model:ir.actions.act_window,name:contract_isp_package_configurator.action_contract_isp_package_configurator | ||
276 | 213 | #, python-format | ||
277 | 214 | msgid "Package Configurator" | ||
278 | 215 | msgstr "" | ||
279 | 216 | |||
280 | 217 | #. module: contract_isp_package_configurator | ||
281 | 218 | #: field:contract.service.configurator.dependency.line,stock_move_id:0 | ||
282 | 219 | #: field:contract.service.configurator.line,stock_move_id:0 | ||
283 | 220 | msgid "Stock Move" | ||
284 | 221 | msgstr "" | ||
285 | 222 | |||
286 | 223 | #. module: contract_isp_package_configurator | ||
287 | 224 | #: field:contract.service.configurator,state:0 | ||
288 | 225 | #: field:contract.service.configurator.dependency.line,state:0 | ||
289 | 226 | #: field:contract.service.configurator.line,state:0 | ||
290 | 227 | msgid "State" | ||
291 | 228 | msgstr "" | ||
292 | 229 | |||
293 | 230 | #. module: contract_isp_package_configurator | ||
294 | 231 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:45 | ||
295 | 232 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:151 | ||
296 | 233 | #: view:contract.service.configurator:0 | ||
297 | 234 | #: selection:contract.service.configurator,state:0 | ||
298 | 235 | #: selection:contract.service.configurator.dependency.line,state:0 | ||
299 | 236 | #: selection:contract.service.configurator.line,state:0 | ||
300 | 237 | #, python-format | ||
301 | 238 | msgid "Done" | ||
302 | 239 | msgstr "" | ||
303 | 240 | |||
304 | 241 | #. module: contract_isp_package_configurator | ||
305 | 242 | #: view:contract.service.configurator:0 | ||
306 | 243 | msgid "Click on add to view the available components" | ||
307 | 244 | msgstr "" | ||
308 | 245 | |||
309 | 246 | #. module: contract_isp_package_configurator | ||
310 | 247 | #: code:addons/contract_isp_package_configurator/wizard/package_configurator.py:450 | ||
311 | 248 | #: view:contract.service.configurator:0 | ||
312 | 249 | #, python-format | ||
313 | 250 | msgid "Cancel" | ||
314 | 251 | msgstr "" | ||
315 | 252 | |||
316 | 253 | #. module: contract_isp_package_configurator | ||
317 | 254 | #: field:contract.service.configurator.dependency.line,message:0 | ||
318 | 255 | #: field:contract.service.configurator.line,message:0 | ||
319 | 256 | msgid "Message" | ||
320 | 257 | msgstr "" | ||
321 | 258 | |||
322 | 259 | #. module: contract_isp_package_configurator | ||
323 | 260 | #: view:contract.service.configurator.line:0 | ||
324 | 261 | msgid "We don't have this product in stock at the moment!" | ||
325 | 262 | msgstr "" | ||
326 | 263 | |||
327 | 0 | 264 | ||
328 | === modified file 'contract_isp_package_configurator/wizard/package_configurator.py' | |||
329 | --- contract_isp_package_configurator/wizard/package_configurator.py 2013-10-11 14:30:38 +0000 | |||
330 | +++ contract_isp_package_configurator/wizard/package_configurator.py 2014-04-07 19:36:16 +0000 | |||
331 | @@ -27,7 +27,6 @@ | |||
332 | 27 | class contract_service_configurator_line(orm.TransientModel): | 27 | class contract_service_configurator_line(orm.TransientModel): |
333 | 28 | _name = 'contract.service.configurator.line' | 28 | _name = 'contract.service.configurator.line' |
334 | 29 | 29 | ||
335 | 30 | #def _get_stock_production_lot_available(self, cr, uid, ) | ||
336 | 31 | _columns = { | 30 | _columns = { |
337 | 32 | 'name': fields.char('Name'), | 31 | 'name': fields.char('Name'), |
338 | 33 | 'product_id': fields.many2one('product.product', 'Product'), | 32 | 'product_id': fields.many2one('product.product', 'Product'), |
339 | @@ -42,7 +41,7 @@ | |||
340 | 42 | 'state': fields.selection((('draft', _('Added')), | 41 | 'state': fields.selection((('draft', _('Added')), |
341 | 43 | ('message', _('Information')), | 42 | ('message', _('Information')), |
342 | 44 | ('serial', _('Select serial number')), | 43 | ('serial', _('Select serial number')), |
344 | 45 | ('stock', ('No Stock')), | 44 | ('stock', _('No Stock')), |
345 | 46 | ('done', _('Done'))), 'State'), | 45 | ('done', _('Done'))), 'State'), |
346 | 47 | } | 46 | } |
347 | 48 | 47 | ||
348 | @@ -51,37 +50,43 @@ | |||
349 | 51 | } | 50 | } |
350 | 52 | 51 | ||
351 | 53 | def router(self, cr, uid, ids, data=None, context=None): | 52 | def router(self, cr, uid, ids, data=None, context=None): |
352 | 53 | if isinstance(ids, list): | ||
353 | 54 | ids = ids[0] | ||
354 | 55 | pool_stock_move = self.pool.get('stock.move') | ||
355 | 56 | pool_model_data = self.pool.get('ir.model.data') | ||
356 | 57 | |||
357 | 54 | stock_move_id = None | 58 | stock_move_id = None |
358 | 55 | if isinstance(ids, list): | ||
359 | 56 | ids = ids[0] | ||
360 | 57 | line = self.browse(cr, uid, ids, context=context) | 59 | line = self.browse(cr, uid, ids, context=context) |
361 | 58 | if line.state == 'message': | 60 | if line.state == 'message': |
364 | 59 | if line.product_id.type == 'product' and \ | 61 | if line.product_id.type == 'product' \ |
365 | 60 | line.product_id.qty_available > 0.0: | 62 | and line.product_id.qty_available > 0: |
366 | 61 | state = 'serial' | 63 | state = 'serial' |
367 | 62 | else: | 64 | else: |
368 | 63 | state = 'stock' | 65 | state = 'stock' |
369 | 64 | elif line.state in ('serial', 'stock'): | 66 | elif line.state in ('serial', 'stock'): |
374 | 65 | stock_move_obj = self.pool.get('stock.move') | 67 | location_id = \ |
375 | 66 | location_id = self.pool.get('ir.model.data').get_object_reference( | 68 | pool_model_data.get_object_reference(cr, uid, 'stock', |
376 | 67 | cr, uid, 'stock', 'stock_location_stock')[1] | 69 | 'stock_location_stock')[1] |
377 | 68 | location_dest_id = line.configurator_id.contract_id.partner_id.property_stock_customer.id | 70 | partner = line.configurator_id.contract_id.partner_id |
378 | 71 | product = line.product_id and line.product_id | ||
379 | 72 | product_uom = product and product.uom_id | ||
380 | 73 | location_dest_id = partner.property_stock_customer.id | ||
381 | 69 | move = { | 74 | move = { |
382 | 70 | 'name': line.product_id and line.product_id.name or '', | 75 | 'name': line.product_id and line.product_id.name or '', |
385 | 71 | 'product_id': line.product_id and line.product_id.id, | 76 | 'product_id': product and product.id, |
386 | 72 | 'product_uom': line.product_id and line.product_id.uom_id and line.product_id.uom_id.id or None, | 77 | 'product_uom': product_uom and product_uom.id or None, |
387 | 73 | 'prodlot_id': line.serial and line.serial.id or None, | 78 | 'prodlot_id': line.serial and line.serial.id or None, |
388 | 74 | 'location_id': location_id, | 79 | 'location_id': location_id, |
389 | 75 | 'location_dest_id': location_dest_id, | 80 | 'location_dest_id': location_dest_id, |
391 | 76 | 'partner_id': line.configurator_id.contract_id.partner_id.id, | 81 | 'partner_id': partner.id, |
392 | 77 | 'type': 'out' | 82 | 'type': 'out' |
393 | 78 | } | 83 | } |
400 | 79 | stock_move_id = stock_move_obj.create( | 84 | stock_move_id = pool_stock_move.create(cr, uid, move, |
401 | 80 | cr, uid, move, context=context) | 85 | context=context) |
402 | 81 | stock_move_obj.action_confirm( | 86 | pool_stock_move.action_confirm(cr, uid, [stock_move_id], |
403 | 82 | cr, uid, [stock_move_id], context=context) | 87 | context=context) |
404 | 83 | stock_move_obj.action_done( | 88 | pool_stock_move.action_done(cr, uid, [stock_move_id], |
405 | 84 | cr, uid, [stock_move_id], context=context) | 89 | context=context) |
406 | 85 | 90 | ||
407 | 86 | state = 'done' | 91 | state = 'done' |
408 | 87 | 92 | ||
409 | @@ -93,37 +98,21 @@ | |||
410 | 93 | if isinstance(ids, int): | 98 | if isinstance(ids, int): |
411 | 94 | ids = [ids] | 99 | ids = [ids] |
412 | 95 | 100 | ||
432 | 96 | for line in self.browse(cr, uid, ids, context=context): | 101 | cancel_dependancy(self, cr, uid, ids, context, cancel_line=False) |
414 | 97 | if line.product_id.type == 'product' and line.stock_move_id: | ||
415 | 98 | stock_move_obj = self.pool.get('stock.move') | ||
416 | 99 | move = { | ||
417 | 100 | 'name': ' '.join([_('Cancel'), line.product_id and line.product_id.name or '']), | ||
418 | 101 | 'product_id': line.product_id and line.product_id.id, | ||
419 | 102 | 'product_uom': line.product_id and line.product_id.uom_id and line.product_id.uom_id.id or None, | ||
420 | 103 | 'prodlot_id': line.serial and line.serial.id or None, | ||
421 | 104 | 'location_id': line.stock_move_id.location_dest_id.id, | ||
422 | 105 | 'location_dest_id': line.stock_move_id.location_id.id, | ||
423 | 106 | 'partner_id': line.configurator_id.contract_id.partner_id.id, | ||
424 | 107 | 'type': 'in' | ||
425 | 108 | } | ||
426 | 109 | stock_move_id = stock_move_obj.create( | ||
427 | 110 | cr, uid, move, context=context) | ||
428 | 111 | stock_move_obj.action_confirm( | ||
429 | 112 | cr, uid, [stock_move_id], context=context) | ||
430 | 113 | stock_move_obj.action_done( | ||
431 | 114 | cr, uid, [stock_move_id], context=context) | ||
433 | 115 | 102 | ||
434 | 116 | return super(contract_service_configurator_line, self).unlink( | 103 | return super(contract_service_configurator_line, self).unlink( |
435 | 117 | cr, uid, ids, context=context) | 104 | cr, uid, ids, context=context) |
436 | 118 | 105 | ||
437 | 119 | def onchange_product_id(self, cr, uid, ids, product_id, context): | 106 | def onchange_product_id(self, cr, uid, ids, product_id, context): |
438 | 120 | ret = {} | 107 | ret = {} |
440 | 121 | product_product_obj = self.pool.get('product.product') | 108 | pool_product_product = self.pool.get('product.product') |
441 | 109 | product_product_obj = pool_product_product.browse(cr, uid, product_id, | ||
442 | 110 | context) | ||
443 | 122 | 111 | ||
445 | 123 | if product_product_obj.browse(cr, uid, product_id, context).description: | 112 | if product_product_obj.description: |
446 | 124 | ret['warning'] = { | 113 | ret['warning'] = { |
447 | 125 | 'title': _('Information'), | 114 | 'title': _('Information'), |
449 | 126 | 'message': product_product_obj.browse(cr, uid, product_id, context).description | 115 | 'message': product_product_obj.description |
450 | 127 | } | 116 | } |
451 | 128 | return ret | 117 | return ret |
452 | 129 | 118 | ||
453 | @@ -136,46 +125,41 @@ | |||
454 | 136 | class contract_service_configurator(orm.TransientModel): | 125 | class contract_service_configurator(orm.TransientModel): |
455 | 137 | _name = 'contract.service.configurator' | 126 | _name = 'contract.service.configurator' |
456 | 138 | 127 | ||
458 | 139 | def _get_default_category(self, cr, uid, context=None): | 128 | def get_default_category(self, cr, uid, context=None): |
459 | 140 | res_company_obj = self.pool.get("res.company") | 129 | res_company_obj = self.pool.get("res.company") |
460 | 141 | company_id = res_company_obj._company_default_get(cr, uid, context) | 130 | company_id = res_company_obj._company_default_get(cr, uid, context) |
461 | 142 | res_company = res_company_obj.browse(cr, uid, company_id, | 131 | res_company = res_company_obj.browse(cr, uid, company_id, |
462 | 143 | context=context) | 132 | context=context) |
465 | 144 | return res_company.default_product_category and \ | 133 | cat = res_company.default_product_category |
466 | 145 | res_company.default_product_category.id | 134 | return cat and cat.id |
467 | 146 | 135 | ||
469 | 147 | def _get_is_level2(self, cr, uid, context=None): | 136 | def get_is_level2(self, cr, uid, context=None): |
470 | 148 | ir_model_data_obj = self.pool.get('ir.model.data') | 137 | ir_model_data_obj = self.pool.get('ir.model.data') |
471 | 149 | res_groups_obj = self.pool.get('res.groups') | ||
472 | 150 | res_user = self.pool.get('res.users').browse( | 138 | res_user = self.pool.get('res.users').browse( |
473 | 151 | cr, uid, uid, context={}) | 139 | cr, uid, uid, context={}) |
474 | 152 | group_agent_n2_id = ir_model_data_obj.get_object_reference( | 140 | group_agent_n2_id = ir_model_data_obj.get_object_reference( |
475 | 153 | cr, uid, 'contract_isp', 'group_isp_agent2')[1] | 141 | cr, uid, 'contract_isp', 'group_isp_agent2')[1] |
476 | 154 | group_agent_n2 = res_groups_obj.browse( | ||
477 | 155 | cr, uid, group_agent_n2_id, context={}) | ||
478 | 156 | 142 | ||
479 | 157 | groups_id = [i.id for i in res_user.groups_id] | 143 | groups_id = [i.id for i in res_user.groups_id] |
484 | 158 | if group_agent_n2_id not in groups_id: | 144 | return group_agent_n2_id in groups_id |
481 | 159 | return False | ||
482 | 160 | else: | ||
483 | 161 | return True | ||
485 | 162 | 145 | ||
486 | 163 | _columns = { | 146 | _columns = { |
487 | 164 | 'contract_id': fields.many2one('account.analytic.account', 'Contract'), | 147 | 'contract_id': fields.many2one('account.analytic.account', 'Contract'), |
488 | 165 | 'state': fields.selection((('draft', _('Start')), | 148 | 'state': fields.selection((('draft', _('Start')), |
489 | 149 | ('dependency', _('Select components')), | ||
490 | 166 | ('product', _('Select product')), | 150 | ('product', _('Select product')), |
491 | 167 | ('dependency', _('Select components')), | ||
492 | 168 | ('done', _('Done'))), 'State'), | 151 | ('done', _('Done'))), 'State'), |
493 | 169 | 'line_ids': fields.one2many('contract.service.configurator.line', | 152 | 'line_ids': fields.one2many('contract.service.configurator.line', |
494 | 170 | 'configurator_id', | 153 | 'configurator_id', |
495 | 171 | 'Line'), | 154 | 'Line'), |
496 | 172 | 'current_product_id': fields.many2one('product.product', | 155 | 'current_product_id': fields.many2one('product.product', |
497 | 173 | 'Add Product'), | 156 | 'Add Product'), |
503 | 174 | 'dependency_ids': fields.many2many('contract.service.configurator.dependency.line', | 157 | 'dependency_ids': fields.many2many( |
504 | 175 | 'contract_service_configurator_dependency_rel', | 158 | 'contract.service.configurator.dependency.line', |
505 | 176 | 'configurator_id', | 159 | 'contract_service_configurator_dependency_rel', |
506 | 177 | 'dependency_id', | 160 | 'configurator_id', |
507 | 178 | 'Dependencies'), | 161 | 'dependency_id', |
508 | 162 | 'Dependencies'), | ||
509 | 179 | 'root_category_id': fields.many2one('product.category', 'Category'), | 163 | 'root_category_id': fields.many2one('product.category', 'Category'), |
510 | 180 | 'product_category_id': fields.many2one('product.category', 'Category'), | 164 | 'product_category_id': fields.many2one('product.category', 'Category'), |
511 | 181 | 'is_level2': fields.boolean('Is level 2') | 165 | 'is_level2': fields.boolean('Is level 2') |
512 | @@ -183,16 +167,18 @@ | |||
513 | 183 | 167 | ||
514 | 184 | _defaults = { | 168 | _defaults = { |
515 | 185 | 'state': 'draft', | 169 | 'state': 'draft', |
519 | 186 | 'product_category_id': lambda s, cr, uid, ctx: s._get_default_category(cr, uid, ctx), | 170 | 'product_category_id': |
520 | 187 | 'root_category_id': lambda s, cr, uid, ctx: s._get_default_category(cr, uid, ctx), | 171 | lambda s, cr, uid, ctx: s.get_default_category(cr, uid, ctx), |
521 | 188 | 'is_level2': lambda s, cr, uid, ctx: s._get_is_level2(cr, uid, ctx) | 172 | 'root_category_id': |
522 | 173 | lambda s, cr, uid, ctx: s.get_default_category(cr, uid, ctx), | ||
523 | 174 | 'is_level2': lambda s, cr, uid, ctx: s.get_is_level2(cr, uid, ctx) | ||
524 | 189 | } | 175 | } |
525 | 190 | 176 | ||
528 | 191 | def onchange_product_category_id(self, cr, uid, ids, | 177 | @staticmethod |
529 | 192 | product_category_id, is_level2): | 178 | def onchange_product_category_id(cr, uid, ids, product_category_id, |
530 | 179 | is_level2): | ||
531 | 193 | domain = [('categ_id', '=', product_category_id)] | 180 | domain = [('categ_id', '=', product_category_id)] |
534 | 194 | ret = { | 181 | ret = {'domain': {'current_product_id': None}} |
533 | 195 | 'domain': {'current_product_id': None}} | ||
535 | 196 | 182 | ||
536 | 197 | if not is_level2: | 183 | if not is_level2: |
537 | 198 | domain.append(('list_price', '>=', 0)) | 184 | domain.append(('list_price', '>=', 0)) |
538 | @@ -202,9 +188,10 @@ | |||
539 | 202 | return ret | 188 | return ret |
540 | 203 | 189 | ||
541 | 204 | def do_next(self, cr, uid, ids, context=None): | 190 | def do_next(self, cr, uid, ids, context=None): |
545 | 205 | contract_service_configurator_line_obj = self.pool.get('contract.service.configurator.line') | 191 | contract_service_configurator_line_obj = self.pool.get( |
546 | 206 | contract_service_configurator_dependency_line_obj = self.pool.get('contract.service.configurator.dependency.line') | 192 | 'contract.service.configurator.line') |
547 | 207 | product_product_obj = self.pool.get('product.product') | 193 | pool_conf_dep_line = self.pool.get( |
548 | 194 | 'contract.service.configurator.dependency.line') | ||
549 | 208 | 195 | ||
550 | 209 | wizard = self.browse(cr, uid, ids[0], context=context) | 196 | wizard = self.browse(cr, uid, ids[0], context=context) |
551 | 210 | 197 | ||
552 | @@ -221,117 +208,116 @@ | |||
553 | 221 | 'name': line.product_id.name, | 208 | 'name': line.product_id.name, |
554 | 222 | 'product_id': line.product_id.id, | 209 | 'product_id': line.product_id.id, |
555 | 223 | 'configurator_id': wizard.id, | 210 | 'configurator_id': wizard.id, |
557 | 224 | 'handle_dependency': line.product_id.dependency_ids and True or False, | 211 | 'handle_dependency': line.product_id.dependency_ids, |
558 | 225 | 'message': line.product_id.description, | 212 | 'message': line.product_id.description, |
559 | 226 | 'state': state | 213 | 'state': state |
560 | 227 | } | 214 | } |
562 | 228 | contract_service_configurator_line_obj.create(cr, uid, l, context=context) | 215 | contract_service_configurator_line_obj.create(cr, uid, l, |
563 | 216 | context=context) | ||
564 | 229 | 217 | ||
565 | 230 | query = [('configurator_id', '=', wizard.id)] | 218 | query = [('configurator_id', '=', wizard.id)] |
570 | 231 | ids_to_unlink = contract_service_configurator_dependency_line_obj.search(cr, | 219 | ids_to_unlink = pool_conf_dep_line.search( |
571 | 232 | uid, | 220 | cr, |
572 | 233 | query, | 221 | uid, |
573 | 234 | context=context) | 222 | query, |
574 | 223 | context=context) | ||
575 | 235 | if ids_to_unlink: | 224 | if ids_to_unlink: |
579 | 236 | contract_service_configurator_dependency_line_obj.unlink(cr, uid, | 225 | pool_conf_dep_line.unlink(cr, uid, ids_to_unlink, context) |
577 | 237 | ids_to_unlink, | ||
578 | 238 | context) | ||
580 | 239 | 226 | ||
581 | 240 | loop_deps = False | 227 | loop_deps = False |
582 | 241 | for line in wizard.line_ids: | 228 | for line in wizard.line_ids: |
639 | 242 | if line.handle_dependency: | 229 | if not line.handle_dependency: |
640 | 243 | loop_deps = True | 230 | continue |
641 | 244 | for dep in line.product_id.dependency_ids: | 231 | |
642 | 245 | if dep.type == 'product': | 232 | loop_deps = True |
643 | 246 | if not wizard.is_level2 and dep.list_price < 0: | 233 | self._write_dependance(line, wizard, cr, uid, context) |
644 | 247 | continue | 234 | line.write({'handle_dependency': False}) |
645 | 248 | 235 | break | |
590 | 249 | if line.product_id.description: | ||
591 | 250 | state = 'message' | ||
592 | 251 | elif line.product_id.type == 'product': | ||
593 | 252 | state = 'serial' | ||
594 | 253 | else: | ||
595 | 254 | state = 'done' | ||
596 | 255 | |||
597 | 256 | wl = { | ||
598 | 257 | 'name': dep.product_id.name, | ||
599 | 258 | 'product_id': dep.product_id.id, | ||
600 | 259 | 'configurator_id': wizard.id, | ||
601 | 260 | 'parent_id': line.id, | ||
602 | 261 | 'message': line.product_id.description, | ||
603 | 262 | 'state': state | ||
604 | 263 | } | ||
605 | 264 | new_dep = contract_service_configurator_dependency_line_obj.create( | ||
606 | 265 | cr, uid, wl, context=context) | ||
607 | 266 | |||
608 | 267 | if dep.auto: | ||
609 | 268 | wizard.write({'dependency_ids': [(4, new_dep)]}) | ||
610 | 269 | |||
611 | 270 | elif dep.type == 'category': | ||
612 | 271 | query = [('categ_id', '=', dep.category_id.id)] | ||
613 | 272 | product_ids = product_product_obj.search(cr, uid, | ||
614 | 273 | query, | ||
615 | 274 | context=context) | ||
616 | 275 | for product in product_product_obj.browse(cr, uid, product_ids, context=context): | ||
617 | 276 | if not wizard.is_level2 and dep.list_price < 0: | ||
618 | 277 | continue | ||
619 | 278 | |||
620 | 279 | if line.product_id.description: | ||
621 | 280 | state = 'message' | ||
622 | 281 | elif line.product_id.type == 'product': | ||
623 | 282 | state = 'serial' | ||
624 | 283 | else: | ||
625 | 284 | state = 'done' | ||
626 | 285 | |||
627 | 286 | wl = { | ||
628 | 287 | 'name': product.name, | ||
629 | 288 | 'product_id': product.id, | ||
630 | 289 | 'configurator_id': wizard.id, | ||
631 | 290 | 'parent_id': line.id, | ||
632 | 291 | 'message': product.description, | ||
633 | 292 | 'state': state | ||
634 | 293 | } | ||
635 | 294 | contract_service_configurator_dependency_line_obj.create(cr, uid, wl, | ||
636 | 295 | context=context) | ||
637 | 296 | line.write({'handle_dependency': False}) | ||
638 | 297 | break | ||
646 | 298 | 236 | ||
647 | 299 | if loop_deps: | 237 | if loop_deps: |
648 | 300 | record = { | 238 | record = { |
649 | 301 | 'state': 'dependency', | 239 | 'state': 'dependency', |
650 | 302 | } | 240 | } |
651 | 303 | wizard.write(record) | ||
652 | 304 | return self.router(cr, uid, ids, {}, context=context) | ||
653 | 305 | |||
654 | 306 | else: | 241 | else: |
655 | 307 | record = { | 242 | record = { |
656 | 308 | 'state': 'product', | 243 | 'state': 'product', |
657 | 309 | 'current_product_id': None, | 244 | 'current_product_id': None, |
659 | 310 | 'dependency_ids': [(5)], | 245 | 'dependency_ids': [5], |
660 | 311 | } | 246 | } |
669 | 312 | wizard.write(record) | 247 | wizard.write(record) |
670 | 313 | 248 | return self.router(cr, uid, ids, {}, context=context) | |
671 | 314 | query = [('configurator_id', '=', wizard.id)] | 249 | |
672 | 315 | ids_to_unlink = contract_service_configurator_dependency_line_obj.search(cr, | 250 | def _write_dependance(self, line, wizard, cr, uid, context): |
673 | 316 | uid, | 251 | pool_conf_dep_line = self.pool.get( |
674 | 317 | query, | 252 | 'contract.service.configurator.dependency.line') |
675 | 318 | context=context) | 253 | product_product_obj = self.pool.get('product.product') |
676 | 319 | return self.router(cr, uid, ids, {}, context=context) | 254 | |
677 | 255 | contains_dep = False | ||
678 | 256 | for dep in line.product_id.dependency_ids: | ||
679 | 257 | if dep.type == 'product': | ||
680 | 258 | if not wizard.is_level2 and dep.list_price < 0: | ||
681 | 259 | continue | ||
682 | 260 | |||
683 | 261 | if line.product_id.description: | ||
684 | 262 | state = 'message' | ||
685 | 263 | elif line.product_id.type == 'product': | ||
686 | 264 | state = 'serial' | ||
687 | 265 | else: | ||
688 | 266 | state = 'done' | ||
689 | 267 | contains_dep = True | ||
690 | 268 | wl = { | ||
691 | 269 | 'name': dep.product_id.name, | ||
692 | 270 | 'product_id': dep.product_id.id, | ||
693 | 271 | 'configurator_id': wizard.id, | ||
694 | 272 | 'parent_id': line.id, | ||
695 | 273 | 'message': line.product_id.description, | ||
696 | 274 | 'state': state | ||
697 | 275 | } | ||
698 | 276 | new_dep = pool_conf_dep_line.create(cr, uid, wl, | ||
699 | 277 | context=context) | ||
700 | 278 | |||
701 | 279 | if dep.auto: | ||
702 | 280 | wizard.write({'dependency_ids': [(4, new_dep)]}) | ||
703 | 281 | |||
704 | 282 | elif dep.type == 'category': | ||
705 | 283 | query = [('categ_id', '=', dep.category_id.id)] | ||
706 | 284 | product_ids = product_product_obj.search(cr, uid, | ||
707 | 285 | query, | ||
708 | 286 | context=context) | ||
709 | 287 | for product in product_product_obj.browse(cr, uid, | ||
710 | 288 | product_ids, | ||
711 | 289 | context=context): | ||
712 | 290 | if not wizard.is_level2 and dep.list_price < 0: | ||
713 | 291 | continue | ||
714 | 292 | |||
715 | 293 | if line.product_id.description: | ||
716 | 294 | state = 'message' | ||
717 | 295 | elif line.product_id.type == 'product': | ||
718 | 296 | state = 'serial' | ||
719 | 297 | else: | ||
720 | 298 | state = 'done' | ||
721 | 299 | contains_dep = True | ||
722 | 300 | wl = { | ||
723 | 301 | 'name': product.name, | ||
724 | 302 | 'product_id': product.id, | ||
725 | 303 | 'configurator_id': wizard.id, | ||
726 | 304 | 'parent_id': line.id, | ||
727 | 305 | 'message': product.description, | ||
728 | 306 | 'state': state | ||
729 | 307 | } | ||
730 | 308 | pool_conf_dep_line.create( | ||
731 | 309 | cr, uid, wl, | ||
732 | 310 | context=context) | ||
733 | 311 | return contains_dep | ||
734 | 320 | 312 | ||
735 | 321 | def do_add_current_product_id(self, cr, uid, ids, context=None): | 313 | def do_add_current_product_id(self, cr, uid, ids, context=None): |
736 | 322 | if context is None: | 314 | if context is None: |
737 | 323 | context = {} | 315 | context = {} |
738 | 324 | deps = 0 | ||
739 | 325 | wizard = self.browse(cr, uid, ids[0], context=context) | 316 | wizard = self.browse(cr, uid, ids[0], context=context) |
746 | 326 | contract_service_configurator_line_obj = self.pool.get( | 317 | pool_cs_conf_line = self.pool.get('contract.service.configurator.line') |
741 | 327 | 'contract.service.configurator.line') | ||
742 | 328 | contract_service_configurator_dependency_line_obj = self.pool.get( | ||
743 | 329 | 'contract.service.configurator.dependency.line') | ||
744 | 330 | product_product_obj = self.pool.get('product.product') | ||
745 | 331 | contract_service_serial_obj = self.pool.get('contract.service.serial') | ||
747 | 332 | 318 | ||
748 | 333 | if wizard.current_product_id: | 319 | if wizard.current_product_id: |
750 | 334 | #if group_agent_n2_id not in res_user.groups_id and \ | 320 | # if group_agent_n2_id not in res_user.groups_id and \ |
751 | 335 | # wizard.current_product_id.type == 'product' and \ | 321 | # wizard.current_product_id.type == 'product' and \ |
752 | 336 | # wizard.current_product_id.qty_available <= 0: | 322 | # wizard.current_product_id.qty_available <= 0: |
753 | 337 | # raise orm.except_orm(_('Error!'), _('Product not available!')) | 323 | # raise orm.except_orm(_('Error!'), _('Product not available!')) |
754 | @@ -350,72 +336,19 @@ | |||
755 | 350 | 'message': wizard.current_product_id.description, | 336 | 'message': wizard.current_product_id.description, |
756 | 351 | 'state': state | 337 | 'state': state |
757 | 352 | } | 338 | } |
819 | 353 | new_line = contract_service_configurator_line_obj.create( | 339 | new_line = pool_cs_conf_line.create(cr, uid, record, |
820 | 354 | cr, uid, record, context=context) | 340 | context=context) |
821 | 355 | 341 | ||
822 | 356 | for dep in contract_service_configurator_line_obj.browse( | 342 | product_obj = pool_cs_conf_line.browse(cr, uid, new_line, |
823 | 357 | cr, uid, new_line, | 343 | context=context) |
824 | 358 | context=context).product_id.dependency_ids: | 344 | contains_dep = self._write_dependance(product_obj, wizard, cr, uid, |
825 | 359 | 345 | context) | |
765 | 360 | if dep.type == 'product': | ||
766 | 361 | if not wizard.is_level2 and dep.product_id.list_price < 0: | ||
767 | 362 | continue | ||
768 | 363 | |||
769 | 364 | if dep.product_id.description: | ||
770 | 365 | state = 'message' | ||
771 | 366 | elif dep.product_id.type == 'product': | ||
772 | 367 | state = 'serial' | ||
773 | 368 | else: | ||
774 | 369 | state = 'done' | ||
775 | 370 | |||
776 | 371 | deps += 1 | ||
777 | 372 | wl = { | ||
778 | 373 | 'name': dep.product_id.name, | ||
779 | 374 | 'product_id': dep.product_id.id, | ||
780 | 375 | 'configurator_id': wizard.id, | ||
781 | 376 | 'parent_id': new_line, | ||
782 | 377 | 'message': dep.product_id.description, | ||
783 | 378 | 'state': state | ||
784 | 379 | } | ||
785 | 380 | new_dep = contract_service_configurator_dependency_line_obj.create(cr, uid, wl, | ||
786 | 381 | context=context) | ||
787 | 382 | |||
788 | 383 | if dep.auto: | ||
789 | 384 | wizard.write({'dependency_ids': [(4, new_dep)]}) | ||
790 | 385 | |||
791 | 386 | elif dep.type == 'category': | ||
792 | 387 | query = [('categ_id', '=', dep.category_id.id)] | ||
793 | 388 | product_ids = product_product_obj.search(cr, uid, query, | ||
794 | 389 | context=context) | ||
795 | 390 | for product in product_product_obj.browse(cr, uid, | ||
796 | 391 | product_ids, | ||
797 | 392 | context=context): | ||
798 | 393 | if not wizard.is_level2 and dep.product_id.list_price < 0: | ||
799 | 394 | continue | ||
800 | 395 | |||
801 | 396 | if product.description: | ||
802 | 397 | state = 'message' | ||
803 | 398 | elif product.type == 'product': | ||
804 | 399 | state = 'serial' | ||
805 | 400 | else: | ||
806 | 401 | state = 'done' | ||
807 | 402 | |||
808 | 403 | deps += 1 | ||
809 | 404 | record = { | ||
810 | 405 | 'name': product.name, | ||
811 | 406 | 'product_id': product.id, | ||
812 | 407 | 'configurator_id': wizard.id, | ||
813 | 408 | 'parent_id': new_line, | ||
814 | 409 | 'message': product.description, | ||
815 | 410 | 'state': state | ||
816 | 411 | } | ||
817 | 412 | contract_service_configurator_dependency_line_obj.create( | ||
818 | 413 | cr, uid, record, context=context) | ||
826 | 414 | 346 | ||
827 | 415 | record = { | 347 | record = { |
828 | 416 | 'current_product_id': None, | 348 | 'current_product_id': None, |
831 | 417 | 'product_category_id': self._get_default_category(cr, uid, context), | 349 | 'product_category_id': self.get_default_category(cr, uid, |
832 | 418 | 'state': deps and 'dependency' or 'product' | 350 | context), |
833 | 351 | 'state': contains_dep and 'dependency' or 'product' | ||
834 | 419 | } | 352 | } |
835 | 420 | 353 | ||
836 | 421 | wizard.write(record) | 354 | wizard.write(record) |
837 | @@ -424,11 +357,7 @@ | |||
838 | 424 | raise orm.except_orm(_('Error'), _('Product not found!')) | 357 | raise orm.except_orm(_('Error'), _('Product not found!')) |
839 | 425 | 358 | ||
840 | 426 | def do_done(self, cr, uid, ids, context=None): | 359 | def do_done(self, cr, uid, ids, context=None): |
846 | 427 | account_analytic_account_obj = self.pool.get('account.analytic.account') | 360 | pool_contract_service = self.pool.get('contract.service') |
842 | 428 | contract_service_obj = self.pool.get('contract.service') | ||
843 | 429 | stock_move_obj = self.pool.get('stock.move') | ||
844 | 430 | contract_service_serial_obj = self.pool.get('contract.service.serial') | ||
845 | 431 | ret = self.write(cr, uid, ids, {'state': 'done'}, context=context) | ||
847 | 432 | wizard = self.browse(cr, uid, ids[0], context=context) | 361 | wizard = self.browse(cr, uid, ids[0], context=context) |
848 | 433 | for line in wizard.line_ids: | 362 | for line in wizard.line_ids: |
849 | 434 | l = { | 363 | l = { |
850 | @@ -439,7 +368,7 @@ | |||
851 | 439 | 'analytic_line_type': line.product_id.analytic_line_type, | 368 | 'analytic_line_type': line.product_id.analytic_line_type, |
852 | 440 | 'require_activation': line.product_id.require_activation | 369 | 'require_activation': line.product_id.require_activation |
853 | 441 | } | 370 | } |
855 | 442 | contract_service_obj.create(cr, uid, l, context=context) | 371 | pool_contract_service.create(cr, uid, l, context=context) |
856 | 443 | 372 | ||
857 | 444 | if line.product_id.type == 'product' and line.stock_move_id: | 373 | if line.product_id.type == 'product' and line.stock_move_id: |
858 | 445 | line.write({'stock_move_id': None}) | 374 | line.write({'stock_move_id': None}) |
859 | @@ -458,44 +387,26 @@ | |||
860 | 458 | if isinstance(ids, int): | 387 | if isinstance(ids, int): |
861 | 459 | ids = [ids] | 388 | ids = [ids] |
862 | 460 | 389 | ||
882 | 461 | for line in self.browse(cr, uid, ids[0], context=context).line_ids: | 390 | cancel_dependancy(self, cr, uid, ids, context, cancel_line=True) |
864 | 462 | if line.product_id.type == 'product' and line.stock_move_id: | ||
865 | 463 | stock_move_obj = self.pool.get('stock.move') | ||
866 | 464 | move = { | ||
867 | 465 | 'name': ' '.join([_('Cancel'), line.product_id and line.product_id.name or '']), | ||
868 | 466 | 'product_id': line.product_id and line.product_id.id, | ||
869 | 467 | 'product_uom': line.product_id and line.product_id.uom_id and line.product_id.uom_id.id or None, | ||
870 | 468 | 'prodlot_id': line.serial and line.serial.id or None, | ||
871 | 469 | 'location_id': line.stock_move_id.location_dest_id.id, | ||
872 | 470 | 'location_dest_id': line.stock_move_id.location_id.id, | ||
873 | 471 | 'partner_id': line.configurator_id.contract_id.partner_id.id, | ||
874 | 472 | 'type': 'in' | ||
875 | 473 | } | ||
876 | 474 | stock_move_id = stock_move_obj.create( | ||
877 | 475 | cr, uid, move, context=context) | ||
878 | 476 | stock_move_obj.action_confirm( | ||
879 | 477 | cr, uid, [stock_move_id], context=context) | ||
880 | 478 | stock_move_obj.action_done( | ||
881 | 479 | cr, uid, [stock_move_id], context=context) | ||
883 | 480 | 391 | ||
884 | 481 | return True | 392 | return True |
885 | 482 | 393 | ||
886 | 483 | def router(self, cr, uid, ids, data=None, context=None): | 394 | def router(self, cr, uid, ids, data=None, context=None): |
887 | 395 | pool_stock_prod_lot = self.pool.get('stock.production.lot') | ||
888 | 484 | if isinstance(ids, list): | 396 | if isinstance(ids, list): |
889 | 485 | ids = ids[0] | 397 | ids = ids[0] |
890 | 486 | wizard = self.browse(cr, uid, ids, context=context) | 398 | wizard = self.browse(cr, uid, ids, context=context) |
891 | 487 | for line in wizard.line_ids: | 399 | for line in wizard.line_ids: |
892 | 488 | if line.state in ('message', 'serial', 'stock'): | 400 | if line.state in ('message', 'serial', 'stock'): |
893 | 489 | if line.state == 'serial': | 401 | if line.state == 'serial': |
894 | 490 | stock_production_lot_obj = self.pool.get('stock.production.lot') | ||
895 | 491 | product_product_obj = self.pool.get('product.product') | ||
896 | 492 | 402 | ||
897 | 493 | query = [ | 403 | query = [ |
898 | 494 | ('product_id', '=', line.product_id.id), | 404 | ('product_id', '=', line.product_id.id), |
899 | 495 | ('stock_available', '>', 0) | 405 | ('stock_available', '>', 0) |
900 | 496 | ] | 406 | ] |
901 | 497 | 407 | ||
903 | 498 | serial_ids = stock_production_lot_obj.search(cr, uid, query, context=context) | 408 | serial_ids = pool_stock_prod_lot.search(cr, uid, query, |
904 | 409 | context=context) | ||
905 | 499 | 410 | ||
906 | 500 | if not serial_ids: | 411 | if not serial_ids: |
907 | 501 | line.write({'state': 'stock'}) | 412 | line.write({'state': 'stock'}) |
908 | @@ -523,3 +434,36 @@ | |||
909 | 523 | 'nodestroy': True, | 434 | 'nodestroy': True, |
910 | 524 | 'context': context | 435 | 'context': context |
911 | 525 | } | 436 | } |
912 | 437 | |||
913 | 438 | |||
914 | 439 | def cancel_dependancy(obj_orm, cr, uid, ids, context, cancel_line=True): | ||
915 | 440 | pool_stock_move = obj_orm.pool.get('stock.move') | ||
916 | 441 | if cancel_line: | ||
917 | 442 | lines = obj_orm.browse(cr, uid, ids[0], context=context).line_ids | ||
918 | 443 | else: | ||
919 | 444 | lines = obj_orm.browse(cr, uid, ids, context=context) | ||
920 | 445 | |||
921 | 446 | for line in lines: | ||
922 | 447 | if line.product_id.type == 'product' and line.stock_move_id: | ||
923 | 448 | product = line.product_id and line.product_id | ||
924 | 449 | product_name = product.name or '' | ||
925 | 450 | product_uom = product.uom_id and line.product_id.uom_id | ||
926 | 451 | name = "%s %s" % (_('Cancel'), product_name) | ||
927 | 452 | |||
928 | 453 | partner = line.configurator_id.contract_id.partner_id.id | ||
929 | 454 | move = { | ||
930 | 455 | 'name': name, | ||
931 | 456 | 'product_id': product.id, | ||
932 | 457 | 'product_uom': product_uom, | ||
933 | 458 | 'prodlot_id': line.serial and line.serial.id or None, | ||
934 | 459 | 'location_id': line.stock_move_id.location_dest_id.id, | ||
935 | 460 | 'location_dest_id': line.stock_move_id.location_id.id, | ||
936 | 461 | 'partner_id': partner, | ||
937 | 462 | 'type': 'in' | ||
938 | 463 | } | ||
939 | 464 | stock_move_id = pool_stock_move.create(cr, uid, move, | ||
940 | 465 | context=context) | ||
941 | 466 | pool_stock_move.action_confirm(cr, uid, [stock_move_id], | ||
942 | 467 | context=context) | ||
943 | 468 | pool_stock_move.action_done(cr, uid, [stock_move_id], | ||
944 | 469 | context=context) | ||
945 | 526 | \ No newline at end of file | 470 | \ No newline at end of file |
946 | 527 | 471 | ||
947 | === modified file 'contract_isp_package_configurator/wizard/package_configurator.xml' | |||
948 | --- contract_isp_package_configurator/wizard/package_configurator.xml 2013-10-10 19:22:10 +0000 | |||
949 | +++ contract_isp_package_configurator/wizard/package_configurator.xml 2014-04-07 19:36:16 +0000 | |||
950 | @@ -4,145 +4,145 @@ | |||
951 | 4 | <record id="view_contract_service_configurator_line_tree" model="ir.ui.view"> | 4 | <record id="view_contract_service_configurator_line_tree" model="ir.ui.view"> |
952 | 5 | <field name="name">Package Configurator Line</field> | 5 | <field name="name">Package Configurator Line</field> |
953 | 6 | <field name="model">contract.service.configurator.line</field> | 6 | <field name="model">contract.service.configurator.line</field> |
955 | 7 | <field name="type">tree</field> | 7 | <field name="type">tree</field> |
956 | 8 | <field name="arch" type="xml"> | 8 | <field name="arch" type="xml"> |
957 | 9 | <tree string="Package Configurator" version="7.0"> | 9 | <tree string="Package Configurator" version="7.0"> |
962 | 10 | <field name="product_id" /> | 10 | <field name="product_id" /> |
963 | 11 | </tree> | 11 | </tree> |
964 | 12 | </field> | 12 | </field> |
965 | 13 | </record> | 13 | </record> |
966 | 14 | 14 | ||
967 | 15 | <record id="view_contract_service_configurator" model="ir.ui.view"> | 15 | <record id="view_contract_service_configurator" model="ir.ui.view"> |
968 | 16 | <field name="name">Package Configurator</field> | 16 | <field name="name">Package Configurator</field> |
969 | 17 | <field name="model">contract.service.configurator</field> | 17 | <field name="model">contract.service.configurator</field> |
970 | 18 | <field name="arch" type="xml"> | 18 | <field name="arch" type="xml"> |
971 | 19 | <form string="Package Configurator" version="7.0"> | 19 | <form string="Package Configurator" version="7.0"> |
1029 | 20 | <header> | 20 | <header> |
1030 | 21 | <field name="state" class="oe_right" widget="statusbar" /> | 21 | <field name="state" class="oe_right" widget="statusbar" /> |
1031 | 22 | </header> | 22 | </header> |
1032 | 23 | <field name="root_category_id" invisible="1" /> | 23 | <field name="root_category_id" invisible="1" /> |
1033 | 24 | <field name="is_level2" invisible="1" /> | 24 | <field name="is_level2" invisible="1" /> |
1034 | 25 | <field name="contract_id" invisible="1" /> | 25 | <field name="contract_id" invisible="1" /> |
1035 | 26 | <group string="Category" attrs="{'invisible': [('state', '=', 'dependency')]}"> | 26 | <group string="Category" attrs="{'invisible': [('state', '=', 'dependency')]}"> |
1036 | 27 | <field | 27 | <field |
1037 | 28 | nolabel="1" | 28 | nolabel="1" |
1038 | 29 | name="product_category_id" | 29 | name="product_category_id" |
1039 | 30 | options="{'no_open': True}" | 30 | options="{'no_open': True}" |
1040 | 31 | domain="[('type', '=', 'normal'), ('id', 'child_of', [root_category_id])]" | 31 | domain="[('type', '=', 'normal'), ('id', 'child_of', [root_category_id])]" |
1041 | 32 | on_change="onchange_product_category_id(product_category_id, is_level2)" /> | 32 | on_change="onchange_product_category_id(product_category_id, is_level2)" /> |
1042 | 33 | </group> | 33 | </group> |
1043 | 34 | <group string="Products" attrs="{'invisible': [('state', '=', 'dependency')]}"> | 34 | <group string="Products" attrs="{'invisible': [('state', '=', 'dependency')]}"> |
1044 | 35 | <group colspan="4"> | 35 | <group colspan="4"> |
1045 | 36 | <div width="100%%"> | 36 | <div width="100%%"> |
1046 | 37 | <field | 37 | <field |
1047 | 38 | name="current_product_id" | 38 | name="current_product_id" |
1048 | 39 | width="70%%" | 39 | width="70%%" |
1049 | 40 | class="oe_inline" | 40 | class="oe_inline" |
1050 | 41 | options="{'no_open': True}" | 41 | options="{'no_open': True}" |
1051 | 42 | domain = "[('categ_id', '=', product_category_id)]" | 42 | domain = "[('categ_id', '=', product_category_id)]" |
1052 | 43 | placeholder="Product" /> | 43 | placeholder="Product" /> |
1053 | 44 | <button | 44 | <button |
1054 | 45 | name="do_add_current_product_id" | 45 | name="do_add_current_product_id" |
1055 | 46 | string="Add" | 46 | string="Add" |
1056 | 47 | type="object" | 47 | type="object" |
1057 | 48 | states="draft,product" | 48 | states="draft,product" |
1058 | 49 | width="15%%" | 49 | width="15%%" |
1059 | 50 | class="oe_inline oe_highlight" /> | 50 | class="oe_inline oe_highlight" /> |
1060 | 51 | </div> | 51 | </div> |
1061 | 52 | </group> | 52 | </group> |
1062 | 53 | <group> | 53 | <group> |
1063 | 54 | <field name="line_ids" nolabel="1" mode="tree"> | 54 | <field name="line_ids" nolabel="1" mode="tree"> |
1064 | 55 | <tree create="0"> | 55 | <tree create="0"> |
1065 | 56 | <field name="product_id" /> | 56 | <field name="product_id" /> |
1066 | 57 | <field name="serial" /> | 57 | <field name="serial" /> |
1067 | 58 | </tree> | 58 | </tree> |
1068 | 59 | </field> | 59 | </field> |
1069 | 60 | </group> | 60 | </group> |
1070 | 61 | </group> | 61 | </group> |
1071 | 62 | <group attrs="{'invisible': [('state', '<>', 'dependency')]}"> | 62 | <group attrs="{'invisible': [('state', '<>', 'dependency')]}"> |
1072 | 63 | <div colspan="4"> | 63 | <div colspan="4"> |
1073 | 64 | <p>Click on add to view the available components</p> | 64 | <p>Click on add to view the available components</p> |
1074 | 65 | </div> | 65 | </div> |
1075 | 66 | <field | 66 | <field |
1076 | 67 | name="dependency_ids" | 67 | name="dependency_ids" |
1077 | 68 | nolabel="1" | 68 | nolabel="1" |
1078 | 69 | mode="tree" | 69 | mode="tree" |
1079 | 70 | widget="many2many" | 70 | widget="many2many" |
1080 | 71 | domain="[('configurator_id', '=', active_id)]"> | 71 | domain="[('configurator_id', '=', active_id)]"> |
1081 | 72 | <tree> | 72 | <tree> |
1082 | 73 | <field name="product_id" on_change="onchange_product_id(product_id, context)"/> | 73 | <field name="product_id" on_change="onchange_product_id(product_id, context)"/> |
1083 | 74 | </tree> | 74 | </tree> |
1084 | 75 | </field> | 75 | </field> |
1085 | 76 | </group> | 76 | </group> |
1086 | 77 | 77 | ||
1111 | 78 | <footer> | 78 | <footer> |
1112 | 79 | <button | 79 | <button |
1113 | 80 | name="do_next" | 80 | name="do_next" |
1114 | 81 | string="Next" | 81 | string="Next" |
1115 | 82 | type="object" | 82 | type="object" |
1116 | 83 | class="oe_highlight" | 83 | class="oe_highlight" |
1117 | 84 | states="dependency" | 84 | states="dependency" |
1118 | 85 | /> | 85 | /> |
1119 | 86 | <button | 86 | <button |
1120 | 87 | name="do_done" | 87 | name="do_done" |
1121 | 88 | string="Done" | 88 | string="Done" |
1122 | 89 | type="object" | 89 | type="object" |
1123 | 90 | class="oe_highlight" | 90 | class="oe_highlight" |
1124 | 91 | states="product,done" | 91 | states="product,done" |
1125 | 92 | /> | 92 | /> |
1126 | 93 | <button | 93 | <button |
1127 | 94 | string="Cancel" | 94 | string="Cancel" |
1128 | 95 | class="oe_link" | 95 | class="oe_link" |
1129 | 96 | type="object" | 96 | type="object" |
1130 | 97 | name="do_cancel" /> | 97 | name="do_cancel" /> |
1131 | 98 | </footer> | 98 | </footer> |
1132 | 99 | </form> | 99 | </form> |
1133 | 100 | </field> | 100 | </field> |
1134 | 101 | </record> | 101 | </record> |
1135 | 102 | 102 | ||
1136 | 103 | <record id="view_contract_service_configurator_line" model="ir.ui.view"> | 103 | <record id="view_contract_service_configurator_line" model="ir.ui.view"> |
1137 | 104 | <field name="name">Product Details</field> | 104 | <field name="name">Product Details</field> |
1138 | 105 | <field name="model">contract.service.configurator.line</field> | 105 | <field name="model">contract.service.configurator.line</field> |
1139 | 106 | <field name="arch" type="xml"> | 106 | <field name="arch" type="xml"> |
1140 | 107 | <form string="Package Configurator" version="7.0"> | 107 | <form string="Package Configurator" version="7.0"> |
1179 | 108 | <header> | 108 | <header> |
1180 | 109 | <field | 109 | <field |
1181 | 110 | name="state" | 110 | name="state" |
1182 | 111 | class="oe_right" | 111 | class="oe_right" |
1183 | 112 | widget="statusbar" | 112 | widget="statusbar" |
1184 | 113 | attrs="{'invisible': [('state', '=', 'message')]}"/> | 113 | attrs="{'invisible': [('state', '=', 'message')]}"/> |
1185 | 114 | </header> | 114 | </header> |
1186 | 115 | <group string="Products" colspan="4" attrs="{'invisible': [('state', 'in', ('message', 'stock'))]}"> | 115 | <group string="Products" colspan="4" attrs="{'invisible': [('state', 'in', ('message', 'stock'))]}"> |
1187 | 116 | <field name="product_id" readonly="1" /> | 116 | <field name="product_id" readonly="1" /> |
1188 | 117 | <field | 117 | <field |
1189 | 118 | name="serial" | 118 | name="serial" |
1190 | 119 | class="oe_inline" | 119 | class="oe_inline" |
1191 | 120 | domain="[('product_id', '=', product_id), '&', ('stock_available', '>', 0)]" | 120 | domain="[('product_id', '=', product_id), '&', ('stock_available', '>', 0)]" |
1192 | 121 | options="{'no_open': True}" | 121 | options="{'no_open': True}" |
1193 | 122 | placeholder="Serial Number" | 122 | placeholder="Serial Number" |
1194 | 123 | attrs="{'invisible': [('state', '=', 'draft')]}"/> | 123 | attrs="{'invisible': [('state', '=', 'draft')]}"/> |
1195 | 124 | </group> | 124 | </group> |
1196 | 125 | <group colspan="4" attrs="{'invisible': [('state', 'in', ('serial', 'stock'))]}"> | 125 | <group colspan="4" attrs="{'invisible': [('state', 'in', ('serial', 'stock'))]}"> |
1197 | 126 | <field | 126 | <field |
1198 | 127 | name="message" | 127 | name="message" |
1199 | 128 | nolabel="1" | 128 | nolabel="1" |
1200 | 129 | readonly="1"/> | 129 | readonly="1"/> |
1201 | 130 | </group> | 130 | </group> |
1202 | 131 | <group colspan="4" attrs="{'invisible': [('state', 'in', ('message', 'serial', 'done'))]}"> | 131 | <group colspan="4" attrs="{'invisible': [('state', 'in', ('message', 'serial', 'done'))]}"> |
1203 | 132 | <p>We don't have this product in stock at the moment!</p> | 132 | <p>We don't have this product in stock at the moment!</p> |
1204 | 133 | </group> | 133 | </group> |
1205 | 134 | <footer> | 134 | <footer> |
1206 | 135 | <button | 135 | <button |
1207 | 136 | name="router" | 136 | name="router" |
1208 | 137 | string="Ok" | 137 | string="Ok" |
1209 | 138 | type="object" | 138 | type="object" |
1210 | 139 | states="message,serial,stock" | 139 | states="message,serial,stock" |
1211 | 140 | class="oe_highlight" | 140 | class="oe_highlight" |
1212 | 141 | /> | 141 | /> |
1213 | 142 | </footer> | 142 | </footer> |
1214 | 143 | </form> | 143 | </form> |
1215 | 144 | </field> | 144 | </field> |
1216 | 145 | </record> | 145 | </record> |
1217 | 146 | 146 | ||
1218 | 147 | <record id="action_contract_isp_package_configurator" model="ir.actions.act_window"> | 147 | <record id="action_contract_isp_package_configurator" model="ir.actions.act_window"> |
1219 | 148 | <field name="name">Package Configurator</field> | 148 | <field name="name">Package Configurator</field> |
1220 | @@ -150,9 +150,9 @@ | |||
1221 | 150 | <field name="res_model">contract.service.configurator</field> | 150 | <field name="res_model">contract.service.configurator</field> |
1222 | 151 | <field name="view_type">form</field> | 151 | <field name="view_type">form</field> |
1223 | 152 | <field name="view_mode">form</field> | 152 | <field name="view_mode">form</field> |
1225 | 153 | <field name="view_id" ref="contract_isp_package_configurator.view_contract_service_configurator" /> | 153 | <field name="view_id" ref="contract_isp_package_configurator.view_contract_service_configurator" /> |
1226 | 154 | <field name="target">new</field> | 154 | <field name="target">new</field> |
1228 | 155 | <field name="context">{'default_contract_id': active_id}</field> | 155 | <field name="context">{'default_contract_id': active_id}</field> |
1229 | 156 | </record> | 156 | </record> |
1230 | 157 | 157 | ||
1231 | 158 | </data> | 158 | </data> |