Revision d41acd2d
Von Moritz Bunkus vor fast 11 Jahren hinzugefügt
sql/Pg-upgrade2/delete_close_follow_ups_when_order_is_deleted_closed.sql | ||
---|---|---|
74 | 74 |
CREATE TRIGGER vendor_before_delete_clear_follow_ups |
75 | 75 |
AFTER DELETE ON vendor |
76 | 76 |
FOR EACH ROW EXECUTE PROCEDURE follow_up_delete_when_customer_vendor_is_deleted_trigger(); |
77 |
|
|
78 |
-- ============================================================ |
|
79 |
|
|
80 |
CREATE OR REPLACE FUNCTION follow_up_close_when_oe_closed_trigger() |
|
81 |
RETURNS TRIGGER AS $$ |
|
82 |
BEGIN |
|
83 |
IF COALESCE(NEW.closed, FALSE) AND NOT COALESCE(OLD.closed, FALSE) THEN |
|
84 |
UPDATE follow_ups |
|
85 |
SET done = TRUE |
|
86 |
WHERE id IN ( |
|
87 |
SELECT follow_up_id |
|
88 |
FROM follow_up_links |
|
89 |
WHERE (trans_id = NEW.id) |
|
90 |
AND (trans_type IN ('sales_quotation', 'sales_order', 'sales_delivery_order', |
|
91 |
'request_quotation', 'purchase_order', 'purchase_delivery_order')) |
|
92 |
); |
|
93 |
END IF; |
|
94 |
|
|
95 |
RETURN NEW; |
|
96 |
END; |
|
97 |
$$ LANGUAGE plpgsql; |
|
98 |
|
|
99 |
DROP TRIGGER IF EXISTS oe_on_update_close_follow_up ON oe; |
|
100 |
|
|
101 |
CREATE TRIGGER oe_on_update_close_follow_up |
|
102 |
AFTER UPDATE ON oe |
|
103 |
FOR EACH ROW EXECUTE PROCEDURE follow_up_close_when_oe_closed_trigger(); |
|
104 |
|
|
105 |
DROP TRIGGER IF EXISTS delivery_orders_on_update_close_follow_up ON delivery_orders; |
|
106 |
|
|
107 |
CREATE TRIGGER delivery_orders_on_update_close_follow_up |
|
108 |
AFTER UPDATE ON delivery_orders |
|
109 |
FOR EACH ROW EXECUTE PROCEDURE follow_up_close_when_oe_closed_trigger(); |
Auch abrufbar als: Unified diff
Wiedervorlagen schließen, wenn dazugehörige Belege geschlossen werden
Siehe #2310.