odoo10通过js获取到模型的json数据后,如果让数据在页面加载出来后以tree形式展示出来?
-
odoo10通过js获取到模型的json数据后,如果让数据在页面加载出来后以tree形式展示出来?
-
是要定义一个层级树吗?Odoo 10.0对有层级关系的数据结构是直接支持层级树的展示的。比如下面的HR的雇员层级列表视图:
<record id="view_partner_tree2" model="ir.ui.view"> <field name="name">hr.employee.tree</field> <field name="model">hr.employee</field> <field name="field_parent">child_ids</field> <field name="priority" eval="20"/> <field name="arch" type="xml"> <tree string="Employees"> <field name="name"/> <field name="work_phone"/> <field name="work_email"/> <field name="company_id" groups="base.group_multi_company"/> <field name="department_id"/> <field name="job_id"/> <field name="coach_id" invisible="1"/> <field name="parent_id" invisible="1"/> </tree> </field> </record>注意
field_parent的定义。V11.0以后,Odoo去除了对
field_parent的支持,不过社区中有位弟兄贡献了一个对tree view的扩展:https://github.com/openliu/odtree -
是要定义一个层级树吗?Odoo 10.0对有层级关系的数据结构是直接支持层级树的展示的。比如下面的HR的雇员层级列表视图:
<record id="view_partner_tree2" model="ir.ui.view"> <field name="name">hr.employee.tree</field> <field name="model">hr.employee</field> <field name="field_parent">child_ids</field> <field name="priority" eval="20"/> <field name="arch" type="xml"> <tree string="Employees"> <field name="name"/> <field name="work_phone"/> <field name="work_email"/> <field name="company_id" groups="base.group_multi_company"/> <field name="department_id"/> <field name="job_id"/> <field name="coach_id" invisible="1"/> <field name="parent_id" invisible="1"/> </tree> </field> </record>注意
field_parent的定义。V11.0以后,Odoo去除了对
field_parent的支持,不过社区中有位弟兄贡献了一个对tree view的扩展:https://github.com/openliu/odtree@digitalsatori 在 odoo10通过js获取到模型的json数据后,如果让数据在页面加载出来后以tree形式展示出来? 中说:
是要定义一个层级树吗?Odoo 10.0对有层级关系的数据结构是直接支持层级树的展示的。比如下面的HR的雇员层级列表视图:
不是层级树,我是 想用ajax请求,拿到 json数据(后台是 dict的 list,用sql 查询出来的,但是没有保存到数据库),然后怎么把这些数据渲染,展示成odoo的tree 形式 (类比easyui,bootstrap-table 的展示方式)。
另外,数据库的内容 ,odoo是通过什么方式,最终展示到前端的,中间的过程是什么? -
This post is deleted!
-
10没用过,12重写search_view
-
参考方案:
1)在views中定义一个client action:
Test
myproject.test
current
2)使用一个html a元素来触发这个action:
Test
3)编写一个js widget,具体写法参考文档:https://www.odoo.com/documentation/12.0/reference/javascript_reference.html#widgets;
主要做三件事:
a)设定模板template,根据要显示tree的需求去定制;
b)定义willStart函数,使用._rpc()函数与后端通讯获得模型数据;
c)定义start()函数,使用上一步获取的数据来render画面;
完成widget之后,调用core.action_registry.add()来注册这个widget,使得点击上文的html a元素,就会显示这个widget4)最后一步,在后端模型类添加方法,用于被js _rpc()函数调用来获取数据;
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login