diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getTrialBalanceReportSectionList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getTrialBalanceReportSectionList.xml index 455e1affc05a74de0a0b2a91de4624650648f145..3d27d717df0449382222d64390ca1187d0715e4d 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getTrialBalanceReportSectionList.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getTrialBalanceReportSectionList.xml @@ -68,9 +68,7 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string encoding="cdata"><![CDATA[ - -""" Trial balance.\n + <value> <string>""" Trial balance.\n """\n from Products.ERP5Form.Report import ReportSection\n \n @@ -86,22 +84,10 @@ show_empty_accounts = request[\'show_empty_accounts\']\n \n section_uid = portal.Base_getSectionUidListForSectionCategory(\n request[\'section_category\'])\n -# XXX for now we guess period start date from the first organisation having\n -# accounting periods\n -period_start_date = None\n -valid_accounting_period = dict(portal_type=\'Accounting Period\',\n - simulation_state=(\'planned\', \'confirmed\',\n - \'stopped\', \'closing\', \'delivered\'))\n -date = from_date or at_date\n -for uid in section_uid:\n - section = portal.portal_catalog.getObject(uid)\n - for ap in section.contentValues(filter=valid_accounting_period):\n - if ap.getStartDate() <= date <= ap.getStopDate():\n - period_start_date = ap.getStartDate().earliestTime()\n - if period_start_date:\n - break\n -else:\n - period_start_date = DateTime(date.year(), 1, 1)\n +\n +period_start_date = portal.Base_getAccountingPeriodStartDateForSectionCategory(\n + section_category=request[\'section_category\'], date=from_date or at_date)\n +# for the report summary\n request.set(\'period_start_date\', period_start_date)\n \n if not from_date:\n @@ -133,9 +119,7 @@ return [ ReportSection(\n section_uid=section_uid,\n simulation_state=simulation_state,\n precision=precision ),) ]\n - - -]]></string> </value> +</string> </value> </item> <item> <key> <string>_code</string> </key> @@ -200,17 +184,10 @@ return [ ReportSection(\n <string>show_empty_accounts</string> <string>section_uid</string> <string>period_start_date</string> - <string>dict</string> - <string>valid_accounting_period</string> - <string>date</string> - <string>_getiter_</string> - <string>uid</string> - <string>section</string> - <string>ap</string> - <string>DateTime</string> <string>currency</string> <string>precision</string> <string>True</string> + <string>dict</string> </tuple> </value> </item> diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getAccountingPeriodStartDateForSectionCategory.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getAccountingPeriodStartDateForSectionCategory.xml new file mode 100644 index 0000000000000000000000000000000000000000..2c3dfa0377291c3e18524035815d8b486524c83d --- /dev/null +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getAccountingPeriodStartDateForSectionCategory.xml @@ -0,0 +1,179 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <tuple> + <string>Products.PythonScripts.PythonScript</string> + <string>PythonScript</string> + </tuple> + <none/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Python_magic</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>__ac_local_roles__</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_body</string> </key> + <value> <string encoding="cdata"><![CDATA[ + +from Products.ERP5Type.Cache import CachingMethod\n +\n +def getAccountingPeriodStartDateForSectionCategory(section_category, date):\n + portal = context.getPortalObject()\n + section_uid = portal.Base_getSectionUidListForSectionCategory(\n + section_category)\n + # XXX for now we guess period start date from the first organisation having\n + # accounting periods\n + period_start_date = None\n + valid_accounting_period = dict(portal_type=\'Accounting Period\',\n + simulation_state=(\'planned\', \'confirmed\',\n + \'stopped\', \'closing\', \'delivered\'))\n + for uid in section_uid:\n + section = portal.portal_catalog.getObject(uid)\n + for ap in section.contentValues(filter=valid_accounting_period):\n + if ap.getStartDate() <= date <= ap.getStopDate():\n + period_start_date = ap.getStartDate().earliestTime()\n + if period_start_date:\n + break\n + else:\n + period_start_date = DateTime(date.year(), 1, 1)\n + return period_start_date\n +\n +getAccountingPeriodStartDateForSectionCategory = CachingMethod(\n + getAccountingPeriodStartDateForSectionCategory,\n + id=script.getId(), cache_factory=\'erp5_content_long\')\n +\n +return getAccountingPeriodStartDateForSectionCategory(section_category, date)\n + + +]]></string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_filepath</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>section_category, date</string> </value> + </item> + <item> + <key> <string>errors</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>func_code</string> </key> + <value> + <object> + <klass> + <global name="FuncCode" module="Shared.DC.Scripts.Signature"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>co_argcount</string> </key> + <value> <int>2</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>section_category</string> + <string>date</string> + <string>Products.ERP5Type.Cache</string> + <string>CachingMethod</string> + <string>getAccountingPeriodStartDateForSectionCategory</string> + <string>_getattr_</string> + <string>script</string> + </tuple> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>func_defaults</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Base_getAccountingPeriodStartDateForSectionCategory</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision index b6e27607fb529c10ffeb626c858f55206242edb7..104fcf5b4e28106211b72ca265f2915043f68e39 100644 --- a/bt5/erp5_accounting/bt/revision +++ b/bt5/erp5_accounting/bt/revision @@ -1 +1 @@ -242 \ No newline at end of file +243 \ No newline at end of file