Я хочу сделать отчет в модуле заявки на покупку. Так вот, я уже сделал это.purchase_requisition_report.py
from odoo import models, fields, api
class purchase_requisition_report(models.Model):
_name = 'purchase.requisition.report'
_description="Purchase Requisition Report"
_column={
'date': fields.datetime('Order Date', readonly=True, help="Date on which this document has been created"),
'state': fields.selection([('draft', 'Request for Quotation'),
('confirmed', 'Waiting Supplier Ack'),
('approved', 'Approved'),
('done', 'Done'),
('cancel', 'Cancelled')], 'Purchase Requisition Status', readonly=True),
'name': fields.char('Purchase Requisition No'),
'product_id': fields.many2many('product.product','Product Name'),
'supplier': fields.many2many('res.partner','Supplier Name'),
}
_order = 'date desc'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, 'purchase_requisition_report')
cr.execute("""
create or replace view purchase_requisition_report as (
SELECT
purchase_requisition.name,
product_product.name_template,
res_partner.display_name,
purchase_order.name,
purchase_requisition.state
FROM
purchase_requisition_line inner join purchase_requisition on(purchase_requisition_line.requisition_id = purchase_requisition.id)
inner join product_product on(purchase_requisition_line.product_id = product_product.id)
inner join purchase_order on(purchase_order.requisition_id = purchase_requisition.id)
inner join res_partner on(purchase_order.partner_id = res_partner.id);
""")
purchase_requisition_report_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_purchase_requisition_report_tree" model="ir.ui.view">
<field name="name">purchase.requisition.report.tree</field>
<field name="model">purchase.requisition.report</field>
<field name="arch" type="xml">
<tree string="Purchase Requisition Report">
<field name="name"/>
<field name="product_id"/>
<field name="supplier"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="view_purchase_requisition_report_search" model="ir.ui.view">
<field name="name">purchase.requisition.report.search</field>
<field name="model">purchase.requisition.report</field>
<field name="arch" type="xml">
<search string="Purchase Requisition Report">
<filter string="Waiting" domain="[('state', '=' ,'confirm')]" help="Confirm Requisition"/>
<filter string="Approved" domain="[('state','=','accepted')]" help="Approved Requisition"/>
<filter string="Done" domain="[('state','=', 'done')]" help="Done Requisition"/>
<group expand="0" string="Extended Filters...">
<field name="product_id"/>
<field name="user_id"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="date" string="Creation Date"/>
<field name="date_confirm"/>
<field name="date_valid"/>
</group>
<group expand="1" string="Group By">
<filter string="Purchase Requisition No" context="{'group_by':'name'}"/>
<filter string="Supplier" context="{'group_by':'supplier'}"/>
<filter string="Product" context="{'group_by':'product_id'}"/>
<filter string="Status" context="{'group_by':'state'}"/>
<filter string="Create Month" context="{'group_by':'create_date:month'}" help="Creation Date"/>
</group>
</search>
</field>
</record>
<record id="action_purchase_requsition_report" model="ir.actions.act_window">
<field name="name">Purchase Requisition</field>
<field name="res_model">purchase.requisition.report</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_purchase_requisition_report_tree"></field>
</record>
<menuitem id="base.next_id_73" name="Purchase" parent="base.menu_reporting" sequence="10"/>
<menuitem action="action_purchase_requsition_report" id="menu_action_purchase_requsition_report" parent="base.next_id_73" sequence="10"/>
</data>
</openerp>
openerp.py
{
'name': 'Purchase Requisitions',
'version': '0.1',
'author': 'OpenERP SA',
'category': 'Purchase Management',
'website': 'https://www.odoo.com/page/purchase',
'description': """
This module allows you to manage your Purchase Requisition.
===========================================================
When a purchase order is created, you now have the opportunity to save the
related requisition. This new object will regroup and will allow you to easily
keep track and order all your purchase orders.
""",
'depends' : ['purchase'],
'demo': ['purchase_requisition_demo.xml'],
'data': ['views/purchase_requisition.xml',
'security/purchase_tender.xml',
'wizard/purchase_requisition_partner_view.xml',
'wizard/bid_line_qty_view.xml',
'purchase_requisition_data.xml',
'purchase_requisition_view.xml',
'purchase_requisition_report.xml',
'report/purchase_requisition_report_view.xml',
'purchase_requisition_workflow.xml',
'security/ir.model.access.csv','purchase_requisition_sequence.xml',
'views/report_purchaserequisition.xml',
],
'auto_install': False,
'test': [
'test/purchase_requisition_users.yml',
'test/purchase_requisition_demo.yml',
'test/cancel_purchase_requisition.yml',
'test/purchase_requisition.yml',
],
'installable': True,
}
После всего этого я получаю следующую ошибку
Error details:
Model not found: purchase.requisition.report
Error context:
View `purchase.requisition.report.tree`
[view_id: 1419, xml_id: n/a, model: purchase.requisition.report, parent_id: n/a]" while parsing file:///C:/Program%20Files/Odoo%208.0-20150515/server/openerp/addons/purchase_requisition/report/purchase_requisition_report_view.xml:5, near
<record id="view_purchase_requisition_report_tree" model="ir.ui.view">
<field name="name">purchase.requisition.report.tree</field>
<field name="model">purchase.requisition.report</field>
<field name="arch" type="xml">
<tree string="Purchase Requisition Report">
<field name="name"/>
<field name="product_id"/>
<field name="supplier"/>
<field name="state"/>
</tree>
</field>
</record>
Я не могу выяснить, где находится ошибка, благодарю за любую помощь. Спасибо. PS: я использую Odoo V.8