first commit
This commit is contained in:
commit
e792ddea45
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.pyc
|
||||
*.pyo
|
||||
*~
|
||||
__pycache__/
|
||||
3
__init__.py
Normal file
3
__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
13
__manifest__.py
Normal file
13
__manifest__.py
Normal file
@ -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',
|
||||
}
|
||||
4
models/__init__.py
Normal file
4
models/__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import stock_picking
|
||||
from . import stock_move
|
||||
16
models/stock_move.py
Normal file
16
models/stock_move.py
Normal file
@ -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)
|
||||
12
models/stock_picking.py
Normal file
12
models/stock_picking.py
Normal file
@ -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
|
||||
)
|
||||
14
readme.md
Normal file
14
readme.md
Normal file
@ -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.
|
||||
Loading…
Reference in New Issue
Block a user