[Erp5-report] r9727 - in /erp5/trunk/bt5/erp5_accounting: SkinTemplateItem/portal_skins/erp...

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Sep 7 09:57:20 CEST 2006


Author: jerome
Date: Thu Sep  7 09:57:18 2006
New Revision: 9727

URL: http://svn.erp5.org?rev=9727&view=rev
Log:
add new script ERP5Accounting_getParams that get parameters from selection/preference (and uses a request cache
AccountModule_getAccountingTransactionCount apply the selection filter for the stat method


Added:
    erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/ERP5Accounting_getParams.xml
Modified:
    erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getAccountingTransactionCount.xml
    erp5/trunk/bt5/erp5_accounting/bt/revision

Modified: erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getAccountingTransactionCount.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getAccountingTransactionCount.xml?rev=9727&r1=9726&r2=9727&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getAccountingTransactionCount.xml (original)
+++ erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getAccountingTransactionCount.xml Thu Sep  7 09:57:18 2006
@@ -68,53 +68,34 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>LOG=lambda message: context.log("AccountModule_getAccountingTransactionCount", message)\n
+            <value> <string>kwd = context.ERP5Accounting_getParams(selection)\n
 \n
-params = selection.getParams()\n
-kwd = {} \n
+# XXX missing :(\n
+# this may fail if we have movements on something else than accounts\n
+#kwd[\'where_expression\'] = \'node.parent_uid = %s\' context.account_module.getUid()\n
 \n
-# read settings from user preference\n
-preference = context.getPortalObject().portal_preferences\n
-from_date = params.get(\'from_date\', preference.getPreferredAccountingTransactionFromDate())\n
-if from_date :\n
-  kwd[\'from_date\'] = from_date\n
-at_date = params.get(\'at_date\', preference.getPreferredAccountingTransactionAtDate())\n
-if at_date :\n
-  kwd[\'at_date\'] = at_date\n
-section_category = params.get(\'section_category\', preference.getPreferredAccountingTransactionSectionCategory())\n
-if section_category :\n
-  kwd[\'section_category\'] = section_category\n
+if kw.get(\'stat\'):\n
+  selection_params = selection.getParams()\n
+  if selection.getDomain():\n
+    kwd[\'selection_domain\'] = selection.getDomain()\n
+  if selection.getReport():\n
+    kwd[\'selection_report\'] = selection.getReport()\n
+  if selection_params.get(\'closed_summary\'):\n
+    kwd[\'closed_summary\'] = selection_params[\'closed_summary\']\n
+  if selection.isInvertMode():\n
+    kwd[\'selection_uids\'] = selection.getInvertModeUidList()\n
+  # is list filtered ?\n
+  if \'title\' in selection_params or \\\n
+     \'preferred_gap_id\' in selection_params or\\\n
+     \'transalated_validation_state_title\' in selection_params:\n
+    # if yes, apply the same filter here\n
+    kwd[\'stock.node_uid\'] = [x.uid for x in\n
+                         context.portal_catalog(**selection.getParams())]\n
+  return context.portal_simulation.getInventoryStat( **kwd )[0][\'stock_uid\']\n
 \n
-simulation_state = params.get(\'simulation_state\', preference.getPreferredAccountingTransactionSimulationStateList())\n
-if simulation_state :\n
-  kwd[\'simulation_state\'] = simulation_state\n
-\n
-resource = params.get(\'accounting_transaction_line_currency\')\n
-if resource:\n
-  currency = context.portal_categories.resolveCategory(resource)\n
-  kwd[\'resource_uid\'] = [currency.getUid()]\n
-\n
-query = {} #context.portal_catalog.buildSQLQuery(query_table=\'node\', **kwd)\n
-if query.get(\'where_expression\'):\n
-  kwd[\'where_expression\'] = query[\'where_expression\']\n
-if query.get(\'from_table_list\'):\n
-  kwd[\'from_table_list\'] = query[\'from_table_list\']\n
-\n
-if kw.get(\'stat\') :\n
-  if selection.getDomain() :\n
-    kwd[\'selection_domain\'] = selection.getDomain()\n
-  if selection.getReport() :\n
-    kwd[\'selection_report\'] = selection.getReport()\n
-  if params.get(\'closed_summary\'):\n
-    kwd[\'closed_summary\'] = params[\'closed_summary\']\n
-  if selection.isInvertMode() :\n
-    kwd[\'selection_uids\'] = selection.getInvertModeUidList()\n
-  return context.portal_simulation.getInventoryStat(omit_simulation=1,\n
-                                               **kwd)[0][\'stock_uid\']\n
-\n
-return context.portal_simulation.getInventoryStat(node_uid=context.getUid(),\n
-                                               omit_simulation=1,\n
-                                               **kwd)[0][\'stock_uid\']\n
+kwd[\'stock.node_uid\'] = brain.uid\n
+return context.portal_simulation.getInventoryStat( **kwd )[0][\'stock_uid\']\n
+# vim: syntax=python\n
 </string> </value>
         </item>
         <item>
@@ -166,22 +147,17 @@
                             <string>selection</string>
                             <string>brain</string>
                             <string>kw</string>
-                            <string>LOG</string>
                             <string>_getattr_</string>
-                            <string>params</string>
+                            <string>context</string>
                             <string>kwd</string>
-                            <string>context</string>
-                            <string>preference</string>
-                            <string>from_date</string>
+                            <string>selection_params</string>
                             <string>_write_</string>
-                            <string>at_date</string>
-                            <string>section_category</string>
-                            <string>simulation_state</string>
-                            <string>resource</string>
-                            <string>currency</string>
-                            <string>query</string>
                             <string>_getitem_</string>
+                            <string>append</string>
+                            <string>$append0</string>
+                            <string>_getiter_</string>
                             <string>_apply_</string>
+                            <string>x</string>
                           </tuple>
                         </value>
                     </item>

Added: erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/ERP5Accounting_getParams.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/ERP5Accounting_getParams.xml?rev=9727&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/ERP5Accounting_getParams.xml (added)
+++ erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/ERP5Accounting_getParams.xml Thu Sep  7 09:57:18 2006
@@ -1,0 +1,209 @@
+<?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>"""Returns all parameters from preferences or selection.\n
+\n
+This script gives priority to selection, and if not found in selection, it\n
+tries to get the parameters from preference tool.\n
+All parameters are stored/retrieved in a REQUEST cache, unless ignore_cache\n
+argument is True.\n
+\n
+caveats:\n
+  * wants_from_date parameter is not taken into account in the cache.\n
+"""\n
+\n
+# do we have a cache already?\n
+# XXX take selection into account ?\n
+if not ignore_cache:\n
+  params_cache = context.REQUEST.other.get(\n
+          \'ERP5Accounting_getParams\', None)\n
+  if params_cache is not None:\n
+    return dict(params_cache)\n
+\n
+params = {}\n
+selection_params = {}\n
+if selection is not None:\n
+  selection_params = selection.getParams()\n
+preference = context.getPortalObject().portal_preferences\n
+\n
+if wants_from_date:\n
+  from_date = selection_params.get(\'from_date\',\n
+                preference.getPreferredAccountingTransactionFromDate())\n
+  if from_date :\n
+    params[\'from_date\'] = from_date\n
+\n
+at_date = params.get(\'at_date\',\n
+              preference.getPreferredAccountingTransactionAtDate())\n
+if at_date:\n
+  params[\'at_date\'] = at_date\n
+\n
+section_category = params.get(\'section_category\',\n
+                 preference.getPreferredAccountingTransactionSectionCategory())\n
+if section_category:\n
+  params[\'section_category\'] = section_category\n
+\n
+simulation_state = params.get(\'simulation_state\',\n
+             preference.getPreferredAccountingTransactionSimulationStateList())\n
+if simulation_state:\n
+  params[\'simulation_state\'] = simulation_state\n
+\n
+if not ignore_cache:\n
+  context.REQUEST.other[\'ERP5Accounting_getParams\'] = params\n
+return dict(params)\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>selection=None, wants_from_date=0, ignore_cache=0</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>3</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>selection</string>
+                            <string>wants_from_date</string>
+                            <string>ignore_cache</string>
+                            <string>_getattr_</string>
+<string>context</string>
+                            <string>None</string>
+                            <string>params_cache</string>
+                            <string>dict</string>
+                            <string>params</string>
+                            <string>selection_params</string>
+                            <string>preference</string>
+                            <string>from_date</string>
+                            <string>_write_</string>
+                            <string>at_date</string>
+                            <string>section_category</string>
+                            <string>simulation_state</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <tuple>
+                <none/>
+                <int>0</int>
+                <int>0</int>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>ERP5Accounting_getParams</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Modified: erp5/trunk/bt5/erp5_accounting/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/bt/revision?rev=9727&r1=9726&r2=9727&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/bt/revision (original)
+++ erp5/trunk/bt5/erp5_accounting/bt/revision Thu Sep  7 09:57:18 2006
@@ -1,1 +1,1 @@
-24
+25




More information about the Erp5-report mailing list