diff --git a/db/ddlutils/oracle/views/AD_FIELD_V.sql b/db/ddlutils/oracle/views/AD_FIELD_V.sql index e53bf1a9bd..ddb98e2b07 100644 --- a/db/ddlutils/oracle/views/AD_FIELD_V.sql +++ b/db/ddlutils/oracle/views/AD_FIELD_V.sql @@ -1,5 +1,5 @@ CREATE OR REPLACE VIEW ad_field_v AS - SELECT t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, f.name, f.description, f.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, c.vformat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, COALESCE(f.isalwaysupdateable, c.isalwaysupdateable) AS isalwaysupdateable, COALESCE(f.readonlylogic, c.readonlylogic) AS readonlylogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS mandatorylogic, COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax, fg.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id, fg.fieldgrouptype, fg.iscollapsedbydefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete, COALESCE(f.isallowcopy, c.isallowcopy) AS isallowcopy, f.isdisplayedgrid, f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, COALESCE(f.istoolbarbutton, c.istoolbarbutton) AS istoolbarbutton, c.formatpattern, f.isadvancedfield, f.isdefaultfocus, c.ad_chart_id, f.ad_labelstyle_id, f.ad_fieldstyle_id, c.pa_dashboardcontent_id + SELECT t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, f.name, f.description, f.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, COALESCE(f.VFormat, c.VFormat) AS VFormat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, COALESCE(f.isalwaysupdateable, c.isalwaysupdateable) AS isalwaysupdateable, COALESCE(f.readonlylogic, c.readonlylogic) AS readonlylogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS mandatorylogic, COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax, fg.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id, fg.fieldgrouptype, fg.iscollapsedbydefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete, COALESCE(f.isallowcopy, c.isallowcopy) AS isallowcopy, f.isdisplayedgrid, f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, COALESCE(f.istoolbarbutton, c.istoolbarbutton) AS istoolbarbutton, c.formatpattern, f.isadvancedfield, f.isdefaultfocus, c.ad_chart_id, f.ad_labelstyle_id, f.ad_fieldstyle_id, c.pa_dashboardcontent_id FROM ad_field f JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id diff --git a/db/ddlutils/oracle/views/AD_FIELD_VT.sql b/db/ddlutils/oracle/views/AD_FIELD_VT.sql index ca003daae4..79468aaa8c 100644 --- a/db/ddlutils/oracle/views/AD_FIELD_VT.sql +++ b/db/ddlutils/oracle/views/AD_FIELD_VT.sql @@ -1,5 +1,5 @@ CREATE OR REPLACE VIEW ad_field_vt AS - SELECT trl.ad_language, t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, trl.name, trl.description, trl.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, c.vformat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, COALESCE(f.isalwaysupdateable, c.isalwaysupdateable) AS isalwaysupdateable, COALESCE(f.readonlylogic, c.readonlylogic) AS readonlylogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS mandatorylogic, COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax, fgt.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id, fg.fieldgrouptype, fg.iscollapsedbydefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete, COALESCE(f.isallowcopy, c.isallowcopy) AS isallowcopy, f.isdisplayedgrid, f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, COALESCE(f.istoolbarbutton, c.istoolbarbutton) AS istoolbarbutton, c.formatpattern, f.isadvancedfield, f.isdefaultfocus, c.ad_chart_id, f.ad_labelstyle_id, f.ad_fieldstyle_id, c.pa_dashboardcontent_id + SELECT trl.ad_language, t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, trl.name, trl.description, trl.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, COALESCE(f.VFormat, c.VFormat) AS VFormat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, COALESCE(f.isalwaysupdateable, c.isalwaysupdateable) AS isalwaysupdateable, COALESCE(f.readonlylogic, c.readonlylogic) AS readonlylogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS mandatorylogic, COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax, fgt.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id, fg.fieldgrouptype, fg.iscollapsedbydefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete, COALESCE(f.isallowcopy, c.isallowcopy) AS isallowcopy, f.isdisplayedgrid, f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, COALESCE(f.istoolbarbutton, c.istoolbarbutton) AS istoolbarbutton, c.formatpattern, f.isadvancedfield, f.isdefaultfocus, c.ad_chart_id, f.ad_labelstyle_id, f.ad_fieldstyle_id, c.pa_dashboardcontent_id FROM ad_field f JOIN ad_field_trl trl ON f.ad_field_id = trl.ad_field_id JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id diff --git a/db/ddlutils/postgresql/views/AD_FIELD_V.sql b/db/ddlutils/postgresql/views/AD_FIELD_V.sql index 0d3a3be630..5a21584e1b 100644 --- a/db/ddlutils/postgresql/views/AD_FIELD_V.sql +++ b/db/ddlutils/postgresql/views/AD_FIELD_V.sql @@ -1,6 +1,6 @@ CREATE OR REPLACE VIEW ad_field_v AS SELECT t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, f.name, f.description, f.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, f.sortno, f.issameline, -f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, c.vformat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, +f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, COALESCE(f.VFormat, c.VFormat) AS VFormat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, COALESCE(f.isalwaysupdateable, c.isalwaysupdateable) AS isalwaysupdateable, COALESCE(f.readonlylogic, c.readonlylogic) AS readonlylogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS mandatorylogic, COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, diff --git a/db/ddlutils/postgresql/views/AD_FIELD_VT.sql b/db/ddlutils/postgresql/views/AD_FIELD_VT.sql index 388d97eca7..0261edd989 100644 --- a/db/ddlutils/postgresql/views/AD_FIELD_VT.sql +++ b/db/ddlutils/postgresql/views/AD_FIELD_VT.sql @@ -1,6 +1,6 @@ CREATE OR REPLACE VIEW ad_field_vt AS SELECT trl.ad_language, t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, trl.name, trl.description, trl.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, - f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, c.vformat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, + f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, COALESCE(f.VFormat, c.VFormat) AS VFormat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, COALESCE(f.isalwaysupdateable, c.isalwaysupdateable) AS isalwaysupdateable, COALESCE(f.readonlylogic, c.readonlylogic) AS readonlylogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS mandatorylogic, COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, diff --git a/migration/i4.1/oracle/201702271800_Ticket_1007607.sql b/migration/i4.1/oracle/201702271800_Ticket_1007607.sql new file mode 100644 index 0000000000..e202110be8 --- /dev/null +++ b/migration/i4.1/oracle/201702271800_Ticket_1007607.sql @@ -0,0 +1,57 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Feb 27, 2017 12:25:32 PM GMT+08:00 +-- 1007607 Implement generic UOM conversions +UPDATE AD_IndexColumn SET ColumnSQL='COALESCE(M_Product_ID,-1)',Updated=TO_DATE('2017-02-27 12:25:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_IndexColumn_ID=200656 +; + +-- Feb 27, 2017 12:25:46 PM GMT+08:00 +DROP INDEX c_uom_conversion_product +; + +-- Feb 27, 2017 12:25:46 PM GMT+08:00 +CREATE UNIQUE INDEX c_uom_conversion_product ON C_UOM_Conversion (C_UOM_ID,C_UOM_To_ID,COALESCE(M_Product_ID,-1)) +; + +-- Feb 27, 2017 12:29:47 PM GMT+08:00 +UPDATE AD_Field SET IsMandatory=NULL, AD_Val_Rule_ID=NULL, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-02-27 12:29:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10831 +; + +-- Feb 27, 2017 12:49:10 PM GMT+08:00 +UPDATE AD_Val_Rule SET Code='( +EXISTS ( + /* UOM is a default UOM and no product selected */ + SELECT * + FROM C_UOM uu + WHERE C_UOM.C_UOM_ID=uu.C_UOM_ID AND IsActive =''Y'' AND IsDefault=''Y'' AND @M_Product_ID@=0 +) +OR EXISTS ( + /* UOM is the products UOM */ + SELECT * + FROM M_Product p + WHERE C_UOM.C_UOM_ID=p.C_UOM_ID AND @M_Product_ID@=p.M_Product_ID +) +OR EXISTS ( + /* For the products UOM there is a conversion that is explicitly bound to the product */ + SELECT * + FROM M_Product p INNER JOIN C_UOM_Conversion c ON (p.C_UOM_ID=c.C_UOM_ID AND p.M_PRODUCT_ID=c.M_Product_ID AND c.IsActive =''Y'' ) + WHERE C_UOM.C_UOM_ID=c.C_UOM_TO_ID AND @M_Product_ID@=p.M_Product_ID +) +OR EXISTS ( + /* For the products UOM there is a conversion that is not bound to any product explicitly */ + SELECT * + FROM M_Product p INNER JOIN C_UOM_Conversion c ON (p.C_UOM_ID=c.C_UOM_ID AND c.M_Product_ID IS NULL AND c.IsActive =''Y'' ) + WHERE C_UOM.C_UOM_ID=c.C_UOM_TO_ID AND @M_Product_ID@=p.M_Product_ID + AND NOT EXISTS ( + SELECT * + FROM M_Product p1 INNER JOIN C_UOM_Conversion c1 ON (p1.C_UOM_ID=c1.C_UOM_ID AND p1.M_PRODUCT_ID=c1.M_Product_ID AND c1.IsActive =''N'' ) + WHERE c.C_UOM_ID=c1.C_UOM_ID AND c.C_UOM_TO_ID=c1.C_UOM_TO_ID AND p1.M_Product_ID=@M_Product_ID@ + ) +) +)',Updated=TO_DATE('2017-02-27 12:49:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=210 +; + +SELECT register_migration_script('201702271800_Ticket_1007607.sql') FROM dual +; + diff --git a/migration/i4.1/oracle/201703311809_IDEMPIERE-3330.sql b/migration/i4.1/oracle/201703311809_IDEMPIERE-3330.sql new file mode 100644 index 0000000000..b593e61503 --- /dev/null +++ b/migration/i4.1/oracle/201703311809_IDEMPIERE-3330.sql @@ -0,0 +1,11 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3330 Shipment Line - movement qty field not shown until qty is changed +-- Mar 31, 2017 6:03:02 PM CEST +UPDATE AD_Column SET Callout='org.compiere.model.CalloutInOut.navigateInOutLine', IsUpdateable='N',Updated=TO_DATE('2017-03-31 18:03:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3529 +; + +SELECT register_migration_script('201703311809_IDEMPIERE-3330.sql') FROM dual +; + diff --git a/migration/i4.1/oracle/201704010847_IDEMPIERE-3115.sql b/migration/i4.1/oracle/201704010847_IDEMPIERE-3115.sql new file mode 100644 index 0000000000..de7dd877c1 --- /dev/null +++ b/migration/i4.1/oracle/201704010847_IDEMPIERE-3115.sql @@ -0,0 +1,27 @@ +CREATE OR REPLACE VIEW ad_field_v AS + SELECT t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, f.name, f.description, f.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, COALESCE(f.VFormat, c.VFormat) AS VFormat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, COALESCE(f.isalwaysupdateable, c.isalwaysupdateable) AS isalwaysupdateable, COALESCE(f.readonlylogic, c.readonlylogic) AS readonlylogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS mandatorylogic, COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax, fg.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id, fg.fieldgrouptype, fg.iscollapsedbydefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete, COALESCE(f.isallowcopy, c.isallowcopy) AS isallowcopy, f.isdisplayedgrid, f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, COALESCE(f.istoolbarbutton, c.istoolbarbutton) AS istoolbarbutton, c.formatpattern, f.isadvancedfield, f.isdefaultfocus, c.ad_chart_id, f.ad_labelstyle_id, f.ad_fieldstyle_id, c.pa_dashboardcontent_id + FROM ad_field f + JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id + LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id + LEFT JOIN ad_column c ON f.ad_column_id = c.ad_column_id + JOIN ad_table tbl ON c.ad_table_id = tbl.ad_table_id + LEFT JOIN ad_val_rule vr ON vr.ad_val_rule_id = COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) + WHERE f.isactive = 'Y' AND c.isactive = 'Y' +; + +CREATE OR REPLACE VIEW ad_field_vt AS + SELECT trl.ad_language, t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, trl.name, trl.description, trl.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, COALESCE(f.VFormat, c.VFormat) AS VFormat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, COALESCE(f.isalwaysupdateable, c.isalwaysupdateable) AS isalwaysupdateable, COALESCE(f.readonlylogic, c.readonlylogic) AS readonlylogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS mandatorylogic, COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax, fgt.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id, fg.fieldgrouptype, fg.iscollapsedbydefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete, COALESCE(f.isallowcopy, c.isallowcopy) AS isallowcopy, f.isdisplayedgrid, f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, COALESCE(f.istoolbarbutton, c.istoolbarbutton) AS istoolbarbutton, c.formatpattern, f.isadvancedfield, f.isdefaultfocus, c.ad_chart_id, f.ad_labelstyle_id, f.ad_fieldstyle_id, c.pa_dashboardcontent_id + FROM ad_field f + JOIN ad_field_trl trl ON f.ad_field_id = trl.ad_field_id + JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id + LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id + LEFT JOIN ad_fieldgroup_trl fgt ON f.ad_fieldgroup_id = fgt.ad_fieldgroup_id AND trl.ad_language = fgt.ad_language + LEFT JOIN ad_column c ON f.ad_column_id = c.ad_column_id + JOIN ad_table tbl ON c.ad_table_id = tbl.ad_table_id + LEFT JOIN ad_val_rule vr ON vr.ad_val_rule_id = COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) + WHERE f.isactive = 'Y' AND c.isactive = 'Y' +; + +SELECT register_migration_script('201704010847_IDEMPIERE-3115.sql') FROM dual +; + diff --git a/migration/i4.1/postgresql/201702271800_Ticket_1007607.sql b/migration/i4.1/postgresql/201702271800_Ticket_1007607.sql new file mode 100644 index 0000000000..11bae61212 --- /dev/null +++ b/migration/i4.1/postgresql/201702271800_Ticket_1007607.sql @@ -0,0 +1,54 @@ +-- Feb 27, 2017 12:25:32 PM GMT+08:00 +-- 1007607 Implement generic UOM conversions +UPDATE AD_IndexColumn SET ColumnSQL='COALESCE(M_Product_ID,-1)',Updated=TO_TIMESTAMP('2017-02-27 12:25:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_IndexColumn_ID=200656 +; + +-- Feb 27, 2017 12:25:46 PM GMT+08:00 +DROP INDEX c_uom_conversion_product +; + +-- Feb 27, 2017 12:25:46 PM GMT+08:00 +CREATE UNIQUE INDEX c_uom_conversion_product ON C_UOM_Conversion (C_UOM_ID,C_UOM_To_ID,COALESCE(M_Product_ID,-1)) +; + +-- Feb 27, 2017 12:29:47 PM GMT+08:00 +UPDATE AD_Field SET IsMandatory=NULL, AD_Val_Rule_ID=NULL, AD_Reference_Value_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-02-27 12:29:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10831 +; + +-- Feb 27, 2017 12:49:10 PM GMT+08:00 +UPDATE AD_Val_Rule SET Code='( +EXISTS ( + /* UOM is a default UOM and no product selected */ + SELECT * + FROM C_UOM uu + WHERE C_UOM.C_UOM_ID=uu.C_UOM_ID AND IsActive =''Y'' AND IsDefault=''Y'' AND @M_Product_ID@=0 +) +OR EXISTS ( + /* UOM is the products UOM */ + SELECT * + FROM M_Product p + WHERE C_UOM.C_UOM_ID=p.C_UOM_ID AND @M_Product_ID@=p.M_Product_ID +) +OR EXISTS ( + /* For the products UOM there is a conversion that is explicitly bound to the product */ + SELECT * + FROM M_Product p INNER JOIN C_UOM_Conversion c ON (p.C_UOM_ID=c.C_UOM_ID AND p.M_PRODUCT_ID=c.M_Product_ID AND c.IsActive =''Y'' ) + WHERE C_UOM.C_UOM_ID=c.C_UOM_TO_ID AND @M_Product_ID@=p.M_Product_ID +) +OR EXISTS ( + /* For the products UOM there is a conversion that is not bound to any product explicitly */ + SELECT * + FROM M_Product p INNER JOIN C_UOM_Conversion c ON (p.C_UOM_ID=c.C_UOM_ID AND c.M_Product_ID IS NULL AND c.IsActive =''Y'' ) + WHERE C_UOM.C_UOM_ID=c.C_UOM_TO_ID AND @M_Product_ID@=p.M_Product_ID + AND NOT EXISTS ( + SELECT * + FROM M_Product p1 INNER JOIN C_UOM_Conversion c1 ON (p1.C_UOM_ID=c1.C_UOM_ID AND p1.M_PRODUCT_ID=c1.M_Product_ID AND c1.IsActive =''N'' ) + WHERE c.C_UOM_ID=c1.C_UOM_ID AND c.C_UOM_TO_ID=c1.C_UOM_TO_ID AND p1.M_Product_ID=@M_Product_ID@ + ) +) +)',Updated=TO_TIMESTAMP('2017-02-27 12:49:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=210 +; + +SELECT register_migration_script('201702271800_Ticket_1007607.sql') FROM dual +; + diff --git a/migration/i4.1/postgresql/201703311809_IDEMPIERE-3330.sql b/migration/i4.1/postgresql/201703311809_IDEMPIERE-3330.sql new file mode 100644 index 0000000000..2b9839faf2 --- /dev/null +++ b/migration/i4.1/postgresql/201703311809_IDEMPIERE-3330.sql @@ -0,0 +1,8 @@ +-- IDEMPIERE-3330 Shipment Line - movement qty field not shown until qty is changed +-- Mar 31, 2017 6:03:02 PM CEST +UPDATE AD_Column SET Callout='org.compiere.model.CalloutInOut.navigateInOutLine', IsUpdateable='N',Updated=TO_TIMESTAMP('2017-03-31 18:03:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=3529 +; + +SELECT register_migration_script('201703311809_IDEMPIERE-3330.sql') FROM dual +; + diff --git a/migration/i4.1/postgresql/201704010847_IDEMPIERE-3115.sql b/migration/i4.1/postgresql/201704010847_IDEMPIERE-3115.sql new file mode 100644 index 0000000000..c298b2ee39 --- /dev/null +++ b/migration/i4.1/postgresql/201704010847_IDEMPIERE-3115.sql @@ -0,0 +1,42 @@ +CREATE OR REPLACE VIEW ad_field_v AS + SELECT t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, f.name, f.description, f.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, f.sortno, f.issameline, +f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, COALESCE(f.VFormat, c.VFormat) AS VFormat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, +c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, +c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, COALESCE(f.isalwaysupdateable, c.isalwaysupdateable) AS isalwaysupdateable, +COALESCE(f.readonlylogic, c.readonlylogic) AS readonlylogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS mandatorylogic, COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, +c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax, fg.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id, fg.fieldgrouptype, +fg.iscollapsedbydefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete, COALESCE(f.isallowcopy, c.isallowcopy) AS isallowcopy, f.isdisplayedgrid, +f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, COALESCE(f.istoolbarbutton, c.istoolbarbutton) AS istoolbarbutton, c.formatpattern, f.isadvancedfield, f.isdefaultfocus, +c.ad_chart_id, f.ad_labelstyle_id, f.ad_fieldstyle_id, c.pa_dashboardcontent_id + FROM ad_field f + JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id + LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id + LEFT JOIN ad_column c ON f.ad_column_id = c.ad_column_id + JOIN ad_table tbl ON c.ad_table_id = tbl.ad_table_id + LEFT JOIN ad_val_rule vr ON vr.ad_val_rule_id = COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) + WHERE f.isactive = 'Y' AND c.isactive = 'Y' +; + +CREATE OR REPLACE VIEW ad_field_vt AS + SELECT trl.ad_language, t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, trl.name, trl.description, trl.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, + f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, COALESCE(f.VFormat, c.VFormat) AS VFormat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, + c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, + c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, COALESCE(f.isalwaysupdateable, + c.isalwaysupdateable) AS isalwaysupdateable, COALESCE(f.readonlylogic, c.readonlylogic) AS readonlylogic, COALESCE(f.mandatorylogic, c.mandatorylogic) AS mandatorylogic, COALESCE(f.isupdateable, c.isupdateable) AS isupdateable, + c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax, fgt.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id, fg.fieldgrouptype, + fg.iscollapsedbydefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete, COALESCE(f.isallowcopy, c.isallowcopy) AS isallowcopy, f.isdisplayedgrid, + f.seqnogrid, c.seqnoselection, f.xposition, f.columnspan, f.numlines, COALESCE(f.istoolbarbutton, c.istoolbarbutton) AS istoolbarbutton, c.formatpattern, f.isadvancedfield, f.isdefaultfocus, c.ad_chart_id, f.ad_labelstyle_id, f.ad_fieldstyle_id, c.pa_dashboardcontent_id + FROM ad_field f + JOIN ad_field_trl trl ON f.ad_field_id = trl.ad_field_id + JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id + LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id + LEFT JOIN ad_fieldgroup_trl fgt ON f.ad_fieldgroup_id = fgt.ad_fieldgroup_id AND trl.ad_language::text = fgt.ad_language::text + LEFT JOIN ad_column c ON f.ad_column_id = c.ad_column_id + JOIN ad_table tbl ON c.ad_table_id = tbl.ad_table_id + LEFT JOIN ad_val_rule vr ON vr.ad_val_rule_id = COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) + WHERE f.isactive = 'Y' AND c.isactive = 'Y' +; + +SELECT register_migration_script('201704010847_IDEMPIERE-3115.sql') FROM dual +; + diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInOut.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInOut.java index 6765e674dd..e2e847022a 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInOut.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInOut.java @@ -719,4 +719,21 @@ public class CalloutInOut extends CalloutEngine return ""; } // asi + public String navigateInOutLine(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) + { + if (isCalloutActive() || value == null) + return ""; + + int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "M_Product_ID"); + // No Product + if (M_Product_ID != 0) { + MProduct product = MProduct.get(ctx, M_Product_ID); + int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, mTab.getTabNo(), "C_UOM_ID"); + boolean conversion = (C_UOM_To_ID != product.getC_UOM_ID()); + Env.setContext(ctx, WindowNo, "UOMConversion", conversion ? "Y" : "N"); + } + return ""; + } // navigateInOutLine + + } // CalloutInOut \ No newline at end of file diff --git a/org.adempiere.base.process/src/org/compiere/process/DunningPrint.java b/org.adempiere.base.process/src/org/compiere/process/DunningPrint.java index 835bfddee6..484a55f868 100644 --- a/org.adempiere.base.process/src/org/compiere/process/DunningPrint.java +++ b/org.adempiere.base.process/src/org/compiere/process/DunningPrint.java @@ -232,7 +232,7 @@ public class DunningPrint extends SvrProcess if (printed) { entry.setProcessed (true); - entry.save (); + entry.saveEx(); } } // for all dunning letters diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportGLJournal.java b/org.adempiere.base.process/src/org/compiere/process/ImportGLJournal.java index ed6523d9ba..e1ab1d4ef8 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportGLJournal.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportGLJournal.java @@ -514,7 +514,7 @@ public class ImportGLJournal extends SvrProcess // Set TrxOrg sql = new StringBuilder ("UPDATE I_GLJournal i ") .append("SET AD_OrgTrx_ID=(SELECT o.AD_Org_ID FROM AD_Org o") - .append(" WHERE o.Value=i.OrgValue AND o.IsSummary='N' AND i.AD_Client_ID=o.AD_Client_ID) ") + .append(" WHERE o.Value=i.OrgTrxValue AND o.IsSummary='N' AND i.AD_Client_ID=o.AD_Client_ID) ") .append("WHERE AD_OrgTrx_ID IS NULL AND OrgTrxValue IS NOT NULL") .append(" AND (C_ValidCombination_ID IS NULL OR C_ValidCombination_ID=0) AND I_IsImported<>'Y'").append (clientCheck); no = DB.executeUpdate(sql.toString(), get_TrxName()); diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java b/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java index 137b6fc424..efd6608de1 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportInvoice.java @@ -609,7 +609,7 @@ public class ImportInvoice extends SvrProcess imp.setAD_User_ID (user.getAD_User_ID ()); } } - imp.save (); + imp.saveEx(); } // for all new BPartners // } diff --git a/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java b/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java index 4f1c6347c2..386d42c713 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java +++ b/org.adempiere.base.process/src/org/compiere/process/ImportOrder.java @@ -610,7 +610,7 @@ public class ImportOrder extends SvrProcess imp.setAD_User_ID (user.getAD_User_ID ()); } } - imp.save (); + imp.saveEx(); } // for all new BPartners // } diff --git a/org.adempiere.base.process/src/org/compiere/process/M_Production_Run.java b/org.adempiere.base.process/src/org/compiere/process/M_Production_Run.java index 22014a4b1c..fcd97ba067 100644 --- a/org.adempiere.base.process/src/org/compiere/process/M_Production_Run.java +++ b/org.adempiere.base.process/src/org/compiere/process/M_Production_Run.java @@ -21,7 +21,6 @@ import java.sql.Timestamp; import java.util.List; import java.util.logging.Level; -import org.compiere.model.MAttributeSetInstance; import org.compiere.model.MClient; import org.compiere.model.MLocator; import org.compiere.model.MProduct; @@ -158,10 +157,9 @@ public class M_Production_Run extends SvrProcess { Timestamp dateMPolicy = production.getMovementDate(); if(pline.getM_AttributeSetInstance_ID()>0){ - if(pline.getM_AttributeSetInstance_ID()>0){ - MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(), pline.getM_AttributeSetInstance_ID(), get_TrxName()); - dateMPolicy = asi.getCreated(); - } + Timestamp t = MStorageOnHand.getDateMaterialPolicy(pline.getM_Product_ID(), pline.getM_AttributeSetInstance_ID(), get_TrxName()); + if (t != null) + dateMPolicy = t; } if (!MStorageOnHand.add(getCtx(), locator.getM_Warehouse_ID(), diff --git a/org.adempiere.base.process/src/org/compiere/process/ProjectGenPO.java b/org.adempiere.base.process/src/org/compiere/process/ProjectGenPO.java index 6ae8c3a22c..08df541ede 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ProjectGenPO.java +++ b/org.adempiere.base.process/src/org/compiere/process/ProjectGenPO.java @@ -161,7 +161,7 @@ public class ProjectGenPO extends SvrProcess } order.setClientOrg (projectLine.getAD_Client_ID (), AD_Org_ID); order.setBPartner (bp); - order.save (); + order.saveEx(); // optionally save for consolidation if (m_ConsolidateDocument) m_pos.add(order); diff --git a/org.adempiere.base.process/src/org/compiere/process/TableCreateColumns.java b/org.adempiere.base.process/src/org/compiere/process/TableCreateColumns.java index 73a67dd5d9..445d30692d 100644 --- a/org.adempiere.base.process/src/org/compiere/process/TableCreateColumns.java +++ b/org.adempiere.base.process/src/org/compiere/process/TableCreateColumns.java @@ -258,7 +258,7 @@ public class TableCreateColumns extends SvrProcess element.setName(uuidColumn); element.setPrintName(uuidColumn); } - element.save (); + element.saveEx(); } column.setColumnName (element.getColumnName ()); column.setName (element.getName ()); diff --git a/org.adempiere.base/META-INF/MANIFEST.MF b/org.adempiere.base/META-INF/MANIFEST.MF index e1a2a32adb..36ab982535 100644 --- a/org.adempiere.base/META-INF/MANIFEST.MF +++ b/org.adempiere.base/META-INF/MANIFEST.MF @@ -192,4 +192,4 @@ Require-Bundle: org.eclipse.equinox.app;bundle-version="0.0.0", com.itextpdf;bundle-version="0.0.0", net.sf.supercsv.super-csv;bundle-version="0.0.0", bcprov;bundle-version="1.54.0", - groovy-all;bundle-version="2.4.7" + groovy-all;bundle-version="[2.4.7,2.5.0)" diff --git a/org.adempiere.base/src/org/adempiere/base/event/RequestEventHandler.java b/org.adempiere.base/src/org/adempiere/base/event/RequestEventHandler.java index d961215868..1db37f7c96 100644 --- a/org.adempiere.base/src/org/adempiere/base/event/RequestEventHandler.java +++ b/org.adempiere.base/src/org/adempiere/base/event/RequestEventHandler.java @@ -67,7 +67,7 @@ public class RequestEventHandler extends AbstractEventHandler implements Managed MNote note = new MNote(Env.getCtx(), AD_Message_ID, eventData.getTo().getAD_User_ID(), X_R_Request.Table_ID, eventData.getRequestID(), eventData.getSubject(), eventData.getMessage(), null); - note.save(); + note.saveEx(); } } else if (topic.equals(IEventTopics.PO_BEFORE_NEW) || topic.equals(IEventTopics.PO_BEFORE_CHANGE) @@ -390,7 +390,7 @@ public class RequestEventHandler extends AbstractEventHandler implements Managed MNote note = new MNote(r.getCtx(), AD_Message_ID, AD_User_ID, X_R_Request.Table_ID, r.getR_Request_ID(), subject, message.toString(), r.get_TrxName()); - note.save(); + note.saveEx(); } } } diff --git a/org.adempiere.base/src/org/adempiere/model/ProductPriceValidator.java b/org.adempiere.base/src/org/adempiere/model/ProductPriceValidator.java index fad0de8a46..66f0281df9 100644 --- a/org.adempiere.base/src/org/adempiere/model/ProductPriceValidator.java +++ b/org.adempiere.base/src/org/adempiere/model/ProductPriceValidator.java @@ -108,7 +108,7 @@ public class ProductPriceValidator implements ModelValidator { { pp1.setPrices(priceList, priceStd, priceLimit); pp1.setIsActive(isActive); - pp1.save(po.get_TrxName()); + pp1.saveEx(po.get_TrxName()); } } else if (type == TYPE_AFTER_DELETE) diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java b/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java index 6934a93025..a82746bc1a 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java @@ -1049,10 +1049,17 @@ class Doc_AllocationTax total, m_WriteOffAmt, precision); if (amount.signum() != 0) { - fact.createLine (line, m_WriteOffAccount, - as.getC_Currency_ID(), amount, null); - fact.createLine (line, taxAcct, - as.getC_Currency_ID(), null, amount); + if (m_IsSOTrx) { + fact.createLine (line, m_WriteOffAccount, + as.getC_Currency_ID(), amount, null); + fact.createLine (line, taxAcct, + as.getC_Currency_ID(), null, amount); + } else { + fact.createLine (line, m_WriteOffAccount, + as.getC_Currency_ID(), amount.negate(), null); + fact.createLine (line, taxAcct, + as.getC_Currency_ID(), null, amount.negate()); + } } } // Original Tax is CR - need to correct it DR @@ -1062,10 +1069,17 @@ class Doc_AllocationTax total, m_WriteOffAmt, precision); if (amount.signum() != 0) { - fact.createLine (line, taxAcct, - as.getC_Currency_ID(), amount, null); - fact.createLine (line, m_WriteOffAccount, - as.getC_Currency_ID(), null, amount); + if(m_IsSOTrx) { + fact.createLine (line, taxAcct, + as.getC_Currency_ID(), amount, null); + fact.createLine (line, m_WriteOffAccount, + as.getC_Currency_ID(), null, amount); + } else { + fact.createLine (line, taxAcct, + as.getC_Currency_ID(), amount.negate(), null); + fact.createLine (line, m_WriteOffAccount, + as.getC_Currency_ID(), null, amount.negate()); + } } } } // WriteOff diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_Invoice.java b/org.adempiere.base/src/org/compiere/acct/Doc_Invoice.java index e253b46533..d3a6498ba4 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_Invoice.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_Invoice.java @@ -21,6 +21,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Savepoint; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -901,11 +902,16 @@ public class Doc_Invoice extends Doc BigDecimal allocationAmt = lca.getAmt(); BigDecimal estimatedAmt = BigDecimal.ZERO; + int oCurrencyId = 0; + boolean usesSchemaCurrency = false; + Timestamp oDateAcct = getDateAcct(); if (lca.getM_InOutLine_ID() > 0) { I_M_InOutLine iol = lca.getM_InOutLine(); if (iol.getC_OrderLine_ID() > 0) { + oCurrencyId = iol.getC_OrderLine().getC_Currency_ID(); + oDateAcct = iol.getC_OrderLine().getC_Order().getDateAcct(); MOrderLandedCostAllocation[] allocations = MOrderLandedCostAllocation.getOfOrderLine(iol.getC_OrderLine_ID(), getTrxName()); for(MOrderLandedCostAllocation allocation : allocations) { @@ -945,7 +951,24 @@ public class Doc_Invoice extends Doc //add back since the sum above would include the original trx estimatedAmt = estimatedAmt.add(allocationAmt.negate()); } - } + } + //added for IDEMPIERE-3014 + //convert to accounting schema currency + if (estimatedAmt.signum() > 0 && oCurrencyId != getC_Currency_ID()) + { + estimatedAmt = MConversionRate.convert(getCtx(), estimatedAmt, + oCurrencyId, as.getC_Currency_ID(), + oDateAcct, getC_ConversionType_ID(), + getAD_Client_ID(), getAD_Org_ID()); + + allocationAmt = MConversionRate.convert(getCtx(), allocationAmt, + getC_Currency_ID(), as.getC_Currency_ID(), + getDateAcct(), getC_ConversionType_ID(), + getAD_Client_ID(), getAD_Org_ID()); + setC_Currency_ID(as.getC_Currency_ID()); + usesSchemaCurrency = true; + } + if (estimatedAmt.signum() > 0) { if (allocationAmt.signum() > 0) @@ -1073,7 +1096,9 @@ public class Doc_Invoice extends Doc fl.setM_Product_ID(lca.getM_Product_ID()); fl.setQty(line.getQty()); } - } + } + if (usesSchemaCurrency) + setC_Currency_ID(line.getC_Currency_ID()); } else { diff --git a/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java b/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java index eb47d489ef..c4545b976f 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc_MatchInv.java @@ -402,9 +402,12 @@ public class Doc_MatchInv extends Doc } String costingMethod = m_pc.getProduct().getCostingMethod(as); + MAccount account = m_pc.getAccount(ProductCost.ACCTTYPE_P_Asset, as); + if (m_pc.isService()) + account = m_pc.getAccount(ProductCost.ACCTTYPE_P_Expense, as); if (X_M_Cost.COSTINGMETHOD_AveragePO.equals(costingMethod)) { - MAccount account = zeroQty ? m_pc.getAccount(ProductCost.ACCTTYPE_P_AverageCostVariance, as) : m_pc.getAccount(ProductCost.ACCTTYPE_P_Asset, as); - + if (zeroQty) + account = m_pc.getAccount(ProductCost.ACCTTYPE_P_AverageCostVariance, as); FactLine line = fact.createLine(null, m_pc.getAccount(ProductCost.ACCTTYPE_P_IPV, as), as.getC_Currency_ID(), ipv.negate()); @@ -413,8 +416,6 @@ public class Doc_MatchInv extends Doc line = fact.createLine(null, account, as.getC_Currency_ID(), ipv); updateFactLine(line); } else if (X_M_Cost.COSTINGMETHOD_AverageInvoice.equals(costingMethod) && !zeroQty) { - MAccount account = m_pc.getAccount(ProductCost.ACCTTYPE_P_Asset, as); - FactLine line = fact.createLine(null, m_pc.getAccount(ProductCost.ACCTTYPE_P_IPV, as), as.getC_Currency_ID(), ipv.negate()); diff --git a/org.adempiere.base/src/org/compiere/cm/TemplateValidate.java b/org.adempiere.base/src/org/compiere/cm/TemplateValidate.java index 2e7f2ef5a9..97810fb92a 100644 --- a/org.adempiere.base/src/org/compiere/cm/TemplateValidate.java +++ b/org.adempiere.base/src/org/compiere/cm/TemplateValidate.java @@ -52,7 +52,7 @@ public class TemplateValidate extends SvrProcess { MTemplate thisTemplate = new MTemplate(getCtx (), getRecord_ID (), get_TrxName ()); thisTemplate.setIsValid (true); - thisTemplate.save (); + thisTemplate.saveEx(); return null; } diff --git a/org.adempiere.base/src/org/compiere/cm/WebProjectDeploy.java b/org.adempiere.base/src/org/compiere/cm/WebProjectDeploy.java index 440510991e..5ab1d0cba3 100644 --- a/org.adempiere.base/src/org/compiere/cm/WebProjectDeploy.java +++ b/org.adempiere.base/src/org/compiere/cm/WebProjectDeploy.java @@ -184,7 +184,7 @@ public class WebProjectDeploy extends SvrProcess thisHandler.cleanContainer(cc.get_ID()); // Reset Modified flag... stage.setIsModified(false); - stage.save(stage.get_TrxName()); + stage.saveEx(stage.get_TrxName()); } if (child.isSummary()) copyStage (child, path + stage.getRelativeURL() + "/"); diff --git a/org.adempiere.base/src/org/compiere/model/AttachmentFileSystem.java b/org.adempiere.base/src/org/compiere/model/AttachmentFileSystem.java index 9ed901f58c..f4d241408a 100644 --- a/org.adempiere.base/src/org/compiere/model/AttachmentFileSystem.java +++ b/org.adempiere.base/src/org/compiere/model/AttachmentFileSystem.java @@ -277,7 +277,7 @@ public class AttachmentFileSystem implements IAttachmentStore { } } attach.m_items.remove(index); - attach.save(); // must save here as the operation cannot be rolled back on filesystem + attach.saveEx(); // must save here as the operation cannot be rolled back on filesystem if (log.isLoggable(Level.CONFIG)) log.config("Index=" + index + " - NewSize=" + attach.m_items.size()); return true; } diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index 78feeb0a83..7c02daba25 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -111,7 +111,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable /** * */ - private static final long serialVersionUID = 5446672147679386907L; + private static final long serialVersionUID = -2946624717834888117L; public static final String DEFAULT_STATUS_MESSAGE = "NavigateOrUpdate"; @@ -1583,6 +1583,17 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable return m_vo.IsInsertRecord; } // isInsertRecord + /** + * Can we Delete Records? + * @return true not read only and allowed + */ + public boolean isDeleteRecord() + { + if (isReadOnly()) + return false; + return m_vo.IsDeleteable; + } // isDeleteRecord + /** * Is the Tab Visible. * Called when constructing the window. diff --git a/org.adempiere.base/src/org/compiere/model/MCalendar.java b/org.adempiere.base/src/org/compiere/model/MCalendar.java index f471f05e31..2f20ef7649 100644 --- a/org.adempiere.base/src/org/compiere/model/MCalendar.java +++ b/org.adempiere.base/src/org/compiere/model/MCalendar.java @@ -127,8 +127,8 @@ public class MCalendar extends X_C_Calendar if (get_ID() == 0) return null; MYear year = new MYear (this); - if (year.save()) - year.createStdPeriods(locale); + year.saveEx(); + year.createStdPeriods(locale); // return year; } // createYear diff --git a/org.adempiere.base/src/org/compiere/model/MCash.java b/org.adempiere.base/src/org/compiere/model/MCash.java index a8d2e162fb..289be65292 100644 --- a/org.adempiere.base/src/org/compiere/model/MCash.java +++ b/org.adempiere.base/src/org/compiere/model/MCash.java @@ -94,7 +94,7 @@ public class MCash extends X_C_Cash implements DocAction // Create New Journal retValue = new MCash (cb, dateAcct); - retValue.save(trxName); + retValue.saveEx(trxName); return retValue; } // get diff --git a/org.adempiere.base/src/org/compiere/model/MContainer.java b/org.adempiere.base/src/org/compiere/model/MContainer.java index 400003fb02..8406315fc3 100644 --- a/org.adempiere.base/src/org/compiere/model/MContainer.java +++ b/org.adempiere.base/src/org/compiere/model/MContainer.java @@ -93,7 +93,7 @@ public class MContainer extends X_CM_Container if (cc == null) // new cc = new MContainer (stage.getCtx (), 0, stage.get_TrxName ()); cc.setStage (project, stage, path); - cc.save (); + cc.saveEx(); if (!stage.isSummary ()) { cc.updateElements (project, stage, stage.get_TrxName ()); @@ -315,7 +315,7 @@ public class MContainer extends X_CM_Container // PO.copyValues(new // X_CM_CStage_Element(project.getCtx(),tableKeys[i],trxName), // thisContainerElement); - thisContainerElement.save (trxName); + thisContainerElement.saveEx(trxName); // Remove Container from cache thisHandler.cleanContainerElement (thisContainerElement .get_ID ()); @@ -391,7 +391,7 @@ public class MContainer extends X_CM_Container thisContainerTTable.setCM_Container_ID (stage.get_ID ()); PO.copyValues (new X_CM_CStageTTable (project.getCtx (), tableKeys[i], trxName), thisContainerTTable); - thisContainerTTable.save (trxName); + thisContainerTTable.saveEx(trxName); } } } diff --git a/org.adempiere.base/src/org/compiere/model/MDunningRunEntry.java b/org.adempiere.base/src/org/compiere/model/MDunningRunEntry.java index 40b603b749..923f13a8b1 100644 --- a/org.adempiere.base/src/org/compiere/model/MDunningRunEntry.java +++ b/org.adempiere.base/src/org/compiere/model/MDunningRunEntry.java @@ -295,7 +295,7 @@ public class MDunningRunEntry extends X_C_DunningRunEntry thisBPartner.setSOCreditStatus (X_C_BPartner.SOCREDITSTATUS_CreditStop); if (level.isSetPaymentTerm ()) thisBPartner.setC_PaymentTerm_ID (level.getC_PaymentTerm_ID ()); - thisBPartner.save (); + thisBPartner.saveEx(); } } return true; diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index 8eb831f898..d21cdc948b 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -132,7 +132,7 @@ public class MInOut extends X_M_InOut implements DocAction } // Create Line if (retValue.get_ID() == 0) // not saved yet - retValue.save(trxName); + retValue.saveEx(trxName); // Create a line until qty is reached for (int ll = 0; ll < storages.length; ll++) { @@ -148,11 +148,11 @@ public class MInOut extends X_M_InOut implements DocAction .multiply(oLines[i].getQtyEntered()) .divide(oLines[i].getQtyOrdered(), 12, BigDecimal.ROUND_HALF_UP)); line.setC_Project_ID(oLines[i].getC_Project_ID()); - line.save(trxName); + line.saveEx(trxName); // Delivered everything ? qty = qty.subtract(lineQty); // storage[ll].changeQtyOnHand(lineQty, !order.isSOTrx()); // Credit Memo not considered - // storage[ll].save(get_TrxName()); + // storage[ll].saveEx(get_TrxName()); if (qty.signum() == 0) break; } @@ -1452,10 +1452,7 @@ public class MInOut extends X_M_InOut implements DocAction if (dateMPolicy == null && storages.length > 0) dateMPolicy = storages[0].getDateMaterialPolicy(); - if (dateMPolicy==null && sLine.getM_AttributeSetInstance_ID()!=0) { - I_M_AttributeSetInstance asi = sLine.getM_AttributeSetInstance(); - dateMPolicy = asi.getCreated(); - } else if(dateMPolicy==null) + if(dateMPolicy==null) dateMPolicy = getMovementDate(); // Fallback: Update Storage - see also VMatch.createMatchRecord diff --git a/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java b/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java index 8aa3526801..cba135b6f7 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java @@ -151,13 +151,10 @@ public class MInOutLineMA extends X_M_InOutLineMA { if (M_AttributeSetInstance_ID > 0) { - MAttributeSetInstance asi = new MAttributeSetInstance(parent.getCtx(), M_AttributeSetInstance_ID, parent.get_TrxName()); - DateMaterialPolicy = asi.getCreated(); + DateMaterialPolicy = MStorageOnHand.getDateMaterialPolicy(parent.getM_Product_ID(), M_AttributeSetInstance_ID, parent.get_TrxName()); } - else - { + if (DateMaterialPolicy == null) DateMaterialPolicy = parent.getParent().getMovementDate(); - } } setDateMaterialPolicy(DateMaterialPolicy); setIsAutoGenerated(isAutoGenerated); @@ -269,7 +266,7 @@ public class MInOutLineMA extends X_M_InOutLineMA Timestamp dateMPolicy = null; if(getM_AttributeSetInstance_ID()>0) { - dateMPolicy = getM_AttributeSetInstance().getCreated(); + dateMPolicy = MStorageOnHand.getDateMaterialPolicy(line.getM_Product_ID(), getM_AttributeSetInstance_ID(), get_TrxName()); } if(dateMPolicy == null) diff --git a/org.adempiere.base/src/org/compiere/model/MInventory.java b/org.adempiere.base/src/org/compiere/model/MInventory.java index 201bf391f3..502e7fc28c 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventory.java +++ b/org.adempiere.base/src/org/compiere/model/MInventory.java @@ -568,10 +568,13 @@ public class MInventory extends X_M_Inventory implements DocAction // Fallback if (mtrx == null) { - Timestamp dateMPolicy= getMovementDate(); - I_M_AttributeSetInstance asi = line.getM_AttributeSetInstance(); - if (asi != null) - dateMPolicy =asi.getCreated(); + Timestamp dateMPolicy= qtyDiff.signum() > 0 ? getMovementDate() : null; + if (line.getM_AttributeSetInstance_ID() > 0) + { + Timestamp t = MStorageOnHand.getDateMaterialPolicy(line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), line.get_TrxName()); + if (t != null) + dateMPolicy = t; + } //Fallback: Update Storage - see also VMatch.createMatchRecord if (!MStorageOnHand.add(getCtx(), getM_Warehouse_ID(), diff --git a/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java b/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java index 951266607a..7166228c46 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java +++ b/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java @@ -167,10 +167,9 @@ public class MInventoryLineMA extends X_M_InventoryLineMA { if (M_AttributeSetInstance_ID > 0) { - MAttributeSetInstance asi = new MAttributeSetInstance(parent.getCtx(), M_AttributeSetInstance_ID, parent.get_TrxName()); - DateMaterialPolicy = asi.getCreated(); + DateMaterialPolicy = MStorageOnHand.getDateMaterialPolicy(parent.getM_Product_ID(), M_AttributeSetInstance_ID, parent.get_TrxName()); } - else + if (DateMaterialPolicy == null) { DateMaterialPolicy = parent.getParent().getMovementDate(); } @@ -244,7 +243,7 @@ public class MInventoryLineMA extends X_M_InventoryLineMA Timestamp dateMPolicy = null; if(getM_AttributeSetInstance_ID()>0) { - dateMPolicy = getM_AttributeSetInstance().getCreated(); + dateMPolicy = MStorageOnHand.getDateMaterialPolicy(line.getM_Product_ID(), getM_AttributeSetInstance_ID(), get_TrxName()); } if(dateMPolicy == null) diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 32e4d1411e..09c164e598 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -1581,7 +1581,7 @@ public class MInvoice extends X_C_Invoice implements DocAction if (bom.getDescription() != null) newLine.setDescription(bom.getDescription()); newLine.setPrice(); - newLine.save(get_TrxName()); + newLine.saveEx(get_TrxName()); } // Convert into Comment Line @@ -2506,28 +2506,26 @@ public class MInvoice extends X_C_Invoice implements DocAction msgall.toString(), get_TrxName()); alloc.setAD_Org_ID(getAD_Org_ID()); - if (alloc.save()) - { - // Amount - BigDecimal gt = getGrandTotal(true); - if (!isSOTrx()) - gt = gt.negate(); - // Orig Line - MAllocationLine aLine = new MAllocationLine (alloc, gt, + alloc.saveEx(); + // Amount + BigDecimal gt = getGrandTotal(true); + if (!isSOTrx()) + gt = gt.negate(); + // Orig Line + MAllocationLine aLine = new MAllocationLine (alloc, gt, Env.ZERO, Env.ZERO, Env.ZERO); - aLine.setC_Invoice_ID(getC_Invoice_ID()); - aLine.saveEx(); - // Reversal Line - MAllocationLine rLine = new MAllocationLine (alloc, gt.negate(), + aLine.setC_Invoice_ID(getC_Invoice_ID()); + aLine.saveEx(); + // Reversal Line + MAllocationLine rLine = new MAllocationLine (alloc, gt.negate(), Env.ZERO, Env.ZERO, Env.ZERO); - rLine.setC_Invoice_ID(reversal.getC_Invoice_ID()); - rLine.saveEx(); - // added AdempiereException by zuhri - if (!alloc.processIt(DocAction.ACTION_Complete)) - throw new AdempiereException("Failed when processing document - " + alloc.getProcessMsg()); - // end added - alloc.saveEx(); - } + rLine.setC_Invoice_ID(reversal.getC_Invoice_ID()); + rLine.saveEx(); + // added AdempiereException by zuhri + if (!alloc.processIt(DocAction.ACTION_Complete)) + throw new AdempiereException("Failed when processing document - " + alloc.getProcessMsg()); + // end added + alloc.saveEx(); return reversal; } diff --git a/org.adempiere.base/src/org/compiere/model/MJournal.java b/org.adempiere.base/src/org/compiere/model/MJournal.java index 14f5d2be77..8b098ff85c 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournal.java +++ b/org.adempiere.base/src/org/compiere/model/MJournal.java @@ -834,9 +834,13 @@ public class MJournal extends X_GL_Journal implements DocAction // Journal MJournal reverse = new MJournal (this); reverse.setGL_JournalBatch_ID(GL_JournalBatch_ID); - reverse.setDateDoc(new Timestamp(System.currentTimeMillis())); + Timestamp reversalDate = Env.getContextAsDate(getCtx(), "#Date"); + if (reversalDate == null) { + reversalDate = new Timestamp(System.currentTimeMillis()); + } + reverse.setDateDoc(reversalDate); reverse.set_ValueNoCheck ("C_Period_ID", null); // reset - reverse.setDateAcct(reverse.getDateDoc()); + reverse.setDateAcct(reversalDate); // Reverse indicator StringBuilder msgd = new StringBuilder("(->").append(getDocumentNo()).append(")"); reverse.addDescription(msgd.toString()); diff --git a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java index fc3beaf415..03f76d1923 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java +++ b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java @@ -713,8 +713,12 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction // Reverse it MJournalBatch reverse = new MJournalBatch (this); reverse.setC_Period_ID(0); - reverse.setDateDoc(new Timestamp(System.currentTimeMillis())); - reverse.setDateAcct(reverse.getDateDoc()); + Timestamp reversalDate = Env.getContextAsDate(getCtx(), "#Date"); + if (reversalDate == null) { + reversalDate = new Timestamp(System.currentTimeMillis()); + } + reverse.setDateDoc(reversalDate); + reverse.setDateAcct(reversalDate); // Reverse indicator StringBuilder msgd = new StringBuilder("(->").append(getDocumentNo()).append(")"); reverse.addDescription(msgd.toString()); diff --git a/org.adempiere.base/src/org/compiere/model/MLdapProcessor.java b/org.adempiere.base/src/org/compiere/model/MLdapProcessor.java index 6d7ae97c48..4765b626e7 100755 --- a/org.adempiere.base/src/org/compiere/model/MLdapProcessor.java +++ b/org.adempiere.base/src/org/compiere/model/MLdapProcessor.java @@ -522,7 +522,7 @@ public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProce access.setR_InterestArea_ID (R_InterestArea_ID); access.setIsError (error != null); access.setSummary (info); - access.save (); + access.saveEx(); } // logAccess @Override diff --git a/org.adempiere.base/src/org/compiere/model/MMatchPO.java b/org.adempiere.base/src/org/compiere/model/MMatchPO.java index 87458d8ad4..0a68c9ef53 100644 --- a/org.adempiere.base/src/org/compiere/model/MMatchPO.java +++ b/org.adempiere.base/src/org/compiere/model/MMatchPO.java @@ -345,7 +345,7 @@ public class MMatchPO extends X_M_MatchPO MInOutLine sLine, int C_OrderLine_ID, Timestamp dateTrx, BigDecimal qty, String trxName) { MMatchPO retValue = null; - String sql = "SELECT * FROM M_MatchPO WHERE C_OrderLine_ID=? ORDER BY M_MatchPO_ID"; + String sql = "SELECT * FROM M_MatchPO WHERE C_OrderLine_ID=? and Reversal_ID IS NULL ORDER BY M_MatchPO_ID"; PreparedStatement pstmt = null; ResultSet rs = null; try @@ -932,13 +932,13 @@ public class MMatchPO extends X_M_MatchPO if (validateOrderedQty) { MOrderLine line = new MOrderLine(getCtx(), getC_OrderLine_ID(), get_TrxName()); - BigDecimal invoicedQty = DB.getSQLValueBD(get_TrxName(), "SELECT Coalesce(SUM(Qty),0) FROM M_MatchPO WHERE C_InvoiceLine_ID > 0 and C_OrderLine_ID=?" , getC_OrderLine_ID()); + BigDecimal invoicedQty = DB.getSQLValueBD(get_TrxName(), "SELECT Coalesce(SUM(Qty),0) FROM M_MatchPO WHERE C_InvoiceLine_ID > 0 and C_OrderLine_ID=? AND Reversal_ID IS NULL" , getC_OrderLine_ID()); if (invoicedQty != null && invoicedQty.compareTo(line.getQtyOrdered()) > 0) { throw new IllegalStateException("Total matched invoiced qty > ordered qty. MatchedInvoicedQty="+invoicedQty+", OrderedQty="+line.getQtyOrdered()+", Line="+line); } - BigDecimal deliveredQty = DB.getSQLValueBD(get_TrxName(), "SELECT Coalesce(SUM(Qty),0) FROM M_MatchPO WHERE M_InOutLine_ID > 0 and C_OrderLine_ID=?" , getC_OrderLine_ID()); + BigDecimal deliveredQty = DB.getSQLValueBD(get_TrxName(), "SELECT Coalesce(SUM(Qty),0) FROM M_MatchPO WHERE M_InOutLine_ID > 0 and C_OrderLine_ID=? AND Reversal_ID IS NULL" , getC_OrderLine_ID()); if (deliveredQty != null && deliveredQty.compareTo(line.getQtyOrdered()) > 0) { throw new IllegalStateException("Total matched delivered qty > ordered qty. MatchedDeliveredQty="+deliveredQty+", OrderedQty="+line.getQtyOrdered()+", Line="+line); diff --git a/org.adempiere.base/src/org/compiere/model/MMovement.java b/org.adempiere.base/src/org/compiere/model/MMovement.java index 35b5c4592c..a56cfd7268 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovement.java +++ b/org.adempiere.base/src/org/compiere/model/MMovement.java @@ -536,32 +536,32 @@ public class MMovement extends X_M_Movement implements DocAction if (dateMPolicy == null && storages.length > 0) dateMPolicy = storages[0].getDateMaterialPolicy(); - if (dateMPolicy==null && line.getM_AttributeSetInstanceTo_ID()!=0) { - I_M_AttributeSetInstance asi = line.getM_AttributeSetInstance(); - dateMPolicy = asi.getCreated(); - } else if(dateMPolicy==null) - dateMPolicy = getMovementDate(); - MLocator locator = new MLocator (getCtx(), line.getM_Locator_ID(), get_TrxName()); //Update Storage + Timestamp effDateMPolicy = dateMPolicy; + if (dateMPolicy == null && line.getMovementQty().negate().signum() > 0) + effDateMPolicy = getMovementDate(); if (!MStorageOnHand.add(getCtx(),locator.getM_Warehouse_ID(), line.getM_Locator_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), - line.getMovementQty().negate(),dateMPolicy, get_TrxName())) + line.getMovementQty().negate(),effDateMPolicy, get_TrxName())) { String lastError = CLogger.retrieveErrorString(""); m_processMsg = "Cannot correct Inventory OnHand (MA) - " + lastError; return DocAction.STATUS_Invalid; } - //Update Storage + //Update Storage + effDateMPolicy = dateMPolicy; + if (dateMPolicy == null && line.getMovementQty().signum() > 0) + effDateMPolicy = getMovementDate(); MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName()); if (!MStorageOnHand.add(getCtx(),locatorTo.getM_Warehouse_ID(), line.getM_LocatorTo_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstanceTo_ID(), - line.getMovementQty(),dateMPolicy, get_TrxName())) + line.getMovementQty(),effDateMPolicy, get_TrxName())) { String lastError = CLogger.retrieveErrorString(""); m_processMsg = "Cannot correct Inventory OnHand (MA) - " + lastError; diff --git a/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java b/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java index 0d30f27fb9..05c415716e 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java +++ b/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java @@ -72,7 +72,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction } MMovementConfirm confirm = new MMovementConfirm (move); - confirm.save(move.get_TrxName()); + confirm.saveEx(move.get_TrxName()); MMovementLine[] moveLines = move.getLines(false); for (int i = 0; i < moveLines.length; i++) { diff --git a/org.adempiere.base/src/org/compiere/model/MMovementLineMA.java b/org.adempiere.base/src/org/compiere/model/MMovementLineMA.java index ddb3a67217..f5e82d96ab 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovementLineMA.java +++ b/org.adempiere.base/src/org/compiere/model/MMovementLineMA.java @@ -169,10 +169,9 @@ public class MMovementLineMA extends X_M_MovementLineMA { if (M_AttributeSetInstance_ID > 0) { - MAttributeSetInstance asi = new MAttributeSetInstance(parent.getCtx(), M_AttributeSetInstance_ID, parent.get_TrxName()); - DateMaterialPolicy = asi.getCreated(); + DateMaterialPolicy = MStorageOnHand.getDateMaterialPolicy(parent.getM_Product_ID(), M_AttributeSetInstance_ID, parent.get_TrxName()); } - else + if (DateMaterialPolicy == null) { DateMaterialPolicy = parent.getParent().getMovementDate(); } @@ -249,7 +248,7 @@ public class MMovementLineMA extends X_M_MovementLineMA Timestamp dateMPolicy = null; if(getM_AttributeSetInstance_ID()>0) { - dateMPolicy = getM_AttributeSetInstance().getCreated(); + dateMPolicy = MStorageOnHand.getDateMaterialPolicy(line.getM_Product_ID(), getM_AttributeSetInstance_ID(), get_TrxName()); } if(dateMPolicy == null) diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index 8316cf7635..ed7a0e1021 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -39,6 +39,7 @@ import org.compiere.process.DocAction; import org.compiere.process.DocumentEngine; import org.compiere.process.ProcessInfo; import org.compiere.process.ServerProcessCtl; +import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Msg; @@ -1355,7 +1356,10 @@ public class MOrder extends X_C_Order implements DocAction lines = getLines(true, MOrderLine.COLUMNNAME_M_Product_ID); if (!reserveStock(dt, lines)) { + String innerMsg = CLogger.retrieveErrorString(""); m_processMsg = "Cannot reserve Stock"; + if (! Util.isEmpty(innerMsg)) + m_processMsg = m_processMsg + " -> " + innerMsg; return DocAction.STATUS_Invalid; } if (!calculateTaxTotal()) @@ -1616,7 +1620,7 @@ public class MOrder extends X_C_Order implements DocAction newLine.setDescription (bomline.getDescription ()); // newLine.setPrice (); - newLine.save (get_TrxName()); + newLine.saveEx(get_TrxName()); } } */ @@ -1629,7 +1633,7 @@ public class MOrder extends X_C_Order implements DocAction if (bom.getDescription() != null) newLine.setDescription(bom.getDescription()); newLine.setPrice(); - newLine.save(get_TrxName()); + newLine.saveEx(get_TrxName()); } // Convert into Comment Line @@ -1647,7 +1651,7 @@ public class MOrder extends X_C_Order implements DocAction if (line.getDescription () != null) description += " " + line.getDescription (); line.setDescription (description); - line.save (get_TrxName()); + line.saveEx(get_TrxName()); } // for all lines with BOM m_lines = null; // force requery diff --git a/org.adempiere.base/src/org/compiere/model/MPackage.java b/org.adempiere.base/src/org/compiere/model/MPackage.java index 49b072d470..fb7ec4b266 100644 --- a/org.adempiere.base/src/org/compiere/model/MPackage.java +++ b/org.adempiere.base/src/org/compiere/model/MPackage.java @@ -93,7 +93,7 @@ public class MPackage extends X_M_Package } // lines retValue.setBoxCount(1); - retValue.save(); + retValue.saveEx(); return retValue; } // create diff --git a/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java b/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java index 3c1946d6b0..e20e35f719 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java +++ b/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java @@ -248,7 +248,7 @@ public class MPaymentTerm extends X_C_PaymentTerm for (int i = 0; i < m_schedule.length; i++) { ips = new MInvoicePaySchedule (invoice, m_schedule[i]); - ips.save(invoice.get_TrxName()); + ips.saveEx(invoice.get_TrxName()); if (log.isLoggable(Level.FINE)) log.fine(ips.toString()); remainder = remainder.subtract(ips.getDueAmt()); } // for all schedules @@ -256,7 +256,7 @@ public class MPaymentTerm extends X_C_PaymentTerm if (remainder.compareTo(Env.ZERO) != 0 && ips != null) { ips.setDueAmt(ips.getDueAmt().add(remainder)); - ips.save(invoice.get_TrxName()); + ips.saveEx(invoice.get_TrxName()); if (log.isLoggable(Level.FINE)) log.fine("Remainder=" + remainder + " - " + ips); } @@ -357,7 +357,7 @@ public class MPaymentTerm extends X_C_PaymentTerm for (int i = 0; i < m_schedule.length; i++) { ops = new MOrderPaySchedule (order, m_schedule[i]); - ops.save(order.get_TrxName()); + ops.saveEx(order.get_TrxName()); if (log.isLoggable(Level.FINE)) log.fine(ops.toString()); remainder = remainder.subtract(ops.getDueAmt()); } // for all schedules @@ -365,7 +365,7 @@ public class MPaymentTerm extends X_C_PaymentTerm if (remainder.compareTo(Env.ZERO) != 0 && ops != null) { ops.setDueAmt(ops.getDueAmt().add(remainder)); - ops.save(order.get_TrxName()); + ops.saveEx(order.get_TrxName()); if (log.isLoggable(Level.FINE)) log.fine("Remainder=" + remainder + " - " + ops); } diff --git a/org.adempiere.base/src/org/compiere/model/MPeriod.java b/org.adempiere.base/src/org/compiere/model/MPeriod.java index 9497281ad4..ba70fe56da 100644 --- a/org.adempiere.base/src/org/compiere/model/MPeriod.java +++ b/org.adempiere.base/src/org/compiere/model/MPeriod.java @@ -741,8 +741,8 @@ public class MPeriod extends X_C_Period if (baseTypes.contains(DocBaseType)) continue; MPeriodControl pc = new MPeriodControl(this, DocBaseType); - if (pc.save()) - count++; + pc.saveEx(); + count++; baseTypes.add (DocBaseType); } if (log.isLoggable(Level.FINE)) log.fine("PeriodControl #" + count); diff --git a/org.adempiere.base/src/org/compiere/model/MProductionLine.java b/org.adempiere.base/src/org/compiere/model/MProductionLine.java index d91aa87553..d141eee7a9 100644 --- a/org.adempiere.base/src/org/compiere/model/MProductionLine.java +++ b/org.adempiere.base/src/org/compiere/model/MProductionLine.java @@ -99,7 +99,9 @@ public class MProductionLine extends X_M_ProductionLine { Timestamp dateMPolicy = date; if(getM_AttributeSetInstance_ID()>0){ - dateMPolicy = asi.getCreated(); + Timestamp t = MStorageOnHand.getDateMaterialPolicy(getM_Product_ID(), getM_AttributeSetInstance_ID(), get_TrxName()); + if (t != null) + dateMPolicy = t; } dateMPolicy = Util.removeTime(dateMPolicy); diff --git a/org.adempiere.base/src/org/compiere/model/MProductionLineMA.java b/org.adempiere.base/src/org/compiere/model/MProductionLineMA.java index b4d7441e52..bede164bec 100644 --- a/org.adempiere.base/src/org/compiere/model/MProductionLineMA.java +++ b/org.adempiere.base/src/org/compiere/model/MProductionLineMA.java @@ -42,10 +42,9 @@ public class MProductionLineMA extends X_M_ProductionLineMA { { if (asi > 0) { - MAttributeSetInstance masi = new MAttributeSetInstance(parent.getCtx(), asi, parent.get_TrxName()); - dateMaterialPolicy = masi.getCreated(); + dateMaterialPolicy = MStorageOnHand.getDateMaterialPolicy(parent.getM_Product_ID(), asi, parent.get_TrxName()); } - else + if (dateMaterialPolicy == null) { dateMaterialPolicy = parent.getM_Production().getMovementDate(); } diff --git a/org.adempiere.base/src/org/compiere/model/MProject.java b/org.adempiere.base/src/org/compiere/model/MProject.java index 7bd1c3cfe4..cd9af41767 100644 --- a/org.adempiere.base/src/org/compiere/model/MProject.java +++ b/org.adempiere.base/src/org/compiere/model/MProject.java @@ -358,13 +358,11 @@ public class MProject extends X_C_Project toPhase.setC_Project_ID (getC_Project_ID ()); toPhase.setC_Order_ID (0); toPhase.setIsComplete (false); - if (toPhase.save ()) - { - count++; - taskCount += toPhase.copyTasksFrom (fromPhases[i]); - //BF 3067850 - monhate - lineCount += toPhase.copyLinesFrom(fromPhases[i]); - } + toPhase.saveEx(); + count++; + taskCount += toPhase.copyTasksFrom (fromPhases[i]); + //BF 3067850 - monhate + lineCount += toPhase.copyLinesFrom(fromPhases[i]); } } if (fromPhases.length != count) diff --git a/org.adempiere.base/src/org/compiere/model/MProjectIssue.java b/org.adempiere.base/src/org/compiere/model/MProjectIssue.java index 528dda36c2..729a8c122d 100644 --- a/org.adempiere.base/src/org/compiere/model/MProjectIssue.java +++ b/org.adempiere.base/src/org/compiere/model/MProjectIssue.java @@ -167,8 +167,9 @@ public class MProjectIssue extends X_C_ProjectIssue Timestamp dateMPolicy = getMovementDate(); if(getM_AttributeSetInstance_ID()>0){ - MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(), getM_AttributeSetInstance_ID(), get_TrxName()); - dateMPolicy = asi.getCreated(); + Timestamp t = MStorageOnHand.getDateMaterialPolicy(getM_Product_ID(), getM_AttributeSetInstance_ID(), get_TrxName()); + if (t != null) + dateMPolicy = t; } if (MStorageOnHand.add(getCtx(), loc.getM_Warehouse_ID(), getM_Locator_ID(), diff --git a/org.adempiere.base/src/org/compiere/model/MProjectPhase.java b/org.adempiere.base/src/org/compiere/model/MProjectPhase.java index 9a966115bc..5ecd16ffc6 100644 --- a/org.adempiere.base/src/org/compiere/model/MProjectPhase.java +++ b/org.adempiere.base/src/org/compiere/model/MProjectPhase.java @@ -159,8 +159,8 @@ public class MProjectPhase extends X_C_ProjectPhase PO.copyValues (fromLines[i], toLine, getAD_Client_ID (), getAD_Org_ID ()); toLine.setC_Project_ID(getC_Project_ID ()); toLine.setC_ProjectPhase_ID (getC_ProjectPhase_ID ()); - if (toLine.save ()) - count++; + toLine.saveEx(); + count++; } if (fromLines.length != count) log.warning("Count difference - ProjectLine=" + fromLines.length + " <> Saved=" + count); @@ -209,11 +209,10 @@ public class MProjectPhase extends X_C_ProjectPhase MProjectTask toTask = new MProjectTask (getCtx (), 0, get_TrxName()); PO.copyValues (fromTasks[i], toTask, getAD_Client_ID (), getAD_Org_ID ()); toTask.setC_ProjectPhase_ID (getC_ProjectPhase_ID ()); - if (toTask.save ()){ - count++; - //BF 3067850 - monhate - countLine += toTask.copyLinesFrom(fromTasks[i]); - } + toTask.saveEx(); + count++; + //BF 3067850 - monhate + countLine += toTask.copyLinesFrom(fromTasks[i]); } } if (fromTasks.length != count) diff --git a/org.adempiere.base/src/org/compiere/model/MProjectTask.java b/org.adempiere.base/src/org/compiere/model/MProjectTask.java index 172effcca2..38804b84cd 100644 --- a/org.adempiere.base/src/org/compiere/model/MProjectTask.java +++ b/org.adempiere.base/src/org/compiere/model/MProjectTask.java @@ -134,8 +134,8 @@ public class MProjectTask extends X_C_ProjectTask toLine.setC_Project_ID(getC_Project_ID(false)); toLine.setC_ProjectPhase_ID (getC_ProjectPhase_ID ()); toLine.setC_ProjectTask_ID(getC_ProjectTask_ID ()); - if (toLine.save ()) - count++; + toLine.saveEx(); + count++; } if (fromLines.length != count) log.warning("Count difference - ProjectLine=" + fromLines.length + " <> Saved=" + count); diff --git a/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java b/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java index bfc4703b74..d5aca5c242 100644 --- a/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java +++ b/org.adempiere.base/src/org/compiere/model/MStorageOnHand.java @@ -80,15 +80,6 @@ public class MStorageOnHand extends X_M_StorageOnHand sqlWhere += "(M_AttributeSetInstance_ID=? OR M_AttributeSetInstance_ID IS NULL)"; else sqlWhere += "M_AttributeSetInstance_ID=?"; - - if (dateMPolicy == null) - { - if (M_AttributeSetInstance_ID > 0) - { - MAttributeSetInstance asi = new MAttributeSetInstance(ctx, M_AttributeSetInstance_ID, trxName); - dateMPolicy = asi.getCreated(); - } - } if (dateMPolicy != null) sqlWhere += " AND DateMaterialPolicy=trunc(cast(? as date))"; @@ -629,12 +620,10 @@ public class MStorageOnHand extends X_M_StorageOnHand if (M_Locator_ID == 0) throw new IllegalArgumentException("M_Locator_ID=0"); if (M_Product_ID == 0) - throw new IllegalArgumentException("M_Product_ID=0"); - if (dateMPolicy == null) - dateMPolicy = new Timestamp(new Date().getTime()); - - dateMPolicy = Util.removeTime(dateMPolicy); - + throw new IllegalArgumentException("M_Product_ID=0"); + if (dateMPolicy != null) + dateMPolicy = Util.removeTime(dateMPolicy); + MStorageOnHand retValue = get(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID,dateMPolicy, trxName); if (retValue != null) { @@ -648,6 +637,11 @@ public class MStorageOnHand extends X_M_StorageOnHand if (locator.get_ID() != M_Locator_ID) throw new IllegalArgumentException("Not found M_Locator_ID=" + M_Locator_ID); // + if (dateMPolicy == null) + { + dateMPolicy = new Timestamp(new Date().getTime()); + dateMPolicy = Util.removeTime(dateMPolicy); + } retValue = new MStorageOnHand (locator, M_Product_ID, M_AttributeSetInstance_ID,dateMPolicy); retValue.saveEx(trxName); if (s_log.isLoggable(Level.FINE)) s_log.fine("New " + retValue); @@ -696,21 +690,9 @@ public class MStorageOnHand extends X_M_StorageOnHand if (diffQtyOnHand == null || diffQtyOnHand.signum() == 0) return true; - if (dateMPolicy == null) - { - if (M_AttributeSetInstance_ID > 0) - { - MAttributeSetInstance asi = new MAttributeSetInstance(ctx, M_AttributeSetInstance_ID, trxName); - dateMPolicy = asi.getCreated(); - } - else - { - dateMPolicy = new Timestamp(System.currentTimeMillis()); - } - } - - dateMPolicy = Util.removeTime(dateMPolicy); - + if (dateMPolicy != null) + dateMPolicy = Util.removeTime(dateMPolicy); + // Get Storage MStorageOnHand storage = getCreate (ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, dateMPolicy, trxName, true, 120); // Verify @@ -1040,6 +1022,9 @@ public class MStorageOnHand extends X_M_StorageOnHand */ public static Timestamp getDateMaterialPolicy(int M_Product_ID, int M_AttributeSetInstance_ID,String trxName){ + if (M_Product_ID <= 0 || M_AttributeSetInstance_ID <= 0) + return null; + String sql = "SELECT dateMaterialPolicy FROM M_StorageOnHand WHERE M_Product_ID=? and M_AttributeSetInstance_ID=?"; PreparedStatement pstmt = null; diff --git a/org.adempiere.base/src/org/compiere/model/MUOMConversion.java b/org.adempiere.base/src/org/compiere/model/MUOMConversion.java index 7c202c5042..cc239dd91a 100644 --- a/org.adempiere.base/src/org/compiere/model/MUOMConversion.java +++ b/org.adempiere.base/src/org/compiere/model/MUOMConversion.java @@ -497,11 +497,6 @@ public class MUOMConversion extends X_C_UOM_Conversion if (M_Product_ID == 0) return null; MUOMConversion[] rates = getProductConversions(ctx, M_Product_ID); - if (rates.length == 0) - { - s_log.fine("None found"); - return null; - } for (int i = 0; i < rates.length; i++) { @@ -509,7 +504,17 @@ public class MUOMConversion extends X_C_UOM_Conversion if (rate.getC_UOM_To_ID() == C_UOM_To_ID) return rate.getMultiplyRate(); } - s_log.fine("None applied"); + + List conversions = new Query(ctx, Table_Name, "C_UOM_ID=? AND C_UOM_TO_ID=?", null) + .setParameters(MProduct.get(ctx, M_Product_ID).getC_UOM_ID(), C_UOM_To_ID) + .setOnlyActiveRecords(true) + .list(); + for (int i = 0; i < conversions.size(); i++) + { + MUOMConversion rate = conversions.get(i); + if (rate.getC_UOM_To_ID() == C_UOM_To_ID) + return rate.getMultiplyRate(); + } return null; } // getProductRateTo @@ -563,11 +568,6 @@ public class MUOMConversion extends X_C_UOM_Conversion int M_Product_ID, int C_UOM_To_ID) { MUOMConversion[] rates = getProductConversions(ctx, M_Product_ID); - if (rates.length == 0) - { - s_log.fine("getProductRateFrom - none found"); - return null; - } for (int i = 0; i < rates.length; i++) { @@ -575,7 +575,18 @@ public class MUOMConversion extends X_C_UOM_Conversion if (rate.getC_UOM_To_ID() == C_UOM_To_ID) return rate.getDivideRate(); } - s_log.fine("None applied"); + + List conversions = new Query(ctx, Table_Name, "C_UOM_ID=? AND C_UOM_TO_ID=?", null) + .setParameters(MProduct.get(ctx, M_Product_ID).getC_UOM_ID(), C_UOM_To_ID) + .setOnlyActiveRecords(true) + .list(); + for (int i = 0; i < conversions.size(); i++) + { + MUOMConversion rate = conversions.get(i); + if (rate.getC_UOM_To_ID() == C_UOM_To_ID) + return rate.getDivideRate(); + } + return null; } // getProductRateFrom diff --git a/org.adempiere.base/src/org/compiere/model/MUserPreference.java b/org.adempiere.base/src/org/compiere/model/MUserPreference.java index 1c73f6e5ea..6de7ba1561 100644 --- a/org.adempiere.base/src/org/compiere/model/MUserPreference.java +++ b/org.adempiere.base/src/org/compiere/model/MUserPreference.java @@ -34,7 +34,7 @@ public class MUserPreference extends X_AD_UserPreference{ /** * */ - private static final long serialVersionUID = 4653362918831026642L; + private static final long serialVersionUID = -5816348717625872665L; public MUserPreference(Properties ctx, int AD_UserPreference_ID, String trxName) { @@ -55,21 +55,25 @@ public class MUserPreference extends X_AD_UserPreference{ super.setAD_User_ID(AD_User_ID); } //setAD_User_ID - private static MUserPreference createUserPreferences(int AD_User_ID, int AD_Client_ID){ - MUserPreference preferences = new MUserPreference(Env.getCtx(), 0, null); + private static MUserPreference createUserPreferences(int AD_User_ID, int AD_Client_ID, String trxName){ + MUserPreference preferences = new MUserPreference(Env.getCtx(), 0, trxName); preferences.setAD_User_ID(AD_User_ID); preferences.setAD_Client_ID(AD_Client_ID); preferences.saveEx(); return preferences; } //createUserPreferences - + public static MUserPreference getUserPreference(int AD_User_ID, int AD_Client_ID){ - Query query = new Query(Env.getCtx(), MUserPreference.Table_Name, "AD_User_ID=? AND AD_Client_ID=?", null); + return getUserPreference(AD_User_ID, AD_Client_ID, null); + } + + public static MUserPreference getUserPreference(int AD_User_ID, int AD_Client_ID, String trxName){ + Query query = new Query(Env.getCtx(), MUserPreference.Table_Name, "AD_User_ID=? AND AD_Client_ID=?", trxName); MUserPreference preferences = query.setParameters(new Object[]{AD_User_ID, AD_Client_ID}).firstOnly(); if(preferences==null){ - preferences = createUserPreferences(AD_User_ID, AD_Client_ID); + preferences = createUserPreferences(AD_User_ID, AD_Client_ID, trxName); } return preferences; diff --git a/org.adempiere.base/src/org/compiere/model/SystemIDs.java b/org.adempiere.base/src/org/compiere/model/SystemIDs.java index d80a915946..822d2c8997 100644 --- a/org.adempiere.base/src/org/compiere/model/SystemIDs.java +++ b/org.adempiere.base/src/org/compiere/model/SystemIDs.java @@ -146,16 +146,11 @@ public class SystemIDs public final static int WINDOW_ACCOUNTCOMBINATION = 153; public final static int WINDOW_CUSTOMERRETURN = 53097; - public final static int WINDOW_INVENTORYMOVE = 170; public final static int WINDOW_LOT = 257; - public final static int WINDOW_MATERIALRECEIPT = 184; public final static int WINDOW_MATERIALTRANSACTIONS_INDIRECTUSER = 223; public final static int WINDOW_MY_REQUESTS = 237; - public final static int WINDOW_PHYSICALINVENTORY = 168; - public final static int WINDOW_PRODUCTION = 191; public final static int WINDOW_REQUESTS_ALL = 232; public final static int WINDOW_RETURNTOVENDOR = 53098; - public final static int WINDOW_SHIPMENT_CUSTOMER = 169; public final static int WINDOW_WAREHOUSE_LOCATOR = 139; public final static int WINDOW_WINDOW_TAB_FIELD = 102; diff --git a/org.adempiere.base/src/org/compiere/print/DataEngine.java b/org.adempiere.base/src/org/compiere/print/DataEngine.java index 62be2fd693..552c84b0e6 100644 --- a/org.adempiere.base/src/org/compiere/print/DataEngine.java +++ b/org.adempiere.base/src/org/compiere/print/DataEngine.java @@ -824,17 +824,32 @@ public class DataEngine // Check Group Change ---------------------------------------- if (m_group.getGroupColumnCount() > 1) // one is GRANDTOTAL_ { + ArrayList changedGroups = new ArrayList(); + ArrayList changedValues = new ArrayList(); + boolean force = false; + // Check Columns for Function Columns - for (int i = pd.getColumnInfo().length-1; i >= 0; i--) // backwards (leaset group first) + for (int i = 0; i < pd.getColumnInfo().length; i++) { PrintDataColumn group_pdc = pd.getColumnInfo()[i]; if (!m_group.isGroupColumn(group_pdc.getColumnName())) continue; // Group change - Object value = m_group.groupChange(group_pdc.getColumnName(), rs.getObject(group_pdc.getAlias())); + Object value = m_group.groupChange(group_pdc.getColumnName(), rs.getObject(group_pdc.getAlias()), force); if (value != null) // Group change { + changedGroups.add(group_pdc); + changedValues.add(value); + force = true; // all subsequent groups force change + } + } + + for (int j = changedGroups.size() - 1; j >= 0; j--) // backwards (least group first) + { + PrintDataColumn group_pdc = changedGroups.get(j); + Object value = changedValues.get(j); + char[] functions = m_group.getFunctions(group_pdc.getColumnName()); for (int f = 0; f < functions.length; f++) { @@ -873,7 +888,6 @@ public class DataEngine m_group.reset(group_pdc.getColumnName(), pdc.getColumnName()); } } // Group change - } // for all columns } // group change // new row --------------------------------------------------- @@ -1035,7 +1049,7 @@ public class DataEngine PrintDataColumn group_pdc = pd.getColumnInfo()[i]; if (!m_group.isGroupColumn(group_pdc.getColumnName())) continue; - Object value = m_group.groupChange(group_pdc.getColumnName(), new Object()); + Object value = m_group.groupChange(group_pdc.getColumnName(), new Object(), false); if (value != null) // Group change { char[] functions = m_group.getFunctions(group_pdc.getColumnName()); diff --git a/org.adempiere.base/src/org/compiere/print/PrintDataGroup.java b/org.adempiere.base/src/org/compiere/print/PrintDataGroup.java index a9941e40ac..38c375fb05 100644 --- a/org.adempiere.base/src/org/compiere/print/PrintDataGroup.java +++ b/org.adempiere.base/src/org/compiere/print/PrintDataGroup.java @@ -95,7 +95,7 @@ public class PrintDataGroup * @param value column value * @return null if no group change otherwise old value */ - public Object groupChange (String groupColumnName, Object value) + public Object groupChange (String groupColumnName, Object value, boolean force) { if (!isGroupColumn(groupColumnName)) return null; @@ -106,7 +106,7 @@ public class PrintDataGroup if (m_groupMap.containsKey(groupColumnName)) { Object oldValue = m_groupMap.get(groupColumnName); - if (newValue.equals(oldValue)) + if (newValue.equals(oldValue) && !force ) return null; m_groupMap.put(groupColumnName, newValue); return oldValue; diff --git a/org.adempiere.base/src/org/compiere/util/Env.java b/org.adempiere.base/src/org/compiere/util/Env.java index c0be165330..b28f081e71 100644 --- a/org.adempiere.base/src/org/compiere/util/Env.java +++ b/org.adempiere.base/src/org/compiere/util/Env.java @@ -549,7 +549,7 @@ public final class Env if (s == null) { // Explicit Base Values - if (context.startsWith("#") || context.startsWith("$")) + if (context.startsWith("#") || context.startsWith("$") || context.startsWith("P|")) return getContext(ctx, context); if (onlyWindow) // no Default values return ""; @@ -2015,9 +2015,9 @@ public final class Env public static int getZoomWindowID(int AD_Table_ID, int Record_ID, int windowNo) { int AD_Window_ID = MZoomCondition.findZoomWindowByTableId(AD_Table_ID, Record_ID, windowNo); - MTable table = MTable.get(Env.getCtx(), AD_Table_ID); if (AD_Window_ID <= 0) { + MTable table = MTable.get(Env.getCtx(), AD_Table_ID); AD_Window_ID = table.getAD_Window_ID(); // Nothing to Zoom to if (AD_Window_ID == 0) diff --git a/org.adempiere.base/src/org/compiere/util/Evaluator.java b/org.adempiere.base/src/org/compiere/util/Evaluator.java index 04379437fb..9b56b85b5d 100644 --- a/org.adempiere.base/src/org/compiere/util/Evaluator.java +++ b/org.adempiere.base/src/org/compiere/util/Evaluator.java @@ -98,7 +98,7 @@ public class Evaluator } String exprStrand = st.nextToken().trim(); - if (exprStrand.matches("^@\\d+$")) + if (exprStrand.matches("^@\\d+$") || "@P".equals(exprStrand)) { exprStrand = exprStrand.concat(st.nextToken()); exprStrand = exprStrand.concat(st.nextToken()); @@ -112,7 +112,7 @@ public class Evaluator //boolean temp = evaluateLogicTuple(source, st.nextToken()); exprStrand = st.nextToken().trim(); - if (exprStrand.matches("^@\\d+$")) + if (exprStrand.matches("^@\\d+$") || "@P".equals(exprStrand)) { exprStrand = exprStrand.concat(st.nextToken()); exprStrand = exprStrand.concat(st.nextToken()); diff --git a/org.adempiere.base/src/org/compiere/util/WebLogin.java b/org.adempiere.base/src/org/compiere/util/WebLogin.java index 9026245e21..78e157159e 100644 --- a/org.adempiere.base/src/org/compiere/util/WebLogin.java +++ b/org.adempiere.base/src/org/compiere/util/WebLogin.java @@ -466,7 +466,7 @@ public class WebLogin thisBPBankAccount.setA_Name (WebUtil.getParamOrNull (m_request, "A_Name")); thisBPBankAccount.setAccountNo (WebUtil.getParamOrNull (m_request, "AccountNo")); thisBPBankAccount.setRoutingNo (WebUtil.getParamOrNull (m_request, "RoutingNo")); - thisBPBankAccount.save (); + thisBPBankAccount.saveEx(); } else log.log(Level.WARNING, "Unknown request='" + m_mode + "'"); diff --git a/org.adempiere.base/src/org/compiere/util/WebUser.java b/org.adempiere.base/src/org/compiere/util/WebUser.java index 94ee629dfe..98a8b3f2cb 100644 --- a/org.adempiere.base/src/org/compiere/util/WebUser.java +++ b/org.adempiere.base/src/org/compiere/util/WebUser.java @@ -488,7 +488,7 @@ public class WebUser // save Location *************************************** if (log.isLoggable(Level.FINE)) log.fine("LOC=" + m_loc); - m_loc.save (); + m_loc.saveEx(); // save BP Location *************************************** if (m_bpl.getC_BPartner_ID () != m_bp.getC_BPartner_ID()) diff --git a/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java b/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java index c2d1a0e88f..374fdaf68c 100644 --- a/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java +++ b/org.adempiere.base/src/org/idempiere/fa/process/ImportFixedAsset.java @@ -253,7 +253,7 @@ public class ImportFixedAsset extends SvrProcess if (!bpl.save ()) continue; } - ifa.save (); + ifa.saveEx(); } // for all new BPartners rs.close (); pstmt.close (); @@ -311,7 +311,7 @@ public class ImportFixedAsset extends SvrProcess } ifa.setM_Product_ID (product.getM_Product_ID()); - ifa.save (); + ifa.saveEx(); } // for all new Products rs.close (); pstmt.close (); diff --git a/org.adempiere.install/install.app.launch b/org.adempiere.install/install.app.launch index 46b8ca7efd..e6f0bd0ae1 100644 --- a/org.adempiere.install/install.app.launch +++ b/org.adempiere.install/install.app.launch @@ -21,7 +21,7 @@ - + diff --git a/org.adempiere.server-feature/server.product.launch b/org.adempiere.server-feature/server.product.launch index 897f033c93..b470e8ade3 100644 --- a/org.adempiere.server-feature/server.product.launch +++ b/org.adempiere.server-feature/server.product.launch @@ -24,7 +24,7 @@ - + diff --git a/org.adempiere.server-feature/utils.unix/oracle/DBExportFulldp.sh b/org.adempiere.server-feature/utils.unix/oracle/DBExportFulldp.sh index 918e2ad964..be0e0c3206 100644 --- a/org.adempiere.server-feature/utils.unix/oracle/DBExportFulldp.sh +++ b/org.adempiere.server-feature/utils.unix/oracle/DBExportFulldp.sh @@ -24,7 +24,7 @@ fi echo ------------------------------------- echo Re-Create DataPump directory echo ------------------------------------- -sqlplus $1@$ADEMPIERE_DB_SERVER/$ADEMPIERE_DB_NAME @$IDEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/CreateDataPumpDir.sql $IDEMPIERE_HOME/data +sqlplus $1@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME @$IDEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/CreateDataPumpDir.sql $IDEMPIERE_HOME/data chgrp dba $IDEMPIERE_HOME/data chmod 770 $IDEMPIERE_HOME/data diff --git a/org.adempiere.server-feature/utils.unix/oracle/DBExportdp.sh b/org.adempiere.server-feature/utils.unix/oracle/DBExportdp.sh index 15cb3f33ac..f7bdd46045 100644 --- a/org.adempiere.server-feature/utils.unix/oracle/DBExportdp.sh +++ b/org.adempiere.server-feature/utils.unix/oracle/DBExportdp.sh @@ -27,7 +27,7 @@ sqlplus $1/$2@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME @$IDEMP echo ------------------------------------- echo Re-Create DataPump directory echo ------------------------------------- -sqlplus $3@$ADEMPIERE_DB_SERVER/$ADEMPIERE_DB_NAME @$IDEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/CreateDataPumpDir.sql $IDEMPIERE_HOME/data +sqlplus $3@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME @$IDEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/CreateDataPumpDir.sql $IDEMPIERE_HOME/data chgrp dba $IDEMPIERE_HOME/data chmod 770 $IDEMPIERE_HOME/data diff --git a/org.adempiere.server-feature/utils.unix/oracle/DBRestoredp.sh b/org.adempiere.server-feature/utils.unix/oracle/DBRestoredp.sh index 7371e5146c..2ebd876df1 100644 --- a/org.adempiere.server-feature/utils.unix/oracle/DBRestoredp.sh +++ b/org.adempiere.server-feature/utils.unix/oracle/DBRestoredp.sh @@ -28,7 +28,7 @@ sqlplus $1@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME @$IDEMPIER echo ------------------------------------- echo Re-Create DataPump directory echo ------------------------------------- -sqlplus $1@$ADEMPIERE_DB_SERVER/$ADEMPIERE_DB_NAME @$IDEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/CreateDataPumpDir.sql $IDEMPIERE_HOME/data +sqlplus $1@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME @$IDEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/CreateDataPumpDir.sql $IDEMPIERE_HOME/data chgrp dba $IDEMPIERE_HOME/data chmod 770 $IDEMPIERE_HOME/data diff --git a/org.adempiere.server-feature/utils.unix/oracle/ImportIdempiere.sh b/org.adempiere.server-feature/utils.unix/oracle/ImportIdempiere.sh index 6b23752c7b..dabbc996ce 100644 --- a/org.adempiere.server-feature/utils.unix/oracle/ImportIdempiere.sh +++ b/org.adempiere.server-feature/utils.unix/oracle/ImportIdempiere.sh @@ -29,7 +29,7 @@ sqlplus $1@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME @$IDEMPIER echo ------------------------------------- echo Re-Create DataPump directory echo ------------------------------------- -sqlplus $1@$ADEMPIERE_DB_SERVER/$ADEMPIERE_DB_NAME @$IDEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/CreateDataPumpDir.sql $IDEMPIERE_HOME/data/seed +sqlplus $1@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME @$IDEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/CreateDataPumpDir.sql $IDEMPIERE_HOME/data/seed chgrp dba $IDEMPIERE_HOME/data/seed chmod 770 $IDEMPIERE_HOME/data/seed diff --git a/org.adempiere.server-feature/utils.windows/oracle/ImportIdempiere.bat b/org.adempiere.server-feature/utils.windows/oracle/ImportIdempiere.bat index c8118f17ca..319fb80ad7 100644 --- a/org.adempiere.server-feature/utils.windows/oracle/ImportIdempiere.bat +++ b/org.adempiere.server-feature/utils.windows/oracle/ImportIdempiere.bat @@ -18,14 +18,19 @@ @echo ------------------------------------- @sqlplus %1@%ADEMPIERE_DB_SERVER%:%ADEMPIERE_DB_PORT%/%ADEMPIERE_DB_NAME% @%IDEMPIERE_HOME%\Utils\%ADEMPIERE_DB_PATH%\CreateUser.sql %2 %3 +@echo ------------------------------------- +@echo Re-Create DataPump directory +@echo ------------------------------------- +@sqlplus %1@%ADEMPIERE_DB_SERVER%:%ADEMPIERE_DB_PORT%/%ADEMPIERE_DB_NAME% @%IDEMPIERE_HOME%\Utils\%ADEMPIERE_DB_PATH%\CreateDataPumpDir.sql %IDEMPIERE_HOME%\data\seed + @echo ------------------------------------- @echo Import Adempiere.dmp @echo ------------------------------------- -@imp %1@%ADEMPIERE_DB_SERVER%:%ADEMPIERE_DB_PORT%/%ADEMPIERE_DB_NAME% FILE=%IDEMPIERE_HOME%\data\seed\Adempiere.dmp FROMUSER=(reference) TOUSER=%2 STATISTICS=RECALCULATE +@impdp %1@%ADEMPIERE_DB_SERVER%:%ADEMPIERE_DB_PORT%/%ADEMPIERE_DB_NAME% DIRECTORY=ADEMPIERE_DATA_PUMP_DIR DUMPFILE=Adempiere.dmp REMAP_SCHEMA=reference:%2 @echo --------========--------========--------========-------- -@echo System Check - The Import phase showed warnings. -@echo This is OK as long as the following does not show errors +@echo Check System +@echo Import may show some warnings. This is OK as long as the following does not show errors @echo --------========--------========--------========-------- @sqlplus %2/%3@%ADEMPIERE_DB_SERVER%:%ADEMPIERE_DB_PORT%/%ADEMPIERE_DB_NAME% @%IDEMPIERE_HOME%\Utils\%ADEMPIERE_DB_PATH%\AfterImport.sql diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/APanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/APanel.java index f01c1e0796..10fc4565f1 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/APanel.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/APanel.java @@ -1234,12 +1234,15 @@ public final class APanel extends CPanel changed = false; boolean readOnly = m_curTab.isReadOnly(); boolean insertRecord = !readOnly; + boolean deleteRecord = !readOnly; if (insertRecord) insertRecord = m_curTab.isInsertRecord(); aNew.setEnabled(!changed && insertRecord); aCopy.setEnabled(!changed && insertRecord); aRefresh.setEnabled(!changed); - aDelete.setEnabled(!changed && !readOnly); + if (deleteRecord) + deleteRecord = m_curTab.isDeleteRecord(); + aDelete.setEnabled(!changed && deleteRecord); aDeleteSelection.setEnabled(!changed && !readOnly); // if (readOnly && m_curTab.isAlwaysUpdateField()) diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTrxMaterial.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VTrxMaterial.java index afc83dd5f6..b74a761279 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTrxMaterial.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/form/VTrxMaterial.java @@ -32,7 +32,6 @@ import java.util.logging.Level; import javax.swing.JLabel; import org.compiere.apps.AEnv; -import org.compiere.apps.AWindow; import org.compiere.apps.ConfirmPanel; import org.compiere.apps.StatusBar; import org.compiere.grid.GridController; @@ -285,17 +284,7 @@ public class VTrxMaterial extends TrxMaterial super.zoom(); // Zoom - panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - AWindow frame = new AWindow(panel.getGraphicsConfiguration()); - if (!frame.initWindow(AD_Window_ID, query)) - { - panel.setCursor(Cursor.getDefaultCursor()); - return; - } - AEnv.addToWindowManager(frame); - AEnv.showCenterScreen(frame); - frame = null; - panel.setCursor(Cursor.getDefaultCursor()); + AEnv.zoom(AD_Table_ID, Record_ID); } // zoom } // VTrxMaterial diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPAttributeDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPAttributeDialog.java index 124b4c3e99..2f8b5cca3c 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPAttributeDialog.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPAttributeDialog.java @@ -746,7 +746,7 @@ public class VPAttributeDialog extends CDialog // New Instance if (m_changed || m_masi.getM_AttributeSetInstance_ID() == 0) { - m_masi.save (); + m_masi.saveEx(); m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID (); m_M_AttributeSetInstanceName = m_masi.getDescription(); } @@ -789,7 +789,7 @@ public class VPAttributeDialog extends CDialog if (m_changed) { m_masi.setDescription (); - m_masi.save (); + m_masi.saveEx(); } m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID (); m_M_AttributeSetInstanceName = m_masi.getDescription(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index 700ff74b65..dc685f118a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -1575,6 +1575,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements boolean readOnly = adTabbox.getSelectedGridTab().isReadOnly(); boolean processed = adTabbox.getSelectedGridTab().isProcessed(); boolean insertRecord = !readOnly; + boolean deleteRecord = !readOnly; if (!detailTab) { // update Change @@ -1587,7 +1588,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements toolbar.enableNew(!changed && insertRecord && !tabPanel.getGridTab().isSortTab()); toolbar.enableCopy(!changed && insertRecord && !tabPanel.getGridTab().isSortTab() && adTabbox.getSelectedGridTab().getRowCount()>0); toolbar.enableRefresh(!changed); - toolbar.enableDelete(!changed && !readOnly && !tabPanel.getGridTab().isSortTab() && !processed); + if (deleteRecord) + { + deleteRecord = tabPanel.getGridTab().isDeleteRecord(); + } + toolbar.enableDelete(!changed && deleteRecord && !tabPanel.getGridTab().isSortTab() && !processed); // if (readOnly && adTabbox.getSelectedGridTab().isAlwaysUpdateField()) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java index 06b63068ed..92cd52f72f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java @@ -58,7 +58,7 @@ public class DetailPane extends Panel implements EventListener, IdSpace { /** * */ - private static final long serialVersionUID = -5714780894880069158L; + private static final long serialVersionUID = 2142502910734162453L; private static final String BTN_PROCESS_ID = "BtnProcess"; @@ -664,12 +664,18 @@ public class DetailPane extends Panel implements EventListener, IdSpace { readOnly = true; boolean insertRecord = !readOnly; + boolean deleteRecord = !readOnly; + if (insertRecord) { insertRecord = adtab.getGridTab().isInsertRecord(); } boolean enableNew = !changed && insertRecord && !adtab.getGridTab().isSortTab(); - boolean enableDelete = !changed && !readOnly && !adtab.getGridTab().isSortTab(); + if (deleteRecord) + { + deleteRecord = adtab.getGridTab().isDeleteRecord(); + } + boolean enableDelete = !changed && deleteRecord && !adtab.getGridTab().isSortTab(); ADWindow adwindow = ADWindow.findADWindow(this); if (adwindow == null) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java index af275dc42d..4c813a777d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java @@ -66,12 +66,6 @@ import org.zkoss.zul.Separator; public class WTrxMaterial extends TrxMaterial implements IFormController, EventListener, ValueChangeListener { - /** - * - */ - @SuppressWarnings("unused") - private static final long serialVersionUID = -2141669182129214237L; - private CustomForm form = new CustomForm(); /** GridController */ @@ -285,7 +279,7 @@ public class WTrxMaterial extends TrxMaterial super.zoom(); // Zoom - AEnv.zoom(AD_Window_ID, query); + AEnv.zoom(AD_Table_ID, Record_ID); } // zoom public ADForm getForm() diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoGeneralPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoGeneralPanel.java index 40e108ae7b..f0b97f817a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoGeneralPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoGeneralPanel.java @@ -470,7 +470,7 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener private void addSQLWhere(StringBuffer sql, int index, String value) { - if (!(value.equals("") || value.equals("%")) && index < m_queryColumns.size()) + if (!(value.equals("")) && index < m_queryColumns.size()) { // Angelo Dabala' (genied) nectosoft: [2893220] avoid to append string parameters directly because of special chars like quote(s) sql.append(" AND UPPER(").append(m_queryColumnsSql.get(index).toString()).append(") LIKE ?"); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index a20d27ecb3..1faad6d865 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -2136,36 +2136,25 @@ public abstract class InfoPanel extends Window implements EventListener, { String tmp = colsql.substring(0, lastSpaceIdx).trim(); char last = tmp.charAt(tmp.length() - 1); - if (tmp.toLowerCase().endsWith("as")) + + String alias = colsql.substring(lastSpaceIdx).trim(); + boolean hasAlias = alias.matches("^[a-zA-Z_][a-zA-Z0-9_]*$"); // valid SQL alias - starts with letter then digits, letters, underscore + + if (tmp.toLowerCase().endsWith("as") && hasAlias) { - colsql = colsql.substring(lastSpaceIdx).trim(); + colsql = alias; } else if (!(last == '*' || last == '-' || last == '+' || last == '/' || last == '>' || last == '<' || last == '=')) { - tmp = colsql.substring(lastSpaceIdx).trim(); - if (tmp.startsWith("\"") && tmp.endsWith("\"")) + if (alias.startsWith("\"") && alias.endsWith("\"")) { - colsql = colsql.substring(lastSpaceIdx).trim(); + colsql = alias; } else { - boolean hasAlias = true; - for(int i = 0; i < tmp.length(); i++) - { - char c = tmp.charAt(i); - if (Character.isLetterOrDigit(c)) - { - continue; - } - else - { - hasAlias = false; - break; - } - } if (hasAlias) { - colsql = colsql.substring(lastSpaceIdx).trim(); + colsql = alias; } } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java index 749804d373..ed8a37c440 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java @@ -528,6 +528,16 @@ public class LoginPanel extends Window implements EventListener Env.verifyLanguage(ctx, language); Env.setContext(ctx, Env.LANGUAGE, language.getAD_Language()); Env.setContext(ctx, AEnv.LOCALE, language.getLocale().toString()); + + //cph::erp added this in order to get the processing dialog in the correct language + Locale locale = language.getLocale(); + try { + Clients.reloadMessages(locale); + } catch (IOException e) { + logger.log(Level.WARNING, e.getLocalizedMessage(), e); + } + Locales.setThreadLocal(locale); + // cph::erp end return language; } /** diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/process/DunningPrint.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/process/DunningPrint.java index df2cc725a2..21f1567fb5 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/process/DunningPrint.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/process/DunningPrint.java @@ -245,7 +245,7 @@ public class DunningPrint extends SvrProcess if (printed) { entry.setProcessed (true); - entry.save (); + entry.saveEx(); } } // for all dunning letters diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java index 71636e6e97..c0469b05bf 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java @@ -979,7 +979,7 @@ public class WPAttributeDialog extends Window implements EventListener // New Instance if (m_changed || m_masi.getM_AttributeSetInstance_ID() == 0) { - m_masi.save (); + m_masi.saveEx(); m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID (); m_M_AttributeSetInstanceName = m_masi.getDescription(); } @@ -1026,7 +1026,7 @@ public class WPAttributeDialog extends Window implements EventListener if (m_changed) { m_masi.setDescription (); - m_masi.save (); + m_masi.saveEx(); } m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID (); m_M_AttributeSetInstanceName = m_masi.getDescription(); diff --git a/org.adempiere.ui.zk/index.zul b/org.adempiere.ui.zk/index.zul index cb93c1a172..7de2c9752b 100644 --- a/org.adempiere.ui.zk/index.zul +++ b/org.adempiere.ui.zk/index.zul @@ -24,6 +24,29 @@ Copyright (C) 2007 Ashley G Ramdass. // just sent fake event when control is textfield and value is not yet sync to server if (wgt.$instanceof(zul.inp.Textbox) && wgt.$n().value != wgt.getText()) zAu.send(new zk.Event(zk.Widget.$(wgt), 'onChange',{"value":wgt.$n().value})); + + else if (zk.$import("ckez.CKeditor") != undefined && wgt.$instanceof(ckez.CKeditor)){//https://www.zkoss.org/javadoc/latest/jsdoc/_global_/zk.html#$import(_global_.String) + // CKEditor extend from zul.Widget not from wget zul.inp.InputWidget + // so some behavior is not same standard input + // this code bring from ckez.CKeditor.onBlur + var editor = wgt._editor; + + if (wgt._tidChg) { + clearInterval(wgt._tidChg); + wgt._tidChg = null; + } + + if (!editor.document) + editor.document = editor.element.getDocument(); + + if (wgt.$class._checkEditorDirty(editor)) { // Issue #13 + var val = editor.getData(); + wgt._value = val; //save for onRestore + //ZKCK-16, 17 use sendAhead to make sure onChange always happens first + wgt.fire('onChange', {value: val}); + editor.resetDirty(); + } + } }, fireOnInitEdit: function (wgt) { diff --git a/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java b/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java index db59e1f6db..46f989b93e 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/Allocation.java @@ -810,7 +810,7 @@ public class Allocation } MBPartner bpartner = new MBPartner(Env.getCtx(), m_C_BPartner_ID, trxName); bpartner.setTotalOpenBalance(); - bpartner.save(); + bpartner.saveEx(); paymentList.clear(); amountList.clear(); diff --git a/org.adempiere.ui/src/org/compiere/apps/form/TrxMaterial.java b/org.adempiere.ui/src/org/compiere/apps/form/TrxMaterial.java index ef6d26f6f4..3545e3927a 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/TrxMaterial.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/TrxMaterial.java @@ -13,9 +13,8 @@ *****************************************************************************/ package org.compiere.apps.form; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import static org.compiere.model.SystemIDs.WINDOW_MATERIALTRANSACTIONS_INDIRECTUSER; + import java.sql.Timestamp; import java.util.logging.Level; @@ -23,10 +22,14 @@ import org.compiere.apps.IStatusBar; import org.compiere.model.GridTab; import org.compiere.model.GridWindow; import org.compiere.model.GridWindowVO; +import org.compiere.model.I_C_ProjectIssue; +import org.compiere.model.I_M_InOutLine; +import org.compiere.model.I_M_InventoryLine; +import org.compiere.model.I_M_MovementLine; +import org.compiere.model.I_M_ProductionLine; +import org.compiere.model.I_M_Transaction; import org.compiere.model.MQuery; -import static org.compiere.model.SystemIDs.*; import org.compiere.util.CLogger; -import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Msg; @@ -108,9 +111,8 @@ public class TrxMaterial { statusBar.setStatusDB(Integer.toString(no)); } // refresh - public int AD_Window_ID; - public MQuery query; - + public int AD_Table_ID; + public int Record_ID; /** * Zoom */ @@ -118,85 +120,33 @@ public class TrxMaterial { { log.info(""); // - AD_Window_ID = 0; - String ColumnName = null; - String SQL = null; - // - int lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_InOutLine_ID"); - if (lineID != 0) - { - if (log.isLoggable(Level.FINE)) log.fine("M_InOutLine_ID=" + lineID); - if (Env.getContext(Env.getCtx(), m_WindowNo, "MovementType").startsWith("C")) - AD_Window_ID = WINDOW_SHIPMENT_CUSTOMER; // Customer - else - AD_Window_ID = WINDOW_MATERIALRECEIPT; // Vendor - ColumnName = "M_InOut_ID"; - SQL = "SELECT M_InOut_ID FROM M_InOutLine WHERE M_InOutLine_ID=?"; - } - else - { - lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_InventoryLine_ID"); - if (lineID != 0) - { - if (log.isLoggable(Level.FINE)) log.fine("M_InventoryLine_ID=" + lineID); - AD_Window_ID = WINDOW_PHYSICALINVENTORY; - ColumnName = "M_Inventory_ID"; - SQL = "SELECT M_Inventory_ID FROM M_InventoryLine WHERE M_InventoryLine_ID=?"; - } - else - { - lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_MovementLine_ID"); - if (lineID != 0) - { - if (log.isLoggable(Level.FINE)) log.fine("M_MovementLine_ID=" + lineID); - AD_Window_ID = WINDOW_INVENTORYMOVE; - ColumnName = "M_Movement_ID"; - SQL = "SELECT M_Movement_ID FROM M_MovementLine WHERE M_MovementLine_ID=?"; - } - else - { - lineID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_ProductionLine_ID"); - if (lineID != 0) - { - if (log.isLoggable(Level.FINE)) log.fine("M_ProductionLine_ID=" + lineID); - AD_Window_ID = WINDOW_PRODUCTION; - ColumnName = "M_Production_ID"; - SQL = "SELECT M_Production_ID FROM M_ProductionLine WHERE M_ProductionLine_ID=?"; + AD_Table_ID = 0; + Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_InOutLine_ID); + if (Record_ID != 0) { + AD_Table_ID = I_M_InOutLine.Table_ID; + } else { + Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_InventoryLine_ID); + if (Record_ID != 0) { + AD_Table_ID = I_M_InventoryLine.Table_ID; + } else { + Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_MovementLine_ID); + if (Record_ID != 0) { + AD_Table_ID = I_M_MovementLine.Table_ID; + } else { + Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_M_ProductionLine_ID); + if (Record_ID != 0) { + AD_Table_ID = I_M_ProductionLine.Table_ID; + } else { + Record_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, I_M_Transaction.COLUMNNAME_C_ProjectIssue_ID); + if (Record_ID != 0) { + AD_Table_ID = I_C_ProjectIssue.Table_ID; + } else { + log.warning("Not found zoom table WindowNo=" + m_WindowNo); + } } - else - if (log.isLoggable(Level.FINE)) log.fine("Not found WindowNo=" + m_WindowNo); } } } - if (AD_Window_ID == 0) - return; - - // Get Parent ID - int parentID = 0; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(SQL, null); - pstmt.setInt(1, lineID); - rs = pstmt.executeQuery(); - if (rs.next()) - parentID = rs.getInt(1); - } - catch (SQLException e) - { - log.log(Level.SEVERE, SQL, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - query = MQuery.getEqualQuery(ColumnName, parentID); - if (log.isLoggable(Level.CONFIG)) log.config("AD_Window_ID=" + AD_Window_ID + " - " + query); - if (parentID == 0) - log.log(Level.SEVERE, "No ParentValue - " + SQL + " - " + lineID); } // zoom diff --git a/org.adempiere.webstore.servlet/src/org/compiere/wstore/AssetServlet.java b/org.adempiere.webstore.servlet/src/org/compiere/wstore/AssetServlet.java index 7e9a94e581..c338276952 100644 --- a/org.adempiere.webstore.servlet/src/org/compiere/wstore/AssetServlet.java +++ b/org.adempiere.webstore.servlet/src/org/compiere/wstore/AssetServlet.java @@ -323,7 +323,7 @@ public class AssetServlet extends HttpServlet if (msg.length () > 120) msg = msg.substring (0, 119); ad.setDeliveryConfirmation (msg); - ad.save (); + ad.saveEx(); // asset.saveEx(); not delivered } catch (Exception ex1) diff --git a/org.adempiere.webstore.servlet/src/org/compiere/wstore/PaymentServlet.java b/org.adempiere.webstore.servlet/src/org/compiere/wstore/PaymentServlet.java index 1db1d725b7..8858beda05 100644 --- a/org.adempiere.webstore.servlet/src/org/compiere/wstore/PaymentServlet.java +++ b/org.adempiere.webstore.servlet/src/org/compiere/wstore/PaymentServlet.java @@ -294,7 +294,7 @@ public class PaymentServlet extends HttpServlet { if (log.isLoggable(Level.FINE)) log.fine(payment.getErrorMessage()); String errMsg = payment.getErrorMessage(); - payment.save (); + payment.saveEx(); payment.setErrorMessage(errMsg); request.getSession().setAttribute(WebSessionCtx.HDR_MESSAGE, errMsg); // diff --git a/org.w3c.dom.fragment/bin/.hgignore b/org.w3c.dom.fragment/bin/.hgignore deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/org.w3c.dom.fragment/src/.hgignore b/org.w3c.dom.fragment/src/.hgignore deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/org.zkoss.zk.library/lib/src/.hgignore b/org.zkoss.zk.library/lib/src/.hgignore deleted file mode 100644 index e69de29bb2..0000000000