Commit 275a868a authored by Titouan Soulard's avatar Titouan Soulard

erp5_trade: SPLIT remove now-useless `isInventoryMovement` getter

Also: add `getTotalQuantity`. Why?
parent 90cd4d73
Pipeline #38692 failed with stage
in 0 seconds
......@@ -29,7 +29,6 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from erp5.component.document.DeliveryCell import DeliveryCell
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
class InventoryOffsetCell(DeliveryCell):
"""
......@@ -39,7 +38,6 @@ class InventoryOffsetCell(DeliveryCell):
meta_type = "ERP5 Inventory Offset Cell"
portal_type = "Inventory Offset Cell"
add_permission = Permissions.AddPortalContent
isInventoryMovement = ConstantGetter("isInventoryMovement", value=True)
# Declarative security
security = ClassSecurityInfo()
......
......@@ -29,7 +29,6 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from erp5.component.document.DeliveryLine import DeliveryLine
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
class InventoryOffsetLine(DeliveryLine):
"""
......@@ -39,7 +38,6 @@ class InventoryOffsetLine(DeliveryLine):
meta_type = "ERP5 Inventory Offset Line"
portal_type = "Inventory Offset Line"
add_permission = Permissions.AddPortalContent
isInventoryMovement = ConstantGetter("isInventoryMovement", value=True)
# Declarative security
security = ClassSecurityInfo()
......@@ -57,3 +55,31 @@ class InventoryOffsetLine(DeliveryLine):
, PropertySheet.VariationRange
, PropertySheet.ItemAggregation
)
security.declareProtected(Permissions.AccessContentsInformation, 'getTotalQuantity')
def getTotalQuantity(self):
"""
Returns the quantity if no cell or the total quantity if cells
"""
if not self.hasCellContent():
return self.getQuantity()
else:
total_quantity = 0.0
for cell in self.getCellValueList(base_id='movement'):
if cell.getQuantity() is not None:
total_quantity += cell.getQuantity()
return total_quantity
security.declareProtected(Permissions.AccessContentsInformation, 'getTotalPrice')
def getTotalPrice(self):
"""
Returns the price if no cell or the total price if cells
"""
if not self.hasCellContent():
return self.getPrice()
else:
total_price = 0.0
for cell in self.getCellValueList(base_id='movement'):
if cell.getPrice() is not None:
total_price += cell.getPrice()
return total_price
......@@ -35,7 +35,10 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
<tuple>
<string>W: 60, 2: Arguments number differs from overridden \'getTotalQuantity\' method (arguments-differ)</string>
<string>W: 74, 2: Arguments number differs from overridden \'getTotalPrice\' method (arguments-differ)</string>
</tuple>
</value>
</item>
<item>
......
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