This is an automated email from the ASF dual-hosted git repository.

mridulpathak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release24.09 by this push:
     new 50700f668b Fixed: duplicate QuoteRole insertion error in copyQuote 
service (OFBIZ-13436) (#1347)
50700f668b is described below

commit 50700f668b438ec7ea35de9e9b88178b2f5a3e5b
Author: chandan-khandelwal <[email protected]>
AuthorDate: Fri Jun 12 20:28:36 2026 +0530

    Fixed: duplicate QuoteRole insertion error in copyQuote service 
(OFBIZ-13436) (#1347)
    
    Fixed: Fix duplicate QuoteRole insertion error in copyQuote service,
    avoid duplicate key constraints when copying quote roles by checking if
    a role already exists for the new quote before creating it.
    (OFBIZ-13436)
---
 .../apache/ofbiz/order/quote/QuoteServicesScript.groovy   | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git 
a/applications/order/src/main/groovy/org/apache/ofbiz/order/quote/QuoteServicesScript.groovy
 
b/applications/order/src/main/groovy/org/apache/ofbiz/order/quote/QuoteServicesScript.groovy
index 45f2c73f13..6e6f575093 100644
--- 
a/applications/order/src/main/groovy/org/apache/ofbiz/order/quote/QuoteServicesScript.groovy
+++ 
b/applications/order/src/main/groovy/org/apache/ofbiz/order/quote/QuoteServicesScript.groovy
@@ -242,11 +242,16 @@ Map copyQuote() {
         List quoteRoles = quote.getRelated('QuoteRole', null, null, false)
         for (GenericValue quoteRole : quoteRoles) {
             if (quoteRole.roleTypeId != 'REQ_TAKER') {
-                Map serviceContext = dctx.makeValidContext('createQuoteRole', 
ModelService.IN_PARAM,
-                        [*: quoteRole, quoteId: quoteIdTo, userLogin: 
userLogin])
-                serviceResult = dispatcher.runSync('createQuoteRole', 
serviceContext)
-                if (ServiceUtil.isError(serviceResult)) {
-                    return serviceResult
+                GenericValue existingQuoteRole = from('QuoteRole')
+                        .where(quoteId: quoteIdTo, partyId: quoteRole.partyId, 
roleTypeId: quoteRole.roleTypeId)
+                        .queryOne()
+                if (!existingQuoteRole) {
+                    Map serviceContext = 
dctx.makeValidContext('createQuoteRole', ModelService.IN_PARAM,
+                            [*: quoteRole, quoteId: quoteIdTo, userLogin: 
userLogin])
+                    serviceResult = dispatcher.runSync('createQuoteRole', 
serviceContext)
+                    if (ServiceUtil.isError(serviceResult)) {
+                        return serviceResult
+                    }
                 }
             }
         }

Reply via email to