Commit 0d702108 authored by Arnaud Fontaine's avatar Arnaud Fontaine

erp5_budget: Fix errors/warnings reported by pylint.

parent b876df9a
......@@ -34,33 +34,32 @@ from Products.ERP5.mixin.variated import VariatedMixin
class Budget(Predicate, VariatedMixin):
"""
Budget means a kind of budget stock.
"""
"""
Budget means a kind of budget stock.
"""
# Default Properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.SimpleItem
, PropertySheet.CategoryCore
, PropertySheet.Folder
, PropertySheet.Predicate
, PropertySheet.SortIndex
, PropertySheet.Task
, PropertySheet.Arrow
, PropertySheet.Budget
, PropertySheet.Path
, PropertySheet.VariationRange
, PropertySheet.Reference
, PropertySheet.Version
)
# Default Properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.SimpleItem
, PropertySheet.CategoryCore
, PropertySheet.Folder
, PropertySheet.Predicate
, PropertySheet.SortIndex
, PropertySheet.Task
, PropertySheet.Arrow
, PropertySheet.Budget
, PropertySheet.Path
, PropertySheet.VariationRange
, PropertySheet.Reference
, PropertySheet.Version
)
# CMF Type Definition
meta_type='ERP5 Budget'
portal_type='Budget'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# CMF Type Definition
meta_type='ERP5 Budget'
portal_type='Budget'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
\ No newline at end of file
......@@ -6,6 +6,12 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>Budget</string> </value>
......@@ -14,6 +20,12 @@
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.Budget</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.Budget</string> </value>
......@@ -37,15 +49,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 37, 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: 59, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 60, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 61, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 64, 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>
</tuple>
<tuple/>
</value>
</item>
<item>
......@@ -55,13 +59,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -74,7 +93,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -83,7 +102,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
......@@ -35,133 +35,133 @@ from Products.ERP5.Document.MetaNode import MetaNode
from Products.ERP5.Document.Movement import Movement
class BudgetCell(Predicate, MetaNode, Movement):
""" Budget Cell defines a cell of budget.
XXX This is not a Movement, but we need getDestinationCredit
XXX This is not a MetaNode
""" Budget Cell defines a cell of budget.
XXX This is not a Movement, but we need getDestinationCredit
XXX This is not a MetaNode
"""
# Default Properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.SimpleItem
, PropertySheet.Folder
, PropertySheet.Predicate
, PropertySheet.SortIndex
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Task
, PropertySheet.Arrow
, PropertySheet.Amount
, PropertySheet.Budget
, PropertySheet.MappedValue
, PropertySheet.VariationRange
)
# CMF Type Definition
meta_type='ERP5 Budget Cell'
portal_type='Budget Cell'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getTitle(self):
"""
Return a calculated title.
"""
script = self._getTypeBasedMethod('asTitle')
if script is not None:
return script()
raise UnboundLocalError(
"Did not find title script for portal type: %r" %
self.getPortalType())
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory')
def getCurrentInventory(self, at_date=None, **kw):
""" Returns current inventory.
at_date parameter can be used to take into account budget transactions
before that date.
"""
kw['node_uid'] = self.getUid()
resource = self.getResourceValue()
if resource is not None:
kw['resource_uid'] = resource.getUid()
if at_date:
kw['at_date'] = at_date
sign = self.getParentValue().BudgetLine_getConsumptionSign()
return sign * self.portal_simulation.getCurrentInventory(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentBalance')
def getCurrentBalance(self, at_date=None):
"""
Returns current balance
"""
sign = self.getParentValue().BudgetLine_getConsumptionSign()
return sign * self.getQuantity(0.0) + self.getCurrentInventory(at_date=at_date)
# Default Properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.SimpleItem
, PropertySheet.Folder
, PropertySheet.Predicate
, PropertySheet.SortIndex
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Task
, PropertySheet.Arrow
, PropertySheet.Amount
, PropertySheet.Budget
, PropertySheet.MappedValue
, PropertySheet.VariationRange
)
# CMF Type Definition
meta_type='ERP5 Budget Cell'
portal_type='Budget Cell'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getTitle(self):
"""
Return a calculated title.
"""
script = self._getTypeBasedMethod('asTitle')
if script is not None:
return script()
raise UnboundLocalError,\
"Did not find title script for portal type: %r" %\
self.getPortalType()
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory')
def getCurrentInventory(self, at_date=None, **kw):
""" Returns current inventory.
at_date parameter can be used to take into account budget transactions
before that date.
"""
kw['node_uid'] = self.getUid()
resource = self.getResourceValue()
if resource is not None:
kw['resource_uid'] = resource.getUid()
if at_date:
kw['at_date'] = at_date
sign = self.getParentValue().BudgetLine_getConsumptionSign()
return sign * self.portal_simulation.getCurrentInventory(**kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentBalance')
def getCurrentBalance(self, at_date=None):
"""
Returns current balance
"""
sign = self.getParentValue().BudgetLine_getConsumptionSign()
return sign * self.getQuantity(0.0) + self.getCurrentInventory(at_date=at_date)
security.declareProtected(Permissions.AccessContentsInformation, 'getConsumedBudget')
def getConsumedBudget(self, src__=0):
"""
Return consumed budget.
"""
script = self._getTypeBasedMethod('getConsumedBudget')
if script is not None:
return script(src__=src__)
raise UnboundLocalError,\
"Did not find consumed budget script for portal type: %r" % \
self.getPortalType()
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableBudget')
def getAvailableBudget(self, at_date=None):
"""
Return available budget.
"""
return self.getCurrentBalance(at_date=at_date) - self.getEngagedBudget()
security.declareProtected(Permissions.AccessContentsInformation, 'getEngagedBudget')
def getEngagedBudget(self, src__=0):
"""
Return Engaged budget.
"""
script = self._getTypeBasedMethod('getEngagedBudget')
if script is not None:
return script(src__=src__)
raise UnboundLocalError,\
"Did not find engaged budget script for portal type: %r" % \
self.getPortalType()
security.declareProtected(Permissions.AccessContentsInformation,
'getExplanationValue')
def getExplanationValue(self, default=None):
"""Explanation has no meaning for a budget cell"""
return default
security.declareProtected(Permissions.ModifyPortalContent,
'setSourceCredit')
def setSourceCredit(self, source_credit):
"""Set the quantity.
Overloaded from movement, we always set the quantity, even if not passed
"""
try:
source_credit = float(source_credit)
except TypeError:
source_credit = 0.0
Movement.setSourceCredit(self, source_credit)
def setSourceDebit(self, source_debit):
"""Set the quantity.
Overloaded from movement, we always set the quantity, even if not passed
"""
try:
source_debit = float(source_debit)
except TypeError:
source_debit = 0.0
Movement.setSourceDebit(self, source_debit)
security.declareProtected( Permissions.ModifyPortalContent,
'setDestinationDebit', 'setDestinationCredit' )
setDestinationDebit = setSourceCredit
setDestinationCredit = setSourceDebit
security.declareProtected(Permissions.AccessContentsInformation, 'getConsumedBudget')
def getConsumedBudget(self, src__=0):
"""
Return consumed budget.
"""
script = self._getTypeBasedMethod('getConsumedBudget')
if script is not None:
return script(src__=src__)
raise UnboundLocalError(
"Did not find consumed budget script for portal type: %r" %
self.getPortalType())
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableBudget')
def getAvailableBudget(self, at_date=None):
"""
Return available budget.
"""
return self.getCurrentBalance(at_date=at_date) - self.getEngagedBudget()
security.declareProtected(Permissions.AccessContentsInformation, 'getEngagedBudget')
def getEngagedBudget(self, src__=0):
"""
Return Engaged budget.
"""
script = self._getTypeBasedMethod('getEngagedBudget')
if script is not None:
return script(src__=src__)
raise UnboundLocalError(
"Did not find engaged budget script for portal type: %r" %
self.getPortalType())
security.declareProtected(Permissions.AccessContentsInformation,
'getExplanationValue')
def getExplanationValue(self):
"""Explanation has no meaning for a budget cell"""
return None
security.declareProtected(Permissions.ModifyPortalContent,
'setSourceCredit')
def setSourceCredit(self, source_credit):
"""Set the quantity.
Overloaded from movement, we always set the quantity, even if not passed
"""
try:
source_credit = float(source_credit)
except TypeError:
source_credit = 0.0
Movement.setSourceCredit(self, source_credit)
def setSourceDebit(self, source_debit):
"""Set the quantity.
Overloaded from movement, we always set the quantity, even if not passed
"""
try:
source_debit = float(source_debit)
except TypeError:
source_debit = 0.0
Movement.setSourceDebit(self, source_debit)
security.declareProtected(Permissions.ModifyPortalContent,
'setDestinationDebit', 'setDestinationCredit' )
setDestinationDebit = setSourceCredit
setDestinationCredit = setSourceDebit
\ No newline at end of file
......@@ -32,37 +32,35 @@ from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.DeliveryLine import DeliveryLine
class BudgetTransaction(DeliveryLine):
"""
BudgetTransaction an order or transfer of budget.
"""
# Default Properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.Amount
, PropertySheet.Task
, PropertySheet.Arrow
, PropertySheet.Movement
, PropertySheet.Price
, PropertySheet.VariationRange
, PropertySheet.ItemAggregation
)
# CMF Type Definition
meta_type='ERP5 Budget Transaction'
portal_type='Budget Transaction'
add_permission = Permissions.AddPortalContent
"""
BudgetTransaction an order or transfer of budget.
"""
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Default Properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.Amount
, PropertySheet.Task
, PropertySheet.Arrow
, PropertySheet.Movement
, PropertySheet.Price
, PropertySheet.VariationRange
, PropertySheet.ItemAggregation
)
# CMF Type Definition
meta_type='ERP5 Budget Transaction'
portal_type='Budget Transaction'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected(Permissions.AccessContentsInformation,
'isAccountable')
def isAccountable(self):
"""
Supersedes the DeliveryLine definition
"""
return 1
security.declareProtected(Permissions.AccessContentsInformation,
'isAccountable')
def isAccountable(self):
"""
Supersedes the DeliveryLine definition
"""
return 1
\ No newline at end of file
......@@ -6,6 +6,12 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>BudgetTransaction</string> </value>
......@@ -14,6 +20,12 @@
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.BudgetTransaction</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.BudgetTransaction</string> </value>
......@@ -37,19 +49,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<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: 52, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 53, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 54, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 57, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 58, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 61, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 63, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 64, 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>
<tuple/>
</value>
</item>
<item>
......@@ -59,13 +59,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -78,7 +93,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -87,7 +102,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
......@@ -33,25 +33,24 @@ from Products.ERP5Type import Permissions, PropertySheet
class BudgetTransfer(Supply):
"""
BudgetTransfer ...
"""
"""
BudgetTransfer ...
"""
# Default Properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.Folder
, PropertySheet.Task
, PropertySheet.Arrow
, PropertySheet.Movement
)
# Default Properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.Folder
, PropertySheet.Task
, PropertySheet.Arrow
, PropertySheet.Movement
)
# CMF Type Definition
meta_type='ERP5 Budget Transfer'
portal_type='Budget Transfer'
add_permission = Permissions.AddPortalContent
# CMF Type Definition
meta_type='ERP5 Budget Transfer'
portal_type='Budget Transfer'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
\ No newline at end of file
......@@ -6,6 +6,12 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>BudgetTransfer</string> </value>
......@@ -14,6 +20,12 @@
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.BudgetTransfer</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.BudgetTransfer</string> </value>
......@@ -37,15 +49,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 36, 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: 51, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 52, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 53, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 56, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 57, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......@@ -55,13 +59,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>