【问题标题】:Oddo - Print selected records of tree view from wizard to pdfOddo - 将选定的树视图记录从向导打印到 pdf
【发布时间】:2019-11-07 12:05:43
【问题描述】:

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

enter image description here

我需要帮助

【问题讨论】:

    标签: drop-down-menu server treeview odoo-10 wizard


    【解决方案1】:

    我创建了向导,它将使用从日期到日期搜索记录,你需要它来制作 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) 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-20
      • 1970-01-01
      • 1970-01-01
      • 2011-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多