From 307493a2415a0579715644a3fdf51c8e8714567e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 1 Oct 2008 07:59:16 +0000
Subject: [PATCH] Purchase Invoice Transaction has two views with exclusive
 conditions; change the conditions to prevent switching to source view when
 setting a source section member of the preferred group

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23923 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../Purchase%20Invoice%20Transaction/view.xml |   8 +-
 .../view_source.xml                           |   8 +-
 ...ccountingTransaction_isDestinationView.xml | 134 ++++++++++++++++++
 bt5/erp5_accounting/bt/revision               |   2 +-
 4 files changed, 137 insertions(+), 15 deletions(-)
 create mode 100644 bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_isDestinationView.xml

diff --git a/bt5/erp5_accounting/ActionTemplateItem/portal_types/Purchase%20Invoice%20Transaction/view.xml b/bt5/erp5_accounting/ActionTemplateItem/portal_types/Purchase%20Invoice%20Transaction/view.xml
index aaea3e2ba7..d5a1cf29f9 100644
--- a/bt5/erp5_accounting/ActionTemplateItem/portal_types/Purchase%20Invoice%20Transaction/view.xml
+++ b/bt5/erp5_accounting/ActionTemplateItem/portal_types/Purchase%20Invoice%20Transaction/view.xml
@@ -9,12 +9,6 @@
     </pickle>
     <pickle>
       <dictionary>
-        <item>
-            <key> <string>__ac_local_roles__</string> </key>
-            <value>
-              <none/>
-            </value>
-        </item>
         <item>
             <key> <string>action</string> </key>
             <value>
@@ -93,7 +87,7 @@
       <dictionary>
         <item>
             <key> <string>text</string> </key>
-            <value> <string>python:not(object.AccountingTransaction_isSourceView())</string> </value>
+            <value> <string>object/AccountingTransaction_isDestinationView</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_accounting/ActionTemplateItem/portal_types/Purchase%20Invoice%20Transaction/view_source.xml b/bt5/erp5_accounting/ActionTemplateItem/portal_types/Purchase%20Invoice%20Transaction/view_source.xml
index 6d41a754bc..b1e4b0f3bf 100644
--- a/bt5/erp5_accounting/ActionTemplateItem/portal_types/Purchase%20Invoice%20Transaction/view_source.xml
+++ b/bt5/erp5_accounting/ActionTemplateItem/portal_types/Purchase%20Invoice%20Transaction/view_source.xml
@@ -9,12 +9,6 @@
     </pickle>
     <pickle>
       <dictionary>
-        <item>
-            <key> <string>__ac_local_roles__</string> </key>
-            <value>
-              <none/>
-            </value>
-        </item>
         <item>
             <key> <string>action</string> </key>
             <value>
@@ -93,7 +87,7 @@
       <dictionary>
         <item>
             <key> <string>text</string> </key>
-            <value> <string>python:object.AccountingTransaction_isSourceView()</string> </value>
+            <value> <string>not: object/AccountingTransaction_isDestinationView</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_isDestinationView.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_isDestinationView.xml
new file mode 100644
index 0000000000..227680bd9d
--- /dev/null
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_isDestinationView.xml
@@ -0,0 +1,134 @@
+<?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>destination = context.getDestinationSectionValue()\n
+section_category = context.portal_preferences\\\n
+         .getPreferredAccountingTransactionSectionCategory()\n
+if destination is not None and section_category:\n
+  if destination.getPortalType() == \'Person\':\n
+    return 0\n
+  if destination.isMemberOf(section_category):\n
+    return 1\n
+\n
+return 0\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>_getattr_</string>
+                            <string>context</string>
+                            <string>destination</string>
+                            <string>section_category</string>
+                            <string>None</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>AccountingTransaction_isDestinationView</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 699ec1b9ee..d0af645045 100644
--- a/bt5/erp5_accounting/bt/revision
+++ b/bt5/erp5_accounting/bt/revision
@@ -1 +1 @@
-781
\ No newline at end of file
+783
\ No newline at end of file
-- 
2.30.9