Commit 4558c52d by Jérome Perrin

Make coding style install less business templates

Move `BusinessTemplate_getPythonSourceCodeMessageList` to `erp5_core`, so that coding style tests don't need to install `erp5_administration` and all its dependencies.

`erp5_core` is not the final place for this, because this is not required to for business template bootstrap, but this is temporary until we finish business template reorganisation.

This revealed several problems of wrong dependencies between business templates that we could not see before, when coding style was installing too many business templates such as `erp5_pdm`, `erp5_trade`, `erp5_simulation`, `erp5_project`.

See merge request !1089
parents b78241cd 1c05093c
Pipeline #8696 passed with stage
in 0 seconds
erp5_base >= 0.8.3
erp5_core >= 1.0rc13
\ No newline at end of file
erp5_core >= 1.0rc13
erp5_simulation
\ No newline at end of file
......@@ -173,52 +173,6 @@ def checkConversionToolAvailability(self):
result.edit(severity=severity)
active_process.postResult(result)
from Products.ERP5Type.Utils import checkPythonSourceCode
def checkPythonSourceCodeAsJSON(self, data, REQUEST=None):
"""
Check Python source suitable for Source Code Editor and return a JSON object
"""
import json
# XXX data is encoded as json, because jQuery serialize lists as []
if isinstance(data, basestring):
data = json.loads(data)
# data contains the code, the bound names and the script params. From this
# we reconstruct a function that can be checked
def indent(text):
return ''.join((" " + line) for line in text.splitlines(True))
is_python_script = 'bound_names' in data
if is_python_script:
signature_parts = data['bound_names']
if data['params']:
signature_parts += [data['params']]
signature = ", ".join(signature_parts)
function_name = "function_name"
body = "def %s(%s):\n%s" % (function_name,
signature,
indent(data['code']) or " pass")
else:
body = data['code']
message_list = checkPythonSourceCode(body.encode('utf8'), data.get('portal_type'))
for message_dict in message_list:
if is_python_script:
message_dict['row'] = message_dict['row'] - 2
else:
message_dict['row'] = message_dict['row'] - 1
if message_dict['type'] in ('E', 'F'):
message_dict['type'] = 'error'
else:
message_dict['type'] = 'warning'
if REQUEST is not None:
REQUEST.RESPONSE.setHeader('content-type', 'application/json')
return json.dumps(dict(annotations=message_list))
def filterSecurityUidDict(security_uid_dict, referenced_security_uid_set):
"""
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>Consumption</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.Consumption</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.Consumption</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 40, 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: 50, 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: 60, 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>
<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: 77, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 78, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 82, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 83, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 85, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 87, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 88, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 93, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 95, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 97, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 99, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:103, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:105, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:107, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:108, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:109, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:110, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:111, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:112, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:113, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:114, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:115, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:117, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 62, 4: Arguments number differs from overridden \'_setVariationCategoryList\' method (arguments-differ)</string>
<string>W: 77, 4: Arguments number differs from overridden \'setVariationCategoryList\' method (arguments-differ)</string>
<string>W: 87, 4: Arguments number differs from overridden \'getVariationRangeBaseCategoryItemList\' method (arguments-differ)</string>
<string>W: 93, 13: map/filter on lambda could be replaced by comprehension (deprecated-lambda)</string>
</tuple>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</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>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -7,5 +7,4 @@ document.erp5.ApparelMeasurement
document.erp5.ApparelModel
document.erp5.ApparelShape
document.erp5.ApparelSize
document.erp5.Consumption
document.erp5.VariationImage
\ No newline at end of file
portal_components/document.erp5.Consumption
\ No newline at end of file
......@@ -66,7 +66,6 @@
<item>Causality Movement Group</item>
<item>Day Movement Group</item>
<item>Delivery Causality Assignment Movement Group</item>
<item>First Causality Movement Group</item>
<item>Invoice Movement Group</item>
<item>Monthly Range Movement Group</item>
<item>Nested Line Movement Group</item>
......@@ -129,7 +128,4 @@
<portal_type id="Rounding Tool">
<item>Rounding Model</item>
</portal_type>
<portal_type id="Solver Tool">
<item>Solver Type</item>
</portal_type>
</allowed_content_type_list>
\ No newline at end of file
......@@ -40,7 +40,6 @@ Order Builder | Causality Assignment Movement Group
Order Builder | Causality Movement Group
Order Builder | Day Movement Group
Order Builder | Delivery Causality Assignment Movement Group
Order Builder | First Causality Movement Group
Order Builder | Invoice Movement Group
Order Builder | Monthly Range Movement Group
Order Builder | Nested Line Movement Group
......@@ -87,5 +86,4 @@ Person | Fax
Person | Link
Person | Telephone
Query Module | Query
Rounding Tool | Rounding Model
Solver Tool | Solver Type
\ No newline at end of file
Rounding Tool | Rounding Model
\ No newline at end of file
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Component_getErrorWarningMessageDictAsJson</string> </value>
<value> <string>ComponentMixin_getErrorWarningMessageDictAsJson</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Component_getTextContentHistoryRevisionDictListAsJSON</string> </value>
<value> <string>ComponentMixin_getTextContentHistoryRevisionDictListAsJSON</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -159,7 +159,7 @@
$.ajax({type: 'GET',
async: false,
url: 'Component_getErrorWarningMessageDictAsJson',
url: 'ComponentMixin_getErrorWarningMessageDictAsJson',
success: getErrorWarningMessageDictHandler});
}
......@@ -651,7 +651,7 @@
$.ajax({type: 'GET',
async: true,
dataType: 'json',
url: 'Component_getTextContentHistoryRevisionDictListAsJSON',
url: 'ComponentMixin_getTextContentHistoryRevisionDictListAsJSON',
success: successHandler});
}
......
erp5_crm
erp5_dms
\ No newline at end of file
erp5_dms
erp5_trade
\ No newline at end of file
erp5_base
erp5_interfaces
\ No newline at end of file
......@@ -37,81 +37,85 @@ from Products.ERP5.mixin.variated import VariatedMixin
class Consumption(XMLObject, XMLMatrix, VariatedMixin):
"""
A matrix which provides default quantities
for a given quantity
"""
"""
A matrix which provides default quantities
for a given quantity
"""
meta_type = 'ERP5 Consumption'
portal_type = 'Consumption'
meta_type = 'ERP5 Consumption'
portal_type = 'Consumption'
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.VariationRange
)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.VariationRange
)
security.declareProtected(Permissions.ModifyPortalContent,
'_setVariationCategoryList')
def _setVariationCategoryList(self,value):
"""
Set consumption variation category list.
Set matrix cell range.
"""
self._setCategoryMembership(self.getVariationRangeBaseCategoryList(),
value, base=1)
# XXX Must use in futur this method, but it failed today
#VariatedMixin._setVariationCategoryList(self, value)
# XXX FIXME: Use a interaction workflow instead
# Kept for compatibility.
self.updateCellRange(base_id='quantity')
security.declareProtected(Permissions.ModifyPortalContent,
'_setVariationCategoryList')
def _setVariationCategoryList(self, value, base_category_list=()):
"""
Set consumption variation category list.
Set matrix cell range.
"""
self._setCategoryMembership(self.getVariationRangeBaseCategoryList(),
value, base=1)
# XXX Must use in futur this method, but it failed today
#VariatedMixin._setVariationCategoryList(self, value)
# XXX FIXME: Use a interaction workflow instead
# Kept for compatibility.
self.updateCellRange(base_id='quantity')
security.declareProtected(Permissions.ModifyPortalContent,
'setVariationCategoryList')
def setVariationCategoryList(self,value):
"""
Set consumption variation category list.
Reindex Object.
"""
self._setVariationCategoryList(value)
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent,
'setVariationCategoryList')
def setVariationCategoryList(self, value, base_category_list=()):
"""
Set consumption variation category list.
Reindex Object.
"""
self._setVariationCategoryList(value)
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent,
'getVariationRangeBaseCategoryItemList')
def getVariationRangeBaseCategoryItemList(self):
"""
Return range of base variation item
Left display
"""
# XXX get TitleOrId
return map( lambda x: (x,x) , self.getVariationRangeBaseCategoryList() )
security.declareProtected(Permissions.ModifyPortalContent,
'getVariationRangeBaseCategoryItemList')
def getVariationRangeBaseCategoryItemList(
self,
base=1,
display_id='getTitle',
current_category=None):
"""
Return range of base variation item
Left display
"""
# XXX get TitleOrId
return [(x, x) for x in self.getVariationRangeBaseCategoryList()]
security.declareProtected(Permissions.ModifyPortalContent,
'getQuantityRatio')
def getQuantityRatio(self, variation_category_line,
variation_category_column):
"""
Return quantity ratio for a virtual cell.
Return None if not result can be return.
"""
cell_quantity_ratio_list = []
security.declareProtected(Permissions.ModifyPortalContent,
'getQuantityRatio')
def getQuantityRatio(self, variation_category_line,
variation_category_column):
"""
Return quantity ratio for a virtual cell.
Return None if not result can be return.
"""
cell_quantity_ratio_list = []
for variation_category in (variation_category_line,
variation_category_column):
cell = self.getCell(variation_category, base_id='quantity')
if cell is None:
for variation_category in (variation_category_line,
variation_category_column):
cell = self.getCell(variation_category, base_id='quantity')
if cell is None:
return None
else:
cell_quantity_ratio = cell.getProperty('quantity')
if cell_quantity_ratio in [None, 0, '']:
return None
else:
cell_quantity_ratio = cell.getProperty('quantity')
if cell_quantity_ratio in [None, 0, '']:
return None
else:
cell_quantity_ratio_list.append( cell_quantity_ratio )
cell_quantity_ratio_list.append( cell_quantity_ratio )
return cell_quantity_ratio_list[1] / cell_quantity_ratio_list[0]
return cell_quantity_ratio_list[1] / cell_quantity_ratio_list[0]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</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>Consumption</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.Consumption</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.Consumption</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<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>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -227,6 +227,8 @@
<string>matrixbox_for_max_order_quantity</string>
<string>my_view_mode_target_delivery</string>
<string>my_base_price_per_slice</string>
<string>my_report_mode_listbox_variation_category_item_list</string>
<string>my_view_mode_read_only_title</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>editable</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_report_mode_listbox_variation_category_item_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>