Corregir descripciones de campos y traducciones.
Ampliar gestión de espacio para ubicaciones tipo Vista (a través de sus hijos).
This commit is contained in:
parent
cf53beb47e
commit
9a860edc1b
|
@ -4,9 +4,10 @@ msgstr "Content-Type: text/plain; charset=utf-8\n"
|
|||
|
||||
msgctxt "error:stock.move:"
|
||||
msgid ""
|
||||
"Products cannot be storage in location \"%s\" due to there is not enough "
|
||||
"space."
|
||||
msgstr "No es posible almacenar productos en la ubicación \"%s\" porque no hay espacio suficiente."
|
||||
"Products cannot be stored in location \"%s\" at date \"%s\" "
|
||||
"due to there is not enough space."
|
||||
msgstr "No es posible almacenar productos en la ubicación \"%s\" a fecha \"%s\" "
|
||||
"porque no hay espacio suficiente."
|
||||
|
||||
msgctxt "field:product.template,occupy_space:"
|
||||
msgid "Occupy space"
|
||||
|
|
44
stock.py
44
stock.py
|
@ -80,7 +80,7 @@ class Location:
|
|||
'overload_behavior': 'warn'}
|
||||
|
||||
def storage_try(self, date, extra_space=float(0)):
|
||||
""" Determines if store in the location at date is possible"""
|
||||
""" Determines if storing in location at date is possible"""
|
||||
with Transaction().set_context(stock_date_end=date):
|
||||
return (self.get_available_space() - extra_space) >= 0
|
||||
|
||||
|
@ -91,8 +91,13 @@ class Location:
|
|||
ModelData = pool.get('ir.model.data')
|
||||
meter = UOM(ModelData.get_id('product', 'uom_meter'))
|
||||
|
||||
if not getattr(self, 'control_space', False):
|
||||
if not self.check_space():
|
||||
return 0
|
||||
if self.type == 'view':
|
||||
space = 0
|
||||
for c in self.childs:
|
||||
space += c.get_space()
|
||||
return space
|
||||
return UOM.compute_qty(self.length_uom, getattr(self, 'length', float(0)), meter)
|
||||
|
||||
def get_available_space(self, name=None):
|
||||
|
@ -101,7 +106,7 @@ class Location:
|
|||
Product = pool.get('product.product')
|
||||
Date_ = pool.get('ir.date')
|
||||
|
||||
if not self.control_space:
|
||||
if not self.check_space():
|
||||
return 0
|
||||
|
||||
context = {'forecast': True}
|
||||
|
@ -114,7 +119,8 @@ class Location:
|
|||
with Transaction().set_context(context):
|
||||
pbl = Product.products_by_location(location_ids=[self.id],
|
||||
product_ids=product_ids,
|
||||
grouping=('product', ))
|
||||
grouping=('product', ),
|
||||
with_childs=(self.type == 'view'))
|
||||
space = float(0)
|
||||
for key, quantity in pbl.iteritems():
|
||||
product = Product(key[1])
|
||||
|
@ -122,6 +128,9 @@ class Location:
|
|||
|
||||
return self.get_space() - space
|
||||
|
||||
def check_space(self):
|
||||
return self.control_space or (self.type == 'view' and self.childs)
|
||||
|
||||
|
||||
class Move:
|
||||
__name__ = 'stock.move'
|
||||
|
@ -129,9 +138,8 @@ class Move:
|
|||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Move, cls).__setup__()
|
||||
cls._error_messages.update({'check_storage_space':
|
||||
'Products cannot be storage in location "%s" '
|
||||
'due to there is not enough space.'})
|
||||
cls._error_messages.update({'check_storage_space': 'Products cannot be stored in location "%s" at date "%s" '
|
||||
'due to there is not enough space.'})
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
|
@ -159,8 +167,9 @@ class Move:
|
|||
pool = Pool()
|
||||
Configuration = pool.get('stock.configuration')
|
||||
Location = pool.get('stock.location')
|
||||
Product = pool.get('product.product')
|
||||
conf = Configuration(1)
|
||||
Lang = pool.get('ir.lang')
|
||||
language = Transaction().language
|
||||
|
||||
if not conf.space_control:
|
||||
return True
|
||||
|
@ -178,19 +187,24 @@ class Move:
|
|||
if not location.storage_try(date, extra_space):
|
||||
if not raise_error:
|
||||
return False
|
||||
languages = Lang.search([('code', '=', language)])
|
||||
if not languages:
|
||||
languages = Lang.search([('code', '=', 'en_US')])
|
||||
language, = languages
|
||||
formatted = Lang.strftime(date, language.code, language.date)
|
||||
if getattr(location, 'overload_behavior', 'warn') == 'warn':
|
||||
cls.raise_user_warning('%.check_storage_space' % loc,
|
||||
'check_storage_space',
|
||||
location.rec_name)
|
||||
(location.rec_name, formatted))
|
||||
elif getattr(location, 'overload_behavior', 'warn') == 'stop':
|
||||
cls.raise_user_error('check_storage_space', location.rec_name)
|
||||
cls.raise_user_error('check_storage_space', (location.rec_name, formatted))
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def _get_locations_to_check_space(cls, moves, grouping=('location', 'date')):
|
||||
""" Collects Locations that might be checked for storage space control.
|
||||
|
||||
Return a dictionary with location id and grouping as key
|
||||
Returns a dictionary with location id and grouping as key
|
||||
and quantity as extra space needed for non persisted movements given.
|
||||
"""
|
||||
pool = Pool()
|
||||
|
@ -216,16 +230,16 @@ class Move:
|
|||
if 'date' in grouping:
|
||||
key_from = key_from + (date,)
|
||||
key_to = key_to + (date,)
|
||||
if m.from_location.control_space:
|
||||
if m.from_location.check_space():
|
||||
locations.setdefault(key_from, float(0))
|
||||
if m.to_location.control_space:
|
||||
if m.to_location.check_space():
|
||||
locations.setdefault(key_to, float(0))
|
||||
# if moves are not persisted we must to include them in space computing
|
||||
if not getattr(m, 'id', None):
|
||||
product = Product(m.product.id)
|
||||
qty = product.get_space(m.quantity, m.uom)
|
||||
if m.from_location.control_space:
|
||||
if m.from_location.check_space():
|
||||
locations[key_from] = locations[key_from] - qty
|
||||
if m.to_location.control_space:
|
||||
if m.to_location.check_space():
|
||||
locations[key_to] = locations[key_to] + qty
|
||||
return locations
|
Loading…
Reference in New Issue