diff --git a/locale/es.po b/locale/es.po index f42d041..f5f92e7 100644 --- a/locale/es.po +++ b/locale/es.po @@ -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" diff --git a/message.xml b/message.xml index 114122b..685067e 100644 --- a/message.xml +++ b/message.xml @@ -45,6 +45,9 @@ The moves of the unit load cannot be done because have date in future. + + Cannot drop UL "%(unit_load)s" without have warehouse at date. + diff --git a/unit_load.py b/unit_load.py index 78af8d6..b13e11e 100644 --- a/unit_load.py +++ b/unit_load.py @@ -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(