Files
stock-logistics-warehouse/stock_location_lockdown/models/stock_quant.py
Sébastien BEAU 56bd5e9127 [FIX] fix negative quant in blocked location
When forcing an outgoing move and then moving it. Odoo create a
negative quant. This quant should not be in the locked location
because no quand will go in it and so the negative quant will stay
here for ever
2020-10-29 11:13:45 +01:00

22 lines
677 B
Python

# -*- coding: utf-8 -*-
# Copyright 2018 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models, _
from odoo.exceptions import UserError
class StockQuant(models.Model):
_inherit = 'stock.quant'
@api.constrains('location_id')
def _check_location_blocked(self):
for record in self:
if record.location_id.block_stock_entrance:
raise UserError(
_('The location %s is blocked and can '
'not be used for moving the product %s')
% (record.location_id.name, record.product_id.name)
)
return True