diff --git a/pos_traceability_validation/__manifest__.py b/pos_traceability_validation/__manifest__.py index 530d33790..f31cb9d6b 100644 --- a/pos_traceability_validation/__manifest__.py +++ b/pos_traceability_validation/__manifest__.py @@ -35,7 +35,9 @@ 'depends': ['point_of_sale', 'stock'], 'assets': { 'web.assets_backend': [ - 'pos_traceability_validation/static/src/js/pos_models.js', + 'pos_traceability_validation/static/src/js/EditListPopup.js', + 'pos_traceability_validation/static/src/js/OrderWidget.js', + 'pos_traceability_validation/static/src/js/ProductScreen.js', ], }, 'images': ['static/description/banner.jpg'], diff --git a/pos_traceability_validation/doc/RELEASE_NOTES.md b/pos_traceability_validation/doc/RELEASE_NOTES.md index dc360dadf..c9fb8289e 100644 --- a/pos_traceability_validation/doc/RELEASE_NOTES.md +++ b/pos_traceability_validation/doc/RELEASE_NOTES.md @@ -4,3 +4,8 @@ #### Version 16.0.1.0.0 #### ADD - Initial Commit for POS Serial Number Validator + +#### 11.02.2024 +#### Version 16.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 d38fc94e7..66fdfcd11 100644 --- a/pos_traceability_validation/models/__init__.py +++ b/pos_traceability_validation/models/__init__.py @@ -18,4 +18,4 @@ # If not, see . # ############################################################################## -from . import serial_no_validation +from . import stock_lot diff --git a/pos_traceability_validation/models/serial_no_validation.py b/pos_traceability_validation/models/serial_no_validation.py deleted file mode 100644 index 389a95bf4..000000000 --- a/pos_traceability_validation/models/serial_no_validation.py +++ /dev/null @@ -1,42 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Cybrosys Technologies Pvt. Ltd. -# -# Copyright (C) 2023-TODAY Cybrosys Technologies(). -# Author: Jumana Jabin MP() -# 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 api, models - - -class SerialNoValidation(models.Model): - """Serial Number Validation Model.This model is used for serial number - validation in Odoo.""" - _name = 'serial_no.validation' - - @api.model - def validate_lots(self, lots): - """ This method validates a list of lots.""" - processed = [] - LotObj = self.env['stock.lot'] - for lot in lots: - lot_id = LotObj.search([('name', '=', lot)], limit=1) - if lot_id.product_qty > 0 and lot not in processed: - processed.append(lot) - continue - if lot in processed: - return ['duplicate', lot] - return ['no_stock', lot] - return True diff --git a/pos_traceability_validation/models/stock_lot.py b/pos_traceability_validation/models/stock_lot.py new file mode 100644 index 000000000..11de92160 --- /dev/null +++ b/pos_traceability_validation/models/stock_lot.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Jumana Jabin MP() +# 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 api, models + + +class StockLot(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.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/static/description/assets/screenshots/1.png b/pos_traceability_validation/static/description/assets/screenshots/1.png index bd60cc70a..df8095471 100644 Binary files a/pos_traceability_validation/static/description/assets/screenshots/1.png and b/pos_traceability_validation/static/description/assets/screenshots/1.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/10.png b/pos_traceability_validation/static/description/assets/screenshots/10.png new file mode 100644 index 000000000..fe22e7593 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/10.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/11.png b/pos_traceability_validation/static/description/assets/screenshots/11.png new file mode 100644 index 000000000..07aa48e0b Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/11.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/2.png b/pos_traceability_validation/static/description/assets/screenshots/2.png index 5d964d750..769fbb017 100644 Binary files a/pos_traceability_validation/static/description/assets/screenshots/2.png and b/pos_traceability_validation/static/description/assets/screenshots/2.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/3.png b/pos_traceability_validation/static/description/assets/screenshots/3.png index 859b4769a..15cce54ca 100644 Binary files a/pos_traceability_validation/static/description/assets/screenshots/3.png and b/pos_traceability_validation/static/description/assets/screenshots/3.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/4.png b/pos_traceability_validation/static/description/assets/screenshots/4.png index 1020673bf..56c378427 100644 Binary files a/pos_traceability_validation/static/description/assets/screenshots/4.png and b/pos_traceability_validation/static/description/assets/screenshots/4.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/5.png b/pos_traceability_validation/static/description/assets/screenshots/5.png index 1817ad5ae..613af5386 100644 Binary files a/pos_traceability_validation/static/description/assets/screenshots/5.png and b/pos_traceability_validation/static/description/assets/screenshots/5.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/6.png b/pos_traceability_validation/static/description/assets/screenshots/6.png index 620bbcc76..0417c2c09 100644 Binary files a/pos_traceability_validation/static/description/assets/screenshots/6.png and b/pos_traceability_validation/static/description/assets/screenshots/6.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/7.png b/pos_traceability_validation/static/description/assets/screenshots/7.png index 1519b7c48..1a2d197b7 100644 Binary files a/pos_traceability_validation/static/description/assets/screenshots/7.png and b/pos_traceability_validation/static/description/assets/screenshots/7.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/8.png b/pos_traceability_validation/static/description/assets/screenshots/8.png index be3dd16ea..f787d89ca 100644 Binary files a/pos_traceability_validation/static/description/assets/screenshots/8.png and b/pos_traceability_validation/static/description/assets/screenshots/8.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/9.png b/pos_traceability_validation/static/description/assets/screenshots/9.png new file mode 100644 index 000000000..9af2b9c96 Binary files /dev/null and b/pos_traceability_validation/static/description/assets/screenshots/9.png differ diff --git a/pos_traceability_validation/static/description/assets/screenshots/hero.gif b/pos_traceability_validation/static/description/assets/screenshots/hero.gif index a8f601dd9..dab317ce6 100644 Binary files a/pos_traceability_validation/static/description/assets/screenshots/hero.gif and b/pos_traceability_validation/static/description/assets/screenshots/hero.gif differ diff --git a/pos_traceability_validation/static/description/index.html b/pos_traceability_validation/static/description/index.html index c83d336b5..1841f7564 100644 --- a/pos_traceability_validation/static/description/index.html +++ b/pos_traceability_validation/static/description/index.html @@ -1,678 +1,614 @@ -
- -
- -
-
- Community -
-
- Enterprise -
-
- Odoo.sh -
-
-
- -
-
-
-

- POS Serial Number Validator

-

- Validate Serial Number of a Product by Checking - Availability in Stock

- -
-
-
-
- - - - -
-
-

- Overview -

-
- -
-

- This module validates the serial number of a product in - the Point of Sale (POS) by checking its availability in - stock. If the - serial number is not in stock or is a duplicate entry, it - displays an - error message. -

- -
-
-
-
-

- Features -

-
- -
-
- -
-
-

- Community & Enterprise Support

-

- Available in Odoo 16.0 Community and Enterprise.

-
-
-
-
- -
-
-

- Validates given Serial Number is Available in - Stock

-
-
- -
-
- -
-
-

- Prevents Duplicated Entry for more than one - Quantity

-
-
- - -
- -
-
-

- Screenshots -

-
-
-

- - Enable Lot & Serial Number for a Product and Assign Values

- - - -
-
-

- - Add a Product with a Serial Number or Lot Number to the POS Product - Screen.

- - - -
-
-

- - Warnings for invalid Serial Number

- - -
- -
-

- Warnings for Duplicate Serial Number

- - - - -
- - -
- - -
-
-

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 +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+ + + +
+

+ POS Serial Number Validator

+

+ Validate Serial Number of a Product by Checking Availability in Stock

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

+ Explore This Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+

+ This module validates the serial number of a product in the Point of Sale (POS) by checking its availability in + stock. If the serial number is not in stock or is a duplicate entry, it displays an error message. +

+
+
+ + + +
+
+ +
+

+ Features +

+
+
+
+
+ + Community & Enterprise Support +

+ Available in Odoo 16.0 Community and Enterprise.

+
+
+ + Validates given Serial Number is Available in Stock +
+
+ + Prevents Duplicated Entry for more than one Quantity +
+
+
+ + + +
+
+ +
+

+ 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 Lots or Serial Numbers for Products in Stock

+

+ 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.

+ +
+
+

+ The Pop-up will be Displayed to Add the Lot/ Serial Number on Selecting the Products with Traceability.

+ +
+
+

+ Warning for Invalid Lot/ 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 scenario.

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

+ 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

+
+
+
+
+
+
+
+ +
+
+
+ diff --git a/pos_traceability_validation/static/src/js/EditListPopup.js b/pos_traceability_validation/static/src/js/EditListPopup.js new file mode 100644 index 000000000..09efb592c --- /dev/null +++ b/pos_traceability_validation/static/src/js/EditListPopup.js @@ -0,0 +1,77 @@ +odoo.define('pos_traceability_validation.PoSEditListPopup', function (require) { +"use strict"; + const EditListPopup = require('point_of_sale.EditListPopup'); + const Registries = require('point_of_sale.Registries'); + var rpc = require('web.rpc'); + /** + * EditListPopup Override + * + * This module overrides the EditListPopup component in the Point of Sale (POS) module + * to add custom behavior for 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.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': this.env._t('Out of stock'), + 'body': this.env._t("The product is out of 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] == 'invalid'){ + this.showPopup('ErrorPopup', { + 'title': this.env._t('Invalid Lot/ Serial Number'), + 'body': this.env._t("The Lot/ Serial Number " + result[1]+ ' is not available for this product.'), + }); + } + } + else{ + this.env.posbus.trigger('close-popup', { + popupId: this.props.id, + response: { confirmed: true, payload: await this.getPayload() }, + }); + } + } + else{ + this.env.posbus.trigger('close-popup', { + popupId: this.props.id, + response: { confirmed: true, payload: await this.getPayload() }, + }); + } + } + }; + Registries.Component.extend(EditListPopup, PosEditlistpopup); + return EditListPopup; +}); diff --git a/pos_traceability_validation/static/src/js/OrderWidget.js b/pos_traceability_validation/static/src/js/OrderWidget.js new file mode 100644 index 000000000..d9282d26e --- /dev/null +++ b/pos_traceability_validation/static/src/js/OrderWidget.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/ProductScreen.js b/pos_traceability_validation/static/src/js/ProductScreen.js new file mode 100644 index 000000000..3faa72156 --- /dev/null +++ b/pos_traceability_validation/static/src/js/ProductScreen.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 ed87f1934..000000000 --- a/pos_traceability_validation/static/src/js/pos_models.js +++ /dev/null @@ -1,69 +0,0 @@ -odoo.define('pos_traceability_validation.pos_models', function (require) { -"use strict"; - /** - * EditListPopup Override - * - * This module overrides the EditListPopup component in the Point of Sale (POS) module - * to add custom behavior for serial number validation. - */ - 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 { - /** - * Confirm Override - * - * Overrides the base confirm method to handle serial number validation. - * If the title of the popup is 'Lot/Serial Number(s) Required', it validates - * the entered lot numbers using the 'serial_no.validation' model. - */ - 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 occurred with " + result[1]) - this.showPopup('ErrorPopup', { - 'title': this.env._t('Exception'), - 'body': this.env._t("Exception occurred 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; -});