mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_request: Improve _check_qty constrain (moved to stock.request)
Example use case: - A request (not draft) must be able to be changed to quantity 0 (although not negative). TT50450
This commit is contained in:
@@ -9,8 +9,8 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 11.0\n"
|
"Project-Id-Version: Odoo Server 11.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2024-02-23 08:52+0000\n"
|
"POT-Creation-Date: 2024-08-07 07:30+0000\n"
|
||||||
"PO-Revision-Date: 2024-02-23 09:53+0100\n"
|
"PO-Revision-Date: 2024-08-07 09:31+0200\n"
|
||||||
"Last-Translator: Víctor Martínez <victor.martinez@tecnativa.com>\n"
|
"Last-Translator: Víctor Martínez <victor.martinez@tecnativa.com>\n"
|
||||||
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
|
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
|
||||||
"Language: es\n"
|
"Language: es\n"
|
||||||
@@ -553,7 +553,6 @@ msgstr "Nombre"
|
|||||||
|
|
||||||
#. module: stock_request
|
#. module: stock_request
|
||||||
#: model:ir.model.constraint,message:stock_request.constraint_stock_request_abstract_name_uniq
|
#: model:ir.model.constraint,message:stock_request.constraint_stock_request_abstract_name_uniq
|
||||||
#: model:ir.model.constraint,message:stock_request.constraint_stock_request_kanban_name_uniq
|
|
||||||
msgid "Name must be unique"
|
msgid "Name must be unique"
|
||||||
msgstr "El nombre debe ser único"
|
msgstr "El nombre debe ser único"
|
||||||
|
|
||||||
@@ -952,7 +951,14 @@ msgid "Stock Request name must be unique"
|
|||||||
msgstr "El nombre de la solicitud debe ser único"
|
msgstr "El nombre de la solicitud debe ser único"
|
||||||
|
|
||||||
#. module: stock_request
|
#. module: stock_request
|
||||||
#: code:addons/stock_request/models/stock_request_abstract.py:0
|
#: code:addons/stock_request/models/stock_request.py:0
|
||||||
|
#, python-format
|
||||||
|
msgid "Stock Request product quantity cannot be negative."
|
||||||
|
msgstr ""
|
||||||
|
"La cantidad de producto de la solicitud de stock no puede ser negativa."
|
||||||
|
|
||||||
|
#. module: stock_request
|
||||||
|
#: code:addons/stock_request/models/stock_request.py:0
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Stock Request product quantity has to be strictly positive."
|
msgid "Stock Request product quantity has to be strictly positive."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 14.0\n"
|
"Project-Id-Version: Odoo Server 14.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2024-08-07 07:30+0000\n"
|
||||||
|
"PO-Revision-Date: 2024-08-07 07:30+0000\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
@@ -534,7 +536,6 @@ msgstr ""
|
|||||||
|
|
||||||
#. module: stock_request
|
#. module: stock_request
|
||||||
#: model:ir.model.constraint,message:stock_request.constraint_stock_request_abstract_name_uniq
|
#: model:ir.model.constraint,message:stock_request.constraint_stock_request_abstract_name_uniq
|
||||||
#: model:ir.model.constraint,message:stock_request.constraint_stock_request_kanban_name_uniq
|
|
||||||
msgid "Name must be unique"
|
msgid "Name must be unique"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -925,7 +926,13 @@ msgid "Stock Request name must be unique"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: stock_request
|
#. module: stock_request
|
||||||
#: code:addons/stock_request/models/stock_request_abstract.py:0
|
#: code:addons/stock_request/models/stock_request.py:0
|
||||||
|
#, python-format
|
||||||
|
msgid "Stock Request product quantity cannot be negative."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: stock_request
|
||||||
|
#: code:addons/stock_request/models/stock_request.py:0
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Stock Request product quantity has to be strictly positive."
|
msgid "Stock Request product quantity has to be strictly positive."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -137,6 +137,18 @@ class StockRequest(models.Model):
|
|||||||
("name_uniq", "unique(name, company_id)", "Stock Request name must be unique")
|
("name_uniq", "unique(name, company_id)", "Stock Request name must be unique")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@api.constrains("state", "product_qty")
|
||||||
|
def _check_qty(self):
|
||||||
|
for rec in self:
|
||||||
|
if rec.state == "draft" and rec.product_qty <= 0:
|
||||||
|
raise ValidationError(
|
||||||
|
_("Stock Request product quantity has to be strictly positive.")
|
||||||
|
)
|
||||||
|
elif rec.state != "draft" and rec.product_qty < 0:
|
||||||
|
raise ValidationError(
|
||||||
|
_("Stock Request product quantity cannot be negative.")
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
"route_id",
|
"route_id",
|
||||||
"product_id",
|
"product_id",
|
||||||
|
|||||||
@@ -206,14 +206,6 @@ class StockRequest(models.AbstractModel):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.constrains("product_qty")
|
|
||||||
def _check_qty(self):
|
|
||||||
for rec in self:
|
|
||||||
if rec.product_qty <= 0:
|
|
||||||
raise ValidationError(
|
|
||||||
_("Stock Request product quantity has to be strictly positive.")
|
|
||||||
)
|
|
||||||
|
|
||||||
@api.onchange("warehouse_id")
|
@api.onchange("warehouse_id")
|
||||||
def onchange_warehouse_id(self):
|
def onchange_warehouse_id(self):
|
||||||
"""Finds location id for changed warehouse."""
|
"""Finds location id for changed warehouse."""
|
||||||
|
|||||||
Reference in New Issue
Block a user