Skip to Content
Menu
This question has been flagged

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
Related Posts Replies Views Activity
3
Dec 22
2631
2
Sep 20
5035
2
Apr 20
3559
1
Apr 20
2419
1
Sep 19
5341