Tuesday 21 March 2017

Display field name when inspect element on many2one and char field in odoo

Display field name when inspect element on many2one and char field in odoo

Code Applay In Version - 10

Example is below:-
Example: <input id="oe-field-input-13" name="field_name" type="text">
---------------------------------------------------------------------------------------------
Inherit FieldChar template for add 't-att-name="widget.name"''

Inherit FieldMany2One template for add 't-att-name="widget.name"''

After Create below file register in __openerp__.py file

<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

    <t t-extend="FieldChar">
        <t t-jquery="input" t-operation="replace">
        <input t-if="!widget.get('effective_readonly')" class="o_form_input"
            t-att-barcode_events="widget.options.barcode_events"
            t-att-type="widget.password ? 'password' : 'text'"
            t-att-name="widget.name"
            t-att-id="widget.id_for_label"
            t-att-tabindex="widget.node.attrs.tabindex"
            t-att-autofocus="widget.node.attrs.autofocus"
            t-att-placeholder="widget.node.attrs.placeholder"
            t-att-autocomplete="widget.password ? 'new-password' : widget.node.attrs.autocomplete"
            t-att-maxlength="widget.field.size"/>
        </t>
    </t>

    <t t-extend="FieldMany2One">
        <t t-jquery="input" t-operation="replace">
       <input type="text" class="o_form_input"
            t-att-name="widget.name"
            t-att-barcode_events="widget.options.barcode_events"
            t-att-id="widget.id_for_label"
            t-att-tabindex="widget.node.attrs.tabindex"
            t-att-autofocus="widget.node.attrs.autofocus"
            t-att-placeholder="widget.node.attrs.placeholder"/>
        </t>
    </t>
</templates>

Code Applay In Version - 8

<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

    <t t-extend="FieldChar">
        <t t-jquery="input" t-operation="replace">
   <input t-att-type="widget.password ? 'password' : 'text'"
            t-att-name="widget.name"
                t-att-id="widget.id_for_label"
                t-att-tabindex="widget.node.attrs.tabindex"
                t-att-autofocus="widget.node.attrs.autofocus"
                t-att-placeholder="widget.node.attrs.placeholder"
                t-att-maxlength="widget.field.size"
            />
        </t>
    </t>

    <t t-extend="FieldMany2One">
        <t t-jquery="input" t-operation="replace">
  <input type="text"
t-att-name="widget.name"
t-att-id="widget.id_for_label"
t-att-tabindex="widget.node.attrs.tabindex"
t-att-autofocus="widget.node.attrs.autofocus"
t-att-placeholder="widget.node.attrs.placeholder"
  />
        </t>
    </t>
</templates>

No comments:

Post a Comment

Odoo 17 New Features

  Odoo 17 new Features 1) Duplicate  multiple records from List view. Please have look below screenshots first you need to select records th...