diff --git a/pos_product_create_edit/README.rst b/pos_product_create_edit/README.rst new file mode 100644 index 000000000..b18622d42 --- /dev/null +++ b/pos_product_create_edit/README.rst @@ -0,0 +1,41 @@ +Point Of Sale Product Create Edit +================================= +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 `__ + +Credits +------- +* Developers: Cybrosys Techno Solutions odoo@cybrosys.com + Version 16: Dino @cybrosys + + +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..8d0927546 --- /dev/null +++ b/pos_product_create_edit/__init__.py @@ -0,0 +1,20 @@ +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2022-TODAY Cybrosys Technologies() +# Author: Dino () +# +# 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 . +# +############################################################################# \ No newline at end of file diff --git a/pos_product_create_edit/__manifest__.py b/pos_product_create_edit/__manifest__.py new file mode 100644 index 000000000..d1f43b064 --- /dev/null +++ b/pos_product_create_edit/__manifest__.py @@ -0,0 +1,43 @@ +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2022-TODAY Cybrosys Technologies() +# Author: Dino () +# +# 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': '16.0.1.0.0', + 'summary': 'This Module will help to create and edit products directly from point of sale.', + 'category': 'Point of Sale', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'images': ['static/description/banner.png'], + 'website': 'https://www.cybrosys.com', + 'depends': ['base', 'point_of_sale'], + 'assets': { + 'point_of_sale.assets': [ + 'pos_product_create_edit/static/src/js/*', + 'pos_product_create_edit/static/src/xml/*', + 'pos_product_create_edit/static/src/css/*', + ], + }, + 'license': 'AGPL-3', + 'installable': True, + 'application': True, + '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..c7576ac9b --- /dev/null +++ b/pos_product_create_edit/doc/RELEASE_NOTES.md @@ -0,0 +1,11 @@ +## Module + +#### 27.12.2022 +#### Version 16.0.1.0.0 +#### ADD +Initial Commit Product Create & 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..5238bdeab 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..1ae7cfe3b 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..3c3ff1afb 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..3fae4631e 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/6.png b/pos_product_create_edit/static/description/assets/modules/6.png new file mode 100644 index 000000000..7f2815273 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..1c908f089 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.jpg b/pos_product_create_edit/static/description/assets/screenshots/2.jpg new file mode 100644 index 000000000..119d14fd5 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/screenshots/2.jpg 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..c7524d409 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..4c0d95a8a 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.webp b/pos_product_create_edit/static/description/assets/screenshots/hero.webp new file mode 100644 index 000000000..1c0391ae8 Binary files /dev/null and b/pos_product_create_edit/static/description/assets/screenshots/hero.webp 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..d18dbfdd2 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..984290a94 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..3a7c6a549 --- /dev/null +++ b/pos_product_create_edit/static/description/index.html @@ -0,0 +1,544 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+
+ +
+
+
+ +

+ Product Create & Edit From Pos

+

You can directly edit or create new product from point of sale.

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

Explore This + Module

+
+ + + + +
+
+ +
+

Overview +

+
+
+
+ This module helps to create and edit products directly from the pos
+
+ + + +
+
+ +
+

Features +

+
+
+
+
+ + Available in Odoo 16.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 products have a 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 .The product details will shown as a popup.

+ +
+
+

Create New Product

+

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

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

Related + 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..8a2c159ec --- /dev/null +++ b/pos_product_create_edit/static/src/css/ProductList.css @@ -0,0 +1,34 @@ +button.edit_product{ + border-radius:5px; +} +i.fa.fa-pencil{ + font-size:20px; +} +img.product_img { + max-width:40px; +} +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: 75%; +} +i.fa.fa-plus.create_btn{ + margin-right:5px; +} \ No newline at end of file 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..9ead58dc5 --- /dev/null +++ b/pos_product_create_edit/static/src/js/ProductCreatePopup.js @@ -0,0 +1,91 @@ +/**@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"; +let img = ""; +let base64_img = ""; +class CreateProductPopup extends AbstractAwaitablePopup { + setup() { + super.setup(); + useListener("change", "#img_field", this._onChangeImgField); + } + 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(() => { + $("#img_url_tag_create").hide(); + let element = + ""; + $(".product-img-create-popup").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; + } + } + } + async confirm() { + let img = $("#img_field").val(); + let name = $("#display_name").val(); + let price = $("#list_price").val(); + let cost = $("#cost_price").val(); + let category = $("#product_category").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) { + values["pos_categ_id"] = category; + } + 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'), $("#display_name").val()), 3000); + } else { + this.showNotification(_.str.sprintf(this.env._t('%s - Product Creation Failed'), $("#display_name").val()), 3000); + } + }); + this.env.posbus.trigger("close-popup", { + popupId: this.props.id, + response: { + confirmed: false, + payload: null, + }, + }); + } +} +CreateProductPopup.template = "CreateProductPopup"; +Registries.Component.add(CreateProductPopup); \ No newline at end of file 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..7cc4f1733 --- /dev/null +++ b/pos_product_create_edit/static/src/js/ProductEditPopup.js @@ -0,0 +1,101 @@ +/**@odoo-module **/ +import AbstractAwaitablePopup from "point_of_sale.AbstractAwaitablePopup"; +import Registries from "point_of_sale.Registries"; +import { useListener } from "@web/core/utils/hooks"; +let base64_img = ""; +let img = ""; +class EditProductPopup extends AbstractAwaitablePopup { + setup() { + super.setup(); + useListener("change", "#img_field", this._onChangeImgField); + } + 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(() => { + $("#img_url_tag_edit").hide(); + let element = + ""; + $(".product-img-edit-popup").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; + } + } + } + + confirm() { + let values = {}; + if (base64_img) { + values["image_1920"] = base64_img; + } + if ($("#display_name").val() != this.props.product.display_name) { + values["name"] = $("#display_name").val(); + } + if ($("#list_price").val() != this.props.product.list_price) { + values["lst_price"] = $("#list_price").val(); + } + if ($("#product_category").val()) { + values["pos_categ_id"] = parseInt($("#product_category").val()); + } + this.rpc({ + model: "product.product", + method: "write", + args: [this.props.product.id, values], + }).then((result) => { + if (result) { + this.props.product.display_name = $("#display_name").val(); + this.props.product.lst_price = $("#list_price").val(); + this.props.product.pos_categ_id = [ + parseInt($("#product_category").val()), + $("#product_category")[0].selectedOptions[0].title, + ]; + this.showNotification(_.str.sprintf(this.env._t("%s - Product Updated"),$("#display_name").val()),3000); + } else { + this.showNotification(_.str.sprintf(this.env._t("%s - Product Updation Failed"),$("#display_name").val()),3000); + } + this.env.posbus.trigger("close-popup", { + popupId: this.props.id, + response: { + confirmed: false, + payload: null, + }, + }); + }); + } + cancel() { + this.env.posbus.trigger("close-popup", { + popupId: this.props.id, + response: { + confirmed: false, + payload: null, + }, + }); + } + 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..d1b20223d --- /dev/null +++ b/pos_product_create_edit/static/src/js/ProductLine.js @@ -0,0 +1,18 @@ +/**@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 imageUrl() { + const product = this.props.product; + return `/web/image?model=product.product&field=image_128&id=${product.id}&unique=${product.write_date}`; + } + async editCurrentProduct() { + await Gui.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..6b2a0ef34 --- /dev/null +++ b/pos_product_create_edit/static/src/js/pos_product_screen.js @@ -0,0 +1,48 @@ +/**@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 { + setup() { + super.setup(); + useListener("click", this.onClick); + } + 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); + }); + } + async onClick() { + try { + let list = this.productsList; + const screen = "ProductListScreen"; + Gui.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..16f87d08e --- /dev/null +++ b/pos_product_create_edit/static/src/js/productScreen.js @@ -0,0 +1,72 @@ +/**@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"; +import { onWillUnmount, useRef, onMounted } from "@odoo/owl"; + +class ProductListScreen extends PosComponent { + setup() { + super.setup(); + this.searchWordInputRef = useRef("search-word-input-product"); + this.state = { + search: null, + }; + } + createProduct() { + this.showPopup("CreateProductPopup", { + product: this.props.product, + }); + } + 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); + }); + } + async updateProductList(event) { + this.state.search = event.target.value; + if (event.code === "Enter") { + this._onPressEnterKey(); + } else { + this.render(true); + } + } + 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(); + } + } + + _clearSearch() { + this.searchWordInputRef.el.value = ""; + this.state.search = ""; + this.render(true); + } + back() { + this.showScreen('ProductScreen'); + } +} +ProductListScreen.template = "ProductListScreen"; +Registries.Component.add(ProductListScreen); diff --git a/pos_product_create_edit/static/src/xml/ProductCreatePopup.xml b/pos_product_create_edit/static/src/xml/ProductCreatePopup.xml new file mode 100644 index 000000000..3ca61e67d --- /dev/null +++ b/pos_product_create_edit/static/src/xml/ProductCreatePopup.xml @@ -0,0 +1,58 @@ + + + + + + \ No newline at end of file diff --git a/pos_product_create_edit/static/src/xml/ProductEditPopup.xml b/pos_product_create_edit/static/src/xml/ProductEditPopup.xml new file mode 100644 index 000000000..332d25f5b --- /dev/null +++ b/pos_product_create_edit/static/src/xml/ProductEditPopup.xml @@ -0,0 +1,59 @@ + + + + + + diff --git a/pos_product_create_edit/static/src/xml/ProductLine.xml b/pos_product_create_edit/static/src/xml/ProductLine.xml new file mode 100644 index 000000000..c63d29773 --- /dev/null +++ b/pos_product_create_edit/static/src/xml/ProductLine.xml @@ -0,0 +1,41 @@ + + + + + + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+