diff --git a/pos_traceability_validation/README.rst b/pos_traceability_validation/README.rst old mode 100644 new mode 100755 index dcf09a67a..d7986562f --- a/pos_traceability_validation/README.rst +++ b/pos_traceability_validation/README.rst @@ -1,15 +1,46 @@ -POS Serial Number Validator v15 -=============================== +.. image:: https://img.shields.io/badge/licence-LGPL--3-green.svg + :target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 -Validate Serial number of a product by checking availability in stock +POS Serial Number Validator +=========================== +Validate lot/ Serial number of a product by checking the availability in the stock and duplication of serial number + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +General Public License, Version 3 (LGPL v3). +(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) Credits -======= -Cybrosys Techno Solutions - -Author ------- -* Akhilesh N S -* V13 Sreenath -* V14 Jibin James -* V15 Mily +------- +Developers: (V12) Akhilesh N S, + (V13) Sreenath + (V14) Jibin James + (V15) Mily Shajan, Abhishek E T +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_traceability_validation/__init__.py b/pos_traceability_validation/__init__.py index 902e46afa..090680cf6 100644 --- a/pos_traceability_validation/__init__.py +++ b/pos_traceability_validation/__init__.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- -############################################################################## +############################################################################### # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2019-TODAY Cybrosys Technologies(). -# Author: Akhilesh N S() -# you can modify it under the terms of the GNU LESSER +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Abhishek E T (odoo@cybrosys.com) +# +# 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, @@ -14,9 +15,8 @@ # GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. # # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE -# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# (LGPL v3) along with this program. # If not, see . # -############################################################################## - +############################################################################### from . import models diff --git a/pos_traceability_validation/__manifest__.py b/pos_traceability_validation/__manifest__.py index 39979c572..e4bd4de41 100644 --- a/pos_traceability_validation/__manifest__.py +++ b/pos_traceability_validation/__manifest__.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- -############################################################################## +############################################################################### # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2020-TODAY Cybrosys Technologies(). -# Author: Akhilesh N S() -# you can modify it under the terms of the GNU LESSER +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Abhishek E T (odoo@cybrosys.com) +# +# 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, @@ -14,29 +15,33 @@ # GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. # # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE -# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# (LGPL v3) along with this program. # If not, see . # -############################################################################## - +############################################################################### { 'name': 'POS Serial Number Validator', - 'version': '15.0.1.0.0', + 'version': '15.0.1.1.0.', + 'category': 'Point of Sale', + 'summary': 'Validate the lot/ serial number of products in PoS', + 'description': """Validate the lot/ serial number of a product by checking the + availability in stock and duplication of serial number""", 'author': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', 'website': 'https://www.cybrosys.com', - 'category': 'Point of Sale', - 'summary': """Validate Serial number of a product by checking availability in stock""", - 'description': """Validate Serial number of a product by checking availability in stock""", - 'depends': ['point_of_sale'], + 'depends': ['point_of_sale', 'stock'], 'assets': { 'web.assets_backend': [ - 'pos_traceability_validation/static/src/js/pos_models.js', + 'pos_traceability_validation/static/src/js/PoSEditListPopup.js', + 'pos_traceability_validation/static/src/js/PoSOrderWidget.js', + 'pos_traceability_validation/static/src/js/PoSProductScreen.js', ], }, 'images': ['static/description/banner.png'], 'license': 'LGPL-3', 'installable': True, 'auto_install': False, + 'application': False } diff --git a/pos_traceability_validation/doc/RELEASE_NOTES.md b/pos_traceability_validation/doc/RELEASE_NOTES.md index 922b4cb2a..ae5121271 100644 --- a/pos_traceability_validation/doc/RELEASE_NOTES.md +++ b/pos_traceability_validation/doc/RELEASE_NOTES.md @@ -1,7 +1,11 @@ ## Module -#### 08.04.2021 +#### 08.04.2022 #### Version 15.0.1.0.0 #### ADD +Initial Commit for POS Serial Number Validator -Initial Commit +#### 16.10.2023 +#### Version 15.0.1.1.0 +#### REF +Refactor the module and update the index diff --git a/pos_traceability_validation/models/__init__.py b/pos_traceability_validation/models/__init__.py index f607090ab..2e44c2c9d 100644 --- a/pos_traceability_validation/models/__init__.py +++ b/pos_traceability_validation/models/__init__.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- -############################################################################## +############################################################################### # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2019-TODAY Cybrosys Technologies(). -# Author: Akhilesh N S() -# you can modify it under the terms of the GNU LESSER +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Abhishek E T (odoo@cybrosys.com) +# +# 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, @@ -14,9 +15,8 @@ # GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. # # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE -# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# (LGPL v3) along with this program. # If not, see . # -############################################################################## - -from . import traceability_validation +############################################################################### +from . import stock_production_lot diff --git a/pos_traceability_validation/models/stock_production_lot.py b/pos_traceability_validation/models/stock_production_lot.py new file mode 100644 index 000000000..a65d14e42 --- /dev/null +++ b/pos_traceability_validation/models/stock_production_lot.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Abhishek E T (odoo@cybrosys.com) +# +# 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 . +# +############################################################################### +from odoo import api, models + + +class StockProductionLot(models.Model): + """ + This class is inherited for adding a new function to validate the lots and + serial numbers. + Methods: + validate_lots(lots): + check and validate the lots and serial numbers for the product + based on the stock location. + """ + _inherit = 'stock.production.lot' + + @api.model + def validate_lots(self, lots, product_id, picking_type_id): + """ To check + - the invalid lots/ serial numbers + - duplicate serial numbers + - insufficient stock for the lots or serial numbers. + All these cases are checked based on the product and the stock location + set for the active PoS. + Args: + lots (list[str,..., str]): the lots for validation. + product_id (int): id of the selected product. + picking_type_id (int): id of the operation type added for the PoS. + Returns: + list[str, str] or Bool: True if the lot is valid, else the list of + the string that indicates the exception: 'invalid', 'duplicate' or + 'no_stock' with the lot/ serial number. + """ + processed = [] + if not product_id: + return ['invalid', 'product'] + for lot in lots: + stock_lots = self.sudo().search([ + ('name', '=', lot), ('product_id', '=', product_id)]) + if not stock_lots: + return ['invalid', lot] + picking_type = self.env['stock.picking.type'].sudo().browse( + picking_type_id) + stock_quant = self.env['stock.quant'].sudo().search( + [('location_id', '=', picking_type.default_location_src_id.id), + ('lot_id', 'in', stock_lots.ids)]) + if (stock_quant and stock_quant.available_quantity > 0 + and lot not in processed): + processed.append(lot) + else: + if lot in processed: + return ['duplicate', lot] + return ['no_stock', lot] + return True diff --git a/pos_traceability_validation/models/traceability_validation.py b/pos_traceability_validation/models/traceability_validation.py deleted file mode 100644 index 2be1e6e92..000000000 --- a/pos_traceability_validation/models/traceability_validation.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Cybrosys Technologies Pvt. Ltd. -# -# Copyright (C) 2019-TODAY Cybrosys Technologies(). -# Author: Akhilesh N S() -# 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 -# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. -# If not, see . -# -############################################################################## - -from odoo import models, api - - -class ValidateLotNumber(models.Model): - _name = 'serial_no.validation' - - @api.model - def validate_lots(self, lots): - processed = [] - LotObj = self.env['stock.production.lot'] - for lot in lots: - lot_id = LotObj.search([('name', '=', lot)], limit=1) - try: - if lot_id.product_qty > 0 and lot not in processed: - processed.append(lot) - continue - else: - if lot in processed: - return ['duplicate', lot] - else: - return ['no_stock', lot] - except Exception: - return ['except', lot] - return True diff --git a/pos_traceability_validation/static/description/assets/modules/1.png b/pos_traceability_validation/static/description/assets/modules/1.png new file mode 100644 index 000000000..5c8646fae Binary files /dev/null and b/pos_traceability_validation/static/description/assets/modules/1.png differ diff --git a/pos_traceability_validation/static/description/assets/modules/2.png b/pos_traceability_validation/static/description/assets/modules/2.png new file mode 100644 index 000000000..3a5ffa0f9 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/modules/2.png differ diff --git a/pos_traceability_validation/static/description/assets/modules/3.png b/pos_traceability_validation/static/description/assets/modules/3.png new file mode 100644 index 000000000..31f0a1878 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/modules/3.png differ diff --git a/pos_traceability_validation/static/description/assets/modules/4.png b/pos_traceability_validation/static/description/assets/modules/4.png new file mode 100644 index 000000000..20eb5f70c Binary files /dev/null and b/pos_traceability_validation/static/description/assets/modules/4.png differ diff --git a/pos_traceability_validation/static/description/assets/modules/5.png b/pos_traceability_validation/static/description/assets/modules/5.png new file mode 100644 index 000000000..bf412a972 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/modules/5.png differ diff --git a/pos_traceability_validation/static/description/assets/modules/6.png b/pos_traceability_validation/static/description/assets/modules/6.png new file mode 100644 index 000000000..28a75d732 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/modules/6.png differ diff --git a/pos_traceability_validation/static/description/assets/modules/budget_image.png b/pos_traceability_validation/static/description/assets/modules/budget_image.png deleted file mode 100644 index b50130c7d..000000000 Binary files a/pos_traceability_validation/static/description/assets/modules/budget_image.png and /dev/null differ diff --git a/pos_traceability_validation/static/description/assets/modules/credit_image.png b/pos_traceability_validation/static/description/assets/modules/credit_image.png deleted file mode 100644 index 3ad04ecfd..000000000 Binary files a/pos_traceability_validation/static/description/assets/modules/credit_image.png and /dev/null differ diff --git a/pos_traceability_validation/static/description/assets/modules/employee_image.png b/pos_traceability_validation/static/description/assets/modules/employee_image.png deleted file mode 100644 index 30ad58232..000000000 Binary files a/pos_traceability_validation/static/description/assets/modules/employee_image.png and /dev/null differ diff --git a/pos_traceability_validation/static/description/assets/modules/export_image.png b/pos_traceability_validation/static/description/assets/modules/export_image.png deleted file mode 100644 index 492980ad0..000000000 Binary files a/pos_traceability_validation/static/description/assets/modules/export_image.png and /dev/null differ diff --git a/pos_traceability_validation/static/description/assets/modules/gantt_image.png b/pos_traceability_validation/static/description/assets/modules/gantt_image.png deleted file mode 100644 index 1ae7cfe3b..000000000 Binary files a/pos_traceability_validation/static/description/assets/modules/gantt_image.png and /dev/null differ diff --git a/pos_traceability_validation/static/description/assets/modules/quotation_image.png b/pos_traceability_validation/static/description/assets/modules/quotation_image.png deleted file mode 100644 index 499b1a72f..000000000 Binary files a/pos_traceability_validation/static/description/assets/modules/quotation_image.png and /dev/null differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos1.png b/pos_traceability_validation/static/description/assets/screenshots/pos1.png deleted file mode 100644 index 37deab111..000000000 Binary files a/pos_traceability_validation/static/description/assets/screenshots/pos1.png and /dev/null differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos2.png b/pos_traceability_validation/static/description/assets/screenshots/pos2.png deleted file mode 100644 index 607aec73e..000000000 Binary files a/pos_traceability_validation/static/description/assets/screenshots/pos2.png and /dev/null differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_1.png b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_1.png new file mode 100644 index 000000000..39398ed6c Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_1.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_10.png b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_10.png new file mode 100644 index 000000000..5b9189773 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_10.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_11.png b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_11.png new file mode 100644 index 000000000..c2248a965 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_11.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_2.png b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_2.png new file mode 100644 index 000000000..17a7d0405 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_2.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_3.png b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_3.png new file mode 100644 index 000000000..e65efe543 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_3.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_4.png b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_4.png new file mode 100644 index 000000000..a2ecc7d73 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_4.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_5.png b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_5.png new file mode 100644 index 000000000..e648c9583 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_5.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_6.png b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_6.png new file mode 100644 index 000000000..798a1e19b Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_6.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_7.png b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_7.png new file mode 100644 index 000000000..2ce319c84 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_7.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_8.png b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_8.png new file mode 100644 index 000000000..80c8dc9b8 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_8.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_9.png b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_9.png new file mode 100644 index 000000000..e2fb8a9c6 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/pos_traceability_validation_9.png differ diff --git a/pos_traceability_validation/static/description/index.html b/pos_traceability_validation/static/description/index.html index 7e99a7f51..4b3fb9f72 100644 --- a/pos_traceability_validation/static/description/index.html +++ b/pos_traceability_validation/static/description/index.html @@ -1,58 +1,53 @@
+
-
+
-
+
Community
-
+
Enterprise
+
-
-

+
+ +

POS Serial Number Validator

-

- Validate the given Serial number of a product from stock +

+ This module helps to validate the given Lots/ Serial numbers of a product from PoS

+

+
-

+

Explore this module

-
+
-

- Overview

-

- Learn more about this module

+

Overview

+

+ Learn more about this module +

@@ -62,15 +57,12 @@
-
+
-

- Features

-

- View features of this module

+

Features

+

+ View features of this module +

@@ -80,15 +72,12 @@
-
+ + - +
-

+

Overview

-
-

- Currently in Odoo, Serial number validation at POS not available. This module validates given serial number is available in stock and prevent duplicated entry for more than one quantity. -

- +

+ In Odoo, lots/ serial number validation is not available in the Point of Sale. This module checks whether the given lots/ serial numbers are available in stock or not, and prevents the duplicated entry. +

+ - +
-

+

Features

-
-

- Community & Enterprise Support

-

- Available in Odoo 15.0 Community and Enterprise.

+

Community & Enterprise Support

+

+ Available in Odoo 15.0 Community and Enterprise. +

@@ -143,379 +126,333 @@
-

- Validates given serial number is available in stock

+

Validates Given Lots/ Serial Number From PoS

-
-

- Prevents duplicated entry for more than one quantity

+

Prevents Duplicated Entry Of Lots/ Serial Numbers

- -
+ +
-

+

Screenshots

+
+

Enable lots & serial numbers

+

+ The user with Administration Settings access and Administrator access to inventory can enable the setting. +

+ +

+ Add the users to the group Manage Lots / Serial Numbers to use lots & serial numbers. +

+ +

+ Navigate to Inventory / Configuration / Settings and enable the setting Lots & Serial Numbers from the Traceability section. +

+ +
+
+

Enable tracking for the products

+

+ The traceability of the products are managed in the product form view, under the Inventory tab. Check if the Tracking option is enabled and select the By Unique Serial Number Or By Lots option. +

+ +
+
+

Add lot or serial numbers for products in stock

+

+ Confirm that the product Lot/ Serial Number is added to the on-hand quantity in the location which is set as the source location for the PoS. +

+ +
+
+

The Pop-up will be displayed to add the lot/ serial number on selecting the products with traceability.

+ +
-

- - Warnings for invalid Serial Number

- - +

Warning for invalid lot/ serial number

+
-
-

- Warnings for Duplicate Serial Number

- - - +

Warning if the product is out of stock

+ +
+
+

Warning for duplicate serial number

+

+ It is possible to add multiple serial numbers for the selected product from the order line. +

+ +

+ A validation is added to avoid adding duplicate serial numbers. +

+ +

+ A warning will be displayed in this case. +

+
- - -
+ - +
- - +

Our Services

-
+
-
-
+
- Odoo - Customization
+ Odoo Customization +
-
-
+
- Odoo - Implementation
+ Odoo Implementation +
-
-
+
- Odoo - Support
+ Odoo Support +
- -
-
+
- Hire - Odoo - Developer
+ Hire Odoo Developer +
-
-
+
- Odoo - Integration
+ Odoo Integration +
-
-
+
- Odoo - Migration
+ Odoo Migration +
- -
-
+
Odoo - Consultancy
+ Consultancy +
-
-
+
- Odoo - Implementation
+ Odoo Implementation +
-
-
+
- Odoo - Licensing Consultancy
+ Odoo Licensing Consultancy +
- +

Our Industries

-
+
-
-
+
-
+
Trading

- Easily procure - and - sell your products

+ Easily procure and sell your products +

-
-
+
-
+
POS

- Easy - configuration - and convivial experience

+ Easy configuration and convivial experience +

-
-
- -
+
+ +
Education

- A platform for - educational management

+ A platform for educational management +

-
-
- -
+
+ +
Manufacturing

- Plan, track and - schedule your operations

+ Plan, track and schedule your operations +

-
-
+
-
+
E-commerce & Website

- Mobile - friendly, - awe-inspiring product pages

+ Mobile friendly, awe-inspiring product pages +

-
-
+
-
+
Service Management

- Keep track of - services and invoice

+ Keep track of services and invoice +

-
-
- -
+
+ +
Restaurant

- Run your bar or - restaurant methodically

+ Run your bar or restaurant methodically +

-
-
+
-
+
Hotel Management

- An - all-inclusive - hotel management application

+ An all-inclusive hotel management application +

-
- - + @@ -523,32 +460,25 @@

Need Help?

-
+
- -
- + @@ -557,16 +487,14 @@
- +
-
+
-
\ No newline at end of file diff --git a/pos_traceability_validation/static/src/js/PoSEditListPopup.js b/pos_traceability_validation/static/src/js/PoSEditListPopup.js new file mode 100644 index 000000000..99b09baab --- /dev/null +++ b/pos_traceability_validation/static/src/js/PoSEditListPopup.js @@ -0,0 +1,74 @@ +odoo.define('pos_traceability_validation.PoSEditListPopup', function (require) { + 'use strict'; + const EditListPopup = require('point_of_sale.EditListPopup'); + const Registries = require('point_of_sale.Registries'); + const { _lt } = require('@web/core/l10n/translation'); + var rpc = require('web.rpc'); + /** + * Extends EditListPopup for adding functionality for lot/ serial number + * validation + */ + const PoSEditListPopup = (EditListPopup) => + class extends EditListPopup { + constructor() { + super(...arguments); + this.product = this.props.product; + } + /** + * On confirming from the popup after adding lots/ serial numbers, + * the values are passed to the function validate_lots() for the + * validation. The corresponding error messages will be displayed + * on the popup if the lot is invalid or duplicated, or there is + * no insufficient stock. + */ + async confirm() { + if (this.props.title == 'Lot/Serial Number(s) Required') { + var lot_string = this.state.array; + var lot_names = []; + for (var i = 0; i < lot_string.length; i++) { + if (lot_string[i].text != '') { + lot_names.push(lot_string[i].text); + } + } + const picking_type_id = this.env.pos.config && this.env.pos.config.picking_type_id && this.env.pos.config.picking_type_id[0] + const result = await rpc.query({ + model: 'stock.production.lot', + method: 'validate_lots', + args: [lot_names, this.props.product, picking_type_id] + }) + if (result != true) { + if(result[0] == 'no_stock') { + this.showPopup('ErrorPopup', { + 'title': _lt('Out of stock'), + 'body': _lt('The product is out of stock for ' + result[1] + '.') + }); + } else if(result[0] == 'duplicate') { + this.showPopup('ErrorPopup', { + 'title': _lt('Duplicate Serial Number'), + 'body': _lt('Duplicate entry for ' + result[1] + '.') + }); + } else if(result[0] == 'invalid') { + this.showPopup('ErrorPopup', { + 'title': _lt('Invalid Lot/ Serial Number'), + 'body': _lt('The Lot/ Serial Number ' + result[1] + ' is not available for this product.') + }); + } + } else { + this.props.resolve({ + confirmed: true, + payload: await this.getPayload() + }); + this.trigger('close-popup'); + } + } else { + this.props.resolve({ + confirmed: true, + payload: await this.getPayload() + }); + this.trigger('close-popup'); + } + } + }; + Registries.Component.extend(EditListPopup, PoSEditListPopup); + return EditListPopup; +}); diff --git a/pos_traceability_validation/static/src/js/PoSOrderWidget.js b/pos_traceability_validation/static/src/js/PoSOrderWidget.js new file mode 100644 index 000000000..d9282d26e --- /dev/null +++ b/pos_traceability_validation/static/src/js/PoSOrderWidget.js @@ -0,0 +1,37 @@ +odoo.define('pos_traceability_validation.PoSOrderWidget', function (require) { + 'use strict'; + const OrderWidget = require('point_of_sale.OrderWidget'); + const Registries = require('point_of_sale.Registries'); + /** + * Extends OrderWidget for passing the product IDs to the EditListPopup + * validation + */ + const PoSOrderWidget = (OrderWidget) => + class extends OrderWidget { + async _editPackLotLines(event) { + const orderline = event.detail.orderline; + const isAllowOnlyOneLot = orderline.product.isAllowOnlyOneLot(); + const packLotLinesToEdit = orderline.getPackLotLinesToEdit(isAllowOnlyOneLot); + const { confirmed, payload } = await this.showPopup('EditListPopup', { + title: this.env._t('Lot/Serial Number(s) Required'), + isSingleItem: isAllowOnlyOneLot, + array: packLotLinesToEdit, + product: orderline.product.id + }); + if (confirmed) { + // Segregate the old and new packlot lines + const modifiedPackLotLines = Object.fromEntries( + payload.newArray.filter(item => item.id).map(item => [item.id, item.text]) + ); + const newPackLotLines = payload.newArray + .filter(item => !item.id) + .map(item => ({ lot_name: item.text })); + + orderline.setPackLotLines({ modifiedPackLotLines, newPackLotLines }); + } + this.order.select_orderline(event.detail.orderline); + } + } + Registries.Component.extend(OrderWidget, PoSOrderWidget); + return OrderWidget; +}); diff --git a/pos_traceability_validation/static/src/js/PoSProductScreen.js b/pos_traceability_validation/static/src/js/PoSProductScreen.js new file mode 100644 index 000000000..3faa72156 --- /dev/null +++ b/pos_traceability_validation/static/src/js/PoSProductScreen.js @@ -0,0 +1,90 @@ +odoo.define('pos_traceability_validation.PoSProductScreen', function (require) { + 'use strict'; + const ProductScreen = require('point_of_sale.ProductScreen'); + const Registries = require('point_of_sale.Registries'); + /** + * Extends ProductScreen for passing the product ID to the EditListPopup + * validation + */ + const PoSProductScreen = (ProductScreen) => + class extends ProductScreen { + async _getAddProductOptions(product, base_code) { + let price_extra = 0.0; + let draftPackLotLines, weight, description, packLotLinesToEdit; + if (this.env.pos.config.product_configurator && _.some(product.attribute_line_ids, (id) => id in this.env.pos.attributes_by_ptal_id)) { + let attributes = _.map(product.attribute_line_ids, (id) => this.env.pos.attributes_by_ptal_id[id]) + .filter((attr) => attr !== undefined); + let { confirmed, payload } = await this.showPopup('ProductConfiguratorPopup', { + product: product, + attributes: attributes, + }); + if (confirmed) { + description = payload.selected_attributes.join(', '); + price_extra += payload.price_extra; + } else { + return; + } + } + // Gather lot information if required. + if (['serial', 'lot'].includes(product.tracking) && (this.env.pos.picking_type.use_create_lots || this.env.pos.picking_type.use_existing_lots)) { + const isAllowOnlyOneLot = product.isAllowOnlyOneLot(); + if (isAllowOnlyOneLot) { + packLotLinesToEdit = []; + } else { + const orderline = this.currentOrder + .get_orderlines() + .filter(line => !line.get_discount()) + .find(line => line.product.id === product.id); + if (orderline) { + packLotLinesToEdit = orderline.getPackLotLinesToEdit(); + } else { + packLotLinesToEdit = []; + } + } + const { confirmed, payload } = await this.showPopup('EditListPopup', { + title: this.env._t('Lot/Serial Number(s) Required'), + isSingleItem: isAllowOnlyOneLot, + array: packLotLinesToEdit, + product: product.id + }); + if (confirmed) { + // Segregate the old and new packlot lines + const modifiedPackLotLines = Object.fromEntries( + payload.newArray.filter(item => item.id).map(item => [item.id, item.text]) + ); + const newPackLotLines = payload.newArray + .filter(item => !item.id) + .map(item => ({ lot_name: item.text })); + + draftPackLotLines = { modifiedPackLotLines, newPackLotLines }; + } else { + // We don't proceed on adding product. + return; + } + } + // Take the weight if necessary. + if (product.to_weight && this.env.pos.config.iface_electronic_scale) { + // Show the ScaleScreen to weigh the product. + if (this.isScaleAvailable) { + const { confirmed, payload } = await this.showTempScreen('ScaleScreen', { + product, + }); + if (confirmed) { + weight = payload.weight; + } else { + // do not add the product; + return; + } + } else { + await this._onScaleNotAvailable(); + } + } + if (base_code && this.env.pos.db.product_packaging_by_barcode[base_code.code]) { + weight = this.env.pos.db.product_packaging_by_barcode[base_code.code].qty; + } + return { draftPackLotLines, quantity: weight, description, price_extra }; + } + } + Registries.Component.extend(ProductScreen, PoSProductScreen); + return ProductScreen; +}); diff --git a/pos_traceability_validation/static/src/js/pos_models.js b/pos_traceability_validation/static/src/js/pos_models.js deleted file mode 100644 index 041caa851..000000000 --- a/pos_traceability_validation/static/src/js/pos_models.js +++ /dev/null @@ -1,74 +0,0 @@ -odoo.define('pos_traceability_validation.pos_models', function (require) { -"use strict"; - const EditListPopup = require('point_of_sale.EditListPopup'); - const Registries = require('point_of_sale.Registries'); - var rpc = require('web.rpc'); - - const PosEditlistpopup = (EditListPopup) => - class extends EditListPopup { - async confirm() { - - if (this.props.title == 'Lot/Serial Number(s) Required'){ - - var lot_string = this.state.array - var lot_names = []; - for (var i = 0; i < lot_string.length; i++) { - - if (lot_string[i].text != ""){ - lot_names.push(lot_string[i].text); - } - - } - - const result = await rpc.query({ - model: 'serial_no.validation', - method: 'validate_lots', - args: [lot_names] - }) - - if(result != true){ - if(result[0] == 'no_stock'){ - this.showPopup('ErrorPopup', { - 'title': this.env._t('Insufficient stock'), - 'body': this.env._t("Insufficient stock for " + result[1]), - }); - - } - else if(result[0] == 'duplicate'){ - this.showPopup('ErrorPopup', { - 'title': this.env._t('Duplicate entry'), - 'body': this.env._t("Duplicate entry for " + result[1]), - }); - } - else if(result[0] == 'except'){ - alert("Exception occured with " + result[1]) - this.showPopup('ErrorPopup', { - 'title': this.env._t('Exception'), - 'body': this.env._t("Exception occured with" + result[1]), - }); - } - } - else{ - this.props.resolve({ confirmed: true, payload: await this.getPayload() }); - this.trigger('close-popup'); - - } - } - else{ - this.props.resolve({ confirmed: true, payload: await this.getPayload() }); - this.trigger('close-popup'); - } - - } - - }; - - Registries.Component.extend(EditListPopup, PosEditlistpopup); - - return EditListPopup; - - -}); - - -