This question has been flagged

hi ! i am using a sql query to get data into a new module and following is the code


class PostgresReport(models.Model):
_name = 'purchase.comp'
_auto = False

name = fields.Char(string = 'Purchase Order')
origin = fields.Char(string ='Purchase Agreement')
date_order = fields.Datetime('Order Date', index=True, copy=False)
state = fields.Selection([
('draft', 'RFQ'),
('sent', 'RFQ Sent'),
('to approve', 'To Approve'),
('purchase', 'Purchase Order'),
('done', 'Locked'),
('cancel', 'Cancelled')
], string='Status', readonly=True, index=True, copy=False, default='draft', track_visibility='onchange')
product_id = fields.Char(string='Product')
product_qty = fields.Float(string='Quantity')
price_unit = fields.Float(string='Unit Price')
price_subtotal = fields.Monetary(string='Subtotal', store=True)
vendor = fields.Char(string='Vendor')
currency_id = fields.Char('Currency')


@api.model_cr
def init(self):
""" Event Question main report """
tools.drop_view_if_exists(self._cr, 'purchase_comp')
self._cr.execute(""" CREATE VIEW purchase_comp AS (
SELECT
b.id as id,
a.name as "name",
a.origin as "origin",
a.date_order as "date_order",
a.state as "state",
b.name as "product_id",
b.product_qty as "product_qty",
b.price_unit as "price_unit",
b.price_subtotal as "price_subtotal",
c.display_name as "vendor",
d.name as "currency_id"


FROM public.purchase_order as a

inner join
public.purchase_order_line as b
on a.id = b.order_id

inner join
public.res_partner as c
on a.partner_id = c.id

inner join
public.res_currency as d
on d.id = b.currency_id

WHERE a.origin != ''
order by a.name
)""")
Now i am trying to fetch its qweb report too but i am unable to get the report of a complete tree view as i have nothing to loop thorugh.Can someone please explain what approach should i use here.
Avatar
Discard