diff --git a/odoo_calculator_tool/README.rst b/odoo_calculator_tool/README.rst new file mode 100755 index 000000000..35ba996c2 --- /dev/null +++ b/odoo_calculator_tool/README.rst @@ -0,0 +1,49 @@ +.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg + :target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +Odoo Calculator +=============== +This module helps you to perform basic arithmetic calculations seamlessly within the Odoo interface. + +Configuration +============= +* No Additional configuration is needed. + +License +------- +Lesser General Public License, Version 3 (LGPL v3). +(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developer: (V16) Gion Dany, + (V15) Aysha Shalin, + (V17) Aysha Shalin, + Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/odoo_calculator_tool/__init__.py b/odoo_calculator_tool/__init__.py new file mode 100644 index 000000000..626d140e7 --- /dev/null +++ b/odoo_calculator_tool/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################## diff --git a/odoo_calculator_tool/__manifest__.py b/odoo_calculator_tool/__manifest__.py new file mode 100644 index 000000000..edb353789 --- /dev/null +++ b/odoo_calculator_tool/__manifest__.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': "Odoo Calculator", + 'version': '17.0.1.0.0', + 'category': 'Extra Tools', + 'summary': """Perform basic math calculations effortlessly within Odoo.""", + 'description': """This module makes it easy for you to carry out simple + mathematical operations via the Odoo user interface.""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['base'], + 'assets': { + 'web.assets_backend': { + 'odoo_calculator_tool/static/src/css/calculator.css', + 'odoo_calculator_tool/static/src/xml/calculator.xml', + 'odoo_calculator_tool/static/src/js/calculator.js', + }, + }, + 'images': ['static/description/banner.png'], + 'license': "LGPL-3", + 'installable': True, + 'auto_install': False, + 'application': False +} diff --git a/odoo_calculator_tool/doc/RELEASE_NOTES.md b/odoo_calculator_tool/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..3058e501b --- /dev/null +++ b/odoo_calculator_tool/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 18.07.2024 +#### Version 17.0.1.0.0 +##### ADD +- Initial commit for Odoo Calculator diff --git a/odoo_calculator_tool/static/description/assets/icons/capture (1).png b/odoo_calculator_tool/static/description/assets/icons/capture (1).png new file mode 100644 index 000000000..8824deafc Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/capture (1).png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/check.png b/odoo_calculator_tool/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/check.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/chevron.png b/odoo_calculator_tool/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/chevron.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/cogs.png b/odoo_calculator_tool/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/cogs.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/consultation.png b/odoo_calculator_tool/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/consultation.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/ecom-black.png b/odoo_calculator_tool/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/ecom-black.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/education-black.png b/odoo_calculator_tool/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/education-black.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/hotel-black.png b/odoo_calculator_tool/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/hotel-black.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/img.png b/odoo_calculator_tool/static/description/assets/icons/img.png new file mode 100644 index 000000000..70197f477 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/img.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/license.png b/odoo_calculator_tool/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/license.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/lifebuoy.png b/odoo_calculator_tool/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/lifebuoy.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/manufacturing-black.png b/odoo_calculator_tool/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/manufacturing-black.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/photo-capture.png b/odoo_calculator_tool/static/description/assets/icons/photo-capture.png new file mode 100644 index 000000000..06c111758 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/photo-capture.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/pos-black.png b/odoo_calculator_tool/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/pos-black.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/puzzle.png b/odoo_calculator_tool/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/puzzle.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/restaurant-black.png b/odoo_calculator_tool/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/restaurant-black.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/service-black.png b/odoo_calculator_tool/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/service-black.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/trading-black.png b/odoo_calculator_tool/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/trading-black.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/training.png b/odoo_calculator_tool/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/training.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/update.png b/odoo_calculator_tool/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/update.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/user.png b/odoo_calculator_tool/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/user.png differ diff --git a/odoo_calculator_tool/static/description/assets/icons/wrench.png b/odoo_calculator_tool/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/icons/wrench.png differ diff --git a/odoo_calculator_tool/static/description/assets/misc/Cybrosys R.png b/odoo_calculator_tool/static/description/assets/misc/Cybrosys R.png new file mode 100644 index 000000000..da4058087 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/misc/Cybrosys R.png differ diff --git a/odoo_calculator_tool/static/description/assets/misc/email.svg b/odoo_calculator_tool/static/description/assets/misc/email.svg new file mode 100644 index 000000000..15291cdc3 --- /dev/null +++ b/odoo_calculator_tool/static/description/assets/misc/email.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/odoo_calculator_tool/static/description/assets/misc/phone.svg b/odoo_calculator_tool/static/description/assets/misc/phone.svg new file mode 100644 index 000000000..b7bd7f251 --- /dev/null +++ b/odoo_calculator_tool/static/description/assets/misc/phone.svg @@ -0,0 +1,3 @@ + + + diff --git a/odoo_calculator_tool/static/description/assets/misc/star (1) 2.svg b/odoo_calculator_tool/static/description/assets/misc/star (1) 2.svg new file mode 100644 index 000000000..5ae9f507a --- /dev/null +++ b/odoo_calculator_tool/static/description/assets/misc/star (1) 2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/odoo_calculator_tool/static/description/assets/misc/support (1) 1.svg b/odoo_calculator_tool/static/description/assets/misc/support (1) 1.svg new file mode 100644 index 000000000..7d37a8f30 --- /dev/null +++ b/odoo_calculator_tool/static/description/assets/misc/support (1) 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/odoo_calculator_tool/static/description/assets/misc/support-email.svg b/odoo_calculator_tool/static/description/assets/misc/support-email.svg new file mode 100644 index 000000000..eb70370d6 --- /dev/null +++ b/odoo_calculator_tool/static/description/assets/misc/support-email.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/odoo_calculator_tool/static/description/assets/misc/tick-mark.svg b/odoo_calculator_tool/static/description/assets/misc/tick-mark.svg new file mode 100644 index 000000000..2dbb40187 --- /dev/null +++ b/odoo_calculator_tool/static/description/assets/misc/tick-mark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/odoo_calculator_tool/static/description/assets/misc/whatsapp 1.svg b/odoo_calculator_tool/static/description/assets/misc/whatsapp 1.svg new file mode 100644 index 000000000..0bfaf8fc6 --- /dev/null +++ b/odoo_calculator_tool/static/description/assets/misc/whatsapp 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/odoo_calculator_tool/static/description/assets/misc/whatsapp.svg b/odoo_calculator_tool/static/description/assets/misc/whatsapp.svg new file mode 100644 index 000000000..b618aea1d --- /dev/null +++ b/odoo_calculator_tool/static/description/assets/misc/whatsapp.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/odoo_calculator_tool/static/description/assets/modules/access_restriction_by_ip.png b/odoo_calculator_tool/static/description/assets/modules/access_restriction_by_ip.png new file mode 100644 index 000000000..dc8d15471 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/modules/access_restriction_by_ip.png differ diff --git a/odoo_calculator_tool/static/description/assets/modules/custom_gantt_view.png b/odoo_calculator_tool/static/description/assets/modules/custom_gantt_view.png new file mode 100644 index 000000000..ec1472e4a Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/modules/custom_gantt_view.png differ diff --git a/odoo_calculator_tool/static/description/assets/modules/login_user_detail.png b/odoo_calculator_tool/static/description/assets/modules/login_user_detail.png new file mode 100644 index 000000000..27a628b12 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/modules/login_user_detail.png differ diff --git a/odoo_calculator_tool/static/description/assets/modules/project_dashboard_odoo.png b/odoo_calculator_tool/static/description/assets/modules/project_dashboard_odoo.png new file mode 100644 index 000000000..62135f2a4 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/modules/project_dashboard_odoo.png differ diff --git a/odoo_calculator_tool/static/description/assets/modules/web_login_styles.png b/odoo_calculator_tool/static/description/assets/modules/web_login_styles.png new file mode 100644 index 000000000..252f25c4c Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/modules/web_login_styles.png differ diff --git a/odoo_calculator_tool/static/description/assets/modules/whatsapp_redirect.png b/odoo_calculator_tool/static/description/assets/modules/whatsapp_redirect.png new file mode 100644 index 000000000..c4420d292 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/modules/whatsapp_redirect.png differ diff --git a/odoo_calculator_tool/static/description/assets/screenshots/1.png b/odoo_calculator_tool/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..54a37958d Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/screenshots/1.png differ diff --git a/odoo_calculator_tool/static/description/assets/screenshots/2.png b/odoo_calculator_tool/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..8c45f4ce6 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/screenshots/2.png differ diff --git a/odoo_calculator_tool/static/description/assets/screenshots/3.png b/odoo_calculator_tool/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..437abaabc Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/screenshots/3.png differ diff --git a/odoo_calculator_tool/static/description/assets/screenshots/hero.gif b/odoo_calculator_tool/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..c973820c6 Binary files /dev/null and b/odoo_calculator_tool/static/description/assets/screenshots/hero.gif differ diff --git a/odoo_calculator_tool/static/description/banner.png b/odoo_calculator_tool/static/description/banner.png new file mode 100644 index 000000000..406cdd996 Binary files /dev/null and b/odoo_calculator_tool/static/description/banner.png differ diff --git a/odoo_calculator_tool/static/description/icon.png b/odoo_calculator_tool/static/description/icon.png new file mode 100644 index 000000000..3e465e55b Binary files /dev/null and b/odoo_calculator_tool/static/description/icon.png differ diff --git a/odoo_calculator_tool/static/description/index.html b/odoo_calculator_tool/static/description/index.html new file mode 100644 index 000000000..a837139bf --- /dev/null +++ b/odoo_calculator_tool/static/description/index.html @@ -0,0 +1,556 @@ + + + + + + + Odoo App 3 Index + + + + + + + + +
+
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+
+
+
+

+ Odoo Calculator

+

+ Perform Basic Mathematical Calculations Effortlessly within Odoo. +

+
+ +
+
+
+
+
+

Key Highlights +

+
+
+
+
+
+ +
+
+

Effortless Calculations within UI.

+

+ Easily carry out Simple Mathematical Operations via the Odoo User Interface. +

+
+
+
+
+
+
+ +
+
+

Drag-and-Drop Feature.

+

+ Able to Drag the Calculator to Different Positions in the UI. +

+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+

+ Display Calculator.

+

+ Click the Calculator icon to display the Calculator, and click again to hide it. +

+
+
+
+
+
+
+ +
+
+

+ Odoo Calculator.

+

+ Allows users to perform basic arithmetic operations. +

+
+
+
+
+
+
+ +
+
+

+ Drag-and-Drop.

+

+ Allows users to drag and hold the calculator's header or any + draggable area to move it to a different location on the Odoo interface. +

+
+
+
+
+
+
+
    +
  • + Access Calculator Easily from User Interface. +
  • +
  • + Perform Simple Match Calculations using this Calculator. +
  • +
  • + Able to drag calculator. +
  • +
+
+
+
+
+
+
Version + 17.0.1.0.0|Released on:30th June 2024 +
+

+ Initial Commit for Odoo Calculator.

+
+
+
+
+
+ +
+
+

Related Products

+
+
+ +
+
+

Our Services

+
+
+
+
+
+
+
+
+ service-icon +
+
+

Odoo Customization

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Support

+
+
+
+
+
+
+ service-icon +
+
+

Hire Odoo Developer

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Integration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Migration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Consultancy

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo Licensing Consultancy

+
+
+
+
+
+
+

Our Industries

+
+
+
+
+
+
+ +

Trading

+

Easily procure and sell your products

+
+
+
+
+ +

POS

+

Easy configuration and convivial experience

+
+
+
+
+ +

Education

+

A platform for educational management

+
+
+
+
+ +

Manufacturing

+

Plan, track and schedule your operations

+
+
+
+
+ +

E-commerce & Website

+

Mobile friendly, awe-inspiring product pages

+
+
+
+
+ +

Service Management

+

Keep track of services and invoice

+
+
+
+
+ +

Restaurant

+

Run your bar or restaurant methodically

+
+
+
+
+ +

Hotel Management

+

An all-inclusive hotel management application

+
+
+
+
+
+
+

Support

+
+
+
+
+
+
+
+ +
+ Need + Help? +

Got questions or need help? Get in touch.

+
odoo@cybrosys.com +
+
+
+
+
+
+
+
+ +
+ WhatsApp +

Say hi to us on WhatsApp!

+
+91 + 99456767686
+
+
+
+
+
+
+
+
+ + + + + + diff --git a/odoo_calculator_tool/static/src/css/calculator.css b/odoo_calculator_tool/static/src/css/calculator.css new file mode 100644 index 000000000..41745088f --- /dev/null +++ b/odoo_calculator_tool/static/src/css/calculator.css @@ -0,0 +1,103 @@ +.calc-pad-tool { + display: block; + text-align: center; +} +.calc_dropdown { + display: flex; + position: relative; + background: transparent; + color: rgba(255, 255, 255, 0.9); +} +.calc_dropdown-toggle { + background: none; + border: none; + padding: 0; + cursor: pointer; + padding: 0 0.75rem; + color: black; +} +.calc_dropdown-menu { + position: absolute; + top: calc(100% + 5px); + left: 0; + z-index: 1000; + display: none; + padding: 5px 0; + margin: 2px 0 0; + font-size: 14px; + text-align: left; + list-style: none; + min-width: auto; + top: auto; + left: auto; + transform: none; +} +.calculator-app { + width: 320px; + margin: auto; + background-color: #f0f0f7; + padding: 15px; + border-radius: 10px; + box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2); +} +.calculator-app #display { + width: 100%; + height: 60px; + margin-bottom: 10px; + font-size: 32px; + text-align: right; + padding: 10px; + border: none; + background-color: #ececec; + border-radius: 5px; + box-shadow: inset 0px 4px 8px rgba(0, 0, 0, 0.1); +} +.calculator-app .buttons { + display: grid; + grid-template-columns: repeat(4, 1fr); + gap: 10px; +} +.calculator-app button { + width: 100%; + height: 60px; + font-size: 28px; + border: none; + border-radius: 5px; + background-color: #e4e4e4; + cursor: pointer; + transition: background-color 0.3s, transform 0.2s; +} +.calculator-app .number { + background-color: #fff; +} +.calculator-app .number:hover { + background-color: #d0d0d0; +} +.calculator-app .operator { + background-color: #f0f0f0; + color: #ff9500; +} +.calculator-app .operator:hover { + background-color: #e0e0e0; +} +.calculator-app .equals { + background-color: #ff9500; + grid-column: span 2; + color: #fff; +} +.calculator-app .equals:hover { + background-color: #ff7400; +} +.calculator-app .clear { + background-color: #acacac; + color: #fff; +} +.calculator-app .clear:hover { + background-color: #9a9a9a; +} +.calculator-app .decimal { + background-color: #f0f0f0; +} +.calculator-app .decimal:hover { + background-color: #e0e0e0; +} diff --git a/odoo_calculator_tool/static/src/js/calculator.js b/odoo_calculator_tool/static/src/js/calculator.js new file mode 100644 index 000000000..1838811c9 --- /dev/null +++ b/odoo_calculator_tool/static/src/js/calculator.js @@ -0,0 +1,151 @@ +/** @odoo-module **/ +import { Dropdown } from '@web/core/dropdown/dropdown'; +import { DropdownItem } from '@web/core/dropdown/dropdown_item'; +import { registry } from '@web/core/registry'; +import { Component } from '@odoo/owl'; +import { useRef, useState, onMounted, onWillUnmount } from "@odoo/owl"; + +export class Calculator extends Component { + setup() { + super.setup(); + this.rootRef = useRef('root'); + this.currentInput = ''; + this.currentOperator = ''; + this.result = 0; + this.state = useState({ + x: 0, + y: 0, + isVisible: false + }); + + this.dragStartX = 0; + this.dragStartY = 0; + + onMounted(() => { + document.addEventListener('mousemove', this.onDragging); + document.addEventListener('mouseup', this.stopDragging); + }); + + onWillUnmount(() => { + document.removeEventListener('mousemove', this.onDragging); + document.removeEventListener('mouseup', this.stopDragging); + }); + } + + // Display the calculator + onclick_calc_icon() { + this.state.isVisible = !this.state.isVisible; + } + + startDragging(ev) { + this.isDragging = true; + this.dragStartX = ev.clientX - this.state.x; + this.dragStartY = ev.clientY - this.state.y; + } + + onDragging = (ev) => { + if (this.isDragging) { + this.state.x = ev.clientX - this.dragStartX; + this.state.y = ev.clientY - this.dragStartY; + } + } + + stopDragging = () => { + this.isDragging = false; + } + + async onNumberClick(ev){ + // Handles the click event for number buttons. + var number = ev.currentTarget.getAttribute('data-key'); + if (number === '.') { + this.onDecimalClick(ev); + } + else { + this.currentInput += number; + $(this.rootRef.el.querySelector('.display')).val(this.currentInput); + } + } + + async onOperatorClick(ev){ + // Handles the click event for operator buttons. + var operator = ev.currentTarget.getAttribute('data-key'); + if (this.currentInput !== '') { + if (this.currentOperator !== '') { + this.result = this.calculate(this.result, parseFloat(this.currentInput), this.currentOperator); + $(this.rootRef.el.querySelector('.display')).val(this.result) + } + else { + this.result = parseFloat(this.currentInput); + } + this.currentInput = ''; + this.currentOperator = operator; + } + } + + async onEqualsClick(){ + // Handles the click event for the equals button. + if (this.currentInput !== '') { + this.result = this.calculate(this.result, parseFloat(this.currentInput), this.currentOperator); + $(this.rootRef.el.querySelector('.display')).val(this.result); + this.currentInput = this.result.toString(); + this.currentOperator = ''; + } + } + + async onClearClick(){ + // Handles the click event for the Clear button. + this.result = 0; + this.currentInput = ''; + this.currentOperator = ''; + $(this.rootRef.el.querySelector('.display')).val(''); + } + + async onToggleSignClick(){ + // Handles the click event for the sign button. + if (this.currentInput !== '') { + // Check if the current input is a negative number + if (this.currentInput[0] === '-') { + // Remove the negative sign to make it positive + this.currentInput = this.currentInput.substring(1); + } else { + // Add a negative sign to make it negative + this.currentInput = '-' + this.currentInput; + } + $(this.rootRef.el.querySelector('.display')).val(this.currentInput); + } + } + async onDecimalClick(ev){ + // Handles the click event for the decimal point toggle button + var decimal = ev.currentTarget.getAttribute('data-key'); + if (this.currentInput.indexOf('.') === -1) { + this.currentInput += decimal; + $(this.rootRef.el.querySelector('.display')).val(this.currentInput); + } + } + calculate(num1, num2, operator) { + // Performs arithmetic calculations based on the provided operator. + switch (operator) { + case '+': + return num1 + num2; + case '-': + return num1 - num2; + case '*': + return num1 * num2; + case '/': + return num1 / num2; + case '%': + return (num1 / 100) * num2; + default: + return num2; + } + } +} + +Calculator.template = 'CalculatorTool'; +Calculator.components = { Dropdown, DropdownItem }; + +export const calculator = { + Component: Calculator, +}; + +registry.category('systray').add('Calculator', calculator); \ No newline at end of file diff --git a/odoo_calculator_tool/static/src/xml/calculator.xml b/odoo_calculator_tool/static/src/xml/calculator.xml new file mode 100644 index 000000000..f7129a2d9 --- /dev/null +++ b/odoo_calculator_tool/static/src/xml/calculator.xml @@ -0,0 +1,60 @@ + + + + + + \ No newline at end of file