Commit c990e3cd authored by Titouan Soulard's avatar Titouan Soulard

erp5_trade: disallow setting items on Order Line view when Product has variations

parent 96ca750d
"""This script is an helper to replace complex TALES expression
for Base_viewTradeFieldLibrary/my_view_mode_aggregate_title_list.enable
"""
# If the resource accepts items, and the context is a movements (ie. not a line
# already containing cells or line that has variations but not cells yet)
if context.getResource() and context.getResourceValue().getAggregatedPortalTypeList()\
and context.isMovement()\
and (('Cell' in context.getPortalType()) or not context.getVariationCategoryList()):
return True
This script is used to know if a Line or Cell can use Items.
"""
# If the movement already has an aggregate, display it.
if context.getAggregate():
return True
# If there's not resource yet, we give a chance to set an item.
if context.getResource() is None and context.getPortalItemTypeList():
# If there is a resource and the context is a movement...
if context.getResource() and context.isMovement():
resource = context.getResourceValue()
# ...then the resource must accept Items and not use variations
# (in this case, Items are to be set on cells).
if resource.getAggregatedPortalTypeList() and \
(('Cell' in context.getPortalType()) or not resource.getVariationBaseCategoryList()):
return True
return False
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