Merge lp:~unifield-team/unifield-server/us-839 into lp:unifield-server
- us-839
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 3751 |
Proposed branch: | lp:~unifield-team/unifield-server/us-839 |
Merge into: | lp:unifield-server |
Diff against target: |
449 lines (+142/-44) 8 files modified
bin/addons/delivery_mechanism/delivery_mechanism.py (+1/-1) bin/addons/procurement/procurement.py (+8/-1) bin/addons/procurement_request/procurement_request.py (+2/-2) bin/addons/purchase_override/purchase.py (+31/-10) bin/addons/sale/sale.py (+1/-1) bin/addons/sale_override/sale.py (+29/-11) bin/addons/sourcing/res_partner.py (+2/-2) bin/addons/sourcing/sale_order_line.py (+68/-16) |
To merge this branch: | bzr merge lp:~unifield-team/unifield-server/us-839 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+295151@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/addons/delivery_mechanism/delivery_mechanism.py' |
2 | --- bin/addons/delivery_mechanism/delivery_mechanism.py 2016-04-25 09:24:04 +0000 |
3 | +++ bin/addons/delivery_mechanism/delivery_mechanism.py 2016-05-19 07:05:28 +0000 |
4 | @@ -1596,7 +1596,7 @@ |
5 | # for Internal Request (IR) on make_to_order we update PO line data according to the data of the IR (=sale_order) |
6 | sale_order_line_ids = sale_obj.search(cr, uid, [('procurement_id', '=', procurement.id)], context=context) |
7 | for sol in sale_obj.browse(cr, uid, sale_order_line_ids, context=context): |
8 | - if sol.order_id.procurement_request and not sol.product_id and sol.comment: |
9 | + if (sol.order_id.procurement_request or procurement.supplier.partner_type == 'esc') and not sol.product_id and sol.comment: |
10 | line.update({'product_id': False, |
11 | 'name': 'Description: %s' % sol.comment, |
12 | 'comment': sol.comment, |
13 | |
14 | === modified file 'bin/addons/procurement/procurement.py' |
15 | --- bin/addons/procurement/procurement.py 2015-02-05 16:24:18 +0000 |
16 | +++ bin/addons/procurement/procurement.py 2016-05-19 07:05:28 +0000 |
17 | @@ -172,7 +172,14 @@ |
18 | """ |
19 | if not context: |
20 | context = {} |
21 | - return all(not procurement.move_id or procurement.move_id.state == 'done' for procurement in self.browse(cr, uid, ids, context=context)) |
22 | + |
23 | + def check_move(proc): |
24 | + c1 = not proc.move_id or proc.move_id.state == 'done' |
25 | + c2 = proc.po_cft == 'dpo' and proc.move_id.state == 'hidden' |
26 | + return c1 or c2 |
27 | + |
28 | + return all(check_move(procurement) for procurement in self.browse(cr, uid, ids, context=context)) |
29 | + |
30 | # |
31 | # This method may be overrided by objects that override procurement.order |
32 | # for computing their own purpose |
33 | |
34 | === modified file 'bin/addons/procurement_request/procurement_request.py' |
35 | --- bin/addons/procurement_request/procurement_request.py 2016-04-25 09:24:04 +0000 |
36 | +++ bin/addons/procurement_request/procurement_request.py 2016-05-19 07:05:28 +0000 |
37 | @@ -568,9 +568,9 @@ |
38 | request_name = request.name |
39 | raise osv.except_osv(_('Error'), _('Please correct the line %s of the %s: the supplier is required for the procurement method "On Order" !') % (line_number, request_name)) |
40 | # an Internal Request without product can only have Internal, Intersection or Intermission partners. |
41 | - elif line.supplier and not line.product_id and line.order_id.procurement_request and line.supplier.partner_type not in ['internal', 'section', 'intermission']: |
42 | + elif line.supplier and not line.product_id and line.order_id.procurement_request and line.supplier.partner_type not in ['internal', 'section', 'intermission', 'esc']: |
43 | raise osv.except_osv(_('Warning'), _("""For an Internal Request with a procurement method 'On Order' and without product, |
44 | - the supplier must be either in 'Internal', 'Inter-Section' or 'Intermission' type. |
45 | + the supplier must be either in 'Internal', 'Inter-Section', 'Intermission' or 'ESC' type. |
46 | """)) |
47 | message = _("The internal request '%s' has been confirmed (nb lines: %s).") % (request.name, len(request.order_line)) |
48 | proc_view = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'procurement_request', 'procurement_request_form_view') |
49 | |
50 | === modified file 'bin/addons/purchase_override/purchase.py' |
51 | --- bin/addons/purchase_override/purchase.py 2016-05-12 12:09:25 +0000 |
52 | +++ bin/addons/purchase_override/purchase.py 2016-05-19 07:05:28 +0000 |
53 | @@ -1374,9 +1374,12 @@ |
54 | ad_obj = self.pool.get('analytic.distribution') |
55 | date_tools = self.pool.get('date.tools') |
56 | fields_tools = self.pool.get('fields.tools') |
57 | + data_obj = self.pool.get('ir.model.data') |
58 | db_date_format = date_tools.get_db_date_format(cr, uid, context=context) |
59 | wf_service = netsvc.LocalService("workflow") |
60 | |
61 | + tbd_product_id = data_obj.get_object_reference(cr, uid, 'msf_doc_import', 'product_tbd')[1] |
62 | + |
63 | # update corresponding fo if exist |
64 | if so_ids is None: |
65 | so_ids = self.get_so_ids_from_po_ids(cr, uid, ids, context=context) |
66 | @@ -1484,12 +1487,28 @@ |
67 | # write the line |
68 | sol_obj.write(cr, uid, sol_ids, fields_dic, context=ctx) |
69 | |
70 | - if so.procurement_request and so.location_requestor_id.usage == 'customer' \ |
71 | - and line.procurement_id.move_id \ |
72 | - and not line.procurement_id.move_id.processed_stock_move: |
73 | - # In case of replacement of a non-stockable product by a stockable product |
74 | - if line.product_id.id != line.procurement_id.product_id.id and line.procurement_id.product_id.type in ('service', 'service_recep', 'consu') and line.product_id.type == 'product': |
75 | - # Get OUT linked to IR |
76 | + cond2 = not sol.product_id or sol.product_id.id != line.procurement_id.product_id.id |
77 | + cond1 = so.procurement_request and so.location_requestor_id.usage == 'customer' |
78 | + cond3 = bool(line.procurement_id.move_id and not line.procurement_id.move_id.processed_stock_move) |
79 | + |
80 | + if cond2 and line.product_id: |
81 | + proc_obj.write(cr, uid, [line.procurement_id.id], {'product_id': line.product_id.id}) |
82 | + |
83 | + if (cond1 or (not so.procurement_request and cond2)) and cond3: |
84 | + |
85 | + # In case of FO with not only no product lines, the picking tickes will be created with normal flow |
86 | + if not so.procurement_request and cond2: |
87 | + if sol_obj.search(cr, uid, [('order_id', '=', so.id), ('product_id', '!=', False), |
88 | + ('id', '!=', sol.id)], limit=1, context=context): |
89 | + continue |
90 | + |
91 | + cond4 = line.product_id.id != line.procurement_id.product_id.id |
92 | + cond5 = line.procurement_id.product_id.type in ('service', 'service_recep', 'consu') |
93 | + cond6 = line.procurement_id.product_id.id == tbd_product_id |
94 | + cond7 = line.product_id.type == 'product' |
95 | + # In case of replacement of a non-stockable product by a stockable product or replacement of To be Defined product |
96 | + if cond4 and (cond5 or cond6) and cond7: |
97 | + # Get OUT linked to IR or PICK linked to FO |
98 | pick_to_confirm = None |
99 | out_ids = [] |
100 | if line.procurement_id.sale_id: |
101 | @@ -1497,16 +1516,18 @@ |
102 | ('sale_id', '=', line.procurement_id.sale_id.id), |
103 | ('type', '=', 'out'), |
104 | ('state', 'in', ['draft', 'confirmed', 'assigned']), |
105 | - ], context=context) |
106 | + ], limit=1, context=context) |
107 | if not out_ids: |
108 | picking_data = so_obj._get_picking_data(cr, uid, so) |
109 | out_ids = [pick_obj.create(cr, uid, picking_data, context=context)] |
110 | - pick_to_confirm = out_ids |
111 | + if so.procurement_request: |
112 | + pick_to_confirm = out_ids |
113 | |
114 | + sol = sol_obj.browse(cr, uid, sol.id, context=context) |
115 | move_data = so_obj._get_move_data(cr, uid, so, sol, out_ids[0], context=context) |
116 | new_move_id = move_obj.create(cr, uid, move_data, context=context) |
117 | out_move_id = line.procurement_id.move_id.id |
118 | - proc_obj.write(cr, uid, [line.procurement_id.id], {'move_id': new_move_id}, context=context) |
119 | + proc_obj.write(cr, uid, [line.procurement_id.id], {'move_id': new_move_id, 'product_id': sol.product_id.id}, context=context) |
120 | move_obj.write(cr, uid, [out_move_id], {'state': 'draft'}, context=context) |
121 | move_obj.unlink(cr, uid, [out_move_id], context=context) |
122 | |
123 | @@ -1730,7 +1751,7 @@ |
124 | if sol_obj.search(cr, uid, |
125 | [('order_id', 'in', all_so_ids), |
126 | ('type', '=', 'make_to_order'), |
127 | - ('product_id', '!=', False), |
128 | + #('product_id', '!=', False), |
129 | ('procurement_id.state', '!=', 'cancel'), |
130 | ('order_id.procurement_request', '=', False), |
131 | ('state', 'not in', ['confirmed', 'done'])], |
132 | |
133 | === modified file 'bin/addons/sale/sale.py' |
134 | --- bin/addons/sale/sale.py 2015-12-03 15:32:43 +0000 |
135 | +++ bin/addons/sale/sale.py 2016-05-19 07:05:28 +0000 |
136 | @@ -611,7 +611,7 @@ |
137 | self.write(cr, uid, [o.id], {'state': 'manual', 'date_confirm': time.strftime('%Y-%m-%d')}) |
138 | else: |
139 | self.write(cr, uid, [o.id], {'state': 'progress', 'date_confirm': time.strftime('%Y-%m-%d')}) |
140 | - self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line]) |
141 | + self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line if x.product_id]) |
142 | message = _("The quotation '%s' has been converted to a sales order.") % (o.name,) |
143 | message = self._hook_message_action_wait(cr, uid, order=o, message=message) |
144 | self.log(cr, uid, o.id, message) |
145 | |
146 | === modified file 'bin/addons/sale_override/sale.py' |
147 | --- bin/addons/sale_override/sale.py 2016-04-25 09:24:04 +0000 |
148 | +++ bin/addons/sale_override/sale.py 2016-05-19 07:05:28 +0000 |
149 | @@ -1381,7 +1381,7 @@ |
150 | }, context=context) |
151 | # check that each line must have a supplier specified |
152 | if line.type == 'make_to_order': |
153 | - if not line.product_id: |
154 | + if not line.product_id and line.supplier.partner_type != 'esc': |
155 | raise osv.except_osv(_('Warning'), _("""You can't confirm a Sale Order that contains |
156 | lines with procurement method 'On Order' and without product. Please check the line %s |
157 | """) % line.line_number) |
158 | @@ -2277,7 +2277,7 @@ |
159 | |
160 | return True |
161 | |
162 | - def _get_procurement_order_data(self, line, order, rts_date, context=None): |
163 | + def _get_procurement_order_data(self, line, order, rts_date, product_id=False, context=None): |
164 | """ |
165 | Get data for the procurement order creation according to |
166 | sale.order.line and sale.order values. |
167 | @@ -2340,8 +2340,11 @@ |
168 | 'tender_id': line.created_by_tender and line.created_by_tender.id or False, |
169 | }) |
170 | |
171 | - if line.product_id: |
172 | - proc_data['product_id'] = line.product_id.id |
173 | + if not product_id and line.product_id: |
174 | + product_id = line.product_id.id |
175 | + |
176 | + if product_id: |
177 | + proc_data['product_id'] = product_id |
178 | |
179 | return proc_data |
180 | |
181 | @@ -2371,6 +2374,7 @@ |
182 | proc_obj = self.pool.get('procurement.order') |
183 | pol_obj = self.pool.get('purchase.order.line') |
184 | tl_obj = self.pool.get('tender.line') |
185 | + data_obj = self.pool.get('ir.model.data') |
186 | |
187 | if context is None: |
188 | context = {} |
189 | @@ -2451,9 +2455,17 @@ |
190 | # when the line is sourced, we already get a procurement for the line |
191 | # when the line is confirmed, the corresponding procurement order has already been processed |
192 | # if the line is draft, either it is the first call, or we call the method again after having added a line in the procurement's po |
193 | - if line.state not in ['sourced', 'confirmed', 'done'] and not (line.created_by_po_line and line.procurement_id) and line.product_id: |
194 | + if line.state not in ['sourced', 'confirmed', 'done'] and not (line.created_by_po_line and line.procurement_id): |
195 | + if not line.product_id and order.procurement_request: |
196 | + continue |
197 | + |
198 | + product_id = line.product_id.id |
199 | + if not order.procurement_request and not line.product_id and line.comment: |
200 | + product_id = \ |
201 | + data_obj.get_object_reference(cr, uid, 'msf_doc_import', 'product_tbd')[1] |
202 | + |
203 | rts = self._get_date_planned(order, line, prep_lt, db_date_format) |
204 | - proc_data = self._get_procurement_order_data(line, order, rts, context=context) |
205 | + proc_data = self._get_procurement_order_data(line, order, rts, product_id=product_id, context=context) |
206 | proc_id = proc_obj.create(cr, uid, proc_data, context=context) |
207 | # set the flag for log message |
208 | if line.so_back_update_dest_po_id_sale_order_line or line.created_by_po: |
209 | @@ -2540,7 +2552,7 @@ |
210 | # Update the context to get IR lines |
211 | context['procurement_request'] = True |
212 | |
213 | - for order in self.read(cr, uid, ids, ['from_yml_test', 'order_line'], context=context): |
214 | + for order in self.read(cr, uid, ids, ['from_yml_test', 'order_line', 'procurement_request'], context=context): |
215 | if not self._get_ready_to_cancel(cr, uid, [order['id']], order['order_line'], context=context)[order['id']]: |
216 | return False |
217 | |
218 | @@ -2548,15 +2560,21 @@ |
219 | if order['from_yml_test']: |
220 | continue |
221 | |
222 | - line_error = line_obj.search(cr, uid, [ |
223 | + domain = [ |
224 | ('order_id', '=', order['id']), |
225 | - ('product_id', '!=', False), |
226 | - ('type', '=', 'make_to_order',), |
227 | + ('type', '=', 'make_to_order'), |
228 | ('state', '!=', 'confirmed'), |
229 | + ] |
230 | + if order['procurement_request']: |
231 | + domain.append(('product_id', '!=', False)) |
232 | + |
233 | + domain.extend([ |
234 | '|', |
235 | ('procurement_id', '=', 'False'), |
236 | ('procurement_id.state', '!=', 'cancel'), |
237 | - ], limit=1, order='NO_ORDER', context=context) |
238 | + ]) |
239 | + |
240 | + line_error = line_obj.search(cr, uid, domain, limit=1, order='NO_ORDER', context=context) |
241 | |
242 | if line_error: |
243 | return False |
244 | |
245 | === modified file 'bin/addons/sourcing/res_partner.py' |
246 | --- bin/addons/sourcing/res_partner.py 2014-03-10 14:11:36 +0000 |
247 | +++ bin/addons/sourcing/res_partner.py 2016-05-19 07:05:28 +0000 |
248 | @@ -91,7 +91,7 @@ |
249 | if not so.procurement_request: |
250 | newargs.append(('partner_type', 'in', ['external', 'esc'])) |
251 | elif so.procurement_request and not sl.product_id: |
252 | - newargs.append(('partner_type', 'in', ['internal', 'section', 'intermission'])) |
253 | + newargs.append(('partner_type', 'in', ['internal', 'section', 'intermission', 'esc'])) |
254 | else: |
255 | newargs.append(args) |
256 | return newargs |
257 | @@ -129,7 +129,7 @@ |
258 | if active_ids: |
259 | sol = self.pool.get('sale.order.line').browse(cr, uid, active_ids)[0] |
260 | if not context.get('product_id', False) and sol.order_id.procurement_request: |
261 | - newargs.append(('partner_type', 'in', ['internal', 'section', 'intermission'])) |
262 | + newargs.append(('partner_type', 'in', ['internal', 'section', 'intermission', 'esc'])) |
263 | else: |
264 | newargs.append(args) |
265 | return newargs |
266 | |
267 | === modified file 'bin/addons/sourcing/sale_order_line.py' |
268 | --- bin/addons/sourcing/sale_order_line.py 2016-04-25 09:24:04 +0000 |
269 | +++ bin/addons/sourcing/sale_order_line.py 2016-05-19 07:05:28 +0000 |
270 | @@ -44,6 +44,30 @@ |
271 | ] |
272 | |
273 | |
274 | +def check_is_service_nomen(obj, cr, uid, nomen=False): |
275 | + """ |
276 | + Return True if the nomenclature seleced on the line is a service nomenclature |
277 | + @param cr: Cursor to the database |
278 | + @param uid: ID of the res.users that calls this method |
279 | + @param nomen: ID of the nomenclature to check |
280 | + @return: True or False |
281 | + """ |
282 | + nomen_obj = obj.pool.get('product.nomenclature') |
283 | + |
284 | + if not nomen: |
285 | + return False |
286 | + |
287 | + nomen_srv = nomen_obj.search(cr, uid, [ |
288 | + ('name', '=', 'SRV'), |
289 | + ('type', '=', 'mandatory'), |
290 | + ('level', '=', 0), |
291 | + ], limit=1) |
292 | + if not nomen_srv: |
293 | + return False |
294 | + |
295 | + return nomen_srv[0] == nomen |
296 | + |
297 | + |
298 | class sale_order_line(osv.osv): |
299 | _inherit = 'sale.order.line' |
300 | _description = 'Sales Order Line' |
301 | @@ -586,7 +610,8 @@ |
302 | ids = [ids] |
303 | |
304 | for obj in self.browse(cr, uid, ids, context=context): |
305 | - if obj.product_id.type == 'service_recep' and obj.type != 'make_to_order': |
306 | + if (obj.product_id.type == 'service_recep' or (not obj.product_id and check_is_service_nomen(cr, uid, obj.nomen_manda_0.id))) \ |
307 | + and obj.type != 'make_to_order': |
308 | raise osv.except_osv( |
309 | _('Error'), |
310 | _('You must select on order procurement method for Service with Reception products.'), |
311 | @@ -679,6 +704,16 @@ |
312 | vals['po_cft'] = 'po' |
313 | elif not ir and vals.get('po_cft', 'po') == 'po': |
314 | vals['po_cft'] = 'dpo' |
315 | + elif not product and check_is_service_nomen(self, cr, uid, vals.get('nomen_manda_0', False)): |
316 | + vals['po_cft'] = 'dpo' |
317 | + |
318 | + if not product: |
319 | + vals.update({ |
320 | + 'type': 'make_to_order', |
321 | + 'po_cft': 'po', |
322 | + }) |
323 | + if vals.get('nomen_manda_0') and check_is_service_nomen(self, cr, uid, vals.get('nomen_manda_0')): |
324 | + vals['po_cft'] = 'dpo' |
325 | |
326 | # If type is missing, set to make_to_stock and po_cft to False |
327 | if not vals.get('type', False): |
328 | @@ -792,6 +827,7 @@ |
329 | |
330 | if isinstance(ids, (int, long)): |
331 | ids = [ids] |
332 | + |
333 | for line in self.browse(cr, uid, ids, context=context): |
334 | clc = self._check_loan_conditions(cr, uid, line, context=context) |
335 | if clc: |
336 | @@ -810,11 +846,11 @@ |
337 | not line.product_id and \ |
338 | line.order_id.procurement_request and \ |
339 | line.supplier and \ |
340 | - line.supplier.partner_type not in ['internal', 'section', 'intermission']: |
341 | + line.supplier.partner_type not in ['internal', 'section', 'intermission', 'esc']: |
342 | raise osv.except_osv( |
343 | _('Warning'), |
344 | _("""For an Internal Request with a procurement method 'On Order' and without product, |
345 | -the supplier must be either in 'Internal', 'Inter-section' or 'Intermission type."""), |
346 | +the supplier must be either in 'Internal', 'Inter-section', 'Intermission or 'ESC' type."""), |
347 | ) |
348 | |
349 | if line.product_id and \ |
350 | @@ -834,10 +870,10 @@ |
351 | _("""You can't source with 'Request for Quotation' to an internal/inter-section/intermission partner."""), |
352 | ) |
353 | |
354 | - if line.product_id and \ |
355 | - line.product_id.type in ('service', 'service_recep') and \ |
356 | - not line.order_id.procurement_request and \ |
357 | - line.po_cft == 'po': |
358 | + cond1 = not line.order_id.procurement_request and line.po_cft == 'po' |
359 | + cond2 = line.product_id and line.product_id.type in ('service', 'service_recep') |
360 | + cond3 = not line.product_id and check_is_service_nomen(self, cr, uid, line.nomen_manda_0.id) |
361 | + if cond1 and (cond2 or cond3): |
362 | raise osv.except_osv( |
363 | _('Warning'), |
364 | _("""'Purchase Order' is not allowed to source a 'Service' product."""), |
365 | @@ -859,11 +895,10 @@ |
366 | _('Warning'), |
367 | _("You can't Source 'from stock' if you don't have product."), |
368 | ) |
369 | - if line.supplier and line.supplier.partner_type in ('external', 'esc'): |
370 | + if line.supplier and line.supplier.partner_type in ('external'): |
371 | raise osv.except_osv( |
372 | _('Warning'), |
373 | - _("You can't Source to an '%s' partner if you don't have product.") % |
374 | - (line.supplier.partner_type == 'external' and 'External' or 'ESC'), |
375 | + _("You can't Source to an 'External' partner if you don't have product."), |
376 | ) |
377 | |
378 | if line.state not in ('draft', 'cancel') and line.product_id and line.supplier: |
379 | @@ -959,10 +994,19 @@ |
380 | |
381 | product = False |
382 | |
383 | + srv_product = False |
384 | if vals.get('product_id', False): |
385 | product = product_obj.browse(cr, uid, vals['product_id']) |
386 | if product.type in ('consu', 'service', 'service_recep'): |
387 | - vals['type'] = 'make_to_order' |
388 | + srv_product = True |
389 | + elif vals.get('nomen_manda_0') and check_is_service_nomen(self, cr, uid, vals.get('nomen_manda_0')): |
390 | + srv_product = True |
391 | + |
392 | + if srv_product: |
393 | + vals.update({ |
394 | + 'type': 'make_to_order', |
395 | + 'po_cft': 'dpo', |
396 | + }) |
397 | |
398 | if 'state' in vals and vals['state'] == 'cancel': |
399 | self.write(cr, uid, ids, {'cf_estimated_delivery_date': False}, context=context) |
400 | @@ -1044,7 +1088,8 @@ |
401 | no_prod = self.search(cr, uid, [ |
402 | ('id', 'in', ids), |
403 | ('product_id', '=', False), |
404 | - ('order_id.procurement_request', '=', False) |
405 | + ('order_id.procurement_request', '=', False), |
406 | + ('supplier.partner_type', '!=', 'esc'), |
407 | ], count=True, context=context) |
408 | |
409 | if no_prod: |
410 | @@ -1079,12 +1124,12 @@ |
411 | ('supplier', '!=', False), |
412 | ('product_id', '=', False), |
413 | ('order_id.procurement_request', '=', True), |
414 | - ('supplier.partner_type', 'not in', ['internal', 'section', 'intermission']), |
415 | + ('supplier.partner_type', 'not in', ['internal', 'section', 'intermission', 'esc']), |
416 | ], count=True, context=context) |
417 | |
418 | if mto_no_cft_no_prod: |
419 | raise osv.except_osv(_('Warning'), _("""For an Internal Request with a procurement method 'On Order' and without product, |
420 | - the supplier must be either in 'Internal', 'Inter-Section' or 'Intermission' type. |
421 | + the supplier must be either in 'Internal', 'Inter-Section', 'Intermission' or 'ESC' type. |
422 | """)) |
423 | |
424 | stock_no_loc = self.search(cr, uid, [ |
425 | @@ -1437,7 +1482,10 @@ |
426 | |
427 | if l_type == 'make_to_order': |
428 | po_cft = 'po' |
429 | - if line and line.product_id and line.product_id.type in ('service', 'service_recep') and line.order_id and not line.order_id.procurement_request: |
430 | + if line and \ |
431 | + ((line.product_id and line.product_id.type in ('service', 'service_recep')) or \ |
432 | + (not line.product_id and check_is_service_nomen(self, cr, uid, line.nomen_manda_0.id))) and \ |
433 | + line.order_id and not line.order_id.procurement_request: |
434 | po_cft = 'dpo' |
435 | |
436 | result['value'].update({ |
437 | @@ -1489,7 +1537,11 @@ |
438 | |
439 | line = self.browse(cr, uid, line_id, context=context) |
440 | |
441 | - if line.product_id.type in ('service', 'service_recep') and not line.order_id.procurement_request and po_cft == 'po': |
442 | + cond1 = line.product_id.type in ('service', 'service_recep') |
443 | + cond2 = not line.product_id and check_is_service_nomen(self, cr, uid, line.nomen_manda_0.id) |
444 | + cond3 = not line.order_id.procurement_request and po_cft == 'po' |
445 | + |
446 | + if (cond1 or cond2) and cond3: |
447 | res['warning'] = { |
448 | 'title': _('Warning'), |
449 | 'message': _("""'Purchase Order' is not allowed to source a 'Service' product."""), |