1

我正在创建“交货单”报告,我必须检查直接或间接的销售类型,所以 order_type 是在“sale.order”模型中,所以我需要借助销售编号浏览 order_type

from openerp.report import report_sxw

class ps_report(report_sxw.rml_parse):
name_type = ''
name_type1 = ''
v_name = ''
v_model = ''
v_year = ''
picking = ''

def __init__(self, cr, uid, name, context=None):
    super(ps_report, self).__init__(cr, uid, name, context=context)
    do_type = self.pool.get('stock.picking.out').browse(cr, uid, context.get('active_id'))
    do_type1 = self.pool.get('stock.picking.out').browse(cr, uid, context.get('active_ids'))
    print do_type1
    global name_type1
    for list_id in do_type1:
        so_type1 = self.pool.get('sale.order').search(cr,uid,[('name','=',list_id.origin)])
        so1_type1 = self.pool.get('sale.order').browse(cr,uid,so_type1[0])
        name_type1 = so1_type1.order_type    
    so_type = self.pool.get('sale.order').search(cr, uid, [('name','=',do_type.origin)])
    so1_type = self.pool.get('sale.order').browse(cr, uid, so_type[0])
    global picking 
    picking = do_type
    global name_type
    name_type = so1_type.order_type
    global v_name
    global v_model
    global v_year
    for line in so1_type.order_line:
        v_name = line.vehicle_make
        v_model = line.vehicle_model
        v_year = line.vehicle_make_year

    self.localcontext.update({
        'time': time,
        'sale_name':self._sale_name,
        'vech_name':self._vech_name,
        'vech_model':self._vech_model,
        'vech_year':self._vech_year,
        'sum_qty':self._sum_qty,
    })

def _sale_name(self):
    if name_type1 == 'indirectsale':
        return 'INDIRECT SALE'
    elif name_type1 == 'directsale':
        return 'DIRECT SALE'
    return name_type1

def _vech_name(self):
    return v_name

def _vech_model(self):
    return v_model

def _vech_year(self):
    return v_year

def _sum_qty(self):
    total = 0
    for line in picking.move_lines:
        total+=line.product_qty
        str(total)
    print total  
    return total

问题是当我选择多条记录打印时,所有pdf中只打印最后一条记录,那么如何将记录列表传递给RML报告

4

0 回答 0