Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0015818Openbravo ERP07. Sales managementpublic2011-01-31 09:562011-07-20 18:16
egoitz 
jonalegriaesarte 
normalminoralways
newopen 
5
 
 
Core
No
0015818: The c_orderline_trg2 trigger should update the total of the header only if the line amount changes.
The c_orderline_trg2 trigger should update the total of the header only if the line amount changes.

At the moment always is change so it can be a problem if you add some triggers on the c_order table.
Add a new trigger in the c_order table that updates the c_bpartner_id of the lines when changing the partner of the header if order has not been completed.

-Modify the partner of a order not completed.
-The trigger developed is executed and an update on c_orderline is done
-The c_orderline_trg2 trigger is executed and an update on the c_order is done
-This produces to execute again the trigger developed, but this is blocked so you get an error.
xecute the following order only when the amount of the line has been modifyied.

UPDATE C_Order
     SET TotalLines = TotalLines - v_oldLine + v_newLineNetAmt,
     GrandTotal = TotalLines - v_oldLine + v_newLineNetAmt + COALESCE(v_taxAmt, 0)
   -- Updated = SysDate -- Don't update as otherwise it does not save changes
   WHERE C_Order_ID=old.C_Order_ID;

For that you can add the following condition on the where clause of the update:

AND (COALESCE(v_oldLine,0) <> COALESCE(v_newLineNetAmt,0) OR GrandTotal <>
(TotalLines - v_oldLine + v_newLineNetAmt + COALESCE(v_taxAmt, 0)))
No tags attached.
Issue History
2011-01-31 09:56egoitzNew Issue
2011-01-31 09:56egoitzAssigned To => adrianromero
2011-01-31 09:56egoitzModules => Core
2011-06-03 10:58dalsasuaAssigned Toadrianromero => dalsasua
2011-07-20 18:16dalsasuaAssigned Todalsasua => jonalegriaesarte

There are no notes attached to this issue.