~zaber/openobject-addons/zaber-custom

« back to all changes in this revision

Viewing changes to zerp_sanity/stock.py

  • Committer: Amy Tsai
  • Date: 2013-07-25 00:02:53 UTC
  • Revision ID: amy@zaber.com-20130725000253-uu803qjzg9wzc8bt
new email whitelist module, improved sanity checks and interface

email whitelist - checks all emails with whitelist before sending
inventory processing - added last run date to each runs
partner - fixed suppliers without contact
purchase - changed the threshold for old dates in active orphaned stock moves

Show diffs side-by-side

added added

removed removed

Lines of Context:
227
227
            "packing and have a date in the past",
228
228
            'stock_move_old_active_orphan_stock')
229
229
        
230
 
        min_confirmed_date = self.__days_ago(60)
231
 
        min_other_date = self.__days_ago(30)
 
230
        min_date = self.__days_ago(30)
232
231
 
233
232
        ids = self.search(cr,uid,[
234
233
            ("picking_id", "=", None),
235
234
            '|',
236
235
            '&',
237
236
            ('state', '=', 'confirmed'),
238
 
            ('date', '<=', min_confirmed_date),
 
237
            ('date', '<=', min_date),
239
238
            '&',
240
239
            ('state', 'in', ['draft', 'auto', 'assigned']),
241
 
            ('date', '<=', min_other_date)
 
240
            ('date', '<=', min_date)
242
241
        ])
243
242
        
244
243
        if not ids:
245
244
            return # none found
246
245
            
247
 
        problem_writeup = (
248
 
            "The following are active stock moves " +
249
 
            "with old dates and with no related packing\n\n")
 
246
        problem_writeup = "The following are active stock moves with old dates and with no related packing\n\n"
250
247
        for move in self.browse(cr,uid,ids,context):
251
248
            if move.state == "confirmed":
252
 
                problem_writeup += "-%s\t%s\t%s  -  %s\n" % (
 
249
                problem_writeup += "-%s    %s    %s  -  %s\n" % (
253
250
                    move.state,
254
251
                    move.date,
255
 
                    move.name,
256
 
                    move.product_id.name)
 
252
                    move.name.encode('ascii',errors='ignore'),
 
253
                    move.product_id.name.encode('ascii',errors='ignore'))
257
254
                    
258
255
        problem_writeup += "\n"
259
256
        
260
257
        for move in self.browse(cr,uid,ids,context):
261
258
            if move.state != "confirmed":
262
 
                problem_writeup += "-%s\t%s\t%s  -  %s\n" % (
 
259
                problem_writeup += "-%s    %s    %s  -  %s\n" % (
263
260
                    move.state,
264
261
                    move.date,
265
 
                    move.name,
266
 
                    move.product_id.name)
 
262
                    move.name.encode('ascii',errors='ignore'),
 
263
                    move.product_id.name.encode('ascii',errors='ignore'))
267
264
            
268
265
        # now that we've finished documenting the problem let's notify the 
269
266
        # appropriate users