Browse Source

Apr 17 [UPDT] Bug Fixed 'pos_product_creation'

pull/275/head
AjmalCybro 2 years ago
parent
commit
beea99ae45
  1. 40
      pos_product_creation/README.rst
  2. 2
      pos_product_creation/__manifest__.py
  3. 3
      pos_product_creation/controllers/main.py
  4. 6
      pos_product_creation/doc/RELEASE_NOTES.md
  5. BIN
      pos_product_creation/static/description/images/1pos.png
  6. BIN
      pos_product_creation/static/description/images/2pos.png
  7. BIN
      pos_product_creation/static/description/images/hero.gif
  8. BIN
      pos_product_creation/static/description/images/hero.png
  9. 6
      pos_product_creation/static/description/index.html
  10. 59
      pos_product_creation/static/src/js/product_create_button.js
  11. 5
      pos_product_creation/static/src/js/product_create_popup.js
  12. 9
      pos_product_creation/static/src/xml/product_create_popup.xml

40
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 <https://cybrosys.com/>`__
Credits
-------
* Developers: Cybrosys Techno Solutions 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 <https://cybrosys.com/>`__
Further information
===================
HTML Description: `<static/description/index.html>`__

2
pos_product_creation/__manifest__.py

@ -22,7 +22,7 @@
{ {
'name': 'Create Products From POS', 'name': 'Create Products From POS',
'version': '14.0.1.0.0', 'version': '14.0.1.0.1',
'category': 'Point of Sale', 'category': 'Point of Sale',
'summary': 'Create Products From POS Interface', 'summary': 'Create Products From POS Interface',
'author': 'Cybrosys Techno Solutions', 'author': 'Cybrosys Techno Solutions',

3
pos_product_creation/controllers/main.py

@ -27,7 +27,7 @@ from odoo.http import request
class PosProductCreation(http.Controller): class PosProductCreation(http.Controller):
@http.route('/create_product', type="json", auth="none") @http.route('/create_product', type="json", auth="none")
def create_product(self, category, name, price, product_reference, def create_product(self, category, image, name, price, product_reference,
unit_measure, product_categories, barcode, **kwargs): unit_measure, product_categories, barcode, **kwargs):
product_category = '' product_category = ''
if category == 'Consumable': if category == 'Consumable':
@ -40,6 +40,7 @@ class PosProductCreation(http.Controller):
product_category = '' product_category = ''
request.env['product.template'].sudo().create({ request.env['product.template'].sudo().create({
'name': name, 'name': name,
'image_1920': image,
'type': product_category, 'type': product_category,
'default_code': product_reference, 'default_code': product_reference,
'list_price': float(price), 'list_price': float(price),

6
pos_product_creation/doc/RELEASE_NOTES.md

@ -0,0 +1,6 @@
## Module <pos_product_creation>
#### 13.04.2023
#### Version 14.0.1.0.1
#### UPDATE
Updated the product image field.

BIN
pos_product_creation/static/description/images/1pos.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 KiB

After

Width:  |  Height:  |  Size: 252 KiB

BIN
pos_product_creation/static/description/images/2pos.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 60 KiB

BIN
pos_product_creation/static/description/images/hero.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
pos_product_creation/static/description/images/hero.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

6
pos_product_creation/static/description/index.html

@ -32,7 +32,7 @@
style="color: #212529 !important; font-size: 1.5rem !important; letter-spacing: 1px !important;"> style="color: #212529 !important; font-size: 1.5rem !important; letter-spacing: 1px !important;">
Create Products From POS Create Products From POS
</p> </p>
<img src="./images/hero.png" class="img-responsive"> <img src="./images/hero.gif" class="img-responsive">
</div> </div>
</div> </div>
<!-- END OF HERO --> <!-- END OF HERO -->
@ -47,7 +47,7 @@
<p class="text-center" style="color: #212529 !important; font-size: 1.5rem !important;"> <p class="text-center" style="color: #212529 !important; font-size: 1.5rem !important;">
The module provisions the end user to create products directly from Point of Sale. The new The module provisions the end user to create products directly from Point of Sale. The new
button <strong>"Create Product"</strong>, shall enable the end user to add details such as button <strong>"Create Product"</strong>, 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. confirm button, a new product shall be created based on provided details.
</p> </p>
</div> </div>
@ -98,7 +98,7 @@
</h3> </h3>
<p <p
style="color: #212529 !important; font-size: 1.3rem !important; font-weight: 300 !important;"> style="color: #212529 !important; font-size: 1.3rem !important; font-weight: 300 !important;">
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.
</p> </p>
</div> </div>

59
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.'), body: this.env._t('You can Create The product.'),
}); });
if (confirmed) { if (confirmed) {
var product_category = payload[0]; var product_image;
var product_name = payload[1]; var image = $('#product-image')[0].files[0]
var product_reference = payload[2]; var reader = new FileReader();
var product_price = payload[3]; await reader.readAsDataURL(image);
var unit_measure = payload[4]; reader.onload = function(){
var product_categories = payload[5]; product_image = reader.result
var barcode = payload[6]; var image = product_image.slice(23);
if (!product_name){ var product_category = payload[0];
return this.showPopup('ErrorPopup', { var product_name = payload[1];
title: _('A Unit Of Measure Is Required'), 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) {});
} }
} }
} }

5
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, typeValue: this.props.startingValue,
productValue: this.props.startingValue, productValue: this.props.startingValue,
priceValue: this.props.priceValue, priceValue: this.props.priceValue,
productRef: this.props.startingValue productRef: this.props.startingValue,
productImg: this.props.productImage,
}); });
} }
getPayload() { getPayload() {
var selected_vals = []; var selected_vals = [];
var category = this.state.typeValue; var category = this.state.typeValue;
var product = this.state.productValue; var product = this.state.productValue;
var image = this.state.productImg;
var product_reference = this.state.productRef; var product_reference = this.state.productRef;
var price = this.state.priceValue; var price = this.state.priceValue;
var unit = this.state.unitValue; var unit = this.state.unitValue;
@ -29,6 +31,7 @@ odoo.define('pos_product_creation.product_create_popup', function(require) {
var barcode = this.state.barcodeValue; var barcode = this.state.barcodeValue;
selected_vals.push(category); selected_vals.push(category);
selected_vals.push(product); selected_vals.push(product);
selected_vals.push(image);
selected_vals.push(product_reference); selected_vals.push(product_reference);
selected_vals.push(price); selected_vals.push(price);
selected_vals.push(unit); selected_vals.push(unit);

9
pos_product_creation/static/src/xml/product_create_popup.xml

@ -18,6 +18,15 @@
<input class="name" type="text" t-model="state.productValue" required=""/> <input class="name" type="text" t-model="state.productValue" required=""/>
</div> </div>
</div> </div>
<br/>
<div class="row">
<div>
<span>Product Image</span>
</div>
<div style="margin-top: 10px;">
<input class="image" type="file" id="product-image" required=""/>
</div>
</div>
<br/> <br/>
<div class="row"> <div class="row">
<div> <div>

Loading…
Cancel
Save