-
-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] pos_product_expiry: Make it work in Offline mode
- Loading branch information
Showing
8 changed files
with
183 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from . import pos_session | ||
from . import product_product | ||
from . import pos_config | ||
from . import res_config_settings | ||
from . import stock_lot |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2024 Dixmit | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
import pytz | ||
|
||
from odoo import models | ||
|
||
|
||
class StockLot(models.Model): | ||
_inherit = "stock.lot" | ||
|
||
def _get_pos_info(self): | ||
result = super()._get_pos_info() | ||
if self.expiration_date: | ||
timezone = pytz.timezone( | ||
self._context.get("tz") or self.env.user.tz or "UTC" | ||
) | ||
result["expiration_date"] = self.expiration_date.astimezone( | ||
timezone | ||
).isoformat() | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
pos_product_expiry/static/tests/tours/ProductExpiry.tour.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** @odoo-module */ | ||
/* | ||
Copyright 2023 Trobz Consulting | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
*/ | ||
|
||
import * as Chrome from "@point_of_sale/../tests/tours/helpers/ChromeTourMethods"; | ||
import * as ErrorPopup from "@point_of_sale/../tests/tours/helpers/ErrorPopupTourMethods"; | ||
import * as PaymentScreen from "@point_of_sale/../tests/tours/helpers/PaymentScreenTourMethods"; | ||
import * as ProductScreen from "@point_of_sale/../tests/tours/helpers/ProductScreenTourMethods"; | ||
import * as ReceiptScreen from "@point_of_sale/../tests/tours/helpers/ReceiptScreenTourMethods"; | ||
import {registry} from "@web/core/registry"; | ||
import {selectLotNumber} from "@pos_lot_selection/../tests/tours/LotSelection.tour.esm"; | ||
|
||
registry.category("web_tour.tours").add("ProductExpiryNotExpired", { | ||
test: true, | ||
url: "/pos/ui", | ||
steps: () => | ||
[ | ||
ProductScreen.confirmOpeningPopup(), | ||
ProductScreen.clickHomeCategory(), | ||
ProductScreen.clickDisplayedProduct("Lot Product 1"), | ||
selectLotNumber("10120000515"), | ||
ProductScreen.selectedOrderlineHas("Lot Product 1"), | ||
ProductScreen.clickPayButton(), | ||
PaymentScreen.clickPaymentMethod("Cash"), | ||
PaymentScreen.clickValidate(), | ||
ReceiptScreen.trackingMethodIsLot(), | ||
Chrome.endTour(), | ||
].flat(), | ||
}); | ||
|
||
registry.category("web_tour.tours").add("ProductExpiryExpired", { | ||
test: true, | ||
url: "/pos/ui", | ||
steps: () => | ||
[ | ||
ProductScreen.confirmOpeningPopup(), | ||
ProductScreen.clickHomeCategory(), | ||
ProductScreen.clickDisplayedProduct("Lot Product 1"), | ||
selectLotNumber("10120000516"), | ||
ProductScreen.selectedOrderlineHas("Lot Product 1"), | ||
ErrorPopup.isShown(), | ||
ErrorPopup.clickConfirm(), | ||
ProductScreen.pressNumpad("⌫"), | ||
ProductScreen.pressNumpad("⌫"), | ||
// We need to clean the screen | ||
ProductScreen.orderIsEmpty(), | ||
Chrome.endTour(), | ||
].flat(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Copyright 2023 Trobz Consulting | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from datetime import datetime, timedelta | ||
|
||
import odoo.tests | ||
|
||
from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon | ||
|
||
|
||
@odoo.tests.tagged("post_install", "-at_install") | ||
class TestLotScanning(TestPointOfSaleHttpCommon): | ||
@classmethod | ||
def setUpClass(cls, chart_template_ref=None): | ||
super().setUpClass(chart_template_ref=chart_template_ref) | ||
now = datetime.now() | ||
cls.lot_product_1 = cls.env["product.product"].create( | ||
{ | ||
"name": "Lot Product 1", | ||
"type": "product", | ||
"tracking": "lot", | ||
"categ_id": cls.env.ref("product.product_category_all").id, | ||
"available_in_pos": True, | ||
"use_expiration_date": True, | ||
} | ||
) | ||
lots = cls.env["stock.lot"].create( | ||
[ | ||
{ | ||
"name": "10120000515", | ||
"product_id": cls.lot_product_1.id, | ||
"company_id": cls.env.company.id, | ||
"expiration_date": now + timedelta(days=1), | ||
}, | ||
{ | ||
"name": "10120000516", | ||
"product_id": cls.lot_product_1.id, | ||
"company_id": cls.env.company.id, | ||
"expiration_date": now + timedelta(days=-1), | ||
}, | ||
] | ||
) | ||
location_id = cls.main_pos_config.picking_type_id.default_location_src_id.id | ||
cls.env["stock.quant"].with_context(inventory_mode=True).create( | ||
{ | ||
"product_id": cls.lot_product_1.id, | ||
"inventory_quantity": 100, | ||
"location_id": location_id, | ||
"lot_id": lots[0].id, | ||
} | ||
).action_apply_inventory() | ||
cls.env["stock.quant"].with_context(inventory_mode=True).create( | ||
{ | ||
"product_id": cls.lot_product_1.id, | ||
"inventory_quantity": 100, | ||
"location_id": location_id, | ||
"lot_id": lots[1].id, | ||
} | ||
).action_apply_inventory() | ||
|
||
def test_lot_not_expired(self): | ||
self.main_pos_config.with_user(self.pos_user).open_ui() | ||
self.start_tour( | ||
"/pos/ui?config_id=%d" % self.main_pos_config.id, | ||
"ProductExpiryNotExpired", | ||
login="pos_user", | ||
) | ||
|
||
def test_lot_expired(self): | ||
self.main_pos_config.with_user(self.pos_user).open_ui() | ||
self.start_tour( | ||
"/pos/ui?config_id=%d" % self.main_pos_config.id, | ||
"ProductExpiryExpired", | ||
login="pos_user", | ||
) |