From e792ddea455f64ad33a122fc7c9edd9e7537091e Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Wed, 17 Jun 2026 09:53:55 +0700 Subject: [PATCH] first commit --- .gitignore | 4 ++++ __init__.py | 3 +++ __manifest__.py | 13 +++++++++++++ models/__init__.py | 4 ++++ models/stock_move.py | 16 ++++++++++++++++ models/stock_picking.py | 12 ++++++++++++ readme.md | 14 ++++++++++++++ 7 files changed, 66 insertions(+) create mode 100644 .gitignore create mode 100644 __init__.py create mode 100644 __manifest__.py create mode 100644 models/__init__.py create mode 100644 models/stock_move.py create mode 100644 models/stock_picking.py create mode 100644 readme.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07d48cc --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.pyc +*.pyo +*~ +__pycache__/ diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..cde864b --- /dev/null +++ b/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/__manifest__.py b/__manifest__.py new file mode 100644 index 0000000..8c6ffbc --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +{ + 'name': 'POS Stock MTO Bypass', + 'version': '1.0', + 'category': 'Inventory/Point of Sale', + 'summary': 'Bypass Make to Order (MTO) rules for POS orders to prevent stock move cancellations.', + 'author': 'Suherdy Yacob', + 'depends': ['point_of_sale', 'stock', 'mrp'], + 'data': [], + 'installable': True, + 'auto_install': False, + 'license': 'LGPL-3', +} diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..e717f72 --- /dev/null +++ b/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import stock_picking +from . import stock_move diff --git a/models/stock_move.py b/models/stock_move.py new file mode 100644 index 0000000..86d64b8 --- /dev/null +++ b/models/stock_move.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +from odoo import models + +class StockMove(models.Model): + _inherit = 'stock.move' + + def _adjust_procure_method(self, picking_type_code=False): + # Force make_to_stock (MTS) for stock moves created as part of POS pickings. + # This prevents Odoo from trying to trigger MTO procurement on physical sales that have already happened. + pos_moves = self.filtered(lambda m: m.env.context.get('pos_picking_operation') or m.picking_id.pos_session_id or m.picking_id.pos_order_id) + if pos_moves: + pos_moves.write({'procure_method': 'make_to_stock'}) + + non_pos_moves = self - pos_moves + if non_pos_moves: + super(StockMove, non_pos_moves)._adjust_procure_method(picking_type_code=picking_type_code) diff --git a/models/stock_picking.py b/models/stock_picking.py new file mode 100644 index 0000000..d7637bb --- /dev/null +++ b/models/stock_picking.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +from odoo import api, models + +class StockPicking(models.Model): + _inherit = 'stock.picking' + + @api.model + def _create_picking_from_pos_order_lines(self, location_dest_id, lines, picking_type, partner=False): + # Pass pos_picking_operation=True in context during picking creation and confirmation + return super(StockPicking, self.with_context(pos_picking_operation=True))._create_picking_from_pos_order_lines( + location_dest_id, lines, picking_type, partner=partner + ) diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..1f1bd3b --- /dev/null +++ b/readme.md @@ -0,0 +1,14 @@ +# POS Stock MTO Bypass + +This module bypasses Make to Order (MTO) rules for stock pickings created during Point of Sale (POS) order processing and session closing. + +## Problem Description + +By default, when kit products are sold via POS, Odoo explodes the kits into their components. If these components are configured with MTO routes, Odoo attempts to trigger procurement. If no vendor price is configured (or if the procurement rules cannot be satisfied), Odoo cancels the stock moves. This results in missing outbound stock movements for raw materials. + +## Solution + +This module overrides stock.picking and stock.move to: +- Detect if a stock move is being confirmed as part of a POS picking operation. +- Automatically force the procurement method to make_to_stock (MTS) for these moves. +- Avoid triggering MTO rule checks and prevents the stock moves from being cancelled.