diff --git a/setup/stock_move_line_divide_generate_lot_name/odoo/addons/stock_move_line_divide_generate_lot_name b/setup/stock_move_line_divide_generate_lot_name/odoo/addons/stock_move_line_divide_generate_lot_name new file mode 120000 index 0000000000..3b248720b2 --- /dev/null +++ b/setup/stock_move_line_divide_generate_lot_name/odoo/addons/stock_move_line_divide_generate_lot_name @@ -0,0 +1 @@ +../../../../stock_move_line_divide_generate_lot_name \ No newline at end of file diff --git a/setup/stock_move_line_divide_generate_lot_name/setup.py b/setup/stock_move_line_divide_generate_lot_name/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/stock_move_line_divide_generate_lot_name/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_move_line_divide_generate_lot_name/README.rst b/stock_move_line_divide_generate_lot_name/README.rst new file mode 100644 index 0000000000..64507a628a --- /dev/null +++ b/stock_move_line_divide_generate_lot_name/README.rst @@ -0,0 +1,28 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================================== +Stock Move Line Divide Generate Lot Name +======================================== + +* When dividing stock move lines, it generates the name of lots by sequence. + +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 smash it by providing detailed and welcomed feedback. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Contributors +------------ + +* Berezi Amubieta +* Ana Juaristi diff --git a/stock_move_line_divide_generate_lot_name/__init__.py b/stock_move_line_divide_generate_lot_name/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/stock_move_line_divide_generate_lot_name/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_move_line_divide_generate_lot_name/__manifest__.py b/stock_move_line_divide_generate_lot_name/__manifest__.py new file mode 100644 index 0000000000..8e7338d56c --- /dev/null +++ b/stock_move_line_divide_generate_lot_name/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2024 Berezi Amubieta - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Stock Move Line Divide Generate Lot Name", + "version": "16.0.1.0.0", + "author": "Avanzosc", + "website": "https://github.com/avanzosc/odoo-addons", + "category": "Inventory", + "depends": [ + "stock_move_line_divide", + "stock_picking_automatic_lot", + ], + "data": [], + "license": "AGPL-3", + "installable": True, + "auto_install": True, +} diff --git a/stock_move_line_divide_generate_lot_name/models/__init__.py b/stock_move_line_divide_generate_lot_name/models/__init__.py new file mode 100644 index 0000000000..431f51c274 --- /dev/null +++ b/stock_move_line_divide_generate_lot_name/models/__init__.py @@ -0,0 +1 @@ +from . import stock_move_line diff --git a/stock_move_line_divide_generate_lot_name/models/stock_move_line.py b/stock_move_line_divide_generate_lot_name/models/stock_move_line.py new file mode 100644 index 0000000000..7979ab5c59 --- /dev/null +++ b/stock_move_line_divide_generate_lot_name/models/stock_move_line.py @@ -0,0 +1,20 @@ +# Copyright 2024 Berezi Amubieta - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import models + + +class StockMoveLine(models.Model): + _inherit = "stock.move.line" + + def action_divide(self): + result = super().action_divide() + if ( + self.product_id + and self.product_id.tracking != "none" + and self.picking_id + and self.picking_id.picking_type_id + and self.picking_id.picking_type_id.use_create_lots + ): + for line in self.move_id.move_line_ids: + line.lot_name = self.env["ir.sequence"].next_by_code("stock.lot.serial") + return result