# -*- coding: utf-8 -*- ############################################################################## # # Cybrosys Technologies Pvt. Ltd. # Copyright (C) 2017-TODAY Cybrosys Technologies(). # Author: Cybrosys Technologies() # you can modify it under the terms of the GNU LESSER # GENERAL PUBLIC LICENSE (LGPL v3), Version 3. # # It is forbidden to publish, distribute, sublicense, or sell copies # of the Software or modified copies of the Software. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. # # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE # GENERAL PUBLIC LICENSE (LGPL v3) along with this program. # If not, see . # ############################################################################## from odoo import models, api, _ from odoo.exceptions import UserError class StockMoveWarning(models.Model): _inherit = 'stock.move' @api.onchange('product_uom_qty') def check_product_qty(self): qty_sales = 0 for orders in self.env['sale.order'].search([('name', '=', self.picking_id.origin)]).order_line: if orders.product_id == self.product_id: qty_sales += orders.product_uom_qty if self.product_uom_qty > qty_sales: raise UserError(_('You are trying to deliver more than ordered quantity'))