Add user error when create an location from the animals without a warehose.

Task #048049
This commit is contained in:
Juanjo Garcia 2021-11-26 12:11:23 +01:00
parent fdbff2e601
commit 1fc5a8eae0
3 changed files with 10 additions and 0 deletions

View File

@ -871,6 +871,9 @@ class Female(metaclass=PoolMeta):
number = vals.get('number')
initial_location = vals.get('initial_location')
location = Location(initial_location)
if not location.warehouse:
raise UserError(gettext('farm.location_without_warehouse',
location=location))
duplicate = Animal.search([
('number', '=', number),
('farm', '=', location.warehouse.id),

View File

@ -3467,6 +3467,10 @@ msgstr ""
"El inventario \"%(inventory)s\" no puede eliminarse porque no está en estado"
" \"Borrador\" o \"Cancelado\"."
msgctxt "model:ir.message,text:location_without_warehouse"
msgid "The location \"%(location)s\" don't have a warehouse."
msgstr "La ubicación \"%(location)s\" no tiene un almacén."
msgctxt "model:ir.message,text:missing_previous_inventory"
msgid ""
"There isn't any Feed Inventory before the feed provisional inventory "

View File

@ -68,6 +68,9 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.message" id="tag_must_be_unique">
<field name="text">The Name of the Tag must be unique.</field>
</record>
<record model="ir.message" id="location_without_warehouse">
<field name="text">The location "%(location)s" don't have a warehouse.</field>
</record>
<!-- production.py -->
<record model="ir.message" id="missing_semen_input">