javascript - Odoo 11.0 尝试替换预测按钮的视图,javascrip 错误
问题描述
我用 xpath 替换了预测按钮的操作,我将新操作action_stock_level_forecast_report_product_tree设置为按钮的名称
在我的行动中,我设置了我的新视图product_product_forecast_tree_view的 ref
<!--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 错误:
错误: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 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 延迟/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 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 然后/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 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 然后/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 延迟/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 然后/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 延迟/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 延迟/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 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 回调@ 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>
推荐阅读
- javascript - 使用 Discord JS 制作频道
- svelte - 为什么 svelte 将花括号放在标量上?
- javascript - Webpack 构建在 react.js 项目中构建 CSS 失败
- jquery - 在dataTables Jquery中使用2个fixed_columns时如何修复2个scollbars?
- python - 无法在 example_kubernetes_executor_config.py 中导入 DAG:MAC OS 上没有名为“kubernetes”的模块
- mysql - “mysql -uroot”是什么意思?
- xcode - react-native run-ios 构建失败,出现很多错误
- javascript - 组件卸载时停止 setInterval()?(反应)
- python - 删除两个数据集熊猫之间不匹配的行
- github - github个人访问令牌问题