From 85ede0736594d4cb2f5df36256868e733330b1a9 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Wed, 13 Nov 2019 17:59:02 +0100 Subject: [PATCH] WIP BROKEN [erp5[_mrp]_item] new action Do not access form submission REQUEST from the listbox list method, as it is rendered asynchronously in ERP5JS --- .../item_creation.xml | 10 +++-- .../Purchase%20Order%20Line/item_creation.xml | 10 +++-- .../item_creation.xml | 10 +++-- .../item_creation.xml | 10 +++-- .../item_creation.xml | 10 +++-- .../Sale%20Order%20Line/item_creation.xml | 10 +++-- .../item_creation.xml | 10 +++-- .../DeliveryLine_getTempItemList.py | 14 ++----- .../DeliveryLine_getTempItemList.xml | 2 +- .../DeliveryLine_selectItemList.py | 6 ++- ...DeliveryLine_updateSelectItemListDialog.py | 8 +++- .../listbox.xml | 37 +++++++++++++++++-- .../item_creation.xml | 10 +++-- .../item_creation.xml | 10 +++-- .../item_creation.xml | 10 +++-- 15 files changed, 109 insertions(+), 58 deletions(-) diff --git a/bt5/erp5_item/ActionTemplateItem/portal_types/Internal%20Packing%20List%20Line/item_creation.xml b/bt5/erp5_item/ActionTemplateItem/portal_types/Internal%20Packing%20List%20Line/item_creation.xml index c032e7956f..5f6b470612 100644 --- a/bt5/erp5_item/ActionTemplateItem/portal_types/Internal%20Packing%20List%20Line/item_creation.xml +++ b/bt5/erp5_item/ActionTemplateItem/portal_types/Internal%20Packing%20List%20Line/item_creation.xml @@ -16,13 +16,13 @@ <key> <string>categories</string> </key> <value> <tuple> - <string>action_type/object_fast_input</string> + <string>action_type/object_jio_fast_input</string> </tuple> </value> </item> <item> <key> <string>category</string> </key> - <value> <string>object_fast_input</string> </value> + <value> <string>object_jio_fast_input</string> </value> </item> <item> <key> <string>condition</string> </key> @@ -32,7 +32,9 @@ </item> <item> <key> <string>description</string> </key> - <value> <string></string> </value> + <value> + <none/> + </value> </item> <item> <key> <string>icon</string> </key> @@ -73,7 +75,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog</string> </value> + <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog?reset:int=1</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_item/ActionTemplateItem/portal_types/Purchase%20Order%20Line/item_creation.xml b/bt5/erp5_item/ActionTemplateItem/portal_types/Purchase%20Order%20Line/item_creation.xml index c032e7956f..5f6b470612 100644 --- a/bt5/erp5_item/ActionTemplateItem/portal_types/Purchase%20Order%20Line/item_creation.xml +++ b/bt5/erp5_item/ActionTemplateItem/portal_types/Purchase%20Order%20Line/item_creation.xml @@ -16,13 +16,13 @@ <key> <string>categories</string> </key> <value> <tuple> - <string>action_type/object_fast_input</string> + <string>action_type/object_jio_fast_input</string> </tuple> </value> </item> <item> <key> <string>category</string> </key> - <value> <string>object_fast_input</string> </value> + <value> <string>object_jio_fast_input</string> </value> </item> <item> <key> <string>condition</string> </key> @@ -32,7 +32,9 @@ </item> <item> <key> <string>description</string> </key> - <value> <string></string> </value> + <value> + <none/> + </value> </item> <item> <key> <string>icon</string> </key> @@ -73,7 +75,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog</string> </value> + <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog?reset:int=1</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_item/ActionTemplateItem/portal_types/Purchase%20Packing%20List%20Line/item_creation.xml b/bt5/erp5_item/ActionTemplateItem/portal_types/Purchase%20Packing%20List%20Line/item_creation.xml index c032e7956f..5f6b470612 100644 --- a/bt5/erp5_item/ActionTemplateItem/portal_types/Purchase%20Packing%20List%20Line/item_creation.xml +++ b/bt5/erp5_item/ActionTemplateItem/portal_types/Purchase%20Packing%20List%20Line/item_creation.xml @@ -16,13 +16,13 @@ <key> <string>categories</string> </key> <value> <tuple> - <string>action_type/object_fast_input</string> + <string>action_type/object_jio_fast_input</string> </tuple> </value> </item> <item> <key> <string>category</string> </key> - <value> <string>object_fast_input</string> </value> + <value> <string>object_jio_fast_input</string> </value> </item> <item> <key> <string>condition</string> </key> @@ -32,7 +32,9 @@ </item> <item> <key> <string>description</string> </key> - <value> <string></string> </value> + <value> + <none/> + </value> </item> <item> <key> <string>icon</string> </key> @@ -73,7 +75,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog</string> </value> + <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog?reset:int=1</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_item/ActionTemplateItem/portal_types/Returned%20Purchase%20Packing%20List%20Line/item_creation.xml b/bt5/erp5_item/ActionTemplateItem/portal_types/Returned%20Purchase%20Packing%20List%20Line/item_creation.xml index c032e7956f..5f6b470612 100644 --- a/bt5/erp5_item/ActionTemplateItem/portal_types/Returned%20Purchase%20Packing%20List%20Line/item_creation.xml +++ b/bt5/erp5_item/ActionTemplateItem/portal_types/Returned%20Purchase%20Packing%20List%20Line/item_creation.xml @@ -16,13 +16,13 @@ <key> <string>categories</string> </key> <value> <tuple> - <string>action_type/object_fast_input</string> + <string>action_type/object_jio_fast_input</string> </tuple> </value> </item> <item> <key> <string>category</string> </key> - <value> <string>object_fast_input</string> </value> + <value> <string>object_jio_fast_input</string> </value> </item> <item> <key> <string>condition</string> </key> @@ -32,7 +32,9 @@ </item> <item> <key> <string>description</string> </key> - <value> <string></string> </value> + <value> + <none/> + </value> </item> <item> <key> <string>icon</string> </key> @@ -73,7 +75,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog</string> </value> + <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog?reset:int=1</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_item/ActionTemplateItem/portal_types/Returned%20Sale%20Packing%20List%20Line/item_creation.xml b/bt5/erp5_item/ActionTemplateItem/portal_types/Returned%20Sale%20Packing%20List%20Line/item_creation.xml index c032e7956f..5f6b470612 100644 --- a/bt5/erp5_item/ActionTemplateItem/portal_types/Returned%20Sale%20Packing%20List%20Line/item_creation.xml +++ b/bt5/erp5_item/ActionTemplateItem/portal_types/Returned%20Sale%20Packing%20List%20Line/item_creation.xml @@ -16,13 +16,13 @@ <key> <string>categories</string> </key> <value> <tuple> - <string>action_type/object_fast_input</string> + <string>action_type/object_jio_fast_input</string> </tuple> </value> </item> <item> <key> <string>category</string> </key> - <value> <string>object_fast_input</string> </value> + <value> <string>object_jio_fast_input</string> </value> </item> <item> <key> <string>condition</string> </key> @@ -32,7 +32,9 @@ </item> <item> <key> <string>description</string> </key> - <value> <string></string> </value> + <value> + <none/> + </value> </item> <item> <key> <string>icon</string> </key> @@ -73,7 +75,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog</string> </value> + <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog?reset:int=1</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_item/ActionTemplateItem/portal_types/Sale%20Order%20Line/item_creation.xml b/bt5/erp5_item/ActionTemplateItem/portal_types/Sale%20Order%20Line/item_creation.xml index c032e7956f..5f6b470612 100644 --- a/bt5/erp5_item/ActionTemplateItem/portal_types/Sale%20Order%20Line/item_creation.xml +++ b/bt5/erp5_item/ActionTemplateItem/portal_types/Sale%20Order%20Line/item_creation.xml @@ -16,13 +16,13 @@ <key> <string>categories</string> </key> <value> <tuple> - <string>action_type/object_fast_input</string> + <string>action_type/object_jio_fast_input</string> </tuple> </value> </item> <item> <key> <string>category</string> </key> - <value> <string>object_fast_input</string> </value> + <value> <string>object_jio_fast_input</string> </value> </item> <item> <key> <string>condition</string> </key> @@ -32,7 +32,9 @@ </item> <item> <key> <string>description</string> </key> - <value> <string></string> </value> + <value> + <none/> + </value> </item> <item> <key> <string>icon</string> </key> @@ -73,7 +75,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog</string> </value> + <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog?reset:int=1</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_item/ActionTemplateItem/portal_types/Sale%20Packing%20List%20Line/item_creation.xml b/bt5/erp5_item/ActionTemplateItem/portal_types/Sale%20Packing%20List%20Line/item_creation.xml index c032e7956f..5f6b470612 100644 --- a/bt5/erp5_item/ActionTemplateItem/portal_types/Sale%20Packing%20List%20Line/item_creation.xml +++ b/bt5/erp5_item/ActionTemplateItem/portal_types/Sale%20Packing%20List%20Line/item_creation.xml @@ -16,13 +16,13 @@ <key> <string>categories</string> </key> <value> <tuple> - <string>action_type/object_fast_input</string> + <string>action_type/object_jio_fast_input</string> </tuple> </value> </item> <item> <key> <string>category</string> </key> - <value> <string>object_fast_input</string> </value> + <value> <string>object_jio_fast_input</string> </value> </item> <item> <key> <string>condition</string> </key> @@ -32,7 +32,9 @@ </item> <item> <key> <string>description</string> </key> - <value> <string></string> </value> + <value> + <none/> + </value> </item> <item> <key> <string>icon</string> </key> @@ -73,7 +75,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog</string> </value> + <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog?reset:int=1</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_getTempItemList.py b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_getTempItemList.py index b717de45e1..471556c4f5 100644 --- a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_getTempItemList.py +++ b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_getTempItemList.py @@ -1,18 +1,10 @@ +from Products.ERP5Type.Document import newTempDeliveryLine portal = context.getPortalObject() -try: - count = int(context.REQUEST.get('field_your_item_count', '')) -except ValueError: - count = 10 - result = [] -for i in range(count): - obj = portal.newContent( - portal_type='Movement', - temp_object=True, - id="tmp_item_%s" % i, - uid="new_item_%s" % i) +for i in range(item_count): + obj = newTempDeliveryLine(portal, id="tmp_item_%s" % i, uid="new_item_%s" % i) result.append(obj) return result diff --git a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_getTempItemList.xml b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_getTempItemList.xml index 4ad567ee36..75c9153c15 100644 --- a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_getTempItemList.xml +++ b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_getTempItemList.xml @@ -50,7 +50,7 @@ </item> <item> <key> <string>_params</string> </key> - <value> <string>*args, **kw</string> </value> + <value> <string>item_count=10, *args, **kw</string> </value> </item> <item> <key> <string>id</string> </key> diff --git a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_selectItemList.py b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_selectItemList.py index 479d5d318a..dd98decdb1 100644 --- a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_selectItemList.py +++ b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_selectItemList.py @@ -55,8 +55,10 @@ if message: # Script stop here context.Base_updateDialogForm(listbox=listbox,update=1, kw=kw) REQUEST = portal.REQUEST - REQUEST.set('portal_status_message', message) - return getattr(context, REQUEST.form['dialog_id'])(listbox=listbox, kw=kw) + return context.Base_renderForm( + REQUEST.form['dialog_id'], + keep_items={'portal_status_message': message} + ) for item_uid in uids: item = getObject(item_uid) diff --git a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_updateSelectItemListDialog.py b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_updateSelectItemListDialog.py index bc08329f1b..5377667d20 100644 --- a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_updateSelectItemListDialog.py +++ b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_updateSelectItemListDialog.py @@ -1,8 +1,14 @@ request = context.REQUEST +portal = context.getPortalObject() +Base_translateString = portal.Base_translateString # FIXME: this is a workaround, because if listbox is present in request.form, # editable fields will be empty when re-displaying the dialog. request.form.pop('listbox', None) request.other.pop('listbox', None) -return getattr(context, dialog_id)(**kw) +context.Base_updateDialogForm() +return context.Base_renderForm( + dialog_id, + keep_items={'portal_status_message': Base_translateString('Updated')} +) diff --git a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_viewItemCreationDialog/listbox.xml b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_viewItemCreationDialog/listbox.xml index fddbf40871..8b7d2b8e82 100644 --- a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_viewItemCreationDialog/listbox.xml +++ b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item_trade/DeliveryLine_viewItemCreationDialog/listbox.xml @@ -11,6 +11,7 @@ <value> <list> <string>columns</string> + <string>default_params</string> <string>editable_columns</string> <string>lines</string> <string>list_method</string> @@ -62,6 +63,12 @@ <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> </value> </item> + <item> + <key> <string>default_params</string> </key> + <value> + <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + </value> + </item> <item> <key> <string>editable_columns</string> </key> <value> <string></string> </value> @@ -77,7 +84,7 @@ <item> <key> <string>lines</string> </key> <value> - <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> + <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> </value> </item> <item> @@ -130,6 +137,17 @@ </list> </value> </item> + <item> + <key> <string>default_params</string> </key> + <value> + <list> + <tuple> + <string>checked_permission</string> + <string>View</string> + </tuple> + </list> + </value> + </item> <item> <key> <string>editable_columns</string> </key> <value> @@ -176,7 +194,7 @@ <item> <key> <string>list_method</string> </key> <value> - <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> + <persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent> </value> </item> <item> @@ -214,12 +232,25 @@ <dictionary> <item> <key> <string>_text</string> </key> - <value> <string>python: 0</string> </value> + <value> <string>python: [(\'checked_permission\', \'View\'), (\'item_count\', int(context.REQUEST.get(\'field_your_item_count\', \'10\')))]</string> </value> </item> </dictionary> </pickle> </record> <record id="4" aka="AAAAAAAAAAQ="> + <pickle> + <global name="TALESMethod" module="Products.Formulator.TALESField"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_text</string> </key> + <value> <string>python: 0</string> </value> + </item> + </dictionary> + </pickle> + </record> + <record id="5" aka="AAAAAAAAAAU="> <pickle> <global name="Method" module="Products.Formulator.MethodField"/> </pickle> diff --git a/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Manufacturing%20Execution%20Line/item_creation.xml b/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Manufacturing%20Execution%20Line/item_creation.xml index c032e7956f..5f6b470612 100644 --- a/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Manufacturing%20Execution%20Line/item_creation.xml +++ b/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Manufacturing%20Execution%20Line/item_creation.xml @@ -16,13 +16,13 @@ <key> <string>categories</string> </key> <value> <tuple> - <string>action_type/object_fast_input</string> + <string>action_type/object_jio_fast_input</string> </tuple> </value> </item> <item> <key> <string>category</string> </key> - <value> <string>object_fast_input</string> </value> + <value> <string>object_jio_fast_input</string> </value> </item> <item> <key> <string>condition</string> </key> @@ -32,7 +32,9 @@ </item> <item> <key> <string>description</string> </key> - <value> <string></string> </value> + <value> + <none/> + </value> </item> <item> <key> <string>icon</string> </key> @@ -73,7 +75,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog</string> </value> + <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog?reset:int=1</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Production%20Order%20Line/item_creation.xml b/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Production%20Order%20Line/item_creation.xml index c032e7956f..5f6b470612 100644 --- a/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Production%20Order%20Line/item_creation.xml +++ b/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Production%20Order%20Line/item_creation.xml @@ -16,13 +16,13 @@ <key> <string>categories</string> </key> <value> <tuple> - <string>action_type/object_fast_input</string> + <string>action_type/object_jio_fast_input</string> </tuple> </value> </item> <item> <key> <string>category</string> </key> - <value> <string>object_fast_input</string> </value> + <value> <string>object_jio_fast_input</string> </value> </item> <item> <key> <string>condition</string> </key> @@ -32,7 +32,9 @@ </item> <item> <key> <string>description</string> </key> - <value> <string></string> </value> + <value> + <none/> + </value> </item> <item> <key> <string>icon</string> </key> @@ -73,7 +75,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog</string> </value> + <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog?reset:int=1</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Production%20Packing%20List%20Line/item_creation.xml b/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Production%20Packing%20List%20Line/item_creation.xml index c032e7956f..5f6b470612 100644 --- a/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Production%20Packing%20List%20Line/item_creation.xml +++ b/bt5/erp5_mrp_item/ActionTemplateItem/portal_types/Production%20Packing%20List%20Line/item_creation.xml @@ -16,13 +16,13 @@ <key> <string>categories</string> </key> <value> <tuple> - <string>action_type/object_fast_input</string> + <string>action_type/object_jio_fast_input</string> </tuple> </value> </item> <item> <key> <string>category</string> </key> - <value> <string>object_fast_input</string> </value> + <value> <string>object_jio_fast_input</string> </value> </item> <item> <key> <string>condition</string> </key> @@ -32,7 +32,9 @@ </item> <item> <key> <string>description</string> </key> - <value> <string></string> </value> + <value> + <none/> + </value> </item> <item> <key> <string>icon</string> </key> @@ -73,7 +75,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog</string> </value> + <value> <string>string:${object_url}/DeliveryLine_viewItemCreationDialog?reset:int=1</string> </value> </item> </dictionary> </pickle> -- 2.30.9