I am trying to make a report where the user selects a product from a drop down list and it shows a table that has the following columns create date, stock quantity, incoming and outgoing quantities, supplier/customer , and price since it has to get each field from a different model, i had to use sql views, but then when i load the odoo view it doesn't show any of the fields, i made sure the sql statments of the view works fine, and when examining the datatbase, the view is created, still nothing shows up on the view
code below
from odoo import api, fields, models, tools, _
class ProductProfileReportView(models.Model):
_name = "product.profile.report"
_auto = False
action_type = fields.Char(string="Type")
create_date = fields.Date(string="Date")
invoice_id = fields.Many2one(comodel_name="custom.purchase", string="Invoice", required=False, )
qty = fields.Integer(string="Qty")
supplier_id = fields.Many2one(comodel_name="custom.supplier", string="Supplier", required=False, )
price = fields.Float(string="Price")
@api.model_cr
def init(self):
""" Event Question main report """
tools.drop_view_if_exists(self._cr, 'product_profile_report')
self._cr.execute(""" CREATE OR REPLACE VIEW product_profile_report AS (
select p.id as id,
'Purchase' as action_type,
pu.create_date as create_date,
pu.id as invoice_id,
pul.qty as qty,
s.id as supplier_id,
p.sell_price as price
from
custom_product p
inner join custom_purchase_line pul
on p.id = pul.product_id
inner join custom_purchase pu
on pul.purchase_id = pu.id
inner join custom_supplier s
on pu.supplier_id = s.id)""")
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="form_product_profile_report" model="ir.ui.view">
<field name="name">product.profile.report.form</field>
<field name="model">product.profile.report</field>
<field name="arch" type="xml">
<form string="">
<sheet>
<group>
<fields name="action_type"/>
<fields name="create_date"/>
<fields name="invoice_id"/>
<fields name="qty"/>
<fields name="supplier_id"/>
<fields name="price"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="action_product_profile_report" model="ir.actions.act_window">
<field name="name">product profile report</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.profile.report</field>
<field name="view_mode">form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create"></p>
</field>
</record>
<menuitem id="report_item" name="Reports" parent="custom_product_root"/>
<menuitem id="product_profile_report_submenu" name="Product Profile" parent="report_item"
action="action_product_profile_report"/>
</odoo>