This question has been flagged
2 Replies
3009 Views

hello mates, I'm trying to generate a product summary report for odoo pos orders which contains a list of product and sold qty and the cost of sold,

I've added a wizard that displays the start and end date which I search between,

I made a method that loops over all order lines and get all products also merge duplicated ones and get sum of their quantity, and here is all code,


    class posreport(models.TransientModel):
    _name = 'pos.reports'
    _description = 'product_summary'
    start_date = fields.Datetime(string="", required=False, )
    end_date = fields.Datetime(string="", required=False, )
    @api.multi
    def product_summary(self):
        product_summary_dict = {}
        if self.start_date and self.end_date:
            order_detail = self.env['pos.order'].search([('date_order', '>=', self.start_date),
                                                         ('date_order', '<=', self.end_date)])
            if order_detail:
                for each_order in order_detail:
                    for each_order_line in each_order.lines:
                        if each_order_line.product_id.name in product_summary_dict:
                            product_qty = product_summary_dict[each_order_line.product_id.name]
                            product_qty += each_order_line.qty
                        else:
                            product_qty = each_order_line.qty
                        product_summary_dict[each_order_line.product_id.name] = product_qty;
                        tot = each_order_line.product_id.standard_price*product_summary_dict[each_order_line.product_id.name]
                    print(product_summary_dict[each_order_line.product_id.name],each_order_line.product_id.name,tot)
        pass


everything is going well and I check the console and see the printed records and that data all I need exactly, 


now I need to display this data into lines at the wizard form, then print it in pdf Report, 

how can I do that, and which type of field that suitable to contains this type of data, to let the end-user see the product summary before printing the report?


any help will be appreciated, Thanks...

Avatar
Discard
Best Answer

You can take  reference from the link below that i just search from google for you:

https://www.surekhatech.com/blog/generate-report-from-custom-wizard-in-odoo10

It can able to print pdf but you have to display your data in qweb too...

Avatar
Discard