我用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:list未定义
http://localhost:8069/web/content/8507-ea13d16/web.assets_backend.js:1193Retraraçage:_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.datahttp://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 then / http:// localhost:8069 / web / content / 8496-d085622 / web.assets_common.js:802:678 fire @ 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 Deferred / 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 fire @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 add @ 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 fire @ 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 then / http ://本地主机:8069 /网络/内容/ 8496-d 085622 / web.assets_common.js:802:874 fire @ 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 then / http:// localhost:8069 / web / content / 8496-d085622 / web.assets_common.js:802:874 fire @ 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 fire @ 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 then / http:// localhost:8069 / web / content / 8496-d085622 / web.assets_common.js:802:874 fire @ 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 then / http:// localhost: 8069 / web / content / 8496-d085622 / web.assets_common.js:802:874 fire @ 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 Deferred / http:// localhost:8069 / web / content / 8496-d085622 / web.assets_common.js:803 :56 fire @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:796:281 add @ http://localhost:8069/web/content/8496-d085622/web.assets_common.js:797:467 then / http:// localhost:8069 / web / content / 8496-d085622 / web.assets_common.js:802:772 fire @ 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 then / http:// localhost:8069 /web/content/8496-d085622/web.assets_common.js:802:874 fire @ 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 Deferred / 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 then / http:// localhost: 8069 / web / content / 8496-d085622 / web.assets_common.js:802:678 fire @ 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 Deferred / 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 fire @ 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 then / http:// localhost:8069 /web/content/8496-d085622/web.assets_common.js:802:874 fire @ 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 done @ 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的初学者
您的树视图必须包含一些内容才能呈现。在视图中添加至少一个字段,它应该正常加载。
<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>