forked from Techsystech/web
[ADD] web_widget_char_size
parent
271ad52cd4
commit
a780612baa
|
@ -0,0 +1 @@
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Copyright 2021 Simone Rubino - Agile Business Group
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
{
|
||||||
|
"name": "Widget Char size",
|
||||||
|
"summary": "Add size option to Char widget",
|
||||||
|
"version": "14.0.1.0.0",
|
||||||
|
"category": "Hidden",
|
||||||
|
"website": "https://github.com/OCA/web",
|
||||||
|
"author": "Agile Business Group, Odoo Community Association (OCA)",
|
||||||
|
"license": "AGPL-3",
|
||||||
|
"depends": [
|
||||||
|
"web",
|
||||||
|
],
|
||||||
|
"data": [
|
||||||
|
"views/assets.xml",
|
||||||
|
],
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
This module allows to add an option `size` to Char fields in web client:
|
||||||
|
|
||||||
|
.. code-block:: XML
|
||||||
|
|
||||||
|
<field name="sized_5_field" options="{'size': 5}"/>
|
||||||
|
|
||||||
|
that allows to enter only the specified number of characters in the field.
|
||||||
|
|
||||||
|
Note that adding the `size=` attribute in Char field definition raises the following warning:
|
||||||
|
|
||||||
|
unknown parameter 'size', if this is an actual parameter you may want to override the method _valid_field_parameter on the relevant model in order to allow it
|
|
@ -0,0 +1,16 @@
|
||||||
|
odoo.define("web_widget_char_size.char_widget", function (require) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var BasicFields = require("web.basic_fields");
|
||||||
|
|
||||||
|
BasicFields.FieldChar.include({
|
||||||
|
_renderEdit: function () {
|
||||||
|
var def = this._super.apply(this, arguments);
|
||||||
|
var option_size = this.nodeOptions.size;
|
||||||
|
if (option_size && option_size > 0) {
|
||||||
|
this.$el.attr("maxlength", option_size);
|
||||||
|
}
|
||||||
|
return def;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!--
|
||||||
|
~ Copyright 2021 Simone Rubino - Agile Business Group
|
||||||
|
~ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
-->
|
||||||
|
<odoo>
|
||||||
|
<template
|
||||||
|
id="assets_backend"
|
||||||
|
name="web_widget_char_size assets"
|
||||||
|
inherit_id="web.assets_backend"
|
||||||
|
>
|
||||||
|
<xpath expr="." position="inside">
|
||||||
|
<script
|
||||||
|
type="text/javascript"
|
||||||
|
src="/web_widget_char_size/static/src/js/char_widget.js"
|
||||||
|
/>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue