Hi, I'm using Odoo 14 and I want to add price_unit from purchase_order_line to pivot and graph view of purchase.report. This will involve inheriting pivot and graph of purchase.report model .
Here is the error I'm getting .
error
psycopg2.errors.UndefinedColumn: column purchase_report.price_unit does not exist LINE 3: ..._order_line" AS "purchase_report__price_unit" ON ("purchase_...My Model
class PurchaseReport(models.Model):
_inherit = "purchase.report"
price_unit = fields.Many2one('purchase.order.line', string='Unit Price')
def _query(self, with_clause='', fields={}, groupby='', from_clause=''):
fields['price_unit'] = ", s.price_unit as price_unit"
groupby += ', s.price_unit'
return super(PurchaseReport, self)._query(with_clause, fields, groupby, from_clause)
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="view_purchase_order_inherit_pivot">
<field name="name">product.month.pivot.inherit</field>
<field name="model">purchase.report</field>
<field name="inherit_id" ref="purchase.view_purchase_order_pivot"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='untaxed_total']" position="before">
<field name="price_unit" type="col"/>
<field name="price_unit" type="measure"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_purchase_order_inherit_graph">
<field name="name">product.month.graph.inherit</field>
<field name="model">purchase.report</field>
<field name="inherit_id" ref="purchase.view_purchase_order_graph"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='untaxed_total']" position="before">
<field name="price_unit" type="row"/>
<field name="price_unit" type="measure"/>
</xpath>
</field>
</record>
</odoo>