[IMP] add quant check after all process is done

This commit is contained in:
Aungkokolin1997
2023-09-29 12:09:32 +06:30
parent 16da9a9fd6
commit f7fbae2c40
2 changed files with 23 additions and 0 deletions

View File

@@ -1 +1,2 @@
from . import stock_move
from . import stock_picking

View File

@@ -0,0 +1,22 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import models
class StockPicking(models.Model):
_inherit = "stock.picking"
def _action_done(self):
res = super()._action_done()
self._check_negative_quants_after_process()
return res
def _check_negative_quants_after_process(self):
product_ids = self.mapped("move_ids.product_id.id")
quants = self.env["stock.quant"].search(
[
("product_id", "in", product_ids),
]
)
quants.check_negative_qty()