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
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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.
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