Files
odoo_source/addons/mrp_subcontracting/models/stock_move_line.py
T
Arnold Moyaux 4055293873 [IMP] mrp_subcontracting: bypass reservation
A subcontracting receipt should be always assigned even
if the components are not deliver. It depends on the partner
and not our company.
2019-08-19 15:03:59 +00:00

26 lines
1000 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class StockMoveLine(models.Model):
_inherit = 'stock.move.line'
def create(self, values):
records = super(StockMoveLine, self).create(values)
records.filtered(lambda ml: ml.move_id.is_subcontract).move_id._check_overprocessed_subcontract_qty()
return records
def write(self, values):
res = super(StockMoveLine, self).write(values)
self.filtered(lambda ml: ml.move_id.is_subcontract).move_id._check_overprocessed_subcontract_qty()
return res
def _should_bypass_reservation(self, location):
""" If the move line is subcontracted then ignore the reservation. """
should_bypass_reservation = super(StockMoveLine, self)._should_bypass_reservation(location)
if not should_bypass_reservation and self.move_id.is_subcontract:
return True
return should_bypass_reservation