我用xpath替换了预测按钮的操作, 我将新操作 action_stock_level_forecast_report_product_tree
设置为按钮名称在我的操作中,我设置了新视图的引用 product_product_forecast_tree_view
<!--product product -->
<record id="product_product_forecast_tree_view" model="ir.ui.view">
<field name="name">product.template.forecast.tree.view</field>
<field name="model">product.template</field>
<field name="arch" type="xml">
<tree string="test">
<!--<field name="product_id"/>-->
</tree>
</field>
</record>
<record id="action_stock_level_forecast_report_product_tree" model="ir.actions.act_window">
<field name="name">Stock Level Forecast Report product Tree</field>
<field name="res_model">product.product</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="product_product_forecast_tree_view"/>
</record>
<record id="product_product_forecasted_button" model="ir.ui.view">
<field name="name">product.product.forecasted.button</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<data>
<xpath expr="//button[@name='%(stock.action_stock_level_forecast_report_product)d']" position="attributes">
<attribute name="name">%(action_stock_level_forecast_report_product_tree)d</attribute>
</xpath>
</data>
</field>
</record>
然后我尝试运行它,但是出现了一个奇怪的JavaScript错误:
Erreur:TypeError:列表未定义
http://localhost:8069/web/content/8507-ea13d16/web.assets_backend.js:1193 补货: _applyX2ManyOperations @ http://localhost:8069/web/content/8507-ea13d16/web.assets_backend.js:1193:194 get @ http://localhost:8069/web/content/8507-ea13d16/web.assets_backend.js:1124:565 get / list.data <@ http://localhost:8069/web/content/8507-ea13d16/web.assets_backend.js:1128:169 _.collect@http://localhost:8069/web/content/8496-d085622/web.assets_common.js:13:270 get @ http://localhost:8069/web/content/8507-ea13d16/web.assets_backend.js:1128:126 renderSidebar @ http://localhost:8069/web/content/8507-ea13d16/web.assets_backend.js:1688:85 renderSidebar @ http://localhost:8069/web/content/8507-ea13d16/web.assets_backend.js:3013:502 OdooClass.extend / Class.include / http:// localhost:8069 / web / content / 8496-d085622 / web.assets_common.js:3819:368 render_view_control_elements @ http://localhost:8069/web/content/8507-ea13d16/web.assets_backend.js:489:76 _display_view @ http://localhost:8069/web/content/8507-ea13d16/web.assets_backend.js:483:261 switch_mode / http:// localhost:8069 / web / content / 8507-ea13d16 / web.assets_backend.js:482:44 然后/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:802:678 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 递延/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:803:56 switch_mode / http:// localhost:8069 / web / content / 8507-ea13d16 / web.assets_backend.js:481:395 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 添加@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:797:467 switch_mode / http:// localhost:8069 / web / content / 8507-ea13d16 / web.assets_backend.js:481:338 然后/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:802:678 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 然后/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:802:874 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 然后/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:802:874 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 updateFunc / <@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:804:482 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 然后/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:802:874 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 然后/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:802:874 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 递延/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:803:56 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 添加@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:797:467 然后/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:802:772 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 然后/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:802:874 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 递延/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:803:56 rpc / http:// localhost:8069 / web / content / 8496-d085622 / web.assets_common.js:3869:346 然后/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:802:678 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 递延/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:803:56 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 然后/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:802:874 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 然后/http://localhost:8069/web/content/8496-d085622/web.assets_common.js:802:874 火@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 fireWith @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:801:198 完成@ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:1192:86 callback @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:1212:15
有人可以帮我吗? 抱歉我是法国人,我是odoo / python / xml的入门者
答案 0 :(得分:0)
您的树视图必须具有一些内容才能呈现。在视图中至少添加一个字段,它应该可以正常加载。
<record id="product_product_forecast_tree_view" model="ir.ui.view">
<field name="name">product.template.forecast.tree.view</field>
<field name="model">product.template</field>
<field name="arch" type="xml">
<tree string="test">
<!-- Needs real content in the tree element -->
<field name="product_id"/>
</tree>
</field>
</record>