17 lines
786 B
Python
17 lines
786 B
Python
# -*- 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)
|