Web Development | Ios and Android App Development Company in Charlotte Nc
+1 704 215 4622
[email protected]

Tag - odoo development

Tree View Button: Avoiding the Blank Space in the Tree Header for Corresponding Button in Odoo

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 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.

Getting started

STEP 1:  ADD  /static/src/xml/{FILENAME}.xml

odoo.define(ModuleName.EditableListRenderer', function (require) {
"use strict";

var ListRenderer = require('web.ListRenderer');

ListRenderer.include({
  _renderHeaderCell: function (node) {
        const $th = this._super.apply(this, arguments);
        if (node.attrs.class === 'custom_identifier'){
            $th.text(node.attrs.string);
        }
        return $th;
    },
});
});

STEP 2: Add custom class for identifying the button, the given string value is used to render the table header.

<button name="{{ ACTIONNAME }}"
type="{{ ACTIONTYPE }}" 
icon="fa-truck" 
string="Procurement"
        class="custom_identifier"/>

STEP 3: Add the JS files in Odoo assets.

<template id="assets_frontend" inherit_id="web.assets_backend" name="table style">
    <xpath expr="." position="inside">
         <script type="text/javascript"
src="/ModuleName/static/src/js/{{ FILENAME }}.js"></script>
     </xpath>
 </template>

STEP 4:  __manifest__.py

‘data: [
“views/assets.xml”,
]
STEP 5:  Server Restart

if you like us to help you with your next odoo implementation project please contact us

Auto Completion of Date Widget in Odoo

In Odoo, when we click on a date widget a calendar is rendered and along with that recently used dates are also rendered. Because of this, there will be difficulty in choosing a new date from the calendar that rendered.

We can fix this issue by using the below code.

Getting started

STEP 1:  /static/src/xml/{FILENAME}.xml
 At first, inherit the date widget template and then add autocompletion as an argument, then set it as off. This will turn off the autocompletion.

<?xml version="1.0" encoding="utf-8"?>
<templates id="template" xml:space="preserve">
    <t t-extend="web.datepicker">
        <t t-jquery="input.o_datepicker_input" t-operation="replace">
            <input type="text" class="o_datepicker_input o_input datetimepicker-input" 
                t-att-name="widget.name" 
                t-att-placeholder="placeholder" 
                t-attf-data-target="##{datepickerID}" 
                autocomplete="off" />
        </t>
    </t>
</templates>
STEP 2:  __manifest__.py
 Normally, all widgets are loaded by a JS file. Here we also need to load the widget. Add the file in qweb (in manifest file) then we can see the changes made.

‘qweb’ : [
“static/src/xml/{FILENAME}.xml”,
]
STEP 3:  Server Restart

if you like us to help you with your next odoo customisation project please contact us now