database/model/triggers/M_INVENTORYLINE2_TRG.xml
author Adrián Romero <adrian.romero@openbravo.com>
Wed, 05 Dec 2007 20:43:45 +0000
changeset 170 4b5493776a7f
parent 132 33c5ca45fcff
child 239 a30acae847e1
permissions -rw-r--r--
Bug fixed: [ 1845110 ] Database model not in sync with database created
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER M_INVENTORYLINE2_TRG">
adrian@94
     3
    <trigger name="M_INVENTORYLINE2_TRG" table="M_INVENTORYLINE" fires="before" insert="true" update="true" delete="false" foreach="row">
adrian@170
     4
      <body>
adrian@170
     5
adrian@94
     6
adrian@94
     7
adrian@94
     8
/*************************************************************************
adrian@94
     9
* The contents of this file are subject to the Openbravo  Public  License
adrian@94
    10
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
adrian@94
    11
* Version 1.1  with a permitted attribution clause; you may not  use this
adrian@94
    12
* file except in compliance with the License. You  may  obtain  a copy of
adrian@94
    13
* the License at http://www.openbravo.com/legal/license.html
adrian@94
    14
* Software distributed under the License  is  distributed  on  an "AS IS"
adrian@94
    15
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
adrian@94
    16
* License for the specific  language  governing  rights  and  limitations
adrian@94
    17
* under the License.
adrian@94
    18
* The Original Code is Openbravo ERP.
adrian@94
    19
* The Initial Developer of the Original Code is Openbravo SL
adrian@94
    20
* All portions are Copyright (C) 2001-2006 Openbravo SL
adrian@94
    21
* All Rights Reserved.
adrian@94
    22
* Contributor(s):  ______________________________________.
adrian@94
    23
************************************************************************/
adrian@94
    24
    BEGIN IF(UPDATING)
adrian@170
    25
    THEN  IF NOT((COALESCE(:OLD.M_Product_Uom_ID, 0) &lt;&gt; COALESCE(:NEW.M_Product_Uom_ID, 0)
adrian@170
    26
    OR COALESCE(:OLD.QuantityOrderBook, 0) &lt;&gt; COALESCE(:NEW.QuantityOrderBook, 0)))
adrian@94
    27
    THEN  RETURN;
adrian@94
    28
    END IF;
adrian@94
    29
   END IF;
adrian@94
    30
 IF(UPDATING OR INSERTING) THEN
adrian@94
    31
  IF(:NEW.M_Product_Uom_ID IS NOT NULL AND :NEW.QuantityOrderBook IS NULL) THEN
adrian@94
    32
    :NEW.QuantityOrderBook:=0;
adrian@94
    33
  ELSIF(:NEW.M_Product_Uom_ID IS NULL AND :NEW.QuantityOrderBook IS NOT NULL) THEN
adrian@94
    34
    :NEW.QuantityOrderBook:=NULL;
adrian@94
    35
  END IF;
adrian@94
    36
 END IF;
adrian@94
    37
END M_InventoryLine2_Trg
adrian@94
    38
adrian@170
    39
adrian@170
    40
</body>
adrian@94
    41
    </trigger>
adrian@94
    42
  </database>