Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0016629Openbravo ERP07. Sales managementpublic2011-04-04 11:182013-05-13 16:03
adrianromero 
mirurita 
urgentmajorhave not tried
scheduledopen 
5
pi 
 
Core
No
0016629: A sales order with discount cannot be reactivated nor closed
if there is a sales order with discount, and its related invoice or shipment is voided, if you try reactivate or close the sales order, an error is returned and the operation cannot be done.
. business partner with discount with check "apply in order" selected
. create a new sales order "warehouse order"
. process the order
. create and process a new invoice from sales order
. the invoice is voided
. if you try reactivate the sales order, error is returned: "update o delete en «c_orderline» viola la llave foránea «c_invoiceline_c_orderline» en la tabla «c_invoiceline»"
VMA-Reviewed
blocks backport 0016056 closed mirurita A sales order with discount cannot be reactivated nor closed 
Issue History
2011-04-04 11:18adrianromeroNew Issue
2011-04-04 11:18adrianromeroAssigned To => adrianromero
2011-04-04 11:18adrianromeroModules => Core
2011-04-04 11:18adrianromeroIssue generated from0016056
2011-04-04 11:18adrianromeroRelationship addedblocks 0016056
2011-04-04 11:20hgbotCheckin
2011-04-04 11:20hgbotNote Added: 0035517
2011-04-04 11:21adrianromeroStatusnew => scheduled
2011-04-04 11:21adrianromerofix_in_branch => pi
2011-04-27 18:05adrianromeroNote Added: 0036139
2011-06-03 10:58dalsasuaAssigned Toadrianromero => dalsasua
2011-07-20 18:16dalsasuaAssigned Todalsasua => jonalegriaesarte
2012-02-15 19:04iciordiaAssigned Tojonalegriaesarte => vmromanos
2012-02-16 16:05vmromanosTag Attached: VMA-Reviewed
2012-05-02 18:02naiaramartinezNote Added: 0048245
2012-05-10 12:12gorka_gilAssigned Tovmromanos => mirurita
2013-05-13 16:03SandrahuguetTriggers an Emergency Pack => No
2013-05-13 16:03SandrahuguetTypedefect => design defect
2013-05-13 16:03Sandrahuguetfix_in_branchpi =>

Notes
(0035517)
hgbot   
2011-04-04 11:20   
Repository: erp/devel/pi
Changeset: 0d9752224f7aeb21eba531cdf7b0c0f3af0191f2
Author: Adrián Romero <adrianromero <at> openbravo.com>
Date: Mon Apr 04 11:19:19 2011 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/0d9752224f7aeb21eba531cdf7b0c0f3af0191f2 [^]

Issue 0016629: A sales order with discount cannot be reactivated nor closed
It has been disabled the recalculation of discounts when closing orders because this is the origin of the error. The recalculation of discounts when closing an order is not necessary because discounts of a completed order are properly calculated yet.

---
M src-db/database/model/functions/C_ORDER_POST1.xml
---
(0036139)
adrianromero   
2011-04-27 18:05   
Repository: erp/devel/pi
Changeset: d292a70703182120ee241ce8c61e83f8dc94a916
Author: Adrián Romero <adrianromero <at> openbravo.com>
Date: Wed Apr 27 18:00:31 2011 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/d292a70703182120ee241ce8c61e83f8dc94a916 [^] [^]

Issue 0016056: A sales order with discount cannot be reactivated nor closed
It has been fixed the process of closing sales orders. Discounts are recalculated reusing previous discount lines if it is not possible to delete these discount lines because there already exist records linked to these discount lines

---
M src-db/database/model/functions/C_ORDER_POST1.xml
(0048245)
naiaramartinez   
2012-05-02 18:02   
Create a goods shipment related to a sales order. If the good shipment is processed but then you reactivate it to void, you can reactivate the sales order. That's why in the C_ORDER_POST1 the following is done:

UPDATE M_INOUTLINE SET C_ORDERLINE_ID = NULL
WHERE (SELECT DISTINCT A.DOCSTATUS
       FROM M_INOUT A, M_INOUTLINE B, C_ORDERLINE C
       WHERE A.M_INOUT_ID = B.M_INOUT_ID AND B.C_ORDERLINE_ID = C.C_ORDERLINE_ID
       AND C.C_ORDER_DISCOUNT_ID IS NOT NULL AND C.C_ORDER_ID = v_Record_ID) = 'VO'
AND C_ORDERLINE_ID IN (SELECT C_ORDERLINE_ID
                       FROM C_ORDERLINE
                       WHERE C_ORDER_DISCOUNT_ID IS NOT NULL
                       AND C_ORDER_ID = v_Record_ID);

But with invoices this is not done. So if you create an invoice related to a sales order and this invoice you process and then you reactivate to void, the sales order can't be reactivate because the invoicelines are still related to orderlines.

So, we have to set to null c_orderline_Id in C_invoicelines when we want to reactivate the order.