~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to sales_followup/sale_followup.py

  • Committer: jf
  • Date: 2014-06-18 08:26:21 UTC
  • Revision ID: jfb@tempo-consulting.fr-20140618082621-cptq430pbwqo6z1t
Tags: pilot3.1b2
UFTP-249 [FIX] Reference field not imported in Unifield when importing register lines
lp:~unifield-team/unifield-wm/UFTP-78 2000..2001

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from osv import osv, fields
23
23
from tools.translate import _
 
24
import datetime
24
25
import time
25
26
 
26
27
class sale_order_followup_test(osv.osv_memory):
161
162
            raise osv.except_osv(_('Error'), _('You should select one order to follow !'))
162
163
        
163
164
        followup_id = False
164
 
        
 
165
        split_lines = False
165
166
        for o in order_obj.browse(cr, uid, ids, context=context):
166
167
            followup_id = self.create(cr, uid, {'order_id': o.id}, context=context)
167
168
            
168
169
            for line in o.order_line:
169
170
                split_line_ids = sol_obj.search(cr, uid, [('original_line_id', '=', line.id)], context=context)
170
171
                first_line = True
171
 
                split_lines = False
172
172
                if split_line_ids:
173
173
                    split_lines = True
174
174
                    lines = sol_obj.browse(cr, uid, split_line_ids, context=context)
336
336
        
337
337
        return tender_ids
338
338
        
 
339
    def export_get_file_name(self, cr, uid, ids, prefix='FO_Follow_Up', context=None):
 
340
        if isinstance(ids, (int, long)):
 
341
            ids = [ids]
 
342
        if len(ids) != 1:
 
343
            return False
 
344
        foup = self.browse(cr, uid, ids[0], context=context)
 
345
        if not foup or not foup.order_id or not foup.order_id.name:
 
346
            return False
 
347
        dt_now = datetime.datetime.now()
 
348
        po_name = "%s_%s_%d_%02d_%02d" % (prefix,
 
349
            foup.order_id.name.replace('/', '_'),
 
350
            dt_now.year, dt_now.month, dt_now.day)
 
351
        return po_name
 
352
        
 
353
    def export_xls(self, cr, uid, ids, context=None):
 
354
        """
 
355
        Print the report (Excel)
 
356
        """
 
357
        if isinstance(ids, (int, long)):
 
358
            ids = [ids]
 
359
        datas = {'ids': ids}
 
360
        file_name = self.export_get_file_name(cr, uid, ids, context=context)
 
361
        if file_name:
 
362
            datas['target_filename'] = file_name
 
363
        return {
 
364
            'type': 'ir.actions.report.xml',
 
365
            'report_name': 'sales.follow.up.report_xls',
 
366
            'datas': datas,
 
367
            'context': context,
 
368
            'nodestroy': True,
 
369
        }
 
370
                
 
371
    def export_pdf(self, cr, uid, ids, context=None):
 
372
        """
 
373
        Print the report (PDF)
 
374
        """
 
375
        if isinstance(ids, (int, long)):
 
376
            ids = [ids]
 
377
        datas = {'ids': ids}
 
378
        file_name = self.export_get_file_name(cr, uid, ids, context=context)
 
379
        if file_name:
 
380
            datas['target_filename'] = file_name
 
381
        return {
 
382
            'type': 'ir.actions.report.xml',
 
383
            'report_name': 'sales.follow.up.report_pdf',
 
384
            'datas': datas,
 
385
            'context': context,
 
386
            'nodestroy': True,
 
387
        }
339
388
    
340
389
sale_order_followup()
341
390
 
 
391
 
342
392
class sale_order_line_followup(osv.osv_memory):
343
393
    _name = 'sale.order.line.followup'
344
394
    _description = 'Sales Order Lines Followup'
970
1020
        if context.get('from_followup'):
971
1021
            ids = []
972
1022
            if name and len(name) > 1:
973
 
                ids.extend(self.search(cr, uid, [('client_order_ref', operator, name)], context=context))
974
 
 
975
 
            return self.name_get(cr, uid, ids, context=context)
 
1023
                args2 = [('client_order_ref', operator, name)]
 
1024
                if args:
 
1025
                    args2 += args
 
1026
                ids.extend(self.search(cr, uid, args2, context=context))
 
1027
            res = self.name_get(cr, uid, ids, context=context)
976
1028
        else:
977
 
            return super(sale_order, self).name_search(cr, uid, name, args, operator, context, limit)
 
1029
            res = super(sale_order, self).name_search(cr, uid, name, args, operator, context, limit)
 
1030
        return res
978
1031
 
979
1032
    def name_get(self, cr, uid, ids, context=None):
980
1033
        '''