{"id":1026,"date":"2020-07-18T06:13:20","date_gmt":"2020-07-18T06:13:20","guid":{"rendered":"https:\/\/www.confianzit.com\/cit-blog\/?p=1026"},"modified":"2022-10-31T17:53:28","modified_gmt":"2022-10-31T17:53:28","slug":"tree-view-button-avoiding-the-blank-space-in-the-tree-header-for-corresponding-button","status":"publish","type":"post","link":"https:\/\/www.confianzit.com\/cit-blog\/tree-view-button-avoiding-the-blank-space-in-the-tree-header-for-corresponding-button\/","title":{"rendered":"Tree View Button: Avoiding the Blank Space in the Tree Header for Corresponding Button in Odoo"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;3.22&#8243;][et_pb_row _builder_version=&#8221;4.9.4&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; hover_enabled=&#8221;0&#8243; column_structure=&#8221;3_5,2_5&#8243; sticky_enabled=&#8221;0&#8243;][et_pb_column type=&#8221;3_5&#8243; _builder_version=&#8221;3.25&#8243; custom_padding=&#8221;|||&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_text _builder_version=&#8221;4.9.4&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; hover_enabled=&#8221;0&#8243; module_class=&#8221;blog-left-content&#8221; sticky_enabled=&#8221;0&#8243;]<\/p>\n<p><!-- divi:paragraph -->In a normal case, we can create a view by using the corresponding fields in the database table (Odoo model) i.e., the header value of the tree view will be the string value of these fields. But it will be entirely different in case of a button.<\/p>\n<p><!-- \/divi:paragraph --><\/p>\n<p><!-- divi:paragraph -->In model view, the button will be an instance but not a field (not a column) in the database table. Because of this, in the tree header there will be a blank space for the corresponding button.<\/p>\n<p><!-- \/divi:paragraph --><\/p>\n<p><!-- divi:paragraph --><strong>Getting started<\/strong><\/p>\n<p><!-- \/divi:paragraph --><\/p>\n<p><!-- divi:paragraph {\"align\":\"center\"} --><\/p>\n<p class=\"has-text-align-center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/OgxoDXmevD4eYzOVmWDiNn8q30_wX31D1U3jb1kLJLu4KHGkkLy7QwsivxhXrTfnXG-dTcXePwQAGQfNt_ZjTsgBtZMTU3o-JXF772b7WyGu314fYBOnKR8tU5NaoWMyHRlQplqA\" width=\"542\" height=\"441\" \/><\/p>\n<p><!-- \/divi:paragraph --><\/p>\n<p><!-- divi:code --><\/p>\n<pre class=\"wp-block-code\"><code>STEP 1:  ADD  \/static\/src\/xml\/{FILENAME}.xml\n\nodoo.define(ModuleName.EditableListRenderer', function (require) {\n\"use strict\";\n\nvar ListRenderer = require('web.ListRenderer');\n\nListRenderer.include({\n  _renderHeaderCell: function (node) {\n        const $th = this._super.apply(this, arguments);\n        if (node.attrs.class === 'custom_identifier'){\n            $th.text(node.attrs.string);\n        }\n        return $th;\n    },\n});\n});\n\n<\/code><\/pre>\n<p><!-- \/divi:code --><\/p>\n<p><!-- divi:code --><\/p>\n<pre class=\"wp-block-code\"><code>STEP 2: Add custom class for identifying the button, the given string value is used to render the table header.\n\n&lt;button name=\"{{ ACTIONNAME }}\"\ntype=\"{{ ACTIONTYPE }}\" \nicon=\"fa-truck\" \nstring=\"Procurement\"\n        class=\"custom_identifier\"\/&gt;\n\n<\/code><\/pre>\n<p><!-- \/divi:code --><\/p>\n<p><!-- divi:code --><\/p>\n<pre class=\"wp-block-code\"><code>STEP 3: Add the JS files in Odoo assets.\n\n&lt;template id=\"assets_frontend\" inherit_id=\"web.assets_backend\" name=\"table style\"&gt;\n    &lt;xpath expr=\".\" position=\"inside\"&gt;\n         &lt;script type=\"text\/javascript\"\nsrc=\"\/ModuleName\/static\/src\/js\/{{ FILENAME }}.js\"&gt;&lt;\/script&gt;\n     &lt;\/xpath&gt;\n &lt;\/template&gt;\n\n<\/code><\/pre>\n<p><!-- \/divi:code --><\/p>\n<p><!-- divi:code --><\/p>\n<pre class=\"wp-block-code\"><code>STEP 4:  __manifest__.py\n\n\u2018data: [\n\u201cviews\/assets.xml\u201d,\n]\n<\/code><\/pre>\n<p><!-- \/divi:code --><\/p>\n<p><!-- divi:code --><\/p>\n<pre class=\"wp-block-code\"><code>STEP 5:  Server Restart\n<\/code><\/pre>\n<p><!-- \/divi:code --><\/p>\n<p><!-- divi:paragraph --><a href=\"https:\/\/www.confianzit.com\/hire-odoo-developer\" class=\"rank-math-link\"><strong>HIRE AN ODOO DEVELOPER <\/strong><\/a><\/p>\n<p><!-- \/divi:paragraph --><\/p>\n<p><!-- divi:paragraph -->If you like us to help you with your next <a href=\"https:\/\/www.confianzit.com\/odoo-implementation\" class=\"rank-math-link\">Odoo implementation<\/a> project please contact us! Also check out our\u00a0<a href=\"https:\/\/www.confianzit.com\/odoo\/pricing\">Odoo pricing<\/a>\u00a0page to know how much will it cost for a successful Odoo Implementation for your business.\u00a0<\/p>\n<p><!-- \/divi:paragraph --><\/p>\n<p>[\/et_pb_text][\/et_pb_column][et_pb_column type=&#8221;2_5&#8243; _builder_version=&#8221;3.25&#8243; custom_padding=&#8221;|||&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_code _builder_version=&#8221;4.9.4&#8243; _module_preset=&#8221;default&#8221; locked=&#8221;off&#8221; global_module=&#8221;2151&#8243;]<\/p>\n<div class=\"blog-floating-form\"><!-- [et_pb_line_break_holder] -->  <\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_62 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.confianzit.com\/cit-blog\/tree-view-button-avoiding-the-blank-space-in-the-tree-header-for-corresponding-button\/#Talk_to_our_experts_now\" title=\"    Talk to our experts now  \">    Talk to our experts now  <\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.confianzit.com\/cit-blog\/tree-view-button-avoiding-the-blank-space-in-the-tree-header-for-corresponding-button\/#Talk_To_Our_Experts_Now\" title=\"Talk To Our Experts Now\n\t\">Talk To Our Experts Now\n\t<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"Talk_to_our_experts_now\"><\/span><!-- [et_pb_line_break_holder] -->    Talk to our experts now<!-- [et_pb_line_break_holder] -->  <span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p><!-- [et_pb_line_break_holder] -->  \n<div class=\"wpcf7 no-js\" id=\"wpcf7-f1888-o1\" lang=\"en-US\" dir=\"ltr\">\n<div class=\"screen-reader-response\"><p role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"><\/p> <ul><\/ul><\/div>\n<form action=\"\/cit-blog\/wp-json\/wp\/v2\/posts\/1026#wpcf7-f1888-o1\" method=\"post\" class=\"wpcf7-form init\" aria-label=\"Contact form\" novalidate=\"novalidate\" data-status=\"init\">\n<div style=\"display: none;\">\n<input type=\"hidden\" name=\"_wpcf7\" value=\"1888\" \/>\n<input type=\"hidden\" name=\"_wpcf7_version\" value=\"5.8.6\" \/>\n<input type=\"hidden\" name=\"_wpcf7_locale\" value=\"en_US\" \/>\n<input type=\"hidden\" name=\"_wpcf7_unit_tag\" value=\"wpcf7-f1888-o1\" \/>\n<input type=\"hidden\" name=\"_wpcf7_container_post\" value=\"0\" \/>\n<input type=\"hidden\" name=\"_wpcf7_posted_data_hash\" value=\"\" \/>\n<input type=\"hidden\" name=\"_wpcf7_recaptcha_response\" value=\"\" \/>\n<\/div>\n<div class=\"form-block\" style=\"    background: #fff;\">\n\t<h3 style=\"    background: #0C2464;\n    border-bottom: 5px solid #cecece;\n    border-radius: 5px 5px 90px 90px;\n    margin: 0 auto;\n    text-align: center;\n    padding: 20px;\n    color: #fff;    margin-bottom: 15px;\"><span class=\"ez-toc-section\" id=\"Talk_To_Our_Experts_Now\"><\/span><b>Talk To Our Experts Now<\/b>\n\t<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\t<div style=\"padding:20px;\">\n\t\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"your-name\"><input size=\"40\" class=\"wpcf7-form-control wpcf7-text wpcf7-validates-as-required your-name\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Name\" value=\"\" type=\"text\" name=\"your-name\" \/><\/span>\n\t\t<\/p>\n\t\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"your-email\"><input size=\"40\" class=\"wpcf7-form-control wpcf7-email wpcf7-validates-as-required wpcf7-text wpcf7-validates-as-email your-email\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Email\" value=\"\" type=\"email\" name=\"your-email\" \/><\/span>\n\t\t<\/p>\n\t\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"your-number\"><input size=\"40\" class=\"wpcf7-form-control wpcf7-tel wpcf7-validates-as-required wpcf7-text wpcf7-validates-as-tel your-number\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Phone Number\" value=\"\" type=\"tel\" name=\"your-number\" \/><\/span>\n\t\t<\/p>\n\t\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"message\"><textarea cols=\"40\" rows=\"10\" class=\"wpcf7-form-control wpcf7-textarea wpcf7-validates-as-required form-message\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Message\" name=\"message\"><\/textarea><\/span>\n\t\t<\/p>\n\t<span class=\"wpcf7-form-control-wrap recaptcha\" data-name=\"recaptcha\"><span data-sitekey=\"6LfFkQATAAAAAIYlZ_UH9UozO-OLkpAaWPWx6QtM\" class=\"wpcf7-form-control wpcf7-recaptcha g-recaptcha\"><\/span>\r\n<noscript>\r\n\t<div class=\"grecaptcha-noscript\">\r\n\t\t<iframe loading=\"lazy\" src=\"https:\/\/www.google.com\/recaptcha\/api\/fallback?k=6LfFkQATAAAAAIYlZ_UH9UozO-OLkpAaWPWx6QtM\" frameborder=\"0\" scrolling=\"no\" width=\"310\" height=\"430\">\r\n\t\t<\/iframe>\r\n\t\t<textarea name=\"g-recaptcha-response\" rows=\"3\" cols=\"40\" placeholder=\"reCaptcha Response Here\">\r\n\t\t<\/textarea>\r\n\t<\/div>\r\n<\/noscript>\r\n<\/span>\n\t\t<div class=\"form-buttons\">\n\t\t\t<p><input class=\"wpcf7-form-control wpcf7-submit has-spinner\" type=\"submit\" value=\"Get a free quote\" \/>\n\t\t\t<\/p>\n\t\t<\/div>\n\t<\/div>\n<\/div><div class=\"wpcf7-response-output\" aria-hidden=\"true\"><\/div>\n<\/form>\n<\/div>\n<!-- [et_pb_line_break_holder] --><\/div>\n<p>[\/et_pb_code][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a normal case, we can create a view by using the corresponding fields in the database table (Odoo model) i.e., the header value of the tree view will be the string value of these fields. But it will be entirely different in case of a button. In model view, the button will be an [&hellip;]<\/p>\n","protected":false},"author":17,"featured_media":1181,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"<!-- wp:paragraph -->\n<p>In a normal case, we can create a view by using the corresponding fields in the database table (Odoo model) i.e., the header value of the tree view will be the string value of these fields. But it will be entirely different in case of a button.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>In model view, the button will be an instance but not a field (not a column) in the database table. Because of this, in the tree header there will be a blank space for the corresponding button.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><strong>Getting started<\/strong><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph {\"align\":\"center\"} -->\n<p class=\"has-text-align-center\"><img src=\"https:\/\/lh3.googleusercontent.com\/OgxoDXmevD4eYzOVmWDiNn8q30_wX31D1U3jb1kLJLu4KHGkkLy7QwsivxhXrTfnXG-dTcXePwQAGQfNt_ZjTsgBtZMTU3o-JXF772b7WyGu314fYBOnKR8tU5NaoWMyHRlQplqA\" width=\"542\" height=\"441\"><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:code -->\n<pre class=\"wp-block-code\"><code>STEP 1:  ADD  \/static\/src\/xml\/{FILENAME}.xml\n\nodoo.define(ModuleName.EditableListRenderer', function (require) {\n\"use strict\";\n\nvar ListRenderer = require('web.ListRenderer');\n\nListRenderer.include({\n  _renderHeaderCell: function (node) {\n        const $th = this._super.apply(this, arguments);\n        if (node.attrs.class === 'custom_identifier'){\n            $th.text(node.attrs.string);\n        }\n        return $th;\n    },\n});\n});\n\n<\/code><\/pre>\n<!-- \/wp:code -->\n\n<!-- wp:code -->\n<pre class=\"wp-block-code\"><code>STEP 2: Add custom class for identifying the button, the given string value is used to render the table header.\n\n&lt;button name=\"{{ ACTIONNAME }}\"\ntype=\"{{ ACTIONTYPE }}\" \nicon=\"fa-truck\" \nstring=\"Procurement\"\n        class=\"custom_identifier\"\/&gt;\n\n<\/code><\/pre>\n<!-- \/wp:code -->\n\n<!-- wp:code -->\n<pre class=\"wp-block-code\"><code>STEP 3: Add the JS files in Odoo assets.\n\n&lt;template id=\"assets_frontend\" inherit_id=\"web.assets_backend\" name=\"table style\"&gt;\n    &lt;xpath expr=\".\" position=\"inside\"&gt;\n         &lt;script type=\"text\/javascript\"\nsrc=\"\/ModuleName\/static\/src\/js\/{{ FILENAME }}.js\"&gt;&lt;\/script&gt;\n     &lt;\/xpath&gt;\n &lt;\/template&gt;\n\n<\/code><\/pre>\n<!-- \/wp:code -->\n\n<!-- wp:code -->\n<pre class=\"wp-block-code\"><code>STEP 4:  __manifest__.py\n\n\u2018data: &#91;\n\u201cviews\/assets.xml\u201d,\n]\n<\/code><\/pre>\n<!-- \/wp:code -->\n\n<!-- wp:code -->\n<pre class=\"wp-block-code\"><code>STEP 5:  Server Restart\n<\/code><\/pre>\n<!-- \/wp:code -->\n\n<!-- wp:paragraph -->\n<p><a href=\"https:\/\/www.confianzit.com\/hire-odoo-developer\" class=\"rank-math-link\"><strong>HIRE AN ODOO DEVELOPER <\/strong><\/a><\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>If you like us to help you with your next  <a href=\"https:\/\/www.confianzit.com\/odoo-implementation\" class=\"rank-math-link\">Odoo implementation<\/a> project please contact us! Also check out our&nbsp;<a href=\"https:\/\/www.confianzit.com\/odoo\/pricing\">Odoo pricing<\/a>&nbsp;page to know how much will it cost for a successful Odoo Implementation for your business.&nbsp;<\/p>\n<!-- \/wp:paragraph -->","_et_gb_content_width":"","footnotes":""},"categories":[143],"tags":[61,172,173,174],"_links":{"self":[{"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/posts\/1026"}],"collection":[{"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/comments?post=1026"}],"version-history":[{"count":9,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/posts\/1026\/revisions"}],"predecessor-version":[{"id":27260,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/posts\/1026\/revisions\/27260"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/media\/1181"}],"wp:attachment":[{"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/media?parent=1026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/categories?post=1026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/tags?post=1026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}