Browse another model in openerp depending upon the active-ids

血红的双手。 提交于 2019-12-08 07:21:05

问题


I am creating "delivery slip" report, and I have to check the type of sale which is direct or in indirect, so order_type is in "sale.order" model, so I need to browse the order_type with the help of sale number

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

The problem is when I select multiple record to print, only the last record is printed in all the pdf, so how to pass the list of record to RML report

来源:https://stackoverflow.com/questions/26374303/browse-another-model-in-openerp-depending-upon-the-active-ids

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!