我仍在Odoo V8中开发特定模块方面处于首次亮相,我试图在Odoo 8中安装模块,但收到以下错误消息:
Odoo Server Error
Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\http.py", line 546, in _handle_exception
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\http.py", line 583, in dispatch
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\http.py", line 319, in _call_function
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\service\model.py", line 118, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\http.py", line 316, in checked_call
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\http.py", line 812, in __call__
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\http.py", line 412, in response_wrap
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\openerp\addons\web\controllers\main.py", line 948, in call_button
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\openerp\addons\base\module\module.py", line 447, in button_immediate_install
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\openerp\addons\base\module\module.py", line 495, in _button_immediate_function
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\modules\registry.py", line 370, in new
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\modules\loading.py", line 355, in load_modules
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\modules\loading.py", line 255, in load_marked_modules
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\modules\loading.py", line 176, in load_module_graph
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\modules\loading.py", line 118, in _load_data
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\tools\convert.py", line 897, in convert_file
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\tools\convert.py", line 983, in convert_xml_import
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\tools\convert.py", line 849, in parse
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\tools\convert.py", line 759, in _tag_record
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\openerp\addons\base\ir\ir_model.py", line 1069, in _update
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\openerp\addons\base\ir\ir_ui_view.py", line 263, in create
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\api.py", line 372, in old_api
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\models.py", line 4101, in create
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\api.py", line 508, in new_api
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\models.py", line 4298, in _create
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20171010\server\.\openerp\models.py", line 1275, in _validate_fields
ParseError: "ValidateError
Field(s) 'arch' failed against a constraint: Invalid view definition
Error details:
Model not found: forecast.report
Error context:
View `forecast.report.graph`
[view_id: 871, xml_id: n/a, model: forecast.report, parent_id: n/a]" while parsing file:///c:/program%20files%20(x86)/odoo%208.0-20171010/server/openerp/addons/forecast_report/forecast_report_view.xml:5, near
<record id="view_order_product_graph" model="ir.ui.view">
<field name="name">forecast.report.graph</field>
<field name="model">forecast.report</field>
<field name="arch" type="xml">
<graph string="Sales Analysis" type="pivot" stacked="True">
<field name="section_id" type="row"/>
<field name="date" interval="month" type="col"/>
<field name="price_total" type="measure"/>
</graph>
</field>
</record>
我创建了一个“预测报告”模块,并修改了用于生成销售报告的代码,
这是我的代码:
forecast_report.py:
from openerp import models, tools
from openerp.osv import fields, osv
class Forecast_report(models.Model):
_name = "forecast_report"
_description = "Forecast Statistics"
_auto = False
_rec_name = 'date'
_columns = {
'date': fields.datetime('Date Order', readonly=True), # TDE FIXME master: rename into date_order
'date_confirm': fields.date('Date Confirm', readonly=True),
'product_id': fields.many2one('product.product', 'Product', readonly=True),
'product_uom': fields.many2one('product.uom', 'Unit of Measure', readonly=True),
'product_uom_qty': fields.float('# of Qty', readonly=True),
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
'company_id': fields.many2one('res.company', 'Company', readonly=True),
'user_id': fields.many2one('res.users', 'Salesperson', readonly=True),
'price_total': fields.float('Total Price', readonly=True),
'delay': fields.float('Commitment Delay', digits=(16,2), readonly=True),
'categ_id': fields.many2one('product.category','Category of Product', readonly=True),
'nbr': fields.integer('# of Lines', readonly=True), # TDE FIXME master: rename into nbr_lines
'state': fields.selection([
('cancel', 'Cancelled'),
('draft', 'Draft'),
('confirmed', 'Confirmed'),
('exception', 'Exception'),
('done', 'Done')], 'Order Status', readonly=True),
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', readonly=True),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', readonly=True),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
}
_order = 'date desc'
def _select(self):
select_str = """
WITH currency_rate (currency_id, rate, date_start, date_end) AS (
SELECT r.currency_id, r.rate, r.name AS date_start,
(SELECT name FROM res_currency_rate r2
WHERE r2.name > r.name AND
r2.currency_id = r.currency_id
ORDER BY r2.name ASC
LIMIT 1) AS date_end
FROM res_currency_rate r
)
SELECT min(l.id) as id,
l.product_id as product_id,
t.uom_id as product_uom,
sum(l.product_uom_qty / u.factor * u2.factor) as product_uom_qty,
sum(l.product_uom_qty * l.price_unit / cr.rate * (100.0-l.discount) / 100.0) as price_total,
count(*) as nbr,
s.date_order as date,
s.date_confirm as date_confirm,
s.partner_id as partner_id,
s.user_id as user_id,
s.company_id as company_id,
extract(epoch from avg(date_trunc('day',s.date_confirm)-date_trunc('day',s.create_date)))/(24*60*60)::decimal(16,2) as delay,
l.state,
t.categ_id as categ_id,
s.pricelist_id as pricelist_id,
s.project_id as analytic_account_id,
s.section_id as section_id
"""
return select_str
def _from(self):
from_str = """
sale_order_line l
join sale_order s on (l.order_id=s.id)
left join product_product p on (l.product_id=p.id)
left join product_template t on (p.product_tmpl_id=t.id)
left join product_uom u on (u.id=l.product_uom)
left join product_uom u2 on (u2.id=t.uom_id)
left join product_pricelist pp on (s.pricelist_id = pp.id)
join currency_rate cr on (cr.currency_id = pp.currency_id and
cr.date_start <= coalesce(s.date_order, now()) and
(cr.date_end is null or cr.date_end > coalesce(s.date_order, now())))
"""
return from_str
def _group_by(self):
group_by_str = """
GROUP BY l.product_id,
l.order_id,
t.uom_id,
t.categ_id,
s.date_order,
s.date_confirm,
s.partner_id,
s.user_id,
s.company_id,
l.state,
s.pricelist_id,
s.project_id,
s.section_id
"""
return group_by_str
def init(self, cr):
# self._table = sale_report
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
%s
FROM ( %s )
%s
)""" % (self._table, self._select(), self._from(), self._group_by()))
forecast_report_view.xml:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_order_product_graph" model="ir.ui.view">
<field name="name">forecast.report.graph</field>
<field name="model">forecast.report</field>
<field name="arch" type="xml">
<graph string="Sales Analysis" type="pivot" stacked="True">
<field name="section_id" type="row"/>
<field name="date" interval="month" type="col"/>
<field name="price_total" type="measure"/>
</graph>
</field>
</record>
<!-- Custom reports (aka filters) -->
<record id="filter_sale_report_sales_funnel" model="ir.filters">
<field name="name">Sales Funnel</field>
<field name="model_id">forecast.report</field>
<field name="domain">['&', ('date','<=', time.strftime('%%Y-12-31')), '&', ('date','>=',time.strftime('%%Y-01-01')), ('state','not in',('cancel',))]</field>
<field name="user_id" eval="False"/>
<field name="context">{'group_by': ['state'], 'measures': ['price_total']}</field>
</record>
<record id="filter_sale_report_salespersons" model="ir.filters">
<field name="name">By Salespersons</field>
<field name="model_id">forecast.report</field>
<field name="user_id" eval="False"/>
<field name="context">{'group_by': ['date:month', 'user_id']}</field>
</record>
<record id="filter_sale_report_salesteam" model="ir.filters">
<field name="name">By Salesteam</field>
<field name="model_id">forecast.report</field>
<field name="user_id" eval="False"/>
<field name="context">{'group_by': ['date:month', 'section_id']}</field>
</record>
<record id="filter_isale_report_product" model="ir.filters">
<field name="name">By Product</field>
<field name="model_id">forecast.report</field>
<field name="user_id" eval="False"/>
<field name="context">{'group_by': ['date:month', 'product_id']}</field>
</record>
<record id="view_order_product_search" model="ir.ui.view">
<field name="name">forecast.report.search</field>
<field name="model">forecast.report</field>
<field name="arch" type="xml">
<search string="Sales Analysis">
<field name="date"/>
<field name="date_confirm"/>
<filter string="This Year" name="year" invisible="1" domain="[('date','<=', time.strftime('%%Y-12-31')),('date','>=',time.strftime('%%Y-01-01'))]"/>
<filter name="Quotations" string="Quotations" domain="[('state','=','draft')]"/>
<filter name="Sales" string="Sales" domain="[('state','not in',('draft', 'cancel'))]"/>
<separator/>
<filter string="My Sales" help="My Sales" domain="[('user_id','=',uid)]"/>
<field name="partner_id"/>
<field name="product_id"/>
<field name="user_id"/>
<group expand="0" string="Extended Filters">
<field name="categ_id" filter_domain="[('categ_id', 'child_of', self)]"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
<group expand="1" string="Group By">
<filter string="Salesperson" name="User" context="{'group_by':'user_id'}"/>
<filter string="Sales Team" context="{'group_by':'section_id'}" groups="base.group_multi_salesteams"/>
<filter string="Customer" name="Customer" context="{'group_by':'partner_id'}"/>
<filter string="Category of Product" name="Category" context="{'group_by':'categ_id'}"/>
<filter string="Status" context="{'group_by':'state'}"/>
<filter string="Company" groups="base.group_multi_company" context="{'group_by':'company_id'}"/>
<separator/>
<filter string="Order Month" context="{'group_by':'date:month'}" help="Ordered date of the sales order"/>
</group>
</search>
</field>
</record>
<record id="action_order_report_all" model="ir.actions.act_window">
<field name="name">Forecast Analysis</field>
<field name="res_model">forecast.report</field>
<field name="view_type">form</field>
<field name="view_mode">graph</field>
<field name="search_view_id" ref="view_order_product_search"/>
<field name="view_id" ref="view_order_product_graph"/>
<field name="context">{'search_default_Sales':1, 'group_by_no_leaf':1,'group_by':[]}</field>
<field name="help">This report performs analysis on your quotations and sales orders. Analysis check your sales revenues and sort it by different group criteria (salesman, partner, product, etc.) Use this report to perform analysis on sales not having invoiced yet. If you want to analyse your turnover, you should use the Invoice Analysis report in the Accounting application.</field>
</record>
<menuitem action="action_order_report_all" id="menu_report_product_all" parent="base.next_id_64" sequence="10"/>
</data>
</openerp>
forecast_report.xml:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="forecast_sale_order"
string="Sales Forecasts / Sales Forecast Lines"
model="sale.order"
report_type="qweb-pdf"
file="forecast_report.report_saleorder"
name="forecast_report.report_saleorder"
/>
</data>
</openerp>
我希望Odoo 8中的销售分析结果(与基本产品类似),但是模型不同。
答案 0 :(得分:0)
您的模型之所以称为forecase_report
,是因为您已经在_name = "forecast_report"
中定义了该模型。因此,要么在每个相关文件中更改模型名称,要么将_name
更改为odoo的准则样式forecast.report
。
答案 1 :(得分:0)
请更改_name = "forecast.report".
重新启动并升级模块。