Oddo-将树视图的选定记录从向导打印到pdf

问题描述 投票:0回答:1

我必须从向导将树视图的选定记录的列表打印到pdf报告中,我将新菜单项添加到打印dropwwon菜单中,如下图所示

enter image description here

需要帮助

drop-down-menu server treeview odoo-10 wizard
1个回答
0
投票

我创建了向导,它将搜索日期和日期之间的记录,您需要pdf格式,您可以将模板编写为pdf,我认为这可能会对您有所帮助

class WizardContract(models.TransientModel):
_name = 'order.wizard'
customer_ids=fields.Many2one('res.partner',string='Customer Name' )
datefrom = fields.Date(string="Date From")
dateto = fields.Date(string="Date To")
current_date= fields.datetime.now()     

@api.depends('customer_ids','datefrom','dateto')
def print_report(self):

    search_id = self.env['sale.order'].search([('partner_id','=', self.customer_ids.id),('date_order', '>=', self.datefrom), ('date_order', '<=', self.dateto)])
    lst = []
    for loop in search_id:
        lst.append(str(loop.partner_id.name))
        lst.append(str(self.datefrom))
        lst.append(str(self.current_date))
    lines=[]
    if self.current_date:
        current_date= str(self.current_date)
        total=0     
        lines=[]
        rec_sale_line = self.env['sale.order.line'].search([('order_id','=', loop.id),('order_partner_id','=', self.customer_ids.id)])
        for line in rec_sale_line:
            dict_lines = {'product_id':line.product_id.id,
                          'product_uom_qty':line.product_uom_qty,
                          'price_unit':line.price_unit,
                          'sub_total':line.price_subtotal
                }
            lines.append(dict_lines)
    partner_id=lst[0] 
    data = {
                'partner_id': partner_id,
                'confirmation_date': fields.Datetime.now(),
                'lst':lst,
                'lines':lines,
                }
    print line.product_id.name
    print line
    print type(lst)

    return self.env['report'].get_action([],'order_log.report_template_demo',data=data) 
© www.soinside.com 2019 - 2024. All rights reserved.