Commit 1a353a12 authored by Titouan Soulard's avatar Titouan Soulard

erp5_trade: do not show quantity on Order Line view when resource is not set or has variation axes

parent c990e3cd
"""This script is used to know if quantity can be edited by user.
* If this is not a movement (line containing lines or cell), user
cannot edit this line which is just a container, but no actual movement.
* If this line has variation category list, then it means it's a line that
will contain cell, so it's already not possible to set quantity, user have
to create cells and set quantities on cells.
* If items are used, quantity is set by the item quantity.
"""
This script was used to know if quantity can be edited by user.
It is now kept for backward compatibility as it does the same as `Movement_isQuantityEnabled`.
"""
if not context.isMovement():
return False
if context.getVariationCategoryList(omit_optional_variation=1) and not 'Cell' in context.getPortalType():
return False
return not (context.getResource() and context.getResourceValue().getAggregatedPortalTypeList())
return context.Movement_isQuantityEnabled()
return context.isMovement() and not context.getVariationCategoryList()
"""
This script is used to know if quantity field should be displayed to user.
* If no resource is defined yet, user cannot see quantity, as we still don't
know if resource will have variations or items.
* If this is not a movement (line containing lines or cell), user cannot edit
this line which is just a container, but no actual movement.
* If the resource has variation base category list, then it means it's a line
that will contain cell, so it's already not possible to set quantity, user have
to create cells and set quantities on cells.
"""
if context.getResource() is None:
return False
if not context.isMovement():
return False
resource = context.getResourceValue()
return ('Cell' in context.getPortalType()) or not resource.getVariationBaseCategoryList()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment