diff --git a/pos_product_creation/README.rst b/pos_product_creation/README.rst
new file mode 100644
index 000000000..3b14388f0
--- /dev/null
+++ b/pos_product_creation/README.rst
@@ -0,0 +1,40 @@
+Create Products From POS
+=================================
+This module helps you create products directly from POS.
+
+Configuration
+=============
+* No additional configurations needed
+
+Company
+-------
+* `Cybrosys Techno Solutions
+
@@ -47,7 +47,7 @@
The module provisions the end user to create products directly from Point of Sale. The new button "Create Product", shall enable the end user to add details such as - product name, internal reference, price, type, category and more from POS. Upon clicking the + product name, product image, internal reference, price, type, category, barcode and more from POS. Upon clicking the confirm button, a new product shall be created based on provided details.
@@ -98,7 +98,7 @@- Enter the details of products right from the POS. + Enter the details of products right from the POS. Only .jpeg format image is supported as the product image.
diff --git a/pos_product_creation/static/src/js/product_create_button.js b/pos_product_creation/static/src/js/product_create_button.js index 835596423..e83214150 100644 --- a/pos_product_creation/static/src/js/product_create_button.js +++ b/pos_product_creation/static/src/js/product_create_button.js @@ -24,32 +24,41 @@ odoo.define('owl_tutorials.product_create_button', function(require) { body: this.env._t('You can Create The product.'), }); if (confirmed) { - var product_category = payload[0]; - var product_name = payload[1]; - var product_reference = payload[2]; - var product_price = payload[3]; - var unit_measure = payload[4]; - var product_categories = payload[5]; - var barcode = payload[6]; - if (!product_name){ - return this.showPopup('ErrorPopup', { - title: _('A Unit Of Measure Is Required'), - }); + var product_image; + var image = $('#product-image')[0].files[0] + var reader = new FileReader(); + await reader.readAsDataURL(image); + reader.onload = function(){ + product_image = reader.result + var image = product_image.slice(23); + var product_category = payload[0]; + var product_name = payload[1]; + var product_reference = payload[3]; + var product_price = payload[4]; + var unit_measure = payload[5]; + var product_categories = payload[6]; + var barcode = payload[7]; + if (!product_name){ + return this.showPopup('ErrorPopup', { + title: _('A Unit Of Measure Is Required'), + }); + } + if (!unit_measure){ + return this.showPopup('ErrorPopup', { + title: _('A Unit Of Measure Is Required'), + }); + } + ajax.jsonRpc('/create_product', 'call', { + 'category': product_category, + 'image': image, + 'name': product_name, + 'price': product_price, + 'product_reference': product_reference, + 'unit_measure': unit_measure, + 'product_categories': product_categories, + 'barcode': barcode, + }).then(function(response) {}); } - if (!unit_measure){ - return this.showPopup('ErrorPopup', { - title: _('A Unit Of Measure Is Required'), - }); - } - ajax.jsonRpc('/create_product', 'call', { - 'category': product_category, - 'name': product_name, - 'price': product_price, - 'product_reference': product_reference, - 'unit_measure': unit_measure, - 'product_categories': product_categories, - 'barcode': barcode, - }).then(function(response) {}); } } } diff --git a/pos_product_creation/static/src/js/product_create_popup.js b/pos_product_creation/static/src/js/product_create_popup.js index 42e9e0131..a9bf9acf4 100644 --- a/pos_product_creation/static/src/js/product_create_popup.js +++ b/pos_product_creation/static/src/js/product_create_popup.js @@ -15,13 +15,15 @@ odoo.define('pos_product_creation.product_create_popup', function(require) { typeValue: this.props.startingValue, productValue: this.props.startingValue, priceValue: this.props.priceValue, - productRef: this.props.startingValue + productRef: this.props.startingValue, + productImg: this.props.productImage, }); } getPayload() { var selected_vals = []; var category = this.state.typeValue; var product = this.state.productValue; + var image = this.state.productImg; var product_reference = this.state.productRef; var price = this.state.priceValue; var unit = this.state.unitValue; @@ -29,6 +31,7 @@ odoo.define('pos_product_creation.product_create_popup', function(require) { var barcode = this.state.barcodeValue; selected_vals.push(category); selected_vals.push(product); + selected_vals.push(image); selected_vals.push(product_reference); selected_vals.push(price); selected_vals.push(unit); diff --git a/pos_product_creation/static/src/xml/product_create_popup.xml b/pos_product_creation/static/src/xml/product_create_popup.xml index 031f2f1bb..e0e4a69c9 100644 --- a/pos_product_creation/static/src/xml/product_create_popup.xml +++ b/pos_product_creation/static/src/xml/product_create_popup.xml @@ -18,6 +18,15 @@ +