Skip to content

Commit

Permalink
[MIG] pos_lot_selection: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenminhchien committed Dec 1, 2023
1 parent 273888f commit 5f4f759
Show file tree
Hide file tree
Showing 16 changed files with 247 additions and 121 deletions.
7 changes: 7 additions & 0 deletions pos_lot_selection/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ Authors
* Tecnativa
* Camptocamp

Contributors
------------

- Tecnativa
- Camptocamp
- Nguyen Minh Chien <[email protected]>

Maintainers
-----------

Expand Down
7 changes: 5 additions & 2 deletions pos_lot_selection/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "POS Lot Selection",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Point of Sale",
"author": "Tecnativa, Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
Expand All @@ -13,10 +13,13 @@
"point_of_sale",
],
"assets": {
"point_of_sale.assets": [
"point_of_sale._assets_pos": [
"pos_lot_selection/static/src/js/**/*.js",
"pos_lot_selection/static/src/xml/**/*.xml",
],
"web.assets_tests": [
"pos_lot_selection/static/tests/tours/**/*",
],
},
"application": False,
"installable": True,
Expand Down
4 changes: 2 additions & 2 deletions pos_lot_selection/models/stock_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def get_available_lots_for_pos(self, product_id, company_id):
)

lots = lots.filtered(
lambda l: float_compare(
l.product_qty, 0, precision_digits=l.product_uom_id.rounding
lambda rec: float_compare(
rec.product_qty, 0, precision_digits=rec.product_uom_id.rounding
)
> 0
)
Expand Down
3 changes: 3 additions & 0 deletions pos_lot_selection/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Tecnativa
- Camptocamp
- Nguyen Minh Chien \<<[email protected]>\>
13 changes: 11 additions & 2 deletions pos_lot_selection/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ <h1 class="title">POS Lot Selection</h1>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -415,8 +416,16 @@ <h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<li>Camptocamp</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Tecnativa</li>
<li>Camptocamp</li>
<li>Nguyen Minh Chien &lt;<a class="reference external" href="mailto:chien&#64;trobz.com">chien&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
Expand Down
19 changes: 19 additions & 0 deletions pos_lot_selection/static/src/js/EditListPopup.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** @odoo-module */

/*
Copyright 2022 Camptocamp SA
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
*/
import {EditListPopup} from "@point_of_sale/app/store/select_lot_popup/select_lot_popup";
import {_t} from "@web/core/l10n/translation";
import {patch} from "@web/core/utils/patch";
import {session} from "@web/session";

patch(EditListPopup.prototype, {
setup() {
super.setup(...arguments);
if (this.props.title === _t("Lot/Serial Number(s) Required")) {
this.props.lots = session.lots;
}
},
});
23 changes: 0 additions & 23 deletions pos_lot_selection/static/src/js/EditListPopup.js

This file was deleted.

18 changes: 18 additions & 0 deletions pos_lot_selection/static/src/js/OrderWidget.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @odoo-module */

/*
Copyright 2022 Camptocamp SA
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
*/
import {Orderline} from "@point_of_sale/app/store/models";
import {patch} from "@web/core/utils/patch";
import {session} from "@web/session";

patch(Orderline.prototype, {
async editPackLotLines() {
session.lots = await this.pos.getProductLots(this.product);
const res = await super.editPackLotLines(...arguments);
session.lots = undefined;
return res;
},
});
29 changes: 0 additions & 29 deletions pos_lot_selection/static/src/js/OrderWidget.js

This file was deleted.

20 changes: 20 additions & 0 deletions pos_lot_selection/static/src/js/Product.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** @odoo-module */

/*
Copyright 2022 Camptocamp SA (https://www.camptocamp.com).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
*/
import {Product} from "@point_of_sale/app/store/models";
import {patch} from "@web/core/utils/patch";
import {session} from "@web/session";

patch(Product.prototype, {
async getAddProductOptions(code) {
if (["serial", "lot"].includes(this.tracking)) {
session.lots = await this.pos.getProductLots(this);
}
const res = await super.getAddProductOptions(code);
session.lots = undefined;
return res;
},
});
28 changes: 0 additions & 28 deletions pos_lot_selection/static/src/js/ProductScreen.js

This file was deleted.

25 changes: 25 additions & 0 deletions pos_lot_selection/static/src/js/models.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/** @odoo-module */

/*
Copyright 2022 Camptocamp SA
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
*/

import {PosStore} from "@point_of_sale/app/store/pos_store";
import {patch} from "@web/core/utils/patch";
import {session} from "@web/session";

patch(PosStore.prototype, {
async getProductLots(product) {
try {
return await this.orm.silent.call(
"stock.lot",
"get_available_lots_for_pos",
[product.id, session.user_companies.current_company]
);
} catch (error) {
console.error(error);
return [];
}
},
});
35 changes: 0 additions & 35 deletions pos_lot_selection/static/src/js/models.js

This file was deleted.

67 changes: 67 additions & 0 deletions pos_lot_selection/static/tests/tours/LotSelection.tour.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/** @odoo-module */

import * as Chrome from "@point_of_sale/../tests/tours/helpers/ChromeTourMethods";
import * as ReceiptScreen from "@point_of_sale/../tests/tours/helpers/ReceiptScreenTourMethods";
import * as PaymentScreen from "@point_of_sale/../tests/tours/helpers/PaymentScreenTourMethods";
import * as ProductScreen from "@point_of_sale/../tests/tours/helpers/ProductScreenTourMethods";
import {registry} from "@web/core/registry";

export function selectLotNumber(number) {
return [
{
content: `check lot '${number}'`,
trigger: ".list-line-input:first()",
run: () => {
const lot = $(`datalist option:contains("${number}")`);
if (lot.length === 0) {
throw new Error(`Lot ${number} not found`);
}
},
},
{
content: "set lot input",
trigger: ".list-line-input:first()",
run: "text " + number,
},
{
content: "click validate lot number",
trigger: ".popup .button.confirm",
},
];
}

registry.category("web_tour.tours").add("LotSelectionTour", {
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("ClickLotIconTour", {
test: true,
url: "/pos/ui",
steps: () =>
[
ProductScreen.clickHomeCategory(),
ProductScreen.clickDisplayedProduct("Lot Product 1"),
ProductScreen.enterLotNumber("10120000515"),
ProductScreen.clickLotIcon(),
selectLotNumber("10120000516"),
ProductScreen.clickPayButton(),
PaymentScreen.clickPaymentMethod("Cash"),
PaymentScreen.clickValidate(),
ReceiptScreen.trackingMethodIsLot(),
Chrome.endTour(),
].flat(),
});
1 change: 1 addition & 0 deletions pos_lot_selection/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_frontend
Loading

0 comments on commit 5f4f759

Please sign in to comment.