diff --git a/pos_lot_selection/README.rst b/pos_lot_selection/README.rst new file mode 100644 index 0000000000..1841f999b2 --- /dev/null +++ b/pos_lot_selection/README.rst @@ -0,0 +1,85 @@ +================= +POS Lot Selection +================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bbdabf66a65199b6ec3d6b0b42e4b9754b6d93d0ee411f903c3c7c55db2ce777 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github + :target: https://github.com/OCA/pos/tree/14.0/pos_lot_selection + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-14-0/pos-14-0-pos_lot_selection + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to pick between existing lots in POS frontend. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +1. Go to *Inventory > Settings* and set the option *Track lots or serial + numbers* +2. Chose a product that is stockable, go to its *Inventory* + tab, and set *Tracking* to *By Lots*. +3. Go to its *Sales* tab and set it as *Available in the Point of Sale*. +4. Click on *Update Qty On Hand*, chose the same location configured in the + POS you want the lot available in; write a quantity; unfold the *Lot/Serial + Number* field and pick create one if none is available yet. +5. Create a new lot with the serial number of your choice. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa +* Camptocamp + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/pos `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_lot_selection/__init__.py b/pos_lot_selection/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_lot_selection/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_lot_selection/__manifest__.py b/pos_lot_selection/__manifest__.py new file mode 100644 index 0000000000..20905c33aa --- /dev/null +++ b/pos_lot_selection/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2018 Tecnativa S.L. - David Vidal +# Copyright 2022 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "POS Lot Selection", + "version": "14.0.1.0.0", + "category": "Point of Sale", + "author": "Tecnativa, Camptocamp, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/pos", + "license": "AGPL-3", + "depends": [ + "point_of_sale", + ], + "data": ["templates/assets.xml"], + "qweb": ["static/src/xml/LotSelectorPopup.xml"], + "application": False, + "installable": True, +} diff --git a/pos_lot_selection/i18n/es.po b/pos_lot_selection/i18n/es.po new file mode 100644 index 0000000000..a98baf006f --- /dev/null +++ b/pos_lot_selection/i18n/es.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_lot_selection +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-07-11 09:09+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: pos_lot_selection +#: model:ir.model,name:pos_lot_selection.model_stock_production_lot +msgid "Lot/Serial" +msgstr "Lote/Serie" + +#. module: pos_lot_selection +#. openerp-web +#: code:addons/pos_lot_selection/static/src/js/EditListPopup.js:0 +#, python-format +msgid "Lot/Serial Number(s) Required" +msgstr "NĂºmero(s) de lote/serie obligatorio(s)" + +#. module: pos_lot_selection +#. openerp-web +#: code:addons/pos_lot_selection/static/src/xml/LotSelectorPopup.xml:0 +#, python-format +msgid "prepared_lots" +msgstr "lotes_preparados" + +#. module: pos_lot_selection +#. openerp-web +#: code:addons/pos_lot_selection/static/src/xml/LotSelectorPopup.xml:0 +#, python-format +msgid "props.lots" +msgstr "puntales.lotes" diff --git a/pos_lot_selection/i18n/it.po b/pos_lot_selection/i18n/it.po new file mode 100644 index 0000000000..a1d9db61dc --- /dev/null +++ b/pos_lot_selection/i18n/it.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_lot_selection +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-24 17:34+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: pos_lot_selection +#: model:ir.model,name:pos_lot_selection.model_stock_production_lot +msgid "Lot/Serial" +msgstr "Lotto/seriale" + +#. module: pos_lot_selection +#. openerp-web +#: code:addons/pos_lot_selection/static/src/js/EditListPopup.js:0 +#, python-format +msgid "Lot/Serial Number(s) Required" +msgstr "Richiesto numero(i) di lotto/serie" + +#. module: pos_lot_selection +#. openerp-web +#: code:addons/pos_lot_selection/static/src/xml/LotSelectorPopup.xml:0 +#, python-format +msgid "prepared_lots" +msgstr "prepared_lots" + +#. module: pos_lot_selection +#. openerp-web +#: code:addons/pos_lot_selection/static/src/xml/LotSelectorPopup.xml:0 +#, python-format +msgid "props.lots" +msgstr "props.lots" diff --git a/pos_lot_selection/i18n/pos_lot_selection.pot b/pos_lot_selection/i18n/pos_lot_selection.pot new file mode 100644 index 0000000000..92730f1440 --- /dev/null +++ b/pos_lot_selection/i18n/pos_lot_selection.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_lot_selection +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_lot_selection +#: model:ir.model,name:pos_lot_selection.model_stock_production_lot +msgid "Lot/Serial" +msgstr "" + +#. module: pos_lot_selection +#. openerp-web +#: code:addons/pos_lot_selection/static/src/js/EditListPopup.js:0 +#, python-format +msgid "Lot/Serial Number(s) Required" +msgstr "" + +#. module: pos_lot_selection +#. openerp-web +#: code:addons/pos_lot_selection/static/src/xml/LotSelectorPopup.xml:0 +#, python-format +msgid "prepared_lots" +msgstr "" + +#. module: pos_lot_selection +#. openerp-web +#: code:addons/pos_lot_selection/static/src/xml/LotSelectorPopup.xml:0 +#, python-format +msgid "props.lots" +msgstr "" diff --git a/pos_lot_selection/models/__init__.py b/pos_lot_selection/models/__init__.py new file mode 100644 index 0000000000..dd885b7bed --- /dev/null +++ b/pos_lot_selection/models/__init__.py @@ -0,0 +1 @@ +from . import stock_production_lot diff --git a/pos_lot_selection/models/stock_production_lot.py b/pos_lot_selection/models/stock_production_lot.py new file mode 100644 index 0000000000..e0f5c8fbf0 --- /dev/null +++ b/pos_lot_selection/models/stock_production_lot.py @@ -0,0 +1,30 @@ +# Copyright 2022 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) + +from odoo import api, models +from odoo.tools import float_compare + + +class ProductionLot(models.Model): + _inherit = "stock.production.lot" + + @api.model + def get_available_lots_for_pos(self, product_id, company_id): + lots = self.sudo().search( + [ + "&", + ["product_id", "=", product_id], + "|", + ["company_id", "=", company_id], + ["company_id", "=", False], + ] + ) + + lots = lots.filtered( + lambda l: float_compare( + l.product_qty, 0, precision_rounding=l.product_uom_id.rounding + ) + > 0 + ) + + return lots.mapped("name") diff --git a/pos_lot_selection/readme/DESCRIPTION.rst b/pos_lot_selection/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..d0ba2750b2 --- /dev/null +++ b/pos_lot_selection/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to pick between existing lots in POS frontend. diff --git a/pos_lot_selection/readme/USAGE.rst b/pos_lot_selection/readme/USAGE.rst new file mode 100644 index 0000000000..cb7c7509fa --- /dev/null +++ b/pos_lot_selection/readme/USAGE.rst @@ -0,0 +1,9 @@ +1. Go to *Inventory > Settings* and set the option *Track lots or serial + numbers* +2. Chose a product that is stockable, go to its *Inventory* + tab, and set *Tracking* to *By Lots*. +3. Go to its *Sales* tab and set it as *Available in the Point of Sale*. +4. Click on *Update Qty On Hand*, chose the same location configured in the + POS you want the lot available in; write a quantity; unfold the *Lot/Serial + Number* field and pick create one if none is available yet. +5. Create a new lot with the serial number of your choice. diff --git a/pos_lot_selection/static/description/icon.png b/pos_lot_selection/static/description/icon.png new file mode 100644 index 0000000000..ca2e8601cc Binary files /dev/null and b/pos_lot_selection/static/description/icon.png differ diff --git a/pos_lot_selection/static/description/index.html b/pos_lot_selection/static/description/index.html new file mode 100644 index 0000000000..aabc1463e8 --- /dev/null +++ b/pos_lot_selection/static/description/index.html @@ -0,0 +1,429 @@ + + + + + +POS Lot Selection + + + +
+

POS Lot Selection

+ + +

Beta License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

+

This module allows to pick between existing lots in POS frontend.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Inventory > Settings and set the option Track lots or serial +numbers
  2. +
  3. Chose a product that is stockable, go to its Inventory +tab, and set Tracking to By Lots.
  4. +
  5. Go to its Sales tab and set it as Available in the Point of Sale.
  6. +
  7. Click on Update Qty On Hand, chose the same location configured in the +POS you want the lot available in; write a quantity; unfold the Lot/Serial +Number field and pick create one if none is available yet.
  8. +
  9. Create a new lot with the serial number of your choice.
  10. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
  • Camptocamp
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/pos project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/pos_lot_selection/static/src/js/EditListPopup.js b/pos_lot_selection/static/src/js/EditListPopup.js new file mode 100644 index 0000000000..8f9959bbc2 --- /dev/null +++ b/pos_lot_selection/static/src/js/EditListPopup.js @@ -0,0 +1,23 @@ +/* + Copyright 2022 Camptocamp SA + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +*/ +odoo.define("pos_lot_selection.EditListPopup", function (require) { + "use strict"; + + const EditListPopup = require("point_of_sale.EditListPopup"); + const Registries = require("point_of_sale.Registries"); + + const LotSelectEditListPopup = (EditListPopup) => + class extends EditListPopup { + constructor() { + super(...arguments); + if (this.props.title === this.env._t("Lot/Serial Number(s) Required")) { + this.props.lots = this.env.session.lots; + } + } + }; + + Registries.Component.extend(EditListPopup, LotSelectEditListPopup); + return EditListPopup; +}); diff --git a/pos_lot_selection/static/src/js/OrderWidget.js b/pos_lot_selection/static/src/js/OrderWidget.js new file mode 100644 index 0000000000..bcb65a5337 --- /dev/null +++ b/pos_lot_selection/static/src/js/OrderWidget.js @@ -0,0 +1,29 @@ +/* + Copyright 2022 Camptocamp SA + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +*/ +odoo.define("pos_lot_selection.CustomOrderWidget", function (require) { + "use strict"; + + const Registries = require("point_of_sale.Registries"); + const OrderWidget = require("point_of_sale.OrderWidget"); + + const CustomOrderWidget = (OrderWidget) => + class extends OrderWidget { + /** + * @override + */ + async _editPackLotLines(event) { + const orderline = event.detail.orderline; + this.env.session.lots = await this.env.pos.getProductLots( + orderline.product + ); + const res = await super._editPackLotLines(...arguments); + this.env.session.lots = undefined; + return res; + } + }; + + Registries.Component.extend(OrderWidget, CustomOrderWidget); + return OrderWidget; +}); diff --git a/pos_lot_selection/static/src/js/ProductScreen.js b/pos_lot_selection/static/src/js/ProductScreen.js new file mode 100644 index 0000000000..434475d4f8 --- /dev/null +++ b/pos_lot_selection/static/src/js/ProductScreen.js @@ -0,0 +1,28 @@ +/* + Copyright 2022 Camptocamp SA (https://www.camptocamp.com). + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +*/ +odoo.define("pos_lot_selection.ProductScreen", function (require) { + "use strict"; + + const ProductScreen = require("point_of_sale.ProductScreen"); + const Registries = require("point_of_sale.Registries"); + + const PosLotSaleProductScreen = (ProductScreen) => + class extends ProductScreen { + /** + * @override + */ + async _getAddProductOptions(product) { + if (["serial", "lot"].includes(product.tracking)) { + this.env.session.lots = await this.env.pos.getProductLots(product); + } + const res = await super._getAddProductOptions(...arguments); + this.env.session.lots = undefined; + return res; + } + }; + + Registries.Component.extend(ProductScreen, PosLotSaleProductScreen); + return ProductScreen; +}); diff --git a/pos_lot_selection/static/src/js/models.js b/pos_lot_selection/static/src/js/models.js new file mode 100644 index 0000000000..baa8a3ef24 --- /dev/null +++ b/pos_lot_selection/static/src/js/models.js @@ -0,0 +1,32 @@ +/* + Copyright 2022 Camptocamp SA + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +*/ +odoo.define("pos_lot_selection.models", function (require) { + "use strict"; + + const models = require("point_of_sale.models"); + + models.PosModel = models.PosModel.extend({ + async getProductLots(product) { + try { + return await this.rpc( + { + model: "stock.production.lot", + method: "get_available_lots_for_pos", + kwargs: { + product_id: product.id, + company_id: this.env.session.company_id, + }, + }, + {shadow: true} + ); + } catch (error) { + console.error(error); + return []; + } + }, + }); + + return models; +}); diff --git a/pos_lot_selection/static/src/xml/LotSelectorPopup.xml b/pos_lot_selection/static/src/xml/LotSelectorPopup.xml new file mode 100644 index 0000000000..9e3322fed5 --- /dev/null +++ b/pos_lot_selection/static/src/xml/LotSelectorPopup.xml @@ -0,0 +1,32 @@ + + + + + + + props.lots + + + + + + prepared_lots + + + + + + + + + + + diff --git a/pos_lot_selection/templates/assets.xml b/pos_lot_selection/templates/assets.xml new file mode 100644 index 0000000000..c4a12e7f1b --- /dev/null +++ b/pos_lot_selection/templates/assets.xml @@ -0,0 +1,25 @@ + + + +