details: https://code.openbravo.com/erp/devel/pi/rev/3547f6b6e776
changeset: 25100:3547f6b6e776
user: Fernando Soto <fernando.soto <at> peoplewalking.com>
date: Mon Oct 20 16:03:47 2014 -0500
summary: Fixed bug 27102: Create Variants method is not setting the correct
organization
Modified class VariantAutomaticGenerationProcess to set to the Product
Characteristics Value the same organization of the product.
Also created UpdateProductChValueOrg modulescript to fix the previously entered
data.
diffstat:
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateProductChValueOrg.class
| 0
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateProductChValueOrgData.class
| 0
src-util/modulescript/src/org/openbravo/modulescript/UpdateProductChValueOrg.java
| 27 +++
src-util/modulescript/src/org/openbravo/modulescript/UpdateProductChValueOrg_data.xsql
| 68 ++++++++++
src/org/openbravo/materialmgmt/VariantAutomaticGenerationProcess.java
| 4 +-
5 files changed, 97 insertions(+), 2 deletions(-)
diffs (129 lines):
diff -r 02305d00744f -r 3547f6b6e776
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateProductChValueOrg.class
Binary file
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateProductChValueOrg.class
has changed
diff -r 02305d00744f -r 3547f6b6e776
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateProductChValueOrgData.class
Binary file
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateProductChValueOrgData.class
has changed
diff -r 02305d00744f -r 3547f6b6e776
src-util/modulescript/src/org/openbravo/modulescript/UpdateProductChValueOrg.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/src-util/modulescript/src/org/openbravo/modulescript/UpdateProductChValueOrg.java
Mon Oct 20 16:03:47 2014 -0500
@@ -0,0 +1,27 @@
+package org.openbravo.modulescript;
+
+import org.apache.log4j.Logger;
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.modulescript.ModuleScript;
+
+public class UpdateProductChValueOrg extends ModuleScript {
+
+ private static final Logger log4j =
Logger.getLogger(UpdateProductChValueOrg.class);
+
+ @Override
+ public void execute() {
+ try {
+ ConnectionProvider cp = getConnectionProvider();
+ boolean executed =
UpdateProductChValueOrgData.isModuleScriptExecuted(cp);
+ if (!executed) {
+ int count = UpdateProductChValueOrgData.updateProductChValueOrg(cp);
+ if (count > 0)
+ log4j.info("Updated " + count + " invoices.");
+ UpdateProductChValueOrgData.createPreference(cp);
+ }
+ } catch (Exception e) {
+ handleError(e);
+ }
+ }
+
+}
diff -r 02305d00744f -r 3547f6b6e776
src-util/modulescript/src/org/openbravo/modulescript/UpdateProductChValueOrg_data.xsql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/src-util/modulescript/src/org/openbravo/modulescript/UpdateProductChValueOrg_data.xsql
Mon Oct 20 16:03:47 2014 -0500
@@ -0,0 +1,68 @@
+<?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 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+-->
+<SqlClass name="UpdateProductChValueOrgData"
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="updateProductChValueOrg" type="preparedStatement"
return="rowcount">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ update m_product_ch_value chv
+ set ad_org_id =
+ (select p.ad_org_id
+ from m_product p
+ where chv.m_product_id = p.m_product_id)
+ where exists (select 1
+ from m_product p
+ where chv.m_product_id = p.m_product_id and
+ chv.ad_org_id <> p.ad_org_id)
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="isModuleScriptExecuted" type="preparedStatement"
return="boolean">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ SELECT count(*) as exist
+ FROM ad_preference
+ WHERE attribute = 'UpdateProductChValueOrg' 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(), 'UpdateProductChValueOrg')
+ ]]>
+ </Sql>
+ </SqlMethod>
+</SqlClass>
\ No newline at end of file
diff -r 02305d00744f -r 3547f6b6e776
src/org/openbravo/materialmgmt/VariantAutomaticGenerationProcess.java
--- a/src/org/openbravo/materialmgmt/VariantAutomaticGenerationProcess.java
Fri Oct 24 14:32:47 2014 +0200
+++ b/src/org/openbravo/materialmgmt/VariantAutomaticGenerationProcess.java
Mon Oct 20 16:03:47 2014 -0500
@@ -141,8 +141,7 @@
variant.setProductAccountsList(Collections.<ProductAccounts>
emptyList());
variant.setGeneric(false);
for (ProductCharacteristic prCh :
variant.getProductCharacteristicList()) {
- prCh
-
.setProductCharacteristicConfList(Collections.<ProductCharacteristicConf>
emptyList());
+
prCh.setProductCharacteristicConfList(Collections.<ProductCharacteristicConf>
emptyList());
}
String searchKey = product.getSearchKey();
@@ -171,6 +170,7 @@
newPrChValue.setCharacteristic(prChConf.getCharacteristicOfProduct().getCharacteristic());
newPrChValue.setCharacteristicValue(prChConf.getCharacteristicValue());
newPrChValue.setProduct(variant);
+ newPrChValue.setOrganization(product.getOrganization());
if (StringUtils.isNotBlank(strChDesc)) {
strChDesc += ", ";
}
------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits