Dont drop ul if not at warehouse

This commit refs #26948
This commit is contained in:
ramon.vidal 2023-05-24 14:24:57 +02:00 committed by jm.pardo
parent 23ce751860
commit 35e2fe0283
3 changed files with 20 additions and 0 deletions

View File

@ -74,6 +74,10 @@ msgctxt "model:ir.message,text:msg_move_date_in_the_future"
msgid "The moves of the unit load cannot be done because have date in future."
msgstr "Los movimientos de la unidad de carga no se pueden finalizar porque tienen fecha en el futuro."
msgctxt "model:ir.message,text:msg_stock_unit_load_missing_at_warehouse"
msgid "Cannot drop UL \"%(unit_load)s\" without have warehouse at date."
msgstr "No se puede volcar UdC \"%(unit_load)s\" sin tener almacén a fecha."
msgctxt "field:stock.configuration,unit_load_sequence:"
msgid "Load unit Sequence"
msgstr "Secuencia de unidad de carga"

View File

@ -45,6 +45,9 @@
<record model="ir.message" id="msg_move_date_in_the_future">
<field name="text">The moves of the unit load cannot be done because have date in future.</field>
</record>
<record model="ir.message" id="msg_stock_unit_load_missing_at_warehouse">
<field name="text">Cannot drop UL "%(unit_load)s" without have warehouse at date.</field>
</record>
<!-- stock.unit_load.do_drop -->
<record model="ir.message" id="msg_stock_unit_load_do_drop_invalid_ul">

View File

@ -452,6 +452,14 @@ class UnitLoad(ModelSQL, ModelView):
'stock_unit_load.msg_stock_unit_load_ul_not_available',
unit_load=record.rec_name))
@classmethod
def _check_at_warehouse(cls, records):
for record in records:
if not record.at_warehouse:
raise UserError(gettext(
'stock_unit_load.msg_stock_unit_load_missing_at_warehouse',
unit_load=record.rec_name))
def get_rec_name(self, name):
if Transaction().context.get('ul_extended_rec_name', False):
cases_string = self.fields_get(fields_names=['cases_quantity'])[
@ -1522,6 +1530,7 @@ class UnitLoad(ModelSQL, ModelView):
records = PYSONDecoder.decode(records)
if not isinstance(records[0], Model):
records = cls.search(records)
cls._check_at_warehouse(records)
to_do = []
for record in records:
@ -2533,7 +2542,11 @@ class BatchDropUnitLoad(Wizard):
do_ = StateTransition()
def transition_start(self):
pool = Pool()
UnitLoad = pool.get('stock.unit_load')
uls = self._get_unit_loads()
UnitLoad._check_at_warehouse(uls)
for ul in uls:
if not ul.available:
raise UserError(gettext(