mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[REF] changes suggested by @guewen
Set a keyword argument on the context to better respect the convention. Make it clear in docstrings that the side-effects on field_names are intended. Allow the context to contain iterable types supported by the ORM.
This commit is contained in:
@@ -56,8 +56,10 @@ class ProductProduct(orm.Model):
|
||||
The sub-modules MUST call super()._product_available BEFORE their own
|
||||
computations
|
||||
|
||||
Side-effect warning: This method may change the list passed as the
|
||||
field_names parameter, which will then alter the caller's state."""
|
||||
Side-effect warning: By design, we want to change the behavior of the
|
||||
caller (make it aware that an extra field is being computed).
|
||||
For this, this method MAY change the list passed as the parameter
|
||||
`field_names`."""
|
||||
# If we didn't get a field_names list, there's nothing to do
|
||||
if field_names is None:
|
||||
return super(ProductProduct, self)._product_available(
|
||||
|
||||
@@ -26,15 +26,17 @@ class product_immediately_usable(orm.Model):
|
||||
"""Subtract incoming qty from immediately_usable_qty
|
||||
|
||||
We don't need to override the function fields, the module stock_available
|
||||
takes of it for us.
|
||||
|
||||
Side-effect warning: This method may change the list passed as the
|
||||
field_names parameter, which will then alter the caller's state."""
|
||||
takes care of it for us."""
|
||||
_inherit = 'product.product'
|
||||
|
||||
def _product_available(self, cr, uid, ids, field_names=None,
|
||||
arg=False, context=None):
|
||||
"""Ignore the incoming goods in the quantity available to promise"""
|
||||
"""Ignore the incoming goods in the quantity available to promise
|
||||
|
||||
Side-effect warning: By design, we want to change the behavior of the
|
||||
caller (make it aware that an extra field is being computed).
|
||||
For this, this method MAY change the list passed as the parameter
|
||||
`field_names`."""
|
||||
# If we didn't get a field_names list, there's nothing to do
|
||||
if field_names is None or 'immediately_usable_qty' not in field_names:
|
||||
return super(product_immediately_usable, self)._product_available(
|
||||
|
||||
@@ -73,10 +73,12 @@ class product_product(orm.Model):
|
||||
return res
|
||||
|
||||
def _compute_potential_qty_from_bom(self, cr, uid, bom_id, to_uom,
|
||||
context):
|
||||
context=None):
|
||||
"""Compute the potential qty from BoMs with components available"""
|
||||
bom_obj = self.pool['mrp.bom']
|
||||
uom_obj = self.pool['product.uom']
|
||||
if context is None:
|
||||
context = {}
|
||||
if 'uom' in context:
|
||||
context_wo_uom = context.copy()
|
||||
del context_wo_uom['uom']
|
||||
|
||||
@@ -134,7 +134,7 @@ class ProductProduct(orm.Model):
|
||||
# location
|
||||
if context.get('location', False):
|
||||
# Either a single or multiple locations can be in the context
|
||||
if not isinstance(context['location'], list):
|
||||
if isinstance(context['location'], (int, long)):
|
||||
location_ids = [context['location']]
|
||||
else:
|
||||
location_ids = context['location']
|
||||
|
||||
Reference in New Issue
Block a user