[IMP] stock_request: Avoid set stock request orders empty

TT47959
This commit is contained in:
Víctor Martínez
2024-02-23 09:45:22 +01:00
parent dfcbb4d9bb
commit bd2743601d
4 changed files with 41 additions and 8 deletions

View File

@@ -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: 2023-07-06 07:32+0000\n" "POT-Creation-Date: 2024-02-23 08:52+0000\n"
"PO-Revision-Date: 2023-07-06 09:32+0200\n" "PO-Revision-Date: 2024-02-23 09:53+0100\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"
@@ -421,6 +421,19 @@ msgstr "Rutas de inventarios"
msgid "Is Follower" msgid "Is Follower"
msgstr "Es Seguidor" msgstr "Es Seguidor"
#. module: stock_request
#: code:addons/stock_request/models/stock_request_order.py:0
#, fuzzy, python-format
#| msgid ""
#| "It is not possible to set empty stock request orders (maybe\n"
#| " you should cancel it)."
msgid ""
"It is not possible to set empty stock request orders (maybe you should "
"cancel it)."
msgstr ""
"No es posible dejar vacío un pedido de existencias (quizás deberías "
"cancelarlo)."
#. module: stock_request #. module: stock_request
#: model_terms:ir.ui.view,arch_db:stock_request.stock_request_order_form #: model_terms:ir.ui.view,arch_db:stock_request.stock_request_order_form
msgid "Items" msgid "Items"
@@ -543,7 +556,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"
@@ -1223,6 +1235,3 @@ msgid ""
msgstr "" msgstr ""
"Debe seleccionada una unidad de medida de producto de la misma categoría que " "Debe seleccionada una unidad de medida de producto de la misma categoría que "
"la unidad de medida por defecto del producto" "la unidad de medida por defecto del producto"
#~ msgid "SMS Delivery error"
#~ msgstr "Error de entrega de SMS"

View File

@@ -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-02-23 08:52+0000\n"
"PO-Revision-Date: 2024-02-23 08:52+0000\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@@ -407,6 +409,14 @@ msgstr ""
msgid "Is Follower" msgid "Is Follower"
msgstr "" msgstr ""
#. module: stock_request
#: code:addons/stock_request/models/stock_request_order.py:0
#, python-format
msgid ""
"It is not possible to set empty stock request orders (maybe you should "
"cancel it)."
msgstr ""
#. module: stock_request #. module: stock_request
#: model_terms:ir.ui.view,arch_db:stock_request.stock_request_order_form #: model_terms:ir.ui.view,arch_db:stock_request.stock_request_order_form
msgid "Items" msgid "Items"
@@ -526,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 ""

View File

@@ -320,6 +320,16 @@ class StockRequestOrder(models.Model):
) )
) )
@api.constrains("stock_request_ids")
def _check_location_empty_stock_request_ids(self):
if any(not request.stock_request_ids for request in self):
raise ValidationError(
_(
"It is not possible to set empty stock request orders (maybe "
"you should cancel it)."
)
)
@api.model @api.model
def _create_from_product_multiselect(self, products): def _create_from_product_multiselect(self, products):
if not products: if not products:

View File

@@ -6,7 +6,7 @@ from collections import Counter
from datetime import datetime from datetime import datetime
from odoo import exceptions, fields from odoo import exceptions, fields
from odoo.tests import common, new_test_user from odoo.tests import Form, common, new_test_user
class TestStockRequest(common.TransactionCase): class TestStockRequest(common.TransactionCase):
@@ -306,6 +306,11 @@ class TestStockRequestBase(TestStockRequest):
self.assertEqual(stock_request.company_id, self.main_company) self.assertEqual(stock_request.company_id, self.main_company)
self.assertEqual(stock_request.location_id, self.warehouse.lot_stock_id) self.assertEqual(stock_request.location_id, self.warehouse.lot_stock_id)
def test_stock_request_order_empty(self):
request_order = Form(self.request_order)
with self.assertRaises(exceptions.ValidationError):
request_order.save()
def test_stock_request_order_validations_01(self): def test_stock_request_order_validations_01(self):
"""Testing the discrepancy in warehouse_id between """Testing the discrepancy in warehouse_id between
stock request and order""" stock request and order"""