src-db/database/model/triggers/M_INVENTORY_TRG.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Wed, 03 Sep 2008 17:55:37 +0000
changeset 1605 8a0fe0193bef
parent 867 280dd3ba42a1
child 2078 cf88ca44cdd2
permissions -rw-r--r--
Merge r2.5x intro trunk
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER M_INVENTORY_TRG">
adrian@94
     3
    <trigger name="M_INVENTORY_TRG" table="M_INVENTORY" fires="after" insert="false" update="true" delete="true" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
gorkaion@239
     5
adrian@170
     6
adrian@94
     7
gorka@401
     8
adrian@94
     9
/*************************************************************************
adrian@94
    10
    * The contents of this file are subject to the Openbravo  Public  License
adrian@94
    11
    * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
adrian@94
    12
    * Version 1.1  with a permitted attribution clause; you may not  use this
adrian@94
    13
    * file except in compliance with the License. You  may  obtain  a copy of
adrian@94
    14
    * the License at http://www.openbravo.com/legal/license.html
adrian@94
    15
    * Software distributed under the License  is  distributed  on  an "AS IS"
adrian@94
    16
    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
adrian@94
    17
    * License for the specific  language  governing  rights  and  limitations
adrian@94
    18
    * under the License.
adrian@94
    19
    * The Original Code is Openbravo ERP.
adrian@94
    20
    * The Initial Developer of the Original Code is Openbravo SL
carlos@867
    21
    * All portions are Copyright (C) 2008 Openbravo SL
adrian@94
    22
    * All Rights Reserved.
adrian@94
    23
    * Contributor(s):  ______________________________________.
adrian@94
    24
    ************************************************************************/
gorkaion@280
    25
v_DateNull DATE := TO_DATE('01-01-1900','DD-MM-YYYY');
adrian@94
    26
BEGIN
carlos@867
    27
  IF DELETING THEN
carlos@867
    28
    IF (:old.PROCESSED = 'Y') THEN
carlos@867
    29
      RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
carlos@867
    30
    END IF;
carlos@867
    31
  END IF;
carlos@867
    32
  IF UPDATING THEN
carlos@867
    33
    IF (:old.PROCESSED = 'Y' AND(
carlos@867
    34
       (COALESCE(:old.MOVEMENTDATE, v_DateNull) <> COALESCE(:new.MOVEMENTDATE, v_DateNull))
juanpablo@1605
    35
       OR (COALESCE(:old.AD_ORGTRX_ID, '0') <> COALESCE(:new.AD_ORGTRX_ID, '0'))
juanpablo@1605
    36
       OR (COALESCE(:old.M_WAREHOUSE_ID, '0') <> COALESCE(:new.M_WAREHOUSE_ID, '0'))
juanpablo@1605
    37
       OR(COALESCE(:old.AD_ORG_ID, '0') <> COALESCE(:new.AD_ORG_ID, '0'))
juanpablo@1605
    38
       OR(COALESCE(:old.AD_CLIENT_ID, '0') <> COALESCE(:new.AD_CLIENT_ID, '0')))) THEN
carlos@867
    39
      RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted') ;
carlos@867
    40
    END IF;
adrian@94
    41
  END IF;
antonio@735
    42
END M_INVENTORY_TRG
gorkaion@239
    43
]]></body>
adrian@94
    44
    </trigger>
adrian@94
    45
  </database>