Commit 28af5029 authored by Tatuya Kamada's avatar Tatuya Kamada

* Fix

  - copy last-table-row-style when stat method or stat columns does not set
  - clean table-columns-value before listbox values setting
* Append
  the DefaultValue is the marker class indicate to use a ODF Template value



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26314 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 24d1eeb7
master allow_login_change allow_login_change_wip arnau arnau-RD-Components-ERP5ShortMessage arnau-TM-FEC-output arnau-TM-getTypeBasedMethod-for-init_script arnau-TM-isBuildable-with-multiple-BusinessLinks arnau-TM-jabber-client-desktop-notifications arnau-TM-runUnitTest-clear-previous-execution-catalog arnau-kns arnau-kns-without-property-mapping arnau-merge arnau-poc arnau-real-time-inventory-accounting auto_extend_select_list autoflake backup_erp5_workflow bk_erp5ish_actions_tool bk_sqlcatalog boc-interaction-drop bt5_config cache callable-jupyter-storage catalog_filter catalog_fulltext catalog_fulltext_old cedric cedriclen cedriclen-eos certificate_authority cherry-pick-243c2f03 cherry-pick-304d7a28 cherry-pick-4a8e045d cleanJSByJSLint clean_up_upgrader cleanup_acquisition_base_category cmf_upgrade_versions compact_title_no_reference credential_update_action datetimefield deferred_listbox delivery_item_barcode douglas_forum dream_distributor dsn-phase3 eos-dev erp5-component erp5-forum erp5-imt erp5-messenger erp5-preference erp5-release erp5-slapos-upgrade erp5-util-testing erp5-vifib erp5-vifib-cleanup erp5_calendar erp5_catalog erp5_catalog_final erp5_corporate_identity erp5_free_subscription erp5_hal_json_style_fix_restricted_access_with_traverse erp5_payslip_migration erp5_workflow erp5testnode_max_timeout experiment/coding_style_test_suite feat/olapy feat/pdm_content_translation feat/zelenium_failures feature/accounting-reports-stats feature/hal-actions-support feature/hal-support-update feature/jio-accounting-reports feature/jio-action-accounting feature/jio-selection-actions feature/json-allows-all-jio-actions feature/renderjs-matrixbox feature/renderjs-ui-no-header feature/rjs-listbox-stats feature/rjs-mass-transition feature/rjs-print-action fix/consistency_check_alarm fix/login_validate_check_consistency fix/multiple_small_fixes_to_zodb_history_tab fix/support-request-app-empty fix_system_processes_ownership for_testrunner_1 for_testrunner_2 for_testrunner_3 gabriel gabriel-fix-rounding-in-accounting-generation gabriel-fix-rounding-in-accounting-generation2 gadget-json-value hotfix/accounting-test-timeout hotfix/callable_tool hotfix/field-keeps-request hotfix/jio-mass-transition hotfix/jio_view hotfix/pdm-test hotfix/rjs-accounting-tests hotfix/rjs-editability hotfix/rjs-form-less-invasive hotfix/rjs-formfields-padding hotfix/rjs-listbox-mutex hotfix/rjs-replace-query-with-uids hotfix/tests-cleanup http_cache_fix improve_default_caching_policy_manager initsite interaction-drop isDeletable item_tracking_graph_editor ivan jerome-bt-reference-doc jerome_graph_editor_renderjs jerome_new_style_solve_divergence jerome_user_preference_time_zone jio jm/form-action-guard joblib-activity js-ui keep_order_in_set_type_category_accessor kns lazy_simulation_causality lignan lingnan listbox-generator listbox_url macros_fix mame mame-bt5-cleanup mame-erp5_project-cleanup mame-naming-convention mame-naming-convention-list_method mame-test-stock-indexation mame-work mame2 maste_copy master-erp5-test-result-scalability master-erp5-test-result-scalability-rebase master-test-fix-additionalbt5path master_calendar_wip_patches master_calendar_wip_patches_extend_security master_no_guard_on_workflow_transition master_no_guard_on_workflow_transition_plus_calendar_wip_patchs mic_wind mmariani-inventory monitoring monitoring-graph mrp new-render-presentation no_longer_simulated_state officejs officejs_clean officejs_zip ojs_wip pere portal_callables portal_solver_process_security_configuration presentation publish_recursiveReindexObject rebased_mrp refactor/base_edit refactor/renderjs reindex_calendar_after_change_calendar_exception revert-38554dbe revert-6c89fe9b rewrite_test_21_AcquiredPortalType romain-fulltext scalability-master scalability-master2 scalability-master2-rebase scalability-roque scalability-roque-2 scalability-run-command shop-box sms_more_than_140_characters streaming_fix streaming_fix-0 strict_catalog syncml taskdistribution-xmlrpc-binary test_page testnode_software_link timezones tmp/getInstalledBusinessTemplate_never_installed_bt tristan tristan-merge tristan-performance ttrm upgradeSite valentin_translation_fix view-aggregated-amounts vivekpab_renderjs_interfaces wenjie wenjie_branch wip wsgi-gevent yryr yryr-components-cp yryr-inventory-cache yryr-test yryr-with-components yusei 0.4.59.1 0.4.59 test-ui test-rjsacc test-rjs renderjs-test erp5.util-0.4.58 erp5.util-0.4.57 erp5.util-0.4.56 erp5.util-0.4.55 erp5.util-0.4.54 erp5.util-0.4.53 erp5.util-0.4.52 erp5.util-0.4.49 erp5.util-0.4.46 erp5.util-0.4.44 erp5.util-0.4.43 erp5.util-0.4.41 erp5.util-0.4.40 erp5.util-0.4.37 erp5.util-0.4.1 erp5.util-0.4 erp5.util-0.3 erp5.util-0.2 erp5.util-0.1
No related merge requests found
......@@ -28,6 +28,7 @@
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.CMFCore.utils import _checkPermission, getToolByName
from Products.PythonScripts.Utility import allow_class
from Products.ERP5Type import PropertySheet, Permissions
from Products.ERP5Form.ListBox import ListBox
from Products.ERP5Form.FormBox import FormBox
......@@ -102,9 +103,9 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item):
Fields <-> Paragraphs: supported
ListBox <-> Table: supported
Report Section <-> Tables: experimentally supported
FormBox <-> Frame: not supported yet
FormBox <-> Frame: experimentally supported
Photo <-> Image: not supported yet
Style group <-> styles.xml: not supported yet
Style group <-> styles.xml: supported
Meta group <-> meta.xml: not supported yet
"""
......@@ -397,6 +398,7 @@ class ODFStrategy(Implicit):
image_list = element_tree.xpath(image_xpath, namespaces=NAME_SPACE_DICT)
if len(image_list) > 0:
image_list[0].set("{%s}href" % NAME_SPACE_DICT['xlink'], image_field.absolute_url())
return element_tree
def _append_table_by_listbox(self,
......@@ -442,6 +444,7 @@ class ODFStrategy(Implicit):
# if ODF table has header rows, does not update the header rows
# if does not have header rows, insert the listbox title line
is_top = True
last_index = len(listboxline_list) - 1
for (index, listboxline) in enumerate(listboxline_list):
listbox_column_list = listboxline.getColumnItemList()
if listboxline.isTitleLine() and not has_header_rows:
......@@ -454,14 +457,14 @@ class ODFStrategy(Implicit):
row = self._update_column_value(row, listbox_column_list)
newtable.append(row)
is_top = False
elif listboxline.isStatLine() or index is last_index:
row = deepcopy(row_bottom)
row = self._update_column_stat_value(row, listbox_column_list, row_middle)
newtable.append(row)
elif index > 0 and listboxline.isDataLine():
row = deepcopy(row_middle)
row = self._update_column_value(row, listbox_column_list)
newtable.append(row)
elif listboxline.isStatLine():
row = deepcopy(row_bottom)
row = self._update_column_stat_value(row, listbox_column_list, row_middle)
newtable.append(row)
# direct listbox mapping
if render_prefix is None:
......@@ -507,6 +510,7 @@ class ODFStrategy(Implicit):
return row
def _update_column_stat_value(self, row=None, listbox_column_list=[], row_middle=None):
"""stat line is capable of column span setting"""
if row_middle is None:
return row
odf_cell_list = row.findall("{%s}table-cell" % NAME_SPACE_DICT['table'])
......@@ -525,15 +529,13 @@ class ODFStrategy(Implicit):
return row
def _set_column_value(self, column, value):
# if the value is a DefaultValue, uses the ODF template value
if isinstance(value, DefaultValue) or value == DefaultValue:
return
self._clear_column_value(column)
if value is None:
# to eliminate a default value, remove "office:*" attributes.
# if remaining these attribetes, the column shows its default value,
# such as '0.0', '$0'
attrib = column.attrib
for key in attrib.keys():
if key.startswith("{%s}" % NAME_SPACE_DICT['office']):
del attrib[key]
value = ''
self._remove_column_value(column)
column_value = unicode(str(value),'utf-8')
column.text = column_value
column_children = column.getchildren()
......@@ -543,12 +545,35 @@ class ODFStrategy(Implicit):
first_child.text = column_value
for child in column_children:
column.remove(child)
if first_child is not None:
column.append(first_child)
if column_value != '':
value_attribute = self._get_column_value_attribute(column)
if value_attribute is not None:
column.set(value_attribute, column_value)
def _remove_column_value(self, column):
# to eliminate a default value, remove "office:*" attributes.
# if remaining these attribetes, the column shows its default value,
# such as '0.0', '$0'
attrib = column.attrib
for key in attrib.keys():
if key.startswith("{%s}" % NAME_SPACE_DICT['office']):
del attrib[key]
column_children = column.getchildren()
for child in column_children:
column.remove(child)
def _clear_column_value(self, column):
attrib = column.attrib
for key in attrib.keys():
value_attribute = self._get_column_value_attribute(column)
if value_attribute is not None:
column.set(value_attribute, '')
column_children = column.getchildren()
for child in column_children:
child.text = ''
def _get_column_value_attribute(self, column):
attrib = column.attrib
for key in attrib.keys():
......@@ -585,3 +610,19 @@ class ODFStrategy(Implicit):
class ODTStrategy(ODFStrategy):
"""ODTStrategy create a ODT Document from a form and a ODT template"""
pass
class DefaultValue:
"""The DefaultValue is the marker object which indicate that using template value
Python Script Example: 'number' column uses ODF table cell value
from Products.PythonScripts.standard import Object
from Products.ERP5OOo.FormPrintout import DefaultValue
return [ Object(number=DefaultValue(),
total_price=context.getTotalPrice())]
"""
pass
InitializeClass(DefaultValue)
allow_class(DefaultValue)
......@@ -42,6 +42,8 @@ document_classes = updateGlobals( this_module, globals(), permissions_module = P
from AccessControl import ModuleSecurityInfo
ModuleSecurityInfo('Products.ERP5OOo.OOoUtils').declarePublic('OOoParser',)
ModuleSecurityInfo('Products.ERP5OOo.OOoUtils').declarePublic('newOOoParser',)
# Allow access to DefaultValue from scripts
ModuleSecurityInfo('Products.ERP5OOo.FormPrintout').declarePublic('DefalutValue',)
# Define object classes and tools
from OOoTemplate import OOoTemplate
......
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