Commit 1b31fcbd authored by Jérome Perrin's avatar Jérome Perrin

Improve Developer experience (mostly ERP5 Workflow/Python Scripts)

Fixes [#20210517-960A47](https://erp5js.nexedi.net/#/bug_module/20210517-960A47)

The most important changes are:
 - coding style is enabled again for workflow scripts and starts to be enabled for ERP5 Python scripts
 - monaco editor support for workflow scripts, SQL methods and .less
 - small fixes for python/workflow scripts forms and ZMI

See merge request nexedi/erp5!1422
parents 015bc1c1 b1f36ffd
Pipeline #15655 failed with stage
in 0 seconds
......@@ -10,11 +10,9 @@ The test operates on 'today' transactions.
from DateTime import DateTime
portal = context.getPortalObject()
accounting_module = portal.accounting_module
account_module = portal.account_module
ledger = portal.portal_categories.ledger
organisation_module = portal.organisation_module
person_module = portal.person_module
one_hour = 1.0 / 24.0
now = DateTime()
......@@ -26,12 +24,14 @@ if with_ledger:
accounting_ledger = ledger.get('accounting', None)
if accounting_ledger is None:
accounting_ledger = ledger.newContent(portal_type='Category', id='accounting')
accounting_ledger = ledger.newContent(portal_type='Category',
id='accounting')
for sub_category_name in ('general', 'detailed'):
sub_category = accounting_ledger.get(sub_category_name, None)
if sub_category is None:
sub_category = accounting_ledger.newContent(portal_type='Category', id=sub_category_name)
sub_category = accounting_ledger.newContent(portal_type='Category',
id=sub_category_name)
# necessary for the "ledger" form field to appear and have correct options
accounting_transaction = portal.portal_types.get('Accounting Transaction')
......@@ -59,8 +59,7 @@ context.AccountingTransactionModule_createAccountingTestDocument(
dict(portal_type='Accounting Transaction Line',
source_value=account_module.goods_sales,
source_credit=100.0)),
**extra_kwargs_general
)
**extra_kwargs_general)
context.AccountingTransactionModule_createAccountingTestDocument(
portal_type='Accounting Transaction',
......@@ -70,12 +69,12 @@ context.AccountingTransactionModule_createAccountingTestDocument(
destination_section_value=organisation_module.client_1,
start_date=today + 2 * one_hour,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.payable, source_debit=200.0),
source_value=account_module.payable,
source_debit=200.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.goods_sales,
source_credit=200.0)),
**extra_kwargs_general
)
**extra_kwargs_general)
if with_ledger:
context.AccountingTransactionModule_createAccountingTestDocument(
......@@ -86,9 +85,9 @@ if with_ledger:
destination_section_value=organisation_module.client_1,
start_date=today + 3 * one_hour,
embedded=(dict(portal_type='Accounting Transaction Line',
source_value=account_module.payable, source_debit=400.0),
source_value=account_module.payable,
source_debit=400.0),
dict(portal_type='Accounting Transaction Line',
source_value=account_module.goods_sales,
source_credit=400.0)),
**extra_kwargs_detailed
)
**extra_kwargs_detailed)
......@@ -94,8 +94,11 @@
model_language = 'javascript';
} else if (options.portal_type === 'Web Style') {
model_language = 'css';
} else if (options.portal_type === 'SQL Method') {
model_language = 'sql';
} else if (
options.portal_type === 'Python Script' ||
options.portal_type === 'Workflow Script' ||
options.portal_type === 'Test Component' ||
options.portal_type === 'Extension Component' ||
options.portal_type === 'Document Component' ||
......
......@@ -77,9 +77,10 @@ class PythonScript(XMLObject, ZopePythonScript, ExpressionMixin('expression')):
security.declareObjectProtected(Permissions.AccessContentsInformation)
#View content list, Force /view, Standart option in python scripts
manage_options = ( XMLObject.manage_options[0],
manage_options = ( ZopePythonScript.manage_options[0],
{'icon':'', 'label':'View','action':'view'}) \
+ ZopePythonScript.manage_options
+ ( XMLObject.manage_options[0], ) \
+ ZopePythonScript.manage_options[1:]
# Declarative properties
property_sheets = ( PropertySheet.Base
......
......@@ -27,9 +27,7 @@
</item>
<item>
<key> <string>content_icon</string> </key>
<value>
<none/>
</value>
<value> <string>/misc_/PythonScripts/pyscript.gif</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -65,6 +63,18 @@
<key> <string>type_class</string> </key>
<value> <string>PythonScript</string> </value>
</item>
<item>
<key> <string>type_interface</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -8,9 +8,7 @@
<dictionary>
<item>
<key> <string>content_icon</string> </key>
<value>
<none/>
</value>
<value> <string>/misc_/PythonScripts/pyscript.gif</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......
......@@ -61,7 +61,7 @@ def checkPythonScript(script_instance, script_path):
Message(
location="{script_path}:{row}:{column}".format(**annotation),
message=annotation['text'],
edit_url="{script_path}/manage_main?line={row}".format(**annotation),))
edit_url="{script_path}/manage_workspace?line={row}".format(**annotation),))
def checkComponent(component_instance):
"""Check a component, adding messages to global `line_list`
......@@ -93,9 +93,11 @@ for workflow_id in context.getTemplateWorkflowIdList():
for script_container in script_container_list:
for script_path, script_instance in portal.ZopeFind(
script_container,
obj_metatypes=['Script (Python)'],
search_sub=1):
script_container, obj_metatypes=[
'Script (Python)',
'ERP5 Python Script',
'ERP5 Workflow Script',
], search_sub=1):
checkPythonScript(script_instance, "%s/%s" % (
portal.portal_url.getRelativeUrl(script_container), script_path))
......
......@@ -85,8 +85,8 @@
<list>
<string>my_parameter_signature</string>
<string>my_description</string>
<string>error_message</string>
<string>warning_message</string>
<string>your_error_message</string>
<string>your_warning_message</string>
</list>
</value>
</item>
......
......@@ -20,7 +20,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>error_message</string> </value>
<value> <string>your_error_message</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -20,7 +20,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>warning_message</string> </value>
<value> <string>your_warning_message</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -62,10 +62,6 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
......@@ -107,7 +103,7 @@
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
......
......@@ -63,10 +63,28 @@
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>size</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>view_separator</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -85,24 +103,7 @@
<item>
<key> <string>items</string> </key>
<value>
<list>
<tuple>
<string>Manager</string>
<string>Manager</string>
</tuple>
<tuple>
<string>Author</string>
<string>Author</string>
</tuple>
<tuple>
<string>Assignor</string>
<string>Assignor</string>
</tuple>
<tuple>
<string>Assignee</string>
<string>Assignee</string>
</tuple>
</list>
<list/>
</value>
</item>
<item>
......@@ -131,4 +132,17 @@
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(role, role) for role in context.valid_roles()]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -6,12 +6,12 @@ new_group_list = new_line.split('"')
if len(new_group_list) != 5:
return False
before, portal_type, module, erp5_portal_type, after = new_group_list
before, _, module, erp5_portal_type, after = new_group_list
if before != '<global name=' or module != ' module=' or erp5_portal_type != 'erp5.portal_type' or after != '/>':
return False
old_group_list = old_line_list[0].split('"')
if len(old_group_list) == 5:
before2, ignore, module2, products_erp5type, after2 = old_group_list
before2, _, module2, products_erp5type, after2 = old_group_list
return before2 == before and module2 == module and products_erp5type.startswith("Products.ERP5Type.Document.") and after2 == after
return False
......@@ -85,8 +85,8 @@
<list>
<string>my_parameter_signature</string>
<string>my_description</string>
<string>error_message</string>
<string>warning_message</string>
<string>your_error_message</string>
<string>your_warning_message</string>
</list>
</value>
</item>
......
......@@ -20,7 +20,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>error_message</string> </value>
<value> <string>your_error_message</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -20,7 +20,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>warning_message</string> </value>
<value> <string>your_warning_message</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -107,10 +107,6 @@
<key> <string>columns</string> </key>
<value>
<list>
<tuple>
<string>id</string>
<string>ID</string>
</tuple>
<tuple>
<string>reference</string>
<string>Reference</string>
......@@ -119,10 +115,6 @@
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>callable_type</string>
<string>Callable Type</string>
</tuple>
<tuple>
<string>parameter_signature</string>
<string>Parameters</string>
......@@ -186,10 +178,6 @@
<key> <string>url_columns</string> </key>
<value>
<list>
<tuple>
<string>id</string>
<string>WorkflowScript_getListBoxURL</string>
</tuple>
<tuple>
<string>reference</string>
<string>WorkflowScript_getListBoxURL</string>
......@@ -198,10 +186,6 @@
<string>title</string>
<string>WorkflowScript_getListBoxURL</string>
</tuple>
<tuple>
<string>callable_type</string>
<string>WorkflowScript_getListBoxURL</string>
</tuple>
<tuple>
<string>parameter_signature</string>
<string>WorkflowScript_getListBoxURL</string>
......
......@@ -58,7 +58,7 @@ def manage_page_footer(self):
else:
mode = 'html'
textarea_selector = 'textarea[name="filedata:text"]'
elif document.meta_type in ('Script (Python)', ):
elif document.meta_type in ('Script (Python)', 'ERP5 Python Script', 'ERP5 Workflow Script', ):
mode = 'python'
textarea_selector = 'textarea[name="body:text"]'
# printed is from RestrictedPython.RestrictionMutator the rest comes
......@@ -81,6 +81,10 @@ def manage_page_footer(self):
mode = 'xml'
textarea_selector = 'textarea[name="text:text"]'
if mode == 'plain_text':
if document.getId().endswith('.less'):
mode = 'less'
if not textarea_selector:
return default
......
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