Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Generate Reports from sale order line without any category of products [Closed]

By
Odoo
on 4/3/14, 3:41 AM 608 views

The Question has been closed for reason: contains offensive or malicious remarks

by
Odoo
on 07/21/2014 00:59:19
def _get_prdouct_details(self, category_id):
        product_ids = self.pool.get('product.product').search(self.cr, self.uid, [('categ_id','=',category_id)])
        lines = []
        self.res[category_id]={}
        self.res[category_id]['total_qty']=0.00
        self.res[category_id]['total_amt']=0.00
        for product_id in product_ids:
            line = {}
            product=self.pool.get('product.product').browse(self.cr, self.uid, [product_id] )[0]
            line['product_name'] = product.name
            sale_line_ids = self.pool.get('sale.order.line').search(self.cr, self.uid, [('product_id','=',product.id),('state','not in',['cancel','draft'])])
            qty=0.00
            amount=0.00
            for sale_line_id in sale_line_ids:
                sale_line = self.pool.get('sale.order.line').browse(self.cr, self.uid, [sale_line_id])[0]
                amount+=sale_line.price_subtotal
                qty+=sale_line.product_uom_qty
            average=0.00
            if qty:
                average=amount/qty
            line['category_id'] = category_id
            line['product_id'] = product_id
            line['average']=average
            line['amount']=amount
            line['qty']=qty
            line['percentage']=0.00
            if self.total_amount and amount:
                line['percentage'] = (amount / self.total_amount) * 100
            self.res[category_id]['total_qty']+=qty
            self.res[category_id]['total_amt']+=amount
            lines.append(line)
        return lines

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/3/14, 3:41 AM
Seen: 608 times
Last updated: 3/16/15, 8:10 AM