Commit aeaee08d authored by Jérome Perrin's avatar Jérome Perrin

open_trade: fix pylint messages and enable coding style test

parent 1fc37201
...@@ -31,38 +31,38 @@ from Products.ERP5Type import Permissions, PropertySheet ...@@ -31,38 +31,38 @@ from Products.ERP5Type import Permissions, PropertySheet
from erp5.component.document.SupplyCell import SupplyCell from erp5.component.document.SupplyCell import SupplyCell
class OpenOrderCell(SupplyCell): class OpenOrderCell(SupplyCell):
""" """
An Open Order Cell allows to define specific properties An Open Order Cell allows to define specific properties
for each variation of a resource in an Open Order Line. for each variation of a resource in an Open Order Line.
""" """
meta_type = 'ERP5 Open Order Cell' meta_type = 'ERP5 Open Order Cell'
portal_type = 'Open Order Cell' portal_type = 'Open Order Cell'
add_permission = Permissions.AddPortalContent add_permission = Permissions.AddPortalContent
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties # Declarative properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.CategoryCore , PropertySheet.CategoryCore
, PropertySheet.Amount , PropertySheet.Amount
, PropertySheet.Task , PropertySheet.Task
, PropertySheet.Movement , PropertySheet.Movement
, PropertySheet.Price , PropertySheet.Price
, PropertySheet.SupplyLine , PropertySheet.SupplyLine
, PropertySheet.Discount , PropertySheet.Discount
, PropertySheet.Path , PropertySheet.Path
, PropertySheet.FlowCapacity , PropertySheet.FlowCapacity
, PropertySheet.Predicate , PropertySheet.Predicate
, PropertySheet.MappedValue , PropertySheet.MappedValue
, PropertySheet.Reference , PropertySheet.Reference
) )
def getTotalPrice(self): def getTotalPrice(self):
"""Returns the total price for this open order cell. """Returns the total price for this open order cell.
Unlike Amount, we do not calculate a price implicitly if not defined. Unlike Amount, we do not calculate a price implicitly if not defined.
Actually, I (jerome) think amount behaviour itself if wrong. Actually, I (jerome) think amount behaviour itself if wrong.
""" """
return (self.getQuantity() or 0) * (self.getPrice() or 0) return (self.getQuantity() or 0) * (self.getPrice() or 0)
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>OpenOrderCell</string> </value> <value> <string>OpenOrderCell</string> </value>
...@@ -43,18 +49,7 @@ ...@@ -43,18 +49,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 34, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 38, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 39, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 40, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 43, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 44, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 47, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 62, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 63, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 67, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -64,13 +59,28 @@ ...@@ -64,13 +59,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -83,7 +93,7 @@ ...@@ -83,7 +93,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -92,7 +102,7 @@ ...@@ -92,7 +102,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -32,54 +32,54 @@ from Products.ERP5Type import Permissions, PropertySheet ...@@ -32,54 +32,54 @@ from Products.ERP5Type import Permissions, PropertySheet
from erp5.component.document.SupplyLine import SupplyLine from erp5.component.document.SupplyLine import SupplyLine
class OpenOrderLine(SupplyLine): class OpenOrderLine(SupplyLine):
""" """
An Open Order Line is a Supply Line with additional An Open Order Line is a Supply Line with additional
properties to define repeatability properties to define repeatability
""" """
meta_type = 'ERP5 Open Order Line' meta_type = 'ERP5 Open Order Line'
portal_type = 'Open Order Line' portal_type = 'Open Order Line'
add_permission = Permissions.AddPortalContent add_permission = Permissions.AddPortalContent
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties # Declarative properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
, PropertySheet.CategoryCore , PropertySheet.CategoryCore
, PropertySheet.Amount , PropertySheet.Amount
, PropertySheet.Task , PropertySheet.Task
, PropertySheet.Arrow , PropertySheet.Arrow
, PropertySheet.Movement , PropertySheet.Movement
, PropertySheet.Price , PropertySheet.Price
, PropertySheet.SupplyLine , PropertySheet.SupplyLine
, PropertySheet.VariationRange , PropertySheet.VariationRange
, PropertySheet.Path , PropertySheet.Path
, PropertySheet.FlowCapacity , PropertySheet.FlowCapacity
, PropertySheet.Predicate , PropertySheet.Predicate
, PropertySheet.Comment , PropertySheet.Comment
) )
def getTotalQuantity(self, default=0): def getTotalQuantity(self, default=0):
"""Returns the total quantity for this open order line. """Returns the total quantity for this open order line.
If the order line contains cells, the total quantity of cells are If the order line contains cells, the total quantity of cells are
returned. returned.
""" """
if self.hasCellContent(base_id='path'): if self.hasCellContent(base_id='path'):
return sum([cell.getQuantity() for cell in return sum([cell.getQuantity() for cell in
self.getCellValueList(base_id='path')]) self.getCellValueList(base_id='path')])
return self.getQuantity(default) return self.getQuantity(default)
def getTotalPrice(self): def getTotalPrice(self):
"""Returns the total price for this open order line. """Returns the total price for this open order line.
If the order line contains cells, the total price of cells are If the order line contains cells, the total price of cells are
returned. returned.
""" """
if self.hasCellContent(base_id='path'): if self.hasCellContent(base_id='path'):
return sum([cell.getTotalPrice() for cell in return sum([cell.getTotalPrice() for cell in
self.getCellValueList(base_id='path')]) self.getCellValueList(base_id='path')])
return SupplyLine.getTotalPrice(self) return SupplyLine.getTotalPrice(self)
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>OpenOrderLine</string> </value> <value> <string>OpenOrderLine</string> </value>
...@@ -43,25 +49,7 @@ ...@@ -43,25 +49,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 35, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 40, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 41, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 42, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 45, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 46, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 49, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 65, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 66, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 70, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 71, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W: 73, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 75, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 76, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 80, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 81, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W: 83, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -71,13 +59,28 @@ ...@@ -71,13 +59,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -90,7 +93,7 @@ ...@@ -90,7 +93,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -99,7 +102,7 @@ ...@@ -99,7 +102,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -226,7 +226,7 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin, ...@@ -226,7 +226,7 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin,
return None return None
return open_order_line.getQuantityUnit(checked_permission=checked_permission) return open_order_line.getQuantityUnit(checked_permission=checked_permission)
def getPrice(self): def getPrice(self, context=None):
open_order_line = self.getAggregateRelatedValue(portal_type='Open Sale Order Line') open_order_line = self.getAggregateRelatedValue(portal_type='Open Sale Order Line')
if open_order_line is None: if open_order_line is None:
return None return None
...@@ -262,8 +262,16 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin, ...@@ -262,8 +262,16 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin,
return [] return []
return open_order_line.getSpecialiseValueList() return open_order_line.getSpecialiseValueList()
def _getCategoryMembershipList(self, category, spec=(), filter=None, def _getCategoryMembershipList(
portal_type=(), base=0, keep_default=1, checked_permission=None, **kw): self,
category,
spec=(),
filter=None, # pylint:disable=redefined-builtin
portal_type=(),
base=0,
keep_default=1,
checked_permission=None,
**kw):
if category == 'specialise': if category == 'specialise':
open_order_line = self.getAggregateRelatedValue(portal_type='Open Sale Order Line') open_order_line = self.getAggregateRelatedValue(portal_type='Open Sale Order Line')
return open_order_line._getCategoryMembershipList(category, spec=spec, filter=filter, return open_order_line._getCategoryMembershipList(category, spec=spec, filter=filter,
......
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>SubscriptionItem</string> </value> <value> <string>SubscriptionItem</string> </value>
...@@ -43,10 +49,7 @@ ...@@ -43,10 +49,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W:229, 2: Arguments number differs from overridden \'getPrice\' method (arguments-differ)</string>
<string>W:265, 58: Redefining built-in \'filter\' (redefined-builtin)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -56,13 +59,28 @@ ...@@ -56,13 +59,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -75,7 +93,7 @@ ...@@ -75,7 +93,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -84,7 +102,7 @@ ...@@ -84,7 +102,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -6,10 +6,10 @@ if resource is not None: ...@@ -6,10 +6,10 @@ if resource is not None:
for base_category in base_category_list: for base_category in base_category_list:
if matrixbox: if matrixbox:
# XXX matrixbox is right_display (not as listfield) => invert display and value in item # XXX matrixbox is right_display (not as listfield) => invert display and value in item
cell_range.append( map(lambda x: (x[1],x[0]), context.getVariationCategoryItemList(base_category_list=(base_category,), display_id='translated_title' ) ) ) cell_range.append([(x[1], x[0]) for x in context.getVariationCategoryItemList(base_category_list=(base_category,), display_id='translated_title')])
else: else:
cell_range.append( context.getVariationCategoryList(base_category_list = (base_category,) ) ) cell_range.append( context.getVariationCategoryList(base_category_list = (base_category,) ) )
cell_range = filter(lambda x: x != [], cell_range ) cell_range = [x for x in cell_range if x != []]
return cell_range return cell_range
...@@ -3,7 +3,7 @@ subscription_item_set = set() ...@@ -3,7 +3,7 @@ subscription_item_set = set()
for open_order_line in context.objectValues(): for open_order_line in context.objectValues():
for ob in [open_order_line] + open_order_line.getCellValueList(): for ob in [open_order_line] + open_order_line.getCellValueList():
for item in ob.getAggregateValueList(): for item in ob.getAggregateValueList():
if getattr(item.aq_explicit, 'updateSimulation', None) is not None and \ if getattr(item.aq_explicit, 'updateSimulation', None) is not None and \
item not in subscription_item_set: item not in subscription_item_set:
subscription_item_set.add(item) subscription_item_set.add(item)
item.updateSimulation(expand_root=1) item.updateSimulation(expand_root=1)
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