diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionLine_resetGroupingReference.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionLine_resetGroupingReference.xml index 522be5c2f1fd28f0e473fe96b6bdf79ae16dffbd..6372dfe5dc90df3397e71fb3ef33e7e21c7b93b1 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionLine_resetGroupingReference.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionLine_resetGroupingReference.xml @@ -67,18 +67,25 @@ assert context.getGroupingReference()\n \n if context.AccountingTransaction_isSourceView():\n node_uid = context.getSourceUid()\n - section_uid = context.getSourceSectionUid()\n + section_category = None\n + section = context.getSourceSectionValue()\n + if section is not None:\n + section = section.Organisation_getMappingRelatedOrganisation()\n + section_category = section.getGroup(base=1)\n mirror_section_uid = context.getDestinationSectionUid()\n else:\n node_uid = context.getDestinationUid()\n - section_uid = context.getDestinationSectionUid()\n + section = context.getDestinationSectionValue()\n + if section is not None:\n + section = section.Organisation_getMappingRelatedOrganisation()\n + section_category = section.getGroup(base=1)\n mirror_section_uid = context.getSourceSectionUid()\n \n line_list = portal.portal_simulation.getMovementHistoryList(\n portal_type=portal.getPortalAccountingMovementTypeList(),\n grouping_reference=context.getGroupingReference(),\n node_uid=node_uid,\n - section_uid=section_uid,\n + section_category=section_category,\n mirror_section_uid=mirror_section_uid)\n \n # If the group is still valid, we may want to keep it as is.\n @@ -132,7 +139,9 @@ return line_list\n <string>precision</string> <string>AssertionError</string> <string>node_uid</string> - <string>section_uid</string> + <string>None</string> + <string>section_category</string> + <string>section</string> <string>mirror_section_uid</string> <string>line_list</string> <string>round</string> @@ -142,7 +151,6 @@ return line_list\n <string>_getiter_</string> <string>l</string> <string>line</string> - <string>None</string> </tuple> </value> </item> diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getAccountingPeriodForDestinationSection.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getAccountingPeriodForDestinationSection.xml index 0ca5c2999b77a24d18386c3cb5983e54640c3afb..5c92c2b0e9e4eb305bae26f2f92b5b9918b6c8b3 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getAccountingPeriodForDestinationSection.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getAccountingPeriodForDestinationSection.xml @@ -65,6 +65,7 @@ if not operation_date:\n \n section = context.getDestinationSectionValue(portal_type=\'Organisation\')\n if section is not None:\n + section = section.Organisation_getMappingRelatedOrganisation()\n for accounting_period in section.contentValues(\n portal_type=\'Accounting Period\',\n checked_permission=\'Access contents information\'):\n diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getAccountingPeriodForSourceSection.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getAccountingPeriodForSourceSection.xml index 9e5ba6950cafd73eff1bbedf4e5ac8968f31ac69..90019ebc697ae45026f1b5bb9111c4165846cae6 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getAccountingPeriodForSourceSection.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_getAccountingPeriodForSourceSection.xml @@ -65,6 +65,7 @@ if not operation_date:\n \n section = context.getSourceSectionValue(portal_type=\'Organisation\')\n if section is not None:\n + section = section.Organisation_getMappingRelatedOrganisation()\n for accounting_period in section.contentValues(\n portal_type=\'Accounting Period\',\n checked_permission=\'Access contents information\'):\n diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_guessGroupedLines.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_guessGroupedLines.xml index 2ebfca4b87f4d2e4186a6b803e5df930e70e6624..0a022489c84dc5eed6e77f502aa71340e3ef04af 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_guessGroupedLines.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_guessGroupedLines.xml @@ -101,16 +101,29 @@ else:\n for line in accounting_transaction_line_value_list:\n accounting_transaction = line.getParentValue()\n if accounting_transaction.AccountingTransaction_isSourceView():\n + section_relative_url = None\n + source_section = line.getSourceSectionValue(portal_type=\'Organisation\')\n + if source_section is not None:\n + source_section = \\\n + source_section.Organisation_getMappingRelatedOrganisation()\n + section_relative_url = source_section.getRelativeUrl()\n lines_per_node.setdefault(\n (line.getSource(portal_type=\'Account\'),\n - line.getSourceSection(portal_type=\'Organisation\'),\n + section_relative_url,\n line.getDestinationSection(), ), []).append(\n dict(total_price=line.getSourceInventoriatedTotalAssetPrice() or 0,\n path=line.getRelativeUrl()))\n else:\n + section_relative_url = None\n + destination_section = line.getDestinationSectionValue(\n + portal_type=\'Organisation\')\n + if destination_section is not None:\n + destination_section = \\\n + destination_section.Organisation_getMappingRelatedOrganisation()\n + section_relative_url = destination_section.getRelativeUrl()\n lines_per_node.setdefault(\n (line.getDestination(portal_type=\'Account\'),\n - line.getDestinationSection(portal_type=\'Organisation\'),\n + section_relative_url,\n line.getSourceSection(), ), []).append(\n dict(total_price=line.getDestinationInventoriatedTotalAssetPrice() or 0,\n path=line.getRelativeUrl()))\n @@ -195,7 +208,10 @@ return changed_lines\n <string>append</string> <string>$append0</string> <string>uid</string> + <string>section_relative_url</string> + <string>source_section</string> <string>dict</string> + <string>destination_section</string> <string>changed_lines</string> <string>node</string> <string>section</string> diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Organisation_getMappingRelatedOrganisation.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Organisation_getMappingRelatedOrganisation.xml new file mode 100644 index 0000000000000000000000000000000000000000..e5dc82ad058aa47e0971adf7fa2186938d890a67 --- /dev/null +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Organisation_getMappingRelatedOrganisation.xml @@ -0,0 +1,162 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </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>"""Returns the main organisation for that group.\n +"""\n +\n +def getOrganisationForSectionCategory(section):\n + mapping = section.getMappingRelatedValue(portal_type=\'Organisation\',\n + checked_permission=\'Access contents information\')\n + if mapping is not None:\n + return mapping\n + \n + organisation_list = section.getGroupRelatedValueList(portal_type=\'Organisation\',\n + strict_membership=1,\n + checked_permission=\'Access contents information\')\n +\n + for organisation in organisation_list:\n + if organisation.getProperty(\'validation_state\', \'unset\') not in (\'deleted\', \'cancelled\'):\n + return organisation\n +\n +\n +group = context.getGroupValue()\n +if group is None:\n + return context\n +\n +group_chain = []\n +while group.getPortalType() != \'Base Category\':\n + group_chain.append(group)\n + group = group.getParentValue()\n +\n +group_chain.reverse()\n +\n +for group in group_chain:\n + organisation = getOrganisationForSectionCategory(group)\n + if organisation is not None:\n + return organisation\n +\n +return context\n +</string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string></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>0</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>getOrganisationForSectionCategory</string> + <string>_getattr_</string> + <string>context</string> + <string>group</string> + <string>None</string> + <string>group_chain</string> + <string>_getiter_</string> + <string>organisation</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>Organisation_getMappingRelatedOrganisation</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml b/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml index 3096dc9377ff945d87fa928e16a5fdedd9678784..3d59bfdf57d4b725d205a9aa3877a935da396383 100644 --- a/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml +++ b/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml @@ -59,7 +59,6 @@ \n XXX why proxy role ???\n """\n -\n from Products.DCWorkflow.DCWorkflow import ValidationFailed\n from Products.ERP5Type.Message import translateString\n \n @@ -124,26 +123,24 @@ if not skip_period_validation :\n no_accounts = False\n if no_accounts:\n valid_date = True\n - transaction_date = transaction.getStartDate().earliestTime()\n - openned_accounting_period_list = source_section.searchFolder(\n - portal_type="Accounting Period",\n - # planned is for b/w compatibility\n - simulation_state=(\'planned\', \'started\'))\n - if not len(source_section.contentValues(\n + else:\n + section = transaction.getSourceSectionValue()\n + if section is not None and not len(section.contentValues(\n filter=dict(portal_type="Accounting Period"))):\n - # if the entity doesn\'t have any accounting period, we can\n - # consider that they do not want to use accounting periods or\n - # we do not account from their side.\n - valid_date = True\n - for apd in openned_accounting_period_list:\n - apd = apd.getObject()\n - if apd.getStartDate().earliestTime() <= transaction_date <= \\\n - apd.getStopDate().latestTime():\n - valid_date = checkAccountingPeriodRecusivly(apd, transaction_date)\n + valid_date = True\n + else:\n + accounting_period = transaction\\\n + .AccountingTransaction_getAccountingPeriodForSourceSection()\n + transaction_date = transaction.getStartDate().earliestTime()\n + valid_date = False\n + if accounting_period is not None:\n + valid_date = checkAccountingPeriodRecusivly(accounting_period,\n + transaction_date)\n \n if not valid_date:\n raise ValidationFailed(translateString("Date is not in a started Accounting Period "\n "for source section."))\n +\n # do the same for destination section \n if destination_section is not None:\n # if we don\'t have any accounts on this side, we don\'t enforce date checks\n @@ -154,18 +151,19 @@ if not skip_period_validation :\n no_accounts = False\n if no_accounts:\n valid_date = True\n - transaction_date = transaction.getStopDate().earliestTime()\n - openned_accounting_period_list = destination_section.searchFolder(\n - portal_type = "Accounting Period",\n - simulation_state=(\'planned\', \'started\'))\n - if not len(destination_section.contentValues(\n + else:\n + section = transaction.getDestinationSectionValue()\n + if section is not None and not len(section.contentValues(\n filter=dict(portal_type="Accounting Period"))):\n - valid_date = True\n - for apd in openned_accounting_period_list:\n - apd = apd.getObject()\n - if apd.getStartDate().earliestTime() <= transaction_date <= \\\n - apd.getStopDate().latestTime():\n - valid_date = checkAccountingPeriodRecusivly(apd, transaction_date)\n + valid_date = True\n + else:\n + accounting_period = transaction\\\n + .AccountingTransaction_getAccountingPeriodForDestinationSection()\n + transaction_date = transaction.getStopDate().earliestTime()\n + valid_date = False\n + if accounting_period is not None:\n + valid_date = checkAccountingPeriodRecusivly(accounting_period,\n + transaction_date)\n \n if not valid_date:\n raise ValidationFailed(translateString("Date is not in a started Accounting Period "\n @@ -247,11 +245,11 @@ if not skip_period_validation :\n <string>no_accounts</string> <string>_getiter_</string> <string>line</string> - <string>transaction_date</string> - <string>openned_accounting_period_list</string> + <string>section</string> <string>len</string> <string>dict</string> - <string>apd</string> + <string>accounting_period</string> + <string>transaction_date</string> </tuple> </value> </item> diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision index 3935a99d8f1a36593717061ef1b86a24f93467c4..c9ebe1509d764f5826e3d2f71253550491a7f224 100644 --- a/bt5/erp5_accounting/bt/revision +++ b/bt5/erp5_accounting/bt/revision @@ -1 +1 @@ -974 \ No newline at end of file +978 \ No newline at end of file