diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a60b85 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +*.pyc diff --git a/__pycache__/__init__.cpython-310.pyc b/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 026e5af..0000000 Binary files a/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 39e3b77..0000000 Binary files a/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/models/__init__.py b/models/__init__.py index 23e3486..ede103c 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -2,4 +2,5 @@ from . import product_template from . import stock_move from . import stock_lot from . import stock_move_line -from . import mrp_production \ No newline at end of file +from . import mrp_production +from . import stock_picking \ No newline at end of file diff --git a/models/__pycache__/__init__.cpython-310.pyc b/models/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 86288cc..0000000 Binary files a/models/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/models/__pycache__/__init__.cpython-312.pyc b/models/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 93ddb1c..0000000 Binary files a/models/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/models/__pycache__/mrp_production.cpython-310.pyc b/models/__pycache__/mrp_production.cpython-310.pyc deleted file mode 100644 index d2b6487..0000000 Binary files a/models/__pycache__/mrp_production.cpython-310.pyc and /dev/null differ diff --git a/models/__pycache__/mrp_production.cpython-312.pyc b/models/__pycache__/mrp_production.cpython-312.pyc deleted file mode 100644 index a6a86fd..0000000 Binary files a/models/__pycache__/mrp_production.cpython-312.pyc and /dev/null differ diff --git a/models/__pycache__/product_template.cpython-310.pyc b/models/__pycache__/product_template.cpython-310.pyc deleted file mode 100644 index 04d2d22..0000000 Binary files a/models/__pycache__/product_template.cpython-310.pyc and /dev/null differ diff --git a/models/__pycache__/product_template.cpython-312.pyc b/models/__pycache__/product_template.cpython-312.pyc deleted file mode 100644 index 54df751..0000000 Binary files a/models/__pycache__/product_template.cpython-312.pyc and /dev/null differ diff --git a/models/__pycache__/stock_lot.cpython-310.pyc b/models/__pycache__/stock_lot.cpython-310.pyc deleted file mode 100644 index 65f512a..0000000 Binary files a/models/__pycache__/stock_lot.cpython-310.pyc and /dev/null differ diff --git a/models/__pycache__/stock_lot.cpython-312.pyc b/models/__pycache__/stock_lot.cpython-312.pyc deleted file mode 100644 index baabfd1..0000000 Binary files a/models/__pycache__/stock_lot.cpython-312.pyc and /dev/null differ diff --git a/models/__pycache__/stock_move.cpython-310.pyc b/models/__pycache__/stock_move.cpython-310.pyc deleted file mode 100644 index 1fd2024..0000000 Binary files a/models/__pycache__/stock_move.cpython-310.pyc and /dev/null differ diff --git a/models/__pycache__/stock_move.cpython-312.pyc b/models/__pycache__/stock_move.cpython-312.pyc deleted file mode 100644 index c50dd49..0000000 Binary files a/models/__pycache__/stock_move.cpython-312.pyc and /dev/null differ diff --git a/models/__pycache__/stock_move_line.cpython-310.pyc b/models/__pycache__/stock_move_line.cpython-310.pyc deleted file mode 100644 index 3069864..0000000 Binary files a/models/__pycache__/stock_move_line.cpython-310.pyc and /dev/null differ diff --git a/models/__pycache__/stock_move_line.cpython-312.pyc b/models/__pycache__/stock_move_line.cpython-312.pyc deleted file mode 100644 index 6901acd..0000000 Binary files a/models/__pycache__/stock_move_line.cpython-312.pyc and /dev/null differ diff --git a/models/stock_picking.py b/models/stock_picking.py new file mode 100644 index 0000000..7a8f31b --- /dev/null +++ b/models/stock_picking.py @@ -0,0 +1,34 @@ +from odoo import models + +class StockPicking(models.Model): + _inherit = 'stock.picking' + + def action_auto_generate_lots_subcontract(self): + """ + Auto-generate lot names for move lines in this picking that: + 1. Have a product with tracking enabled (serial or lot). + 2. Have an empty 'lot_name' and no 'lot_id'. + 3. Have a product template with a configured 'lot_sequence_id'. + """ + for picking in self: + # We iterate over move_line_ids (operations) + # Filter for lines that need a lot generated + lines_to_process = picking.move_line_ids.filtered( + lambda ml: ( + ml.product_id + and ml.product_id.tracking in ('serial', 'lot') + and not ml.lot_name + and not ml.lot_id + and getattr(ml.product_id.product_tmpl_id, 'lot_sequence_id', False) + ) + ) + + for line in lines_to_process: + # Get the sequence from the product template + seq = line.product_id.product_tmpl_id.lot_sequence_id + if seq: + # strict=True ensures we skip if next_by_id fails, though usually it returns None/False + new_lot_name = seq.next_by_id() + if new_lot_name: + line.lot_name = new_lot_name + return True