Jelajahi Sumber

commit inicial

Rodney Elpidio Enciso Arias 6 tahun lalu
melakukan
9ecc2d3b55
9 mengubah file dengan 155 tambahan dan 0 penghapusan
  1. 2 0
      __init__.py
  2. TEMPAT SAMPAH
      __init__.pyc
  3. 18 0
      __openerp__.py
  4. TEMPAT SAMPAH
      static/description/banner.jpg
  5. TEMPAT SAMPAH
      static/description/config.png
  6. TEMPAT SAMPAH
      static/description/icon.png
  7. 63 0
      static/description/index.html
  8. 62 0
      static/src/js/number_widget.js
  9. 10 0
      views/header.xml

+ 2 - 0
__init__.py

@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+

TEMPAT SAMPAH
__init__.pyc


+ 18 - 0
__openerp__.py

@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+{
+    'name': 'Format Input Number',
+    'version': '1.0.0',
+    'category': '',
+    'author': 'D.Jane',
+    'sequence': 10,
+    'summary': 'Auto thousands separator while user typing. Dynamic with user-language.',
+    'description': "Thousands separator",
+    'depends': ['web'],
+    'data': [
+        'views/header.xml'
+    ],
+    'images': ['static/description/banner.jpg'],
+    'installable': True,
+    'application': True,
+    'license': 'Other proprietary',
+}

TEMPAT SAMPAH
static/description/banner.jpg


TEMPAT SAMPAH
static/description/config.png


TEMPAT SAMPAH
static/description/icon.png


+ 63 - 0
static/description/index.html

@@ -0,0 +1,63 @@
+<section class="oe_container oe_spaced">
+    <h2 class="oe_slogan" style="color:#875A7B;">Format Input Number</h2>
+</section>
+
+<section class="oe_container oe_spaced" >
+    <div class="oe_slogan">
+        <a style="background: #c53c2c;" href="https://youtu.be/Cg3oNFXv_a0" class="oe_button oe_big oe_tacky">Watch the video</a>
+    </div>
+</section>
+
+
+<section class="oe_container oe_dark">
+    <div>
+        <h2 class="oe_slogan" style="color:#875A7B;">Happy</h2>
+        <h3 class="oe_slogan">Automatic, Dynamic, Only digit characters</h3>
+    </div>
+
+    <div class="oe_spaced" style="padding-left: 64px; padding-right: 64px; text-align: center; font-size: 18px;">
+        <p class="oe_mt32">
+            This module auto thousands separator while user typing.
+            Dynamic with user-language.
+        </p>
+        <p class="oe_mt16">
+            1000.01 => 1,000.01 - just for fun !
+        </p>
+        <p class="oe_mt16">
+            1000000000000.01 => 1,000,000,000,000.01 :-))
+        </p>
+    </div>
+    <h3 class="oe_mt16" style="text-align: center;">
+        <a href="https://apps.odoo.com/apps/browse?repo_maintainer_id=205021"
+           style="color: #875A7B; font-weight: bold; margin-top: 16px;">
+            <i class="fa fa-star fa-spin"></i> My Apps Published <i class="fa fa-star fa-spin"></i></a>
+    </h3>
+</section>
+
+<section class="oe_container oe_spaced"></section>
+
+<section class='oe_container oe_dark'>
+    <h2 class='oe_slogan' style="color:#875A7B;">Supports</h2>
+    <h3 class="oe_slogan">Free 24/7</h3>
+    <div class='oe_spaced' style="padding-left: 64px; padding-right: 64px; font-size: 18px; text-align: center;">
+        <p class="oe_mt16">
+            For any supports or questions, please contact me via:
+        </p>
+        <div class="oe_mt16" style="display: flex; flex-flow: row; justify-content: center">
+            <div>
+                <i class="fa fa-2x fa fa-envelope" style="color:white;background: #c53c2c;width: 60px; padding: 4px;"></i>
+                <a href="https://mail.google.com/mail/?view=cm&amp;fs=1&amp;tf=1&amp;to=jane.odoo.sp@gmail.com" target="_blank">
+                    <b style="color: #875A7B">jane.odoo.sp@gmail.com</b></a>
+            </div>
+            <div style="margin-left: 16px;">
+                <a href="https://www.linkedin.com/in/unicode2utf8/" target="_blank">
+                    <i class="fa fa-2x fa-linkedin" style="background: #0077B5; color: white; width: 60px; padding: 4px;"></i>
+                </a>
+            </div>
+        </div>
+    </div>
+</section>
+
+<section class="oe_container oe_spaced">
+    <h3 class="oe_slogan">Thank you!</h3>
+</section>

+ 62 - 0
static/src/js/number_widget.js

@@ -0,0 +1,62 @@
+/*
+* @Author: D.Jane
+* @Email: jane.odoo.sp@gmail.com
+*/
+(function(){
+    var instance = openerp;
+    var core = instance.web;
+    var form_widgets = instance.web.form;
+
+
+    form_widgets.FieldFloat.include({
+        init: function (field_manager, node) {
+            this._super(field_manager, node);
+            this.thousands_sep = core._t.database.parameters.thousands_sep || ',';
+            this.decimal_point = core._t.database.parameters.decimal_point || '.';
+            this.rep = "[^" + this.decimal_point + "-\\d]";
+            this.re = new RegExp(this.rep,"g");
+        },
+        initialize_content: function () {
+            this._super();
+            var self = this;
+            if (this.widget === "float_time"){
+                return;
+            }
+            var input = this.$el.children('input');
+            if (input) {
+                input.on('keyup', function (event) {
+                    // skip arrow keys
+                    if (event.which >= 37 && event.which <= 40) return;
+                    // format number
+                    $(this).val(function (index, value) {
+                        return self.thousands_separate(value);
+                    });
+                });
+            }
+        },
+        format_value: function (val, def){
+            var value = this._super(val, def);
+            return this.thousands_separate(value);
+        },
+        thousands_separate: function (value) {
+            if (!value) {
+                return value;
+            }
+            value = value.toString();
+            var v1 = value.replace(this.re, "").replace(/\B(?=((\d{3})+(?!\d)))/g, this.thousands_sep);
+            var v = v1.split(this.decimal_point);
+            var re = new RegExp("\\" + this.thousands_sep, "g");
+            if (v.length > 1) {
+                v = v[0] + this.decimal_point + v[1].replace(re, '');
+            }
+            return v;
+        }
+    });
+
+    form_widgets.FieldMonetary.include({
+        format_value: function (val, def) {
+            var value = this._super(val, def);
+            return this.thousands_separate(value);
+        }
+    });
+})();

+ 10 - 0
views/header.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <template id="format_number.assets_backend" inherit_id="web.assets_backend">
+            <xpath expr="." position="inside">
+                <script type="text/javascript" src="/format_number/static/src/js/number_widget.js"/>
+            </xpath>
+        </template>
+    </data>
+</openerp>