~unifield-team/unifield-addons/uf-1261

« back to all changes in this revision

Viewing changes to purchase/purchase.py

UF-1050 [DEV] Field Order flow
lp:~unifield-team/unifield-addons/uf-1050

Show diffs side-by-side

added added

removed removed

Lines of Context:
289
289
        self.write(cr, uid, ids, {'state': 'approved', 'date_approve': time.strftime('%Y-%m-%d')})
290
290
        return True
291
291
 
292
 
    def _hook_confirm_order_message(self, cr, uid, context={}, *args, **kwargs):
 
292
    def _hook_confirm_order_message(self, cr, uid, context=None, *args, **kwargs):
293
293
        '''
294
294
        Add a hook to modify the logged message
295
295
        '''
 
296
        # Some verifications
 
297
        if context is None:
 
298
            context = {}
 
299
            
296
300
        return kwargs['message']
 
301
    
 
302
    def _hook_confirm_order_update_corresponding_so(self, cr, uid, ids, context=None, *args, **kwargs):
 
303
        '''
 
304
        Please copy this to your module's method also.
 
305
        This hook belongs to the wkf_confirm_order method from purchase>purchase.py>purchase_order
 
306
        
 
307
        - allow to execute code in order to update corresponding sale order lines and sale orders if exist
 
308
        '''
 
309
        # Some verifications
 
310
        if context is None:
 
311
            context = {}
 
312
        if isinstance(ids, (int, long)):
 
313
            ids = [ids]
 
314
            
 
315
        return True
297
316
 
298
317
    #TODO: implement messages system
299
318
    def wkf_confirm_order(self, cr, uid, ids, context=None):
307
326
            message = _("Purchase order '%s' is confirmed.") % (po.name,)
308
327
            message = self._hook_confirm_order_message(cr, uid, context=context, message=message, po=po)
309
328
            self.log(cr, uid, po.id, message)
 
329
            # hook for corresponding Fo update
 
330
            self._hook_confirm_order_update_corresponding_so(cr, uid, ids, context=context, po=po)
310
331
#        current_name = self.name_get(cr, uid, ids)[0][1]
311
332
        self.pool.get('purchase.order.line').action_confirm(cr, uid, todo, context)
312
333
        for id in ids: