Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
erp5
Commits
a0effd84
Commit
a0effd84
authored
Jan 08, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introspect preference properties instead of hardcoding
parent
0473f076
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
68 deletions
+33
-68
product/ERP5Configurator/Document/PreferenceConfiguratorItem.py
...t/ERP5Configurator/Document/PreferenceConfiguratorItem.py
+15
-29
product/ERP5Configurator/Document/SystemPreferenceConfiguratorItem.py
...Configurator/Document/SystemPreferenceConfiguratorItem.py
+18
-39
No files found.
product/ERP5Configurator/Document/PreferenceConfiguratorItem.py
View file @
a0effd84
...
...
@@ -55,35 +55,21 @@ class PreferenceConfiguratorItem(ConfiguratorItemMixin, XMLObject):
,
PropertySheet
.
DublinCore
)
def
_getPreferenceNameList
(
self
):
"""Returns all existing preference names.
TODO: this should be done by introspecting property sheet.
"""Return names of preference properties.
"""
return
(
'preferred_category_child_item_list_method_id'
,
'preferred_accounting_transaction_from_date'
,
'preferred_accounting_transaction_at_date'
,
'preferred_section_category'
,
'preferred_section'
,
'preferred_accounting_transaction_section_category'
,
'preferred_accounting_transaction_source_section'
,
'preferred_accounting_transaction_currency'
,
'preferred_accounting_transaction_gap'
,
'preferred_accounting_transaction_simulation_state_list'
,
'preferred_text_format'
,
'preferred_text_editor'
,
'preferred_date_order'
,
'preferred_listbox_view_mode_line_count'
,
'preferred_listbox_list_mode_line_count'
,
'preferred_string_field_width'
,
'preferred_textarea_width'
,
'preferred_textarea_height'
,
'preferred_money_quantity_field_width'
,
'preferred_quantity_field_width'
,
'preferred_report_style'
,
'preferred_report_format'
,
'preferred_html_style_access_tab'
,
)
property_id_list
=
[]
portal
=
self
.
getPortalObject
()
for
property_sheet_id
in
portal
.
portal_types
.
Preference
.
getTypePropertySheetList
():
property_sheet
=
portal
.
portal_property_sheets
[
property_sheet_id
]
for
prop
in
property_sheet
.
contentValues
():
if
prop
.
getProperty
(
'preference'
):
list_prefix
=
''
if
prop
.
getProperty
(
'multivalued'
)
or
(
prop
.
getProperty
(
'elementary_type'
)
in
(
'lines'
,
'multiple_selection'
,
'tokens'
)):
list_prefix
=
'_list'
property_id_list
.
append
(
'%s%s'
%
(
prop
.
getReference
(),
list_prefix
))
return
property_id_list
def
_build
(
self
,
business_configuration
):
portal
=
self
.
getPortalObject
()
...
...
@@ -103,7 +89,7 @@ class PreferenceConfiguratorItem(ConfiguratorItemMixin, XMLObject):
for
preference_name
in
self
.
_getPreferenceNameList
():
preference_value
=
getattr
(
self
,
preference_name
,
preference
.
getProperty
(
preference_name
,
marker
))
if
preference_value
is
not
marker
:
if
preference_value
is
not
marker
and
preference_value
is
not
None
:
preference_dict
[
preference_name
]
=
preference_value
if
self
.
portal_workflow
.
isTransitionPossible
(
preference
,
'enable'
):
...
...
product/ERP5Configurator/Document/SystemPreferenceConfiguratorItem.py
View file @
a0effd84
...
...
@@ -55,43 +55,22 @@ class SystemPreferenceConfiguratorItem(ConfiguratorItemMixin, XMLObject):
,
PropertySheet
.
DublinCore
)
def
_getPreferenceNameList
(
self
):
"""Returns all existing preference names.
TODO: this should be done by introspecting property sheet.
"""Return names of preference properties.
"""
return
(
# CRM
'preferred_campaign_resource_list'
,
'preferred_event_assessment_form_id_list'
,
'preferred_event_resource_list'
,
'preferred_event_sender_email'
,
'preferred_meeting_resource_list'
,
'preferred_sale_opportunity_resource_list'
,
'preferred_support_request_resource_list'
,
# DMS
'preferred_conversion_cache_factory'
,
'preferred_document_email_ingestion_address'
,
'preferred_document_reference_method_id'
,
'preferred_document_file_name_regular_expression'
,
'preferred_document_reference_regular_expression'
,
'preferred_document_classification'
,
'preferred_synchronous_metadata_discovery'
,
'preferred_redirect_to_document'
,
'preferred_ooodoc_server_address'
,
'preferred_ooodoc_server_port_number'
,
# PDM
'preferred_product_individual_variation_base_category_list'
,
'preferred_component_individual_variation_base_category_list'
,
'preferred_service_individual_variation_base_category_list'
,
# Trade
'preferred_supplier_role_list'
,
'preferred_client_role_list'
,
'preferred_sale_use_list'
,
'preferred_purchase_use_list'
,
'preferred_packing_use_list'
,
'preferred_tax_use_list'
,
# Express
)
property_id_list
=
[]
portal
=
self
.
getPortalObject
()
for
property_sheet_id
in
portal
.
portal_types
[
'System Preference'
].
getTypePropertySheetList
():
property_sheet
=
portal
.
portal_property_sheets
[
property_sheet_id
]
for
prop
in
property_sheet
.
contentValues
():
if
prop
.
getProperty
(
'preference'
):
list_prefix
=
''
if
prop
.
getProperty
(
'multivalued'
)
or
(
prop
.
getProperty
(
'elementary_type'
)
in
(
'lines'
,
'multiple_selection'
,
'tokens'
)):
list_prefix
=
'_list'
property_id_list
.
append
(
'%s%s'
%
(
prop
.
getReference
(),
list_prefix
))
return
property_id_list
def
_build
(
self
,
business_configuration
):
portal
=
self
.
getPortalObject
()
...
...
@@ -112,9 +91,9 @@ class SystemPreferenceConfiguratorItem(ConfiguratorItemMixin, XMLObject):
for
preference_name
in
self
.
_getPreferenceNameList
():
preference_value
=
getattr
(
self
,
preference_name
,
preference
.
getProperty
(
preference_name
,
marker
))
if
preference_value
is
None
and
activated_preference
is
not
None
:
preference_value
=
activated_preference
.
getProperty
(
preference_name
)
if
preference_value
is
not
marker
:
if
preference_value
is
marker
and
activated_preference
is
not
None
:
preference_value
=
activated_preference
.
getProperty
(
preference_name
,
marker
)
if
preference_value
is
not
marker
and
preference_value
is
not
None
:
preference_dict
[
preference_name
]
=
preference_value
if
self
.
portal_workflow
.
isTransitionPossible
(
preference
,
'enable'
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment