[FIX] stock: scrap order with 0 quantity

currently odoo is allowing to create a scrap order record with 0 quantty, which doesn't make sense and also if it is allowed, user wont be able to edit change the quantity later. currently zero quantity is not blocked by _check_positive_qty_done on stock.move.line. And it doesn't make sense to scrap 0, thus preventing the same by raising a validation

closes odoo/odoo#105752

X-original-commit: eb899fe8dda12d0f0e4ae515bb01e65981f4fbcd
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
This commit is contained in:
niyasraphy
2022-11-16 16:24:48 +01:00
parent 2e68b13160
commit b345e1963b
2 changed files with 10 additions and 1 deletions
+6
View File
@@ -9042,6 +9042,12 @@ msgstr ""
msgid "You can only delete draft moves."
msgstr ""
#. module: stock
#: code:addons/stock/models/stock_scrap.py:0
#, python-format
msgid "You can only enter positive quantities."
msgstr ""
#. module: stock
#: code:addons/stock/models/stock_move_line.py:0
#, python-format
+4 -1
View File
@@ -3,7 +3,7 @@
from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.tools import float_compare
from odoo.tools import float_compare, float_is_zero
class StockScrap(models.Model):
@@ -171,6 +171,9 @@ class StockScrap(models.Model):
def action_validate(self):
self.ensure_one()
if float_is_zero(self.scrap_qty,
precision_rounding=self.product_uom_id.rounding):
raise UserError(_('You can only enter positive quantities.'))
if self.product_id.type != 'product':
return self.do_scrap()
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')