src-util/modulescript/src/org/openbravo/modulescript/UpdateBpPaymentLine_data.xsql
author Asier Lostalé <asier.lostale@openbravo.com>
Mon, 23 Feb 2015 11:17:39 +0100
changeset 26041 d061c9e837aa
parent 25772 5ef45cfcb9a5
child 26141 b9fc7e8e60ae
permissions -rw-r--r--
fixed bug 28712: record selection lost in p&e grid if data has multiple pages

In P&E grid with data displayed in several pages, if part of the selection was
not in the 1st page two errors occured:

-If after selecting a record in 2nd page another one in the 1st page was selected,
selection of record in 2nd page was lost
-If record in 2nd page was selected by using a filter, the filter was removed, and
the p&e was submitted, the selection was not sent to backend

The problem is in SC grid.getSelectedRecords which returns records only in current
page.

To solve this a cache of selected/unselected records is completelly maintained for p&e
grids without using getSelectedRecords, this is used also to send the selected recors
on p&e submission.
<?xml version="1.0" encoding="UTF-8" ?>
<!--
 *************************************************************************
 * The contents of this file are subject to the Openbravo  Public  License
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
 * Version 1.1  with a permitted attribution clause; you may not  use this
 * file except in compliance with the License. You  may  obtain  a copy of
 * the License at http://www.openbravo.com/legal/license.html
 * Software distributed under the License  is  distributed  on  an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific  language  governing  rights  and  limitations
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
 * All portions are Copyright (C) 2014-2015 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************
-->
<SqlClass name="UpdateBpPaymentLineData" package="org.openbravo.modulescript">
   <SqlClassComment></SqlClassComment>
  <SqlMethod name="select" type="preparedStatement" return="multiple">
    <SqlMethodComment></SqlMethodComment>
    <Sql><![CDATA[
      SELECT '' as exist FROM DUAL
      ]]>
    </Sql>
  </SqlMethod>
  <SqlMethod name="updateBpPaymentLineInvoice" type="preparedStatement" return="rowcount">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
      <![CDATA[
				update fin_payment_scheduledetail psd
				set c_bpartner_id = (select c_bpartner_id from c_invoice i, fin_payment_schedule ps
				                     where ps.fin_payment_schedule_id = fin_payment_schedule_invoice 
				                     and ps.c_invoice_id = i.c_invoice_id)
				where c_bpartner_id is null and fin_payment_schedule_invoice is not null 
      ]]>
    </Sql>
  </SqlMethod>
  <SqlMethod name="updateBpPaymentLineOrder" type="preparedStatement" return="rowcount">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
      <![CDATA[
				update fin_payment_scheduledetail psd
				set c_bpartner_id = (select c_bpartner_id from c_order o, fin_payment_schedule ps
				                     where ps.fin_payment_schedule_id = fin_payment_schedule_order 
				                     and ps.c_order_id = o.c_order_id)
				where c_bpartner_id is null and fin_payment_schedule_order is not null
					and fin_payment_schedule_invoice is null
      ]]>
    </Sql>
  </SqlMethod>
   <SqlMethod name="isModuleScriptExecuted" type="preparedStatement" return="boolean">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
      <![CDATA[
    SELECT count(*) as exist
    FROM ad_preference
    WHERE attribute = 'UpdateBpPaymentLine2' and isactive = 'Y'
      ]]>
    </Sql>
  </SqlMethod>
   <SqlMethod name="createPreference" type="preparedStatement" return="rowcount">
    <SqlMethodComment></SqlMethodComment>
    <Sql>
      <![CDATA[
    INSERT INTO ad_preference (
    ad_preference_id, ad_client_id, ad_org_id, isactive,
    createdby, created, updatedby, updated, attribute
    ) VALUES (
    get_uuid(), '0', '0', 'Y', 
    '0', NOW(), '0', NOW(), 'UpdateBpPaymentLine2')
      ]]>
    </Sql>
  </SqlMethod>
</SqlClass>