js_class attribute in odoo how its work
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
1
Trả lời
9428
Lượt xem
js_class attribute in odoo how its work
Sometimes, we need to inform the web client that a specific ``ir.ui.view`` needs to use our new JS class. Note that this is a web client specific concern.
The proper way to do this is by using a special attribute ``js_class`` (which will be renamed someday into ``widget``, because this is really not a good name) on the root node of the arch:
.. code-block:: xml
<record id="helpdesk_team_view_kanban" model="ir.ui.view" >
...
<field name="arch" type="xml">
<kanban js_class="helpdesk_dashboard">
...
</kanban>
</field>
</record>
Note: You can change the way the view interprets the arch structure. However, from the server point of view, this is still a view of the same base type, subjected to the same rules. So, your views still need to have a valid arch field.
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký
The main use of js_class attribute is to call js functions by defining js_class=' ' code from <tree> or <form> or <kanban> view.
Keep best practise to use js_class because it'll not breaking odoo core flow sometimes you did the hard code for only one changes it'll affect somewhere.
If you see in odoo v12 CE > account > views > account_invoice_view.xml file you can search js_class="account_bills_tree"
<tree decoration-info="state == 'draft'" decoration-muted="state == 'cancel'" decoration-bf="not partner_id" string="Vendor Bill" js_class="account_bills_tree">
</tree>
The Upload button defining from js template <t t-name="BillsListView.upload_button">
and this Upload opened the Wizard which is calling from js code You can check BillsListController in bills_tree_upload.js