From e5ef2b0f3a39f3873300d694d11c7944eb2d2c9e Mon Sep 17 00:00:00 2001 From: FrankC013 Date: Thu, 15 Feb 2024 11:49:55 +0100 Subject: [PATCH 1/5] [ADD] stock_barcodes_serial_source_relocation: new module --- .../README.rst | 64 +++ .../__init__.py | 4 + .../__manifest__.py | 17 + .../models/__init__.py | 4 + .../models/stock_inventory.py | 16 + .../models/stock_move_line.py | 11 + .../models/stock_picking.py | 165 +++++++ .../models/stock_picking_type.py | 37 ++ .../readme/CONTRIBUTORS.rst | 4 + .../readme/DESCRIPTION.rst | 1 + .../static/description/icon.png | Bin 0 -> 6342 bytes .../static/description/index.html | 421 ++++++++++++++++++ .../views/stock_picking_type_views.xml | 17 + .../wizard/__init__.py | 1 + .../wizard/stock_barcodes_read_picking.py | 20 + 15 files changed, 782 insertions(+) create mode 100644 stock_barcodes_serial_source_relocation/README.rst create mode 100644 stock_barcodes_serial_source_relocation/__init__.py create mode 100644 stock_barcodes_serial_source_relocation/__manifest__.py create mode 100644 stock_barcodes_serial_source_relocation/models/__init__.py create mode 100644 stock_barcodes_serial_source_relocation/models/stock_inventory.py create mode 100644 stock_barcodes_serial_source_relocation/models/stock_move_line.py create mode 100644 stock_barcodes_serial_source_relocation/models/stock_picking.py create mode 100644 stock_barcodes_serial_source_relocation/models/stock_picking_type.py create mode 100644 stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.rst create mode 100644 stock_barcodes_serial_source_relocation/readme/DESCRIPTION.rst create mode 100644 stock_barcodes_serial_source_relocation/static/description/icon.png create mode 100644 stock_barcodes_serial_source_relocation/static/description/index.html create mode 100644 stock_barcodes_serial_source_relocation/views/stock_picking_type_views.xml create mode 100644 stock_barcodes_serial_source_relocation/wizard/__init__.py create mode 100644 stock_barcodes_serial_source_relocation/wizard/stock_barcodes_read_picking.py diff --git a/stock_barcodes_serial_source_relocation/README.rst b/stock_barcodes_serial_source_relocation/README.rst new file mode 100644 index 000000000..9b29a2f9c --- /dev/null +++ b/stock_barcodes_serial_source_relocation/README.rst @@ -0,0 +1,64 @@ +======================================= +Stock Barcodes Serial Source Relocation +======================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:2e5788fe8cb1bd9f1a4f43a27cbc9fa24c9d1b1546cb88e7082e499b42aab687 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-NuoBiT%2Fodoo--addons-lightgray.png?logo=github + :target: https://github.com/NuoBiT/odoo-addons/tree/14.0/stock_barcodes_serial_source_relocation + :alt: NuoBiT/odoo-addons + +|badge1| |badge2| |badge3| + +Allow to always have quantities available when entering a serial product from the barcodes module. + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* NuoBiT Solutions +* S.L. + +Contributors +~~~~~~~~~~~~ + +* `NuoBiT `_: + + * Frank Cespedes + * Eric Antones + +Maintainers +~~~~~~~~~~~ + +This module is part of the `NuoBiT/odoo-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/stock_barcodes_serial_source_relocation/__init__.py b/stock_barcodes_serial_source_relocation/__init__.py new file mode 100644 index 000000000..a7faefa57 --- /dev/null +++ b/stock_barcodes_serial_source_relocation/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from . import models +from . import wizard diff --git a/stock_barcodes_serial_source_relocation/__manifest__.py b/stock_barcodes_serial_source_relocation/__manifest__.py new file mode 100644 index 000000000..6a8f479fd --- /dev/null +++ b/stock_barcodes_serial_source_relocation/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright NuoBiT Solutions, S.L. () +# Eric Antones +# Frank Cespedes +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +{ + "name": "Stock Barcodes Serial Source Relocation", + "summary": "Allow to always have quantities available when entering a serial " + "product from the barcodes module.", + "version": "14.0.1.0.0", + "author": "NuoBiT Solutions, S.L.", + "website": "https://github.com/nuobit/odoo-addons", + "category": "Extra Tools", + "depends": ["stock_barcodes"], + "data": ["views/stock_picking_type_views.xml"], + "license": "AGPL-3", +} diff --git a/stock_barcodes_serial_source_relocation/models/__init__.py b/stock_barcodes_serial_source_relocation/models/__init__.py new file mode 100644 index 000000000..cf209eb3f --- /dev/null +++ b/stock_barcodes_serial_source_relocation/models/__init__.py @@ -0,0 +1,4 @@ +from . import stock_picking_type +from . import stock_inventory +from . import stock_picking +from . import stock_move_line diff --git a/stock_barcodes_serial_source_relocation/models/stock_inventory.py b/stock_barcodes_serial_source_relocation/models/stock_inventory.py new file mode 100644 index 000000000..33adf7c86 --- /dev/null +++ b/stock_barcodes_serial_source_relocation/models/stock_inventory.py @@ -0,0 +1,16 @@ +# Copyright NuoBiT Solutions - Frank Cespedes +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import models + + +class InventoryLine(models.Model): + _inherit = "stock.inventory.line" + + def _get_move_values(self, qty, location_id, location_dest_id, out): + values = super()._get_move_values(qty, location_id, location_dest_id, out) + origin = self.env.context.get("relocation_origin", False) + if origin: + values["origin"] = origin + values["move_line_ids"][0][2]["origin"] = origin + return values diff --git a/stock_barcodes_serial_source_relocation/models/stock_move_line.py b/stock_barcodes_serial_source_relocation/models/stock_move_line.py new file mode 100644 index 000000000..ff178e434 --- /dev/null +++ b/stock_barcodes_serial_source_relocation/models/stock_move_line.py @@ -0,0 +1,11 @@ +# Copyright NuoBiT Solutions - Eric Antones +# Copyright NuoBiT Solutions - Frank Cespedes +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import fields, models + + +class StockMoveLine(models.Model): + _inherit = "stock.move.line" + + barcode_relocation_scanned = fields.Boolean(default=False, copy=False) diff --git a/stock_barcodes_serial_source_relocation/models/stock_picking.py b/stock_barcodes_serial_source_relocation/models/stock_picking.py new file mode 100644 index 000000000..6cef817cf --- /dev/null +++ b/stock_barcodes_serial_source_relocation/models/stock_picking.py @@ -0,0 +1,165 @@ +# Copyright NuoBiT Solutions - Eric Antones +# Copyright NuoBiT Solutions - Frank Cespedes +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import _, models +from odoo.exceptions import ValidationError +from odoo.tools import float_compare + + +class Picking(models.Model): + _inherit = "stock.picking" + + def _prepare_relocation_move_line_values(self, move_line, new_picking, quant): + return { + "picking_id": new_picking.id, + "product_id": move_line.product_id.id, + "origin": self.name, + "product_uom_id": move_line.product_id.uom_id.id, + "qty_done": quant.quantity, + "location_id": quant.location_id.id, + "location_dest_id": move_line.location_id.id, + "lot_id": move_line.lot_id.id, + } + + def _prepare_relocation_move_values(self, move_line, quant): + return { + "name": self.name, + "origin": self.name, + "company_id": self.company_id.id, + "product_id": move_line.product_id.id, + "product_uom": move_line.product_id.uom_id.id, + "product_uom_qty": quant.quantity, + "quantity_done": quant.quantity, + "location_id": quant.location_id.id, + "location_dest_id": move_line.location_id.id, + } + + def _prepare_relocation_picking_values(self, move_line, new_picking_type, quant): + return { + "picking_type_id": new_picking_type.id, + "location_id": quant.location_id.id, + "location_dest_id": move_line.location_id.id, + "origin": move_line.picking_id.name, + "company_id": move_line.company_id.id, + "move_lines": [ + ( + 0, + 0, + self._prepare_relocation_move_values(move_line, quant), + ) + ], + } + + def _prepare_relocation_inventory_line_values(self, move_line): + return { + "location_id": move_line.location_id.id, + "product_id": move_line.product_id.id, + "product_uom_id": move_line.product_id.uom_id.id, + "product_qty": 1, + "prod_lot_id": move_line.lot_id.id, + "company_id": self.company_id.id, + } + + def _prepare_relocation_inventory_values(self, move_line): + return { + "name": "Regularization by relocation", + "product_ids": [(6, 0, move_line.product_id.ids)], + "location_ids": [(6, 0, move_line.location_id.ids)], + "exhausted": True, + "line_ids": [ + ( + 0, + 0, + self._prepare_relocation_inventory_line_values(move_line), + ) + ], + } + + def button_validate(self): + if ( + self.picking_type_code != "incoming" + and not self.picking_type_id.barcode_option_group_id.allow_negative_quant + ): + for move_line in self.move_line_ids.filtered( + lambda x: x.product_id.tracking == "serial" + and x.barcode_relocation_scanned + and x.lot_id + ): + quants = move_line.lot_id.quant_ids.filtered( + lambda q: float_compare( + q.quantity, + 0, + precision_rounding=move_line.product_id.uom_id.rounding, + ) + > 0 + ) + if len(quants) > 1: + raise ValidationError( + _( + "S/N %s is found in more than one location." + % move_line.lot_id.name + ) + ) + if quants: + qty_available = quants.filtered( + lambda x: x.location_id == move_line.location_id + ).quantity + if ( + float_compare( + move_line.qty_done, + qty_available, + precision_rounding=move_line.product_id.uom_id.rounding, + ) + > 0 + ): + warehouse = move_line.location_id.get_warehouse() + picking_type = ( + self.env["stock.picking.type"] + .search( + [ + ("warehouse_id", "in", (warehouse.id, False)), + ("code", "=", "internal"), + ("is_regularization", "=", True), + ], + ) + .sorted(lambda x: x.warehouse_id, reverse=True) + ) + warehouse_ids = [pt.warehouse_id.id for pt in picking_type] + if len(warehouse_ids) != len(set(warehouse_ids)): + raise ValidationError( + _( + "More than one regularization picking " + "type for the same warehouse %s" + % move_line.location_id.name + ) + ) + if not picking_type: + raise ValidationError( + _( + "No regularization picking type for location %s" + % move_line.location_id.name + ) + ) + new_picking = self.env["stock.picking"].create( + self._prepare_relocation_picking_values( + move_line, picking_type[0], quants + ) + ) + new_picking.action_confirm() + for move in new_picking.move_lines: + move.move_line_ids.write( + self._prepare_relocation_move_line_values( + move_line, new_picking, quants + ) + ) + new_picking.button_validate() + else: + inventory = self.env["stock.inventory"].create( + self._prepare_relocation_inventory_values(move_line) + ) + inventory._action_start() + inventory.with_context( + relocation_origin=self.name + ).action_validate() + return super().button_validate() diff --git a/stock_barcodes_serial_source_relocation/models/stock_picking_type.py b/stock_barcodes_serial_source_relocation/models/stock_picking_type.py new file mode 100644 index 000000000..1f4db0cc4 --- /dev/null +++ b/stock_barcodes_serial_source_relocation/models/stock_picking_type.py @@ -0,0 +1,37 @@ +# Copyright NuoBiT Solutions - Frank Cespedes +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class PickingType(models.Model): + _inherit = "stock.picking.type" + + is_regularization = fields.Boolean(copy=False) + + @api.constrains("is_regularization", "code", "warehouse_id", "company_id") + def _check_is_regularization(self): + for rec in self: + if rec.is_regularization: + if rec.code != "internal": + raise ValidationError( + _("Only internal picking types can be regularization."), + ) + if ( + rec.env["stock.picking.type"].search_count( + [ + ("is_regularization", "=", True), + ("warehouse_id", "=", rec.warehouse_id.id), + ("code", "=", rec.code), + ("company_id", "=", rec.company_id.id), + ] + ) + > 1 + ): + raise ValidationError( + _( + "Only one picking type can be regularization in a warehouse %s." + ) + % rec.warehouse_id.name, + ) diff --git a/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.rst b/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..b5c0d2df9 --- /dev/null +++ b/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `NuoBiT `_: + + * Frank Cespedes + * Eric Antones diff --git a/stock_barcodes_serial_source_relocation/readme/DESCRIPTION.rst b/stock_barcodes_serial_source_relocation/readme/DESCRIPTION.rst new file mode 100644 index 000000000..8e6014d8f --- /dev/null +++ b/stock_barcodes_serial_source_relocation/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Allow to always have quantities available when entering a serial product from the barcodes module. diff --git a/stock_barcodes_serial_source_relocation/static/description/icon.png b/stock_barcodes_serial_source_relocation/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1cd641e792c30455187ca30940bc0f329ce8bbb0 GIT binary patch literal 6342 zcmd^^hf`C}*TzHWpfm-MZa|7OjYtjE(4`3pP0Eid3J8V{0s)mKJ<q zp^9|rp$mb~2}po9-@oIXJG(oxcjoS%d!O@s&d!Z9HP*e##KQyt0IurmK_64bp8pyH z9i^|ds>-JfbWVo4P{8GX*QeIfbjl2)kDfIG0ALvZuTgp2ZfK=U();NfY11z-vM>r= zo6RyI007+P`cO@apy}VqnaiVCLL`CEUGVGYE&5WpdhhbZv%|*-Y|2t(4~Cq|y`-Nmm-W zxaTf4+R69rVU1b%qjm?yu*PFgHFYd#J82-D8cpXqO&omwG2*Hd6ZIUiK@+ zNCo8Lg{1^vn^0ZQgz*~*ZR3wsULxnnSBN%7p()3EYs>sX9In)T{*nJ2q*qxXPNhFk z=z=+?4VOOdAF!ZYAVisYzF29g?udLQJtx@=HoAK_Kjx;4SO7>H_v*McB7(}RHMa> z+PNao{Hw&Mjo0P}CBR&l(k@iIeRI@PRH6R9^lR3e?TL?ZHra#GHvKmkeVBHG8nv4{ zz$nHGR7`D$ae@TrcXCSA=$~Yvp@J|bKul>6s-`yT7>JaM5?KcltZ)(ilt^74fqLA{ z1k!bKw(GMV*AOgI*glG_($h!cZgArkEAa1SkSG`0yF8JLWTq^J->2CRaqKH1ZSQt7 z29|+OBS3Rj91K1XL~_9&zn1p z)2Ez)&{9Of1X#b+mpgJ`{gurrlYqKrwrWXTOH{M%kEUhcgSp1J2FK4FF`JS|NfaAA6)?-&1}B`@lI2~kKWK) zhQ|}GQ$j(rNS}9?Yu9}MzWxz*HMwR=u8$RYY6sr2pu3x5Yx*P!Z&c|X zFZcC{+kqJV=XTZH=cMb6)MtgWo%C~XU8TEXDKx9;0hEV*74Z6i8v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av9ZLIhbS&|=U$t!9iq*i5vy)(RsBw0TU#?~zdTKUXjyIl z%7Q)Vp}YoU$acz-9y_`%Oig!%TPyC=ie3*Qut3@4V`+A4d<*f%jOx>*bX%#Ao+@wM z;NW0DZKvmp%_oxvFw2#S9r8Sc?wXh}`3gVG`rBKr&jpxwTRQ7WtKY06QQVhs$u$!e zs;Y%~2xwpH*9vxfQ~q#gAwn+P+=YE(L>|P(Fl&H27@?);kUI4FW%LjHZKYGk#f~@3 zXW;a;3+{&c`g+uCR+``$V9)N#RBCk_#RQ(K-PxlQ7Ym;XdCqGn$j%JmAwgtkWKn1} z8^>3&)Q05VbBm+t`9B_${w9F7WfM{Jvawk;HDc*{Sa_Sla|zqX!vbKV%>gB|z6BCc z8_bdnPnzloGP1I)!^5hnC6CLZUU`;nO2NF2)FaAkYhQL$Z58+`p75dj7RKse#Z!uacCm z0@|m~U!QZOdb|V~`ktFK4;lg_ZOCjFXeV4`jGj&bh7Q6BEyN8~yGd*JyzwFbIRaAf z#KG$rvQxWFvqwn`i6jBQ?6o+k+oOC)Gj9ChlgabiScr};b5|opxUYjCZOwmhjTj6W zFzJt_htTuopW4IRiQ}r0L}`w=pE{HN<@(9Hl11P5cHmN6A1F^sg2OWXcw<+q2x>I5 zq9Bu>PBob6#^vrr<|IC)m+zJpFRRcCVsqbspNybriu&!R=H^@RcG#aBGz9RH}ZI=>4 zi(m?IA?Vr$Q7?wN6ZW7H`S?3}K8=$7J5MjWKri=_igw1%J?0~*6e_Ii*1&23dGcF} z&=vaMgF!^veGQ1f$3k?WK5Jaw%==+Bb!tI6zQ68&-dQ3Orl+Tqh#Nt?dBEV_w^wkjY+qJ+X*NCMs%J-Lc4%}pKryM#O)O&9 un*HHVB-AlUN`suyDkKONktc!@Ievk;6wT20MOSqhE{1gM*SZGeqiYU literal 0 HcmV?d00001 diff --git a/stock_barcodes_serial_source_relocation/static/description/index.html b/stock_barcodes_serial_source_relocation/static/description/index.html new file mode 100644 index 000000000..947af890c --- /dev/null +++ b/stock_barcodes_serial_source_relocation/static/description/index.html @@ -0,0 +1,421 @@ + + + + + + +Stock Barcodes Serial Source Relocation + + + +
+

Stock Barcodes Serial Source Relocation

+ + +

Beta License: AGPL-3 NuoBiT/odoo-addons

+

Allow to always have quantities available when entering a serial product from the barcodes module.

+

Table of contents

+ +
+

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

+
    +
  • NuoBiT Solutions
  • +
  • S.L.
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the NuoBiT/odoo-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/stock_barcodes_serial_source_relocation/views/stock_picking_type_views.xml b/stock_barcodes_serial_source_relocation/views/stock_picking_type_views.xml new file mode 100644 index 000000000..7795804c1 --- /dev/null +++ b/stock_barcodes_serial_source_relocation/views/stock_picking_type_views.xml @@ -0,0 +1,17 @@ + + + + + stock.picking.type + + + + + + + + diff --git a/stock_barcodes_serial_source_relocation/wizard/__init__.py b/stock_barcodes_serial_source_relocation/wizard/__init__.py new file mode 100644 index 000000000..63d37ec49 --- /dev/null +++ b/stock_barcodes_serial_source_relocation/wizard/__init__.py @@ -0,0 +1 @@ +from . import stock_barcodes_read_picking diff --git a/stock_barcodes_serial_source_relocation/wizard/stock_barcodes_read_picking.py b/stock_barcodes_serial_source_relocation/wizard/stock_barcodes_read_picking.py new file mode 100644 index 000000000..4892ab675 --- /dev/null +++ b/stock_barcodes_serial_source_relocation/wizard/stock_barcodes_read_picking.py @@ -0,0 +1,20 @@ +# Copyright NuoBiT Solutions - Eric Antones +# Copyright NuoBiT Solutions - Frank Cespedes +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import models + + +class WizStockBarcodesReadPicking(models.TransientModel): + _inherit = "wiz.stock.barcodes.read.picking" + + def check_done_conditions(self): + if self.product_id.tracking == "serial": + self = self.with_context(force_create_move=True) + return super(WizStockBarcodesReadPicking, self).check_done_conditions() + + def _prepare_move_line_values(self, candidate_move, available_qty): + vals = super()._prepare_move_line_values(candidate_move, available_qty) + if self.product_id.tracking == "serial": + vals["barcode_relocation_scanned"] = True + return vals From 084fc2e64dde0a7d13ac89bee954e807ef8110bd Mon Sep 17 00:00:00 2001 From: FrankC013 Date: Fri, 12 Apr 2024 14:02:00 +0200 Subject: [PATCH 2/5] [FIX] stock_barcodes_serial_source_relocation: avoid duplicate creation of moves lines --- .../models/__init__.py | 1 + .../models/stock_location.py | 13 +++++++++++++ .../models/stock_picking.py | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 stock_barcodes_serial_source_relocation/models/stock_location.py diff --git a/stock_barcodes_serial_source_relocation/models/__init__.py b/stock_barcodes_serial_source_relocation/models/__init__.py index cf209eb3f..b438dc971 100644 --- a/stock_barcodes_serial_source_relocation/models/__init__.py +++ b/stock_barcodes_serial_source_relocation/models/__init__.py @@ -2,3 +2,4 @@ from . import stock_inventory from . import stock_picking from . import stock_move_line +from . import stock_location diff --git a/stock_barcodes_serial_source_relocation/models/stock_location.py b/stock_barcodes_serial_source_relocation/models/stock_location.py new file mode 100644 index 000000000..d52faa6cd --- /dev/null +++ b/stock_barcodes_serial_source_relocation/models/stock_location.py @@ -0,0 +1,13 @@ +# Copyright NuoBiT Solutions - Frank Cespedes +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import models + + +class Location(models.Model): + _inherit = "stock.location" + + def should_bypass_reservation(self): + if self.env.context.get("relocation"): + return False + return super().should_bypass_reservation() diff --git a/stock_barcodes_serial_source_relocation/models/stock_picking.py b/stock_barcodes_serial_source_relocation/models/stock_picking.py index 6cef817cf..847123128 100644 --- a/stock_barcodes_serial_source_relocation/models/stock_picking.py +++ b/stock_barcodes_serial_source_relocation/models/stock_picking.py @@ -146,7 +146,7 @@ def button_validate(self): move_line, picking_type[0], quants ) ) - new_picking.action_confirm() + new_picking.with_context(relocation=self.name).action_confirm() for move in new_picking.move_lines: move.move_line_ids.write( self._prepare_relocation_move_line_values( From 22c0c9a5ff4e58356c43777a70baecf83d643e08 Mon Sep 17 00:00:00 2001 From: ??? Date: Mon, 26 Jan 2026 16:01:39 +0100 Subject: [PATCH 3/5] [IMP] stock_barcodes_serial_source_relocation: pre-commit auto fixes --- .../README.rst | 21 ++++++++++--------- .../__manifest__.py | 2 +- .../pyproject.toml | 3 +++ .../readme/CONTRIBUTORS.md | 3 +++ .../readme/CONTRIBUTORS.rst | 4 ---- .../{DESCRIPTION.rst => DESCRIPTION.md} | 3 ++- .../static/description/index.html | 17 ++++++++------- .../wizard/stock_barcodes_read_picking.py | 2 +- 8 files changed, 30 insertions(+), 25 deletions(-) create mode 100644 stock_barcodes_serial_source_relocation/pyproject.toml create mode 100644 stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.md delete mode 100644 stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.rst rename stock_barcodes_serial_source_relocation/readme/{DESCRIPTION.rst => DESCRIPTION.md} (64%) diff --git a/stock_barcodes_serial_source_relocation/README.rst b/stock_barcodes_serial_source_relocation/README.rst index 9b29a2f9c..273f5e26e 100644 --- a/stock_barcodes_serial_source_relocation/README.rst +++ b/stock_barcodes_serial_source_relocation/README.rst @@ -17,12 +17,13 @@ Stock Barcodes Serial Source Relocation :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-NuoBiT%2Fodoo--addons-lightgray.png?logo=github - :target: https://github.com/NuoBiT/odoo-addons/tree/14.0/stock_barcodes_serial_source_relocation + :target: https://github.com/NuoBiT/odoo-addons/tree/18.0/stock_barcodes_serial_source_relocation :alt: NuoBiT/odoo-addons |badge1| |badge2| |badge3| -Allow to always have quantities available when entering a serial product from the barcodes module. +Allow to always have quantities available when entering a serial product +from the barcodes module. **Table of contents** @@ -35,7 +36,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -43,22 +44,22 @@ Credits ======= Authors -~~~~~~~ +------- * NuoBiT Solutions * S.L. Contributors -~~~~~~~~~~~~ +------------ -* `NuoBiT `_: +- `NuoBiT `__: - * Frank Cespedes - * Eric Antones + - Frank Cespedes + - Eric Antones Maintainers -~~~~~~~~~~~ +----------- -This module is part of the `NuoBiT/odoo-addons `_ project on GitHub. +This module is part of the `NuoBiT/odoo-addons `_ project on GitHub. You are welcome to contribute. diff --git a/stock_barcodes_serial_source_relocation/__manifest__.py b/stock_barcodes_serial_source_relocation/__manifest__.py index 6a8f479fd..6b0cd3bef 100644 --- a/stock_barcodes_serial_source_relocation/__manifest__.py +++ b/stock_barcodes_serial_source_relocation/__manifest__.py @@ -9,7 +9,7 @@ "product from the barcodes module.", "version": "14.0.1.0.0", "author": "NuoBiT Solutions, S.L.", - "website": "https://github.com/nuobit/odoo-addons", + "website": "https://github.com/NuoBiT/odoo-addons", "category": "Extra Tools", "depends": ["stock_barcodes"], "data": ["views/stock_picking_type_views.xml"], diff --git a/stock_barcodes_serial_source_relocation/pyproject.toml b/stock_barcodes_serial_source_relocation/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/stock_barcodes_serial_source_relocation/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.md b/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..a8ecfb6d9 --- /dev/null +++ b/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [NuoBiT](https://www.nuobit.com): + - Frank Cespedes \ + - Eric Antones \ diff --git a/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.rst b/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.rst deleted file mode 100644 index b5c0d2df9..000000000 --- a/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,4 +0,0 @@ -* `NuoBiT `_: - - * Frank Cespedes - * Eric Antones diff --git a/stock_barcodes_serial_source_relocation/readme/DESCRIPTION.rst b/stock_barcodes_serial_source_relocation/readme/DESCRIPTION.md similarity index 64% rename from stock_barcodes_serial_source_relocation/readme/DESCRIPTION.rst rename to stock_barcodes_serial_source_relocation/readme/DESCRIPTION.md index 8e6014d8f..5116c0302 100644 --- a/stock_barcodes_serial_source_relocation/readme/DESCRIPTION.rst +++ b/stock_barcodes_serial_source_relocation/readme/DESCRIPTION.md @@ -1 +1,2 @@ -Allow to always have quantities available when entering a serial product from the barcodes module. +Allow to always have quantities available when entering a serial product +from the barcodes module. diff --git a/stock_barcodes_serial_source_relocation/static/description/index.html b/stock_barcodes_serial_source_relocation/static/description/index.html index 947af890c..ffbddc89f 100644 --- a/stock_barcodes_serial_source_relocation/static/description/index.html +++ b/stock_barcodes_serial_source_relocation/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -369,8 +369,9 @@

Stock Barcodes Serial Source Relocation

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:2e5788fe8cb1bd9f1a4f43a27cbc9fa24c9d1b1546cb88e7082e499b42aab687 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 NuoBiT/odoo-addons

-

Allow to always have quantities available when entering a serial product from the barcodes module.

+

Beta License: AGPL-3 NuoBiT/odoo-addons

+

Allow to always have quantities available when entering a serial product +from the barcodes module.

Table of contents

    @@ -388,7 +389,7 @@

    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.

    +feedback.

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

@@ -412,7 +413,7 @@

Contributors

Maintainers

-

This module is part of the NuoBiT/odoo-addons project on GitHub.

+

This module is part of the NuoBiT/odoo-addons project on GitHub.

You are welcome to contribute.

diff --git a/stock_barcodes_serial_source_relocation/wizard/stock_barcodes_read_picking.py b/stock_barcodes_serial_source_relocation/wizard/stock_barcodes_read_picking.py index 4892ab675..7a1bfa02a 100644 --- a/stock_barcodes_serial_source_relocation/wizard/stock_barcodes_read_picking.py +++ b/stock_barcodes_serial_source_relocation/wizard/stock_barcodes_read_picking.py @@ -11,7 +11,7 @@ class WizStockBarcodesReadPicking(models.TransientModel): def check_done_conditions(self): if self.product_id.tracking == "serial": self = self.with_context(force_create_move=True) - return super(WizStockBarcodesReadPicking, self).check_done_conditions() + return super().check_done_conditions() def _prepare_move_line_values(self, candidate_move, available_qty): vals = super()._prepare_move_line_values(candidate_move, available_qty) From dfb385a66fc4d1bcd5feeb00ed097a4c45728ff9 Mon Sep 17 00:00:00 2001 From: ??? Date: Mon, 26 Jan 2026 16:32:37 +0100 Subject: [PATCH 4/5] [MIG] stock_barcodes_serial_source_relocation: Migration to 18.0 --- .../README.rst | 8 +- .../__manifest__.py | 10 +- .../models/__init__.py | 2 +- .../models/stock_inventory.py | 16 ---- .../models/stock_picking.py | 92 +++++++++---------- .../models/stock_picking_type.py | 5 +- .../models/stock_quant.py | 25 +++++ .../readme/CONTRIBUTORS.md | 5 +- .../static/description/index.html | 8 +- .../views/stock_picking_type_views.xml | 8 +- 10 files changed, 94 insertions(+), 85 deletions(-) delete mode 100644 stock_barcodes_serial_source_relocation/models/stock_inventory.py create mode 100644 stock_barcodes_serial_source_relocation/models/stock_quant.py diff --git a/stock_barcodes_serial_source_relocation/README.rst b/stock_barcodes_serial_source_relocation/README.rst index 273f5e26e..d75de6ac1 100644 --- a/stock_barcodes_serial_source_relocation/README.rst +++ b/stock_barcodes_serial_source_relocation/README.rst @@ -46,16 +46,16 @@ Credits Authors ------- -* NuoBiT Solutions -* S.L. +* NuoBiT Solutions SL Contributors ------------ - `NuoBiT `__: - - Frank Cespedes - - Eric Antones + - Frank Cespedes fcespedes@nuobit.com + - Eric Antones eantones@nuobit.com + - Deniz Gallo dgallo@nuobit.com Maintainers ----------- diff --git a/stock_barcodes_serial_source_relocation/__manifest__.py b/stock_barcodes_serial_source_relocation/__manifest__.py index 6b0cd3bef..dbc95dbc3 100644 --- a/stock_barcodes_serial_source_relocation/__manifest__.py +++ b/stock_barcodes_serial_source_relocation/__manifest__.py @@ -1,14 +1,14 @@ -# Copyright NuoBiT Solutions, S.L. () -# Eric Antones -# Frank Cespedes +# Copyright NuoBiT Solutions - Eric Antones +# Copyright NuoBiT Solutions - Frank Cespedes +# Copyright 2026 NuoBiT Solutions - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) { "name": "Stock Barcodes Serial Source Relocation", "summary": "Allow to always have quantities available when entering a serial " "product from the barcodes module.", - "version": "14.0.1.0.0", - "author": "NuoBiT Solutions, S.L.", + "version": "18.0.1.0.0", + "author": "NuoBiT Solutions SL", "website": "https://github.com/NuoBiT/odoo-addons", "category": "Extra Tools", "depends": ["stock_barcodes"], diff --git a/stock_barcodes_serial_source_relocation/models/__init__.py b/stock_barcodes_serial_source_relocation/models/__init__.py index b438dc971..1e4f45c34 100644 --- a/stock_barcodes_serial_source_relocation/models/__init__.py +++ b/stock_barcodes_serial_source_relocation/models/__init__.py @@ -1,5 +1,5 @@ from . import stock_picking_type -from . import stock_inventory from . import stock_picking from . import stock_move_line from . import stock_location +from . import stock_quant diff --git a/stock_barcodes_serial_source_relocation/models/stock_inventory.py b/stock_barcodes_serial_source_relocation/models/stock_inventory.py deleted file mode 100644 index 33adf7c86..000000000 --- a/stock_barcodes_serial_source_relocation/models/stock_inventory.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright NuoBiT Solutions - Frank Cespedes -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) - -from odoo import models - - -class InventoryLine(models.Model): - _inherit = "stock.inventory.line" - - def _get_move_values(self, qty, location_id, location_dest_id, out): - values = super()._get_move_values(qty, location_id, location_dest_id, out) - origin = self.env.context.get("relocation_origin", False) - if origin: - values["origin"] = origin - values["move_line_ids"][0][2]["origin"] = origin - return values diff --git a/stock_barcodes_serial_source_relocation/models/stock_picking.py b/stock_barcodes_serial_source_relocation/models/stock_picking.py index 847123128..11af366c1 100644 --- a/stock_barcodes_serial_source_relocation/models/stock_picking.py +++ b/stock_barcodes_serial_source_relocation/models/stock_picking.py @@ -1,5 +1,6 @@ # Copyright NuoBiT Solutions - Eric Antones # Copyright NuoBiT Solutions - Frank Cespedes +# Copyright 2026 NuoBiT Solutions - Deniz Gallo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) from odoo import _, models @@ -16,7 +17,7 @@ def _prepare_relocation_move_line_values(self, move_line, new_picking, quant): "product_id": move_line.product_id.id, "origin": self.name, "product_uom_id": move_line.product_id.uom_id.id, - "qty_done": quant.quantity, + "quantity": quant.quantity, "location_id": quant.location_id.id, "location_dest_id": move_line.location_id.id, "lot_id": move_line.lot_id.id, @@ -30,7 +31,7 @@ def _prepare_relocation_move_values(self, move_line, quant): "product_id": move_line.product_id.id, "product_uom": move_line.product_id.uom_id.id, "product_uom_qty": quant.quantity, - "quantity_done": quant.quantity, + "quantity": quant.quantity, "location_id": quant.location_id.id, "location_dest_id": move_line.location_id.id, } @@ -42,7 +43,7 @@ def _prepare_relocation_picking_values(self, move_line, new_picking_type, quant) "location_dest_id": move_line.location_id.id, "origin": move_line.picking_id.name, "company_id": move_line.company_id.id, - "move_lines": [ + "move_ids": [ ( 0, 0, @@ -51,32 +52,36 @@ def _prepare_relocation_picking_values(self, move_line, new_picking_type, quant) ], } - def _prepare_relocation_inventory_line_values(self, move_line): - return { - "location_id": move_line.location_id.id, - "product_id": move_line.product_id.id, - "product_uom_id": move_line.product_id.uom_id.id, - "product_qty": 1, - "prod_lot_id": move_line.lot_id.id, - "company_id": self.company_id.id, - } - - def _prepare_relocation_inventory_values(self, move_line): - return { - "name": "Regularization by relocation", - "product_ids": [(6, 0, move_line.product_id.ids)], - "location_ids": [(6, 0, move_line.location_id.ids)], - "exhausted": True, - "line_ids": [ - ( - 0, - 0, - self._prepare_relocation_inventory_line_values(move_line), - ) + def _create_inventory_adjustment(self, move_line): + quant = self.env["stock.quant"].search( + [ + ("location_id", "=", move_line.location_id.id), + ("product_id", "=", move_line.product_id.id), + ("lot_id", "=", move_line.lot_id.id), + ("company_id", "=", self.company_id.id), ], - } + limit=1, + ) + + if not quant: + quant = self.env["stock.quant"].create( + { + "location_id": move_line.location_id.id, + "product_id": move_line.product_id.id, + "lot_id": move_line.lot_id.id, + "company_id": self.company_id.id, + "quantity": 0, + } + ) + + quant.inventory_quantity_set = True + quant.inventory_quantity = 1 + quant.with_context( + inventory_mode=True, relocation_origin=self.name + ).action_apply_inventory() def button_validate(self): + res = super().button_validate() if ( self.picking_type_code != "incoming" and not self.picking_type_id.barcode_option_group_id.allow_negative_quant @@ -87,33 +92,33 @@ def button_validate(self): and x.lot_id ): quants = move_line.lot_id.quant_ids.filtered( - lambda q: float_compare( + lambda q, ml=move_line: float_compare( q.quantity, 0, - precision_rounding=move_line.product_id.uom_id.rounding, + precision_rounding=ml.product_id.uom_id.rounding, ) > 0 ) if len(quants) > 1: raise ValidationError( _( - "S/N %s is found in more than one location." - % move_line.lot_id.name + "S/N %(name)s is found in more than one location.", + name=move_line.lot_id.name, ) ) if quants: qty_available = quants.filtered( - lambda x: x.location_id == move_line.location_id + lambda x, ml=move_line: x.location_id == ml.location_id ).quantity if ( float_compare( - move_line.qty_done, + move_line.quantity, qty_available, precision_rounding=move_line.product_id.uom_id.rounding, ) > 0 ): - warehouse = move_line.location_id.get_warehouse() + warehouse = move_line.location_id.warehouse_id picking_type = ( self.env["stock.picking.type"] .search( @@ -130,15 +135,16 @@ def button_validate(self): raise ValidationError( _( "More than one regularization picking " - "type for the same warehouse %s" - % move_line.location_id.name + "type for the same warehouse %(warehouse)s", + warehouse=move_line.location_id.name, ) ) if not picking_type: raise ValidationError( _( - "No regularization picking type for location %s" - % move_line.location_id.name + "No regularization picking " + "type for location %(location)s", + location=move_line.location_id.name, ) ) new_picking = self.env["stock.picking"].create( @@ -147,7 +153,7 @@ def button_validate(self): ) ) new_picking.with_context(relocation=self.name).action_confirm() - for move in new_picking.move_lines: + for move in new_picking.move_ids: move.move_line_ids.write( self._prepare_relocation_move_line_values( move_line, new_picking, quants @@ -155,11 +161,5 @@ def button_validate(self): ) new_picking.button_validate() else: - inventory = self.env["stock.inventory"].create( - self._prepare_relocation_inventory_values(move_line) - ) - inventory._action_start() - inventory.with_context( - relocation_origin=self.name - ).action_validate() - return super().button_validate() + self._create_inventory_adjustment(move_line) + return res diff --git a/stock_barcodes_serial_source_relocation/models/stock_picking_type.py b/stock_barcodes_serial_source_relocation/models/stock_picking_type.py index 1f4db0cc4..d8979c3b4 100644 --- a/stock_barcodes_serial_source_relocation/models/stock_picking_type.py +++ b/stock_barcodes_serial_source_relocation/models/stock_picking_type.py @@ -31,7 +31,8 @@ def _check_is_regularization(self): ): raise ValidationError( _( - "Only one picking type can be regularization in a warehouse %s." + "Only one picking type can be regularization " + "in a warehouse %(warehouse)s.", + warehouse=rec.warehouse_id.name, ) - % rec.warehouse_id.name, ) diff --git a/stock_barcodes_serial_source_relocation/models/stock_quant.py b/stock_barcodes_serial_source_relocation/models/stock_quant.py new file mode 100644 index 000000000..e822858e6 --- /dev/null +++ b/stock_barcodes_serial_source_relocation/models/stock_quant.py @@ -0,0 +1,25 @@ +# Copyright 2026 NuoBiT Solutions - Deniz Gallo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import models + + +class StockQuant(models.Model): + _inherit = "stock.quant" + + def _get_inventory_move_values( + self, + qty, + location_id, + location_dest_id, + package_id=False, + package_dest_id=False, + ): + values = super()._get_inventory_move_values( + qty, location_id, location_dest_id, package_id, package_dest_id + ) + origin = self.env.context.get("relocation_origin", False) + if origin: + values["origin"] = origin + values["move_line_ids"][0][2]["origin"] = origin + return values diff --git a/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.md b/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.md index a8ecfb6d9..0ff45d152 100644 --- a/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.md +++ b/stock_barcodes_serial_source_relocation/readme/CONTRIBUTORS.md @@ -1,3 +1,4 @@ - [NuoBiT](https://www.nuobit.com): - - Frank Cespedes \ - - Eric Antones \ + - Frank Cespedes + - Eric Antones + - Deniz Gallo diff --git a/stock_barcodes_serial_source_relocation/static/description/index.html b/stock_barcodes_serial_source_relocation/static/description/index.html index ffbddc89f..132897b30 100644 --- a/stock_barcodes_serial_source_relocation/static/description/index.html +++ b/stock_barcodes_serial_source_relocation/static/description/index.html @@ -397,16 +397,16 @@

Credits

Authors

    -
  • NuoBiT Solutions
  • -
  • S.L.
  • +
  • NuoBiT Solutions SL

Contributors

diff --git a/stock_barcodes_serial_source_relocation/views/stock_picking_type_views.xml b/stock_barcodes_serial_source_relocation/views/stock_picking_type_views.xml index 7795804c1..917d3b019 100644 --- a/stock_barcodes_serial_source_relocation/views/stock_picking_type_views.xml +++ b/stock_barcodes_serial_source_relocation/views/stock_picking_type_views.xml @@ -1,16 +1,14 @@ stock.picking.type - - + + From bd303db72ff99760627ad633ea462274e499298c Mon Sep 17 00:00:00 2001 From: ??? Date: Mon, 26 Jan 2026 12:17:12 +0100 Subject: [PATCH 5/5] [DO NOT MERGE] test-requirements.txt --- test-requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test-requirements.txt diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..1ca304aa6 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-stock_barcodes@git+https://github.com/OCA/stock-logistics-barcode.git@refs/pull/725/head#subdirectory=stock_barcodes