在odoo13中,我有一个如下所示的python函数
def get_data(self, params):
json_string = [{"SKU": "A4110","Unit": "PC"}]
return json_string和如下所示的文件xml视图
<record id="view_report_product_qweb" model="ir.ui.view">
<field name="name">report.view.qweb</field>
<field name="model">view.product</field>
<field name="mode">primary</field>
<field name="arch" type="xml">
<qweb>
<div id="pivot-container1"></div>
<script>
new WebDataRocks({
"container": "#pivot-container1",
"width": "100%",
"height": 430,
"toolbar": true,
"report": {
"dataSource": {
"type": "json", "data": json_string
},
"slice": {
"rows": [{"uniqueName": "Product"}],
"columns": [{"uniqueName": "[Measures]"}],
"measures": [{"uniqueName": "Quantity", "aggregation": "sum"}]
}
}
});
</script>
</qweb>
</field>
</record>如何将数据从函数推送到xml视图以呈现webdatarock excel
发布于 2020-09-25 15:17:59
感谢@Eric推荐,但这不是我需要从动作菜单按钮(如this )访问的xml视图,为了呈现webdatarock表,我需要在表单视图(如thís )中添加scrpit标记
<odoo>
<data>
<!-- Form View -->
<record id="view_report_product_form" model="ir.ui.view">
<field name="name">purchase.product.report.view.form</field>
<field name="model">dms.excel.view.product</field>
<field name="arch" type="xml">
<form string="Purchase Products Report">
<group>
<group>
<field name="from_date" required="1"/>
<field name="to_date" required="1"/>
</group>
<group>
<field name="product_ids" widget="many2many_tags" options="{'no_create': True}"/>
</group>
</group>
<footer>
<button id="submit_data" name="action_print" string="Print" class="oe_highlight" default_focus="1" type="object"/>
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
<div id="pivot-container1"></div>
<script>
new WebDataRocks({
"container": "#pivot-container1",
"width": "100%",
"height": 430,
"toolbar": true,
"report": {
"dataSource": {
"type": "json",
"data": json_string
},
"slice": {
"rows": [
{
"uniqueName": "sku"
},
{
"uniqueName": "product_name"
},
{
"uniqueName": "unit"
},
{
"uniqueName": "purchase_qty"
},
{
"uniqueName": "purchase_price_unit"
},
{
"uniqueName": "return_qty"
},
{
"uniqueName": "price_total"
}
],
"columns": [
{
"uniqueName": "Measures"
}
],
"measures": [
{
"uniqueName": "purchase_qty",
"aggregation": "sum"
}
],
"flatOrder": [
"sku",
"product_name",
"unit",
"purchase_qty",
"purchase_price_unit",
"return_qty",
"price_total"
]
},
"options": {
"grid": {
"type": "flat"
}
}
}
});
</script>
</form>
</field>
</record>
<!-- Action -->
<record id="action_dms_purchase_report_product" model="ir.actions.act_window">
<field name="name">Dashboard</field>
<field name="res_model">dms.excel.view.product</field>
<field name="type">ir.actions.act_window</field>
<field name="target">inline</field>
<field name="view_mode">form</field>
</record>
</data>
</odoo>我需要的是从python函数中获取数据,放入下面这行
"data": json_stringhttps://stackoverflow.com/questions/64042127
复制相似问题