在自定义模块中,我们有不同的detail-View-definitions和2种不同的树形视图
如果我使用第二个树形视图,如何实现,在该树形视图中选择一个项应该以第二个详细视图为目标。
示例代码:
<record model="ir.ui.view" id="dummy_form_view">
<field name="name">dummy.form</field>
<field name="model">x_dummy.dummy</field>
<field name="type">form</field>
<field name="priority" eval="13"/>
<field name="arch" type="xml">
<form string="dummy" create="false" edit="false" delete="false">
<sheet>
<group>
<field name="name" nolabel="1"/>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="dummy_form_view2">
<field name="name">dummy.form</field>
<field name="model">x_dummy.dummy</field>
<field name="type">form</field>
<field name="priority" eval="15"/>
<field name="arch" type="xml">
<form string="dummy" delete="false" duplicate="false">
<group>
<field name="name2" />
</group>
</form>
</field>
</record>
<record model="ir.ui.view" id="dummy_tree_view">
<field name="name">dummy.tree</field>
<field name="model">x_dummy.dummy</field>
<field name="arch" type="xml">
<tree>
<field name="name" context="{'form_view_ref': 'x_dummy.dummy_form_view2'}"/>
</tree>
</field>
</record>
答案 0 :(得分:0)
所以下面的代码不起作用。
'use strict';
const {promisify} = require('util');
const fs = require('fs');
const readFileAsync = promisify(fs.readFile);
const readDirAsync = promisify(fs.readdir);
const writeFileAsync = promisify(fs.writeFile);
function writeImportStatement(filepath) {
return new Promise(async (resolve, reject) => {
let content = '';
const files = await readDirAsync(`${filepath}/scss`)
const done = await Promise.all(files.forEach(async (file) => {
return new Promise((resolve, reject) => {
fs.stat(`${filepath}/scss/${file}`, async (err, stats) => {
if(err) reject(err)
if (stats.isDirectory()) {
const scssfiles = await readDirAsync(`${filepath}/scss/${file}`)
scssfiles.forEach((scssfile) => {
content += `@import "${filepath}/scss/${file}/${scssfile}"; \n`;
})
}
resolve()
});
});
});
console.log("loging import statement content: " + content);
resolve(content);
})
}
然后,您可以通过将操作与特定的表单视图相关联来完成此操作。
动作示例
<field name="name" context="{'form_view_ref': 'your_module.your_view_id'}"/>
默认情况下,此操作将链接到 dummy_form_view 和 dummy_tree_view
以下是将 dummy_form_view2 链接到 dummy_action
的示例<record id="dummy_action" model="ir.actions.act_window">
<field name="name">Dummy</field>
<field name="res_model">x_dummy.dummy</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
<field name="context">{}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create"></p>
</field>
</record>
请记住,顺序很重要。