diff --git a/pos_product_create_edit/README.rst b/pos_product_create_edit/README.rst new file mode 100644 index 000000000..7d11c1651 --- /dev/null +++ b/pos_product_create_edit/README.rst @@ -0,0 +1,46 @@ +.. 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 + +Product Create Or Edit From Point of Sale +========================================== +This module helps you create products directly from POS, or you can edit the products from point of sale. + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +General Public License, Version 3 (LGPL v3). +(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) + +Credits +------- +* Developers: (V15) Mruthul Raj,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/pos_product_create_edit/__init__.py b/pos_product_create_edit/__init__.py new file mode 100644 index 000000000..5ce96beb7 --- /dev/null +++ b/pos_product_create_edit/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Mruthul Raj () +# +# 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/pos_product_create_edit/__manifest__.py b/pos_product_create_edit/__manifest__.py new file mode 100644 index 000000000..840896ce1 --- /dev/null +++ b/pos_product_create_edit/__manifest__.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Mruthul Raj () +# +# 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': 'Product Create Or Edit From Point of Sale', + 'version': '15.0.1.0.0', + 'category': 'Point of Sale', + 'summary': 'Create or edit products directly from the Point' + ' of Sale interface.', + 'description': 'This module allows users to create or edit products ' + 'directly from the Point of Sale (POS) interface.' + ' It provides a convenient way to manage products' + ' on the fly without navigating to the backend.', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['point_of_sale'], + 'assets': { + 'point_of_sale.assets': [ + 'pos_product_create_edit/static/src/js/*', + 'pos_product_create_edit/static/src/css/*', + ], + 'web.assets_qweb': [ + 'pos_product_create_edit/static/src/xml/*', + ] + }, + 'images': ['static/description/banner.png'], + 'license': 'LGPL-3', + 'installable': True, + 'application': False, + 'auto_install': False, +} diff --git a/pos_product_create_edit/doc/RELEASE_NOTES.md b/pos_product_create_edit/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..3ec3087cb --- /dev/null +++ b/pos_product_create_edit/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 18.11.2023 +#### Version 15.0.1.0.0 +#### ADD +- Initial Commit Product Create Or Edit From Point of Sale diff --git a/pos_product_create_edit/static/description/assets/icons/check.png b/pos_product_create_edit/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/check.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/chevron.png b/pos_product_create_edit/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/chevron.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/cogs.png b/pos_product_create_edit/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/cogs.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/consultation.png b/pos_product_create_edit/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/consultation.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/ecom-black.png b/pos_product_create_edit/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/ecom-black.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/education-black.png b/pos_product_create_edit/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/education-black.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/hotel-black.png b/pos_product_create_edit/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/hotel-black.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/license.png b/pos_product_create_edit/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/license.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/lifebuoy.png b/pos_product_create_edit/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/lifebuoy.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/manufacturing-black.png b/pos_product_create_edit/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/manufacturing-black.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/pos-black.png b/pos_product_create_edit/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/pos-black.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/puzzle.png b/pos_product_create_edit/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/puzzle.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/restaurant-black.png b/pos_product_create_edit/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/restaurant-black.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/service-black.png b/pos_product_create_edit/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/service-black.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/trading-black.png b/pos_product_create_edit/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/trading-black.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/training.png b/pos_product_create_edit/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/training.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/update.png b/pos_product_create_edit/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/update.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/user.png b/pos_product_create_edit/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/user.png differ diff --git a/pos_product_create_edit/static/description/assets/icons/wrench.png b/pos_product_create_edit/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/pos_product_create_edit/static/description/assets/icons/wrench.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/categories.png b/pos_product_create_edit/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/categories.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/check-box.png b/pos_product_create_edit/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/check-box.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/compass.png b/pos_product_create_edit/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/compass.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/corporate.png b/pos_product_create_edit/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/corporate.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/customer-support.png b/pos_product_create_edit/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/customer-support.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/cybrosys-logo.png b/pos_product_create_edit/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/cybrosys-logo.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/features.png b/pos_product_create_edit/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/features.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/logo.png b/pos_product_create_edit/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/logo.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/pictures.png b/pos_product_create_edit/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/pictures.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/pie-chart.png b/pos_product_create_edit/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/pie-chart.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/right-arrow.png b/pos_product_create_edit/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/right-arrow.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/star.png b/pos_product_create_edit/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/star.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/support.png b/pos_product_create_edit/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/support.png differ diff --git a/pos_product_create_edit/static/description/assets/misc/whatsapp.png b/pos_product_create_edit/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/misc/whatsapp.png differ diff --git a/pos_product_create_edit/static/description/assets/modules/1.png b/pos_product_create_edit/static/description/assets/modules/1.png new file mode 100644 index 000000000..b9375c944 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/modules/1.png differ diff --git a/pos_product_create_edit/static/description/assets/modules/2.png b/pos_product_create_edit/static/description/assets/modules/2.png new file mode 100644 index 000000000..a89c30f00 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/modules/2.png differ diff --git a/pos_product_create_edit/static/description/assets/modules/3.png b/pos_product_create_edit/static/description/assets/modules/3.png new file mode 100644 index 000000000..bafcdc5b5 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/modules/3.png differ diff --git a/pos_product_create_edit/static/description/assets/modules/4.png b/pos_product_create_edit/static/description/assets/modules/4.png new file mode 100644 index 000000000..1ca1b66f2 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/modules/4.png differ diff --git a/pos_product_create_edit/static/description/assets/modules/5.gif b/pos_product_create_edit/static/description/assets/modules/5.gif new file mode 100644 index 000000000..2a5f8e659 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/modules/5.gif differ diff --git a/pos_product_create_edit/static/description/assets/modules/5.png b/pos_product_create_edit/static/description/assets/modules/5.png new file mode 100644 index 000000000..6b1fb9016 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/modules/5.png differ diff --git a/pos_product_create_edit/static/description/assets/modules/6.png b/pos_product_create_edit/static/description/assets/modules/6.png new file mode 100644 index 000000000..b9da6a367 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/modules/6.png differ diff --git a/pos_product_create_edit/static/description/assets/screenshots/1.jpg b/pos_product_create_edit/static/description/assets/screenshots/1.jpg new file mode 100644 index 000000000..68b177896 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/screenshots/1.jpg differ diff --git a/pos_product_create_edit/static/description/assets/screenshots/2.png b/pos_product_create_edit/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..fb28a3243 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/screenshots/2.png differ diff --git a/pos_product_create_edit/static/description/assets/screenshots/3.png b/pos_product_create_edit/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..b57e4ff0e Binary files /dev/null and b/pos_product_create_edit/static/description/assets/screenshots/3.png differ diff --git a/pos_product_create_edit/static/description/assets/screenshots/4.png b/pos_product_create_edit/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..7ec44cbe0 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/screenshots/4.png differ diff --git a/pos_product_create_edit/static/description/assets/screenshots/hero.gif b/pos_product_create_edit/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..0dd0bc935 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/screenshots/hero.gif differ diff --git a/pos_product_create_edit/static/description/banner.png b/pos_product_create_edit/static/description/banner.png new file mode 100644 index 000000000..17e445b7a Binary files /dev/null and b/pos_product_create_edit/static/description/banner.png differ diff --git a/pos_product_create_edit/static/description/icon.png b/pos_product_create_edit/static/description/icon.png new file mode 100644 index 000000000..8d9ec23e1 Binary files /dev/null and b/pos_product_create_edit/static/description/icon.png differ diff --git a/pos_product_create_edit/static/description/index.html b/pos_product_create_edit/static/description/index.html new file mode 100644 index 000000000..67581abd5 --- /dev/null +++ b/pos_product_create_edit/static/description/index.html @@ -0,0 +1,648 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+ +
+
+
+ +

+ Product Create Or Edit From Point of Sale

+

+ You Can Directly Edit Or Create a New Product From the Point Of + Sale.

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

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+ This Module Helps to Create and Edit Products Directly from the POS +
+
+ + + +
+
+ +
+

+ Features +

+
+
+
+
+ + Available in Odoo 15.0 + Community and Enterprise. +
+ +
+ + Create new products directly from point of sale. +
+ +
+
+ +
+ + Edit products directly from point of sale. +
+
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+ +
+

+ New Product Screen Button +

+

+ This button will show All products.Form this screen you can + Create new product, or you can Edit already existing product. +

+ +
+ +
+

+ Product Edit Button +

+

+

+ On the product screen you can see All products Listed. Each + product has an Edit button on the right side. By clicking on + the button, you can Edit the product directly from POS.

+ +
+
+

+ Product Edit popup +

+

+ When you click on the Edit button of any product, product + details will show as a popup.

+ +
+
+

+ Create New Product

+

+ On the product screen we have a dedicated creation button. + Clicking on the button will show a popup to fill with details of + new product.

+ +
+ +
+
+ + + +
+
+

Suggested Products

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

+ Our Services +

+
+ +
+
+
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ 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 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/pos_product_create_edit/static/src/css/ProductList.css b/pos_product_create_edit/static/src/css/ProductList.css new file mode 100644 index 000000000..04056f257 --- /dev/null +++ b/pos_product_create_edit/static/src/css/ProductList.css @@ -0,0 +1,37 @@ +button.edit_product{ + border-radius:5px; +} +i.fa.fa-pencil{ + font-size:20px; +} +.full-content{ + overflow:scroll; +} +img.product_img { + max-width:60px; +} +label.field_label{ + padding:3%; +} +.field_div{ + margin-bottom:5px; +} +select.form-control{ + text-align: left; + display: inline-block; + overflow: hidden; + background: white; + min-height: 44px; + font-family: "Lato"; + font-size: 20px; + color: #444; + padding: 10px; + border-radius: 3px; + border: none; + box-shadow: 0px 0px 0px 1px gainsboro inset; + box-sizing: border-box; + width: 85%; +} +i.fa.fa-plus.create_btn{ + margin-right:5px; +} diff --git a/pos_product_create_edit/static/src/js/ProductCreatePopup.js b/pos_product_create_edit/static/src/js/ProductCreatePopup.js new file mode 100644 index 000000000..9401e1024 --- /dev/null +++ b/pos_product_create_edit/static/src/js/ProductCreatePopup.js @@ -0,0 +1,121 @@ +/**@odoo-module **/ +import AbstractAwaitablePopup from "point_of_sale.AbstractAwaitablePopup"; +import Registries from "point_of_sale.Registries"; +import { isConnectionError } from "point_of_sale.utils"; +import {useListener} from "@web/core/utils/hooks"; +const { Gui } = require('point_of_sale.Gui'); +let img = ""; +let base64_img = ""; +class CreateProductPopup extends AbstractAwaitablePopup { + /** + * Set up the component and attach the change event listener to the image field. + */ + setup() { + super.setup(); + useListener("change", "#img_field", this._onChangeImgField); + } + /** + * Handle the change event of the image field. + * @param {Event} ev - The change event object. + */ + async _onChangeImgField(ev) { + // This function will work when adding image to the image field + try { + let current = ev.target.files[0]; + const reader = new FileReader(); + reader.readAsDataURL(current); + reader.onload = await + + function() { + img = reader.result; + base64_img = reader.result.toString().replace(/^data:(.*,)?/, ""); + const myTimeout = setTimeout(() => { + $(ev.target.parentElement.previousElementSibling.childNodes[0]).hide(); + let element = + ""; + $(ev.target.parentElement.previousElementSibling.childNodes[0].parentElement).append($(element)); + }, 100); + }; + reader.onerror = (error) => + reject(() => { + console.log("error", error); + }); + } catch (error) { + if (isConnectionError(error)) { + this.showPopup("ErrorPopup", { + title: this.env._t("Network Error"), + body: this.env._t("Cannot access Product screen if offline."), + }); + } else { + throw error; + } + } + } + /** + * Function for validating number. + */ + async _numberCheck(ev){ + ev.target.value = ev.target.value.replace(/[^0-9.]/g, ''); + } + /** + * Confirm the creation of the product. + */ + async confirm(ev) { + let img = $(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[2].children[1]).val(); + let name = $(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[3].children[1]).val(); + let price = $(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[4].children[1]).val(); + let cost = $(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[5].children[1]).val(); + let category = $(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[8].children[1]).val(); + let barcode = $(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[6].children[1]).val(); + let default_code = $(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[7].children[1]).val(); + let values = {}; + if (base64_img) { + values["image_1920"] = base64_img; + } + if (name) { + values["name"] = name; + } + if (cost) { + values["standard_price"] = cost; + } + if (price) { + values["lst_price"] = price; + } + if (category) { + if (category == 0){ + Gui.showPopup('ErrorPopup', { + title: this.env._t('Mismatch Category'), + body: this.env._t('You cannot add to root category.'), + }); + }else{ + values["pos_categ_id"] = category; + } + } + if (barcode) { + values["barcode"] = barcode; + } + if (default_code) { + values["default_code"] = default_code; + } + values["available_in_pos"] = true; + await this.rpc({ + model: "product.product", + method: "create", + args: [values], + }).then((result) => { + if (result) { + this.showNotification(_.str.sprintf(this.env._t('%s - Product Created'), values["name"]), 3000); + window.location.reload(); + } else { + this.showNotification(_.str.sprintf(this.env._t('%s - Product Creation Failed'), values["name"]), 3000); + } + this.props.resolve({ + confirmed: false, + payload: null + }); + this.trigger('close-popup'); + }); + } +} +CreateProductPopup.template = "CreateProductPopup"; +Registries.Component.add(CreateProductPopup); diff --git a/pos_product_create_edit/static/src/js/ProductEditPopup.js b/pos_product_create_edit/static/src/js/ProductEditPopup.js new file mode 100644 index 000000000..c0e59b0d0 --- /dev/null +++ b/pos_product_create_edit/static/src/js/ProductEditPopup.js @@ -0,0 +1,140 @@ +/**@odoo-module **/ +import AbstractAwaitablePopup from "point_of_sale.AbstractAwaitablePopup"; +import Registries from "point_of_sale.Registries"; +import { useListener } from "@web/core/utils/hooks"; +const { Gui } = require('point_of_sale.Gui'); +let base64_img = ""; +let img = ""; +class EditProductPopup extends AbstractAwaitablePopup { + setup() { + super.setup(); + useListener("change", "#img_field", this._onChangeImgField); + } + /** + * Handle the change event of the image field. + * @param {Event} ev - The change event object. + */ + async _onChangeImgField(ev) { + try { + // This function will work when adding image to the image field + var self = this; + let current = ev.target.files[0]; + const reader = new FileReader(); + reader.readAsDataURL(current); + reader.onload = await + + function() { + img = reader.result; + base64_img = reader.result.toString().replace(/^data:(.*,)?/, ""); + const myTimeout = setTimeout(() => { + $(ev.target.parentElement.previousElementSibling.childNodes[0]).hide(); + let element = + ""; + $(ev.target.parentElement.previousElementSibling.childNodes[0].parentElement).append($(element)); + }, 100); + }; + reader.onerror = (error) => + reject(() => { + console.log("error", error); + }); + } catch (error) { + if (isConnectionError(error)) { + this.showPopup("ErrorPopup", { + title: this.env._t("Network Error"), + body: this.env._t("Cannot access Product screen if offline."), + }); + } else { + throw error; + } + } + } + /** + * Function for validating number. + */ + async _numberCheck(ev){ + ev.target.value = ev.target.value.replace(/[^0-9.]/g, ''); + } + /** + * Confirm the updates to the product. + */ + confirm(ev) { + let values = {}; + if (base64_img) { + values["image_1920"] = base64_img; + } + if ($(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[3].childNodes[1]).val() != this.props.product.display_name) { + values["name"] = $(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[3].childNodes[1]).val(); + } + if ($(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[4].childNodes[1]).val() != this.props.product.list_price) { + values["lst_price"] = $(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[4].childNodes[1]).val(); + } + if ($(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[7].childNodes[1]).val()) { + values["pos_categ_id"] = parseInt($(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[7].childNodes[1]).val()); + } + if ($(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[6].childNodes[1]).val()) { + values["barcode"] = $(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[6].childNodes[1]).val(); + } + if ($(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[5].childNodes[1]).val()) { + values["default_code"] = $(ev.target.parentElement.parentElement.previousElementSibling.firstChild.firstElementChild.childNodes[5].childNodes[1]).val(); + } + if (values["pos_categ_id"] == 0) { + Gui.showPopup('ErrorPopup', { + title: this.env._t('Mismatch Category'), + body: this.env._t('You cannot add to root category.'), + }); + } + this.rpc({ + model: "product.product", + method: "write", + args: [this.props.product.id, values], + }).then((result) => { + if (result) { + if (values['name']) { + this.props.product.display_name = values['name']; + } + if (values['lst_price']) { + this.props.product.lst_price = values['lst_price']; + } + if (values['barcode']) { + this.props.product.lst_price = values['barcode']; + } + if (values['default_code']) { + this.props.product.lst_price = values['default_code']; + } + if (values['pos_categ_id']) { + if (values['pos_categ_id'] == 0) { + Gui.showPopup('ErrorPopup', { + title: this.env._t('Mismatch Category'), + body: this.env._t('You cannot add to root category.'), + }); + } else { + this.props.product.pos_categ_id = [ + values["pos_categ_id"], + ]; + } + } + Gui.setSyncStatus(_.str.sprintf(this.env._t('%s - Product Created'), values['name']), 3000); + window.location.reload(); + } else { + this.showNotification(_.str.sprintf(this.env._t("%s - Product Updation Failed"), values['name']), 3000); + } + this.props.resolve({ + confirmed: false, + payload: null + }); + this.trigger('close-popup'); + }); + } + /** + * Get the URL for the product image. + * @returns {string} The URL of the product image. + */ + get imageUrl() { + const product = this.props.product; + return `/web/image?model=product.product&field=image_128&id=${product.id}&unique=${product.write_date}`; + } +} +EditProductPopup.template = "EditProductPopup"; +Registries.Component.add(EditProductPopup); diff --git a/pos_product_create_edit/static/src/js/ProductLine.js b/pos_product_create_edit/static/src/js/ProductLine.js new file mode 100644 index 000000000..e863ee077 --- /dev/null +++ b/pos_product_create_edit/static/src/js/ProductLine.js @@ -0,0 +1,25 @@ +/**@odoo-module **/ +import PosComponent from "point_of_sale.PosComponent"; +import Registries from "point_of_sale.Registries"; +import { Gui } from 'point_of_sale.Gui'; + +class ProductLine extends PosComponent { + /** + * Get the URL for the product image. + * @returns {string} The URL of the product image. + */ + get imageUrl() { + const product = this.props.product; + return `/web/image?model=product.product&field=image_128&id=${product.id}&unique=${product.write_date}`; + } + /** + * Edit the current product by showing the EditProductPopup. + */ + async editCurrentProduct() { + await this.showPopup("EditProductPopup", { + product: this.props.product, + }); + } +} +ProductLine.template = "ProductLine"; +Registries.Component.add(ProductLine); diff --git a/pos_product_create_edit/static/src/js/pos_product_screen.js b/pos_product_create_edit/static/src/js/pos_product_screen.js new file mode 100644 index 000000000..2eb2f57b9 --- /dev/null +++ b/pos_product_create_edit/static/src/js/pos_product_screen.js @@ -0,0 +1,57 @@ +/**@odoo-module **/ + +import PosComponent from "point_of_sale.PosComponent"; +import ProductScreen from "point_of_sale.ProductScreen"; +import { useListener } from "@web/core/utils/hooks"; +import Registries from "point_of_sale.Registries"; +import { Gui } from "point_of_sale.Gui"; +import { isConnectionError } from "point_of_sale.utils"; +export class SetProductListButton extends PosComponent { + /** + * Set up the component and attach the click event listener. + */ + setup() { + super.setup(); + useListener("click", this.onClick); + } + /** + * Get the list of products filtered by the selected category. + * @returns {Array} The sorted list of products. + */ + get productsList() { + let list = []; + list = this.env.pos.db.get_product_by_category( + this.env.pos.selectedCategoryId + ); + return list.sort(function(a, b) { + return a.display_name.localeCompare(b.display_name); + }); + } + /** + * Handle the click event of the button. + */ + async onClick() { + try { + let list = this.productsList; + const screen = "ProductListScreen"; + this.showScreen(screen); + } catch (error) { + if (isConnectionError(error)) { + this.showPopup("ErrorPopup", { + title: this.env._t("Network Error"), + body: this.env._t("Cannot access Product screen if offline."), + }); + } else { + throw error; + } + } + } +} +SetProductListButton.template = "SetProductListButton"; +ProductScreen.addControlButton({ + component: SetProductListButton, + condition: function() { + return true; + }, +}); +Registries.Component.add(SetProductListButton); diff --git a/pos_product_create_edit/static/src/js/productScreen.js b/pos_product_create_edit/static/src/js/productScreen.js new file mode 100644 index 000000000..f2b2d5f97 --- /dev/null +++ b/pos_product_create_edit/static/src/js/productScreen.js @@ -0,0 +1,91 @@ +/**@odoo-module **/ + +import ControlButtonsMixin from "point_of_sale.ControlButtonsMixin"; +import Registries from "point_of_sale.Registries"; +import IndependentToOrderScreen from "point_of_sale.IndependentToOrderScreen"; +import { useListener } from "@web/core/utils/hooks"; +import PosComponent from "point_of_sale.PosComponent"; +import { Gui } from "point_of_sale.Gui"; +const { useRef } = owl.hooks; + +class ProductListScreen extends PosComponent { + setup() { + super.setup(); + this.searchWordInputRef = useRef("search-word-input-product"); + this.state = { + search: null, + }; + } + /** + * Create a new product by showing the CreateProductPopup. + */ + createProduct() { + this.showPopup("CreateProductPopup", { + product: this.props.product, + }); + } + /** + * Get the list of products to display. + * @returns {Array} The list of products. + */ + get products() { + let list; + if (this.state.search && this.state.search.trim() !== "") { + list = this.env.pos.db.search_product_in_category( + 0, + this.state.search.trim() + ); + } else { + list = this.env.pos.db.get_product_by_category(0); + } + return list.sort(function (a, b) { + return a.display_name.localeCompare(b.display_name); + }); + } + /** + * Update the product list based on the search input. + * @param {Event} event - The event object. + */ + async updateProductList(event) { + this.state.search = event.target.value; + if (event.code === "Enter") { + this._onPressEnterKey(); + } else { + this.render(true); + } + } + /** + * Handle the Enter key press event. + */ + async _onPressEnterKey() { + if (!this.state.search) return; + if (!this.env.pos.isEveryProductLoaded) { + const result = await this.products; + this.showNotification( + _.str.sprintf( + this.env._t('%s Product(s) found for "%s".'), + result.length, + this.state.search + ), + 3000 + ); + if (!result.length) this._clearSearch(); + } + } + /** + * Clear the search input and reset the search state. + */ + _clearSearch() { + this.searchWordInputRef.el.value = ""; + this.state.search = ""; + this.render(true); + } + /** + * Navigate back to the ProductScreen. + */ + back() { + this.showScreen('ProductScreen'); + } +} +ProductListScreen.template = "ProductListScreen"; +Registries.Component.add(ProductListScreen); diff --git a/pos_product_create_edit/static/src/xml/pos_product_button_templates.xml b/pos_product_create_edit/static/src/xml/pos_product_button_templates.xml new file mode 100644 index 000000000..5f873c98f --- /dev/null +++ b/pos_product_create_edit/static/src/xml/pos_product_button_templates.xml @@ -0,0 +1,11 @@ + + + + +
+ + Products +
+
+
diff --git a/pos_product_create_edit/static/src/xml/product_create_popup_templates.xml b/pos_product_create_edit/static/src/xml/product_create_popup_templates.xml new file mode 100644 index 000000000..e060e12a8 --- /dev/null +++ b/pos_product_create_edit/static/src/xml/product_create_popup_templates.xml @@ -0,0 +1,100 @@ + + + + + + + diff --git a/pos_product_create_edit/static/src/xml/product_edit_popup_templates.xml b/pos_product_create_edit/static/src/xml/product_edit_popup_templates.xml new file mode 100644 index 000000000..6d66d7f34 --- /dev/null +++ b/pos_product_create_edit/static/src/xml/product_edit_popup_templates.xml @@ -0,0 +1,97 @@ + + + + + + + diff --git a/pos_product_create_edit/static/src/xml/product_line_templates.xml b/pos_product_create_edit/static/src/xml/product_line_templates.xml new file mode 100644 index 000000000..c108e606c --- /dev/null +++ b/pos_product_create_edit/static/src/xml/product_line_templates.xml @@ -0,0 +1,47 @@ + + + + + + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+