Skip to Content
Menu
This question has been flagged
3 Replies
5203 Views

Report Preview

from odoo import fields, models, api

class PurchaseReport(models.Model): 

 _inherit = 'purchase.report'

product_qty = fields.Float(string='Quantity', digits=dp.get_precision('Product Unit of Measure'), readonly=True) qty_received = fields.Float(string="Received Qty", digits=dp.get_precision('Product Unit of Measure'), readonly=True) qty_balanced = fields.Float(string="Balance", digits=dp.get_precision('Product Unit of Measure'), readonly=True) 

def _select(self): 

 return super(PurchaseReport, self)._select() + ", (l.product_qty - l.qty_received) as qty_balanced"

Where my Balance Measure show ?????
where im wrong which point i'm missing ?

Avatar
Discard
Best Answer

Hello,

Please try this code

def _select(self):
return super(PurchaseReport, self)._select() + ", sum(l.qty_received),sum(l.product_qty - l.qty_received) as qty_balanced"

You can found your Balance in Measures Button (Graph and Pivot).
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

Avatar
Discard
Best Answer

 Hi,

   Just try this

     

def _select(self):
res = super(PurchaseReport, self)._select()
select_str = res + """,sum(l.product_qty -l.qty_received)
as qty_balanced"""
return select_str

                                                                                                                                                                                                                                       qty_received and product_qty are already there in purchase order line.so we can directly taken the balance from that

                                                                                                                                                                                                                                                                                                                                                                                                                                                

Avatar
Discard
Author Best Answer

i Use this 


from odoo import fields, models, api

class PurchaseReport(models.Model): _inherit = 'purchase.report'

qty_balanced = fields.Float(string="Balance",group_operator = 'avg', readonly=True) 

 def _select(self): 

 return super(PurchaseReport, self)._select() + ", (l.product_qty - l.qty_received) as qty_balanced"
    

def _group_by(self):

 return super(PurchaseReport, self)._group_by() + ", l.product_qty" + ", l.qty_received"


Avatar
Discard