Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-5579

Error when add product to an order.

Details

    • Bug Crush Event - 21/2/2015, Community Day 3 - 2015

    Description

      Flow:
      1. Create Sales Order with default option (store - OFBiz - Ecommerce store; No channel; user login ID: admin)
      2. Continue with default option of Currency, Agreements, and Ship Dates.
      3. Select product for this order (Ex: Forklift - Propane)
      4. Click add to order

      --> Error:

      Forklift - Propane Powered.
      FORKLIFT_PROPANE
      Your Price: $0.00

      Maximum Expression product.reservMaxPersons is undefined on line 364, column 190 in component://order/webapp/ordermgr/entry/catalog/productdetail.ftl. The problematic instruction: ---------- ==> ${product.reservMaxPersons} [on line 364, column 188 in component://order/webapp/ordermgr/entry/catalog/productdetail.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression product.reservMaxPersons is undefined on line 364, column 190 in component://order/webapp/ordermgr/entry/catalog/productdetail.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125) at freemarker.core.Expression.getStringValue(Expression.java:118) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.Environment.process(Environment.java:199) at org.ofbiz.base.util.template.FreeMarkerWorker.renderTemplate(FreeMarkerWorker.java:251) at org.ofbiz.widget.screen.HtmlWidget.renderHtmlTemplate(HtmlWidget.java:224) at org.ofbiz.widget.screen.HtmlWidget$HtmlTemplate.renderWidgetString(HtmlWidget.java:269) at org.ofbiz.widget.screen.HtmlWidget.renderWidgetString(HtmlWidget.java:129) at org.ofbiz.widget.screen.ModelScreenWidget$PlatformSpecific.renderWidgetString(ModelScreenWidget.java:988) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:189) at org.ofbiz.widget.screen.ModelScreen.renderScreenString(ModelScreen.java:396) at org.ofbiz.widget.screen.ScreenFactory.renderReferencedScreen(ScreenFactory.java:216) at org.ofbiz.widget.screen.ModelScreenWidget$IncludeScreen.renderWidgetString(ModelScreenWidget.java:596) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:189) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$DecoratorSection.renderWidgetString(ModelScreenWidget.java:696) at org.ofbiz.widget.screen.ModelScreenWidget$SectionsRenderer.render(ModelScreenWidget.java:127) at org.ofbiz.widget.screen.ModelScreenWidget$DecoratorSectionInclude.renderWidgetString(ModelScreenWidget.java:729) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Container.renderWidgetString(ModelScreenWidget.java:331) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Container.renderWidgetString(ModelScreenWidget.java:331) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:189) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$DecoratorSection.renderWidgetString(ModelScreenWidget.java:696) at org.ofbiz.widget.screen.ModelScreenWidget$SectionsRenderer.render(ModelScreenWidget.java:127) at org.ofbiz.widget.screen.ModelScreenWidget$DecoratorSectionInclude.renderWidgetString(ModelScreenWidget.java:729) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Container.renderWidgetString(ModelScreenWidget.java:331) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Container.renderWidgetString(ModelScreenWidget.java:331) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:203) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Container.renderWidgetString(ModelScreenWidget.java:331) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Container.renderWidgetString(ModelScreenWidget.java:331) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:189) at org.ofbiz.widget.screen.ModelScreen.renderScreenString(ModelScreen.java:396) at org.ofbiz.widget.screen.ScreenFactory.renderReferencedScreen(ScreenFactory.java:216) at org.ofbiz.widget.screen.ModelScreenWidget$IncludeScreen.renderWidgetString(ModelScreenWidget.java:596) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:189) at org.ofbiz.widget.screen.ModelScreen.renderScreenString(ModelScreen.java:396) at org.ofbiz.widget.screen.ScreenFactory.renderReferencedScreen(ScreenFactory.java:216) at org.ofbiz.widget.screen.ModelScreenWidget$IncludeScreen.renderWidgetString(ModelScreenWidget.java:596) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:189) at org.ofbiz.widget.screen.ModelScreen.renderScreenString(ModelScreen.java:396) at org.ofbiz.widget.screen.ScreenFactory.renderReferencedScreen(ScreenFactory.java:216) at org.ofbiz.widget.screen.ModelScreenWidget$DecoratorScreen.renderWidgetString(ModelScreenWidget.java:663) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:189) at org.ofbiz.widget.screen.ModelScreen.renderScreenString(ModelScreen.java:396) at org.ofbiz.widget.screen.ScreenFactory.renderReferencedScreen(ScreenFactory.java:216) at org.ofbiz.widget.screen.ModelScreenWidget$DecoratorScreen.renderWidgetString(ModelScreenWidget.java:663) at org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:102) at org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:189) at org.ofbiz.widget.screen.ModelScreen.renderScreenString(ModelScreen.java:396) at org.ofbiz.widget.screen.ScreenRenderer.render(ScreenRenderer.java:135) at org.ofbiz.widget.screen.ScreenRenderer.render(ScreenRenderer.java:97) at org.ofbiz.widget.screen.MacroScreenViewHandler.render(MacroScreenViewHandler.java:111) at org.ofbiz.webapp.control.RequestHandler.renderView(RequestHandler.java:987) at org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:668) at org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:219) at org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:91) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:327) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:701) persons.
      

      Attachments

        1. OFBIZ-5579.patch
          3 kB
          jitendra kumar khasdev

        Activity

          jleroux Jacques Le Roux added a comment - - edited

          Thanks for report Thang,

          This is quite an old bug that I already fixed in ecommerce side at http://svn.apache.org/viewvc?view=revision&revision=745101
          It has been reported for order manager here http://markmail.org/message/vcuypwuh4szmpq3f

          It's an easy fix, but actually we rather face a data error. For a "Forklift - Propane" these Product entity fields

                <field name="reservMaxPersons" type="fixed-point"><description>maximum number of persons who can rent this asset at the same time</description></field>
                <field name="reserv2ndPPPerc" type="fixed-point"><description>percentage of the end price for the 2nd person renting this asset connected to this product</description></field>
                <field name="reservNthPPPerc" type="fixed-point"><description>percentage of the end price for the Nth person renting this asset connected to this product</description></field>
          

          have not been set in demo data. They should obviously be
          reservMaxPersons =1
          reserv2ndPPPerc=0
          reservNthPPPerc=0

          It's possible to set them at catalog/control/EditProductAssetUsage?productId=FORKLIFT_PROPANE with fields
          "Max.Nbr. of Persons for rental"
          "Second person add.price percentage"
          "Nth person add.price percentage"
          Thenn the problem vanishes.

          What I will do: change the default I used in ecommerce to set the values above and use the same in order manager. The logic behind being that these values should be set in data. But if people forgot them then it's because they did not make sense to them and the best default values are those above.

          What we should do for demo data: add these default values to these products

              <Product productId="FORKLIFT_PROPANE" productTypeId="ASSET_USAGE" productName="Forklift - Propane" internalName="Forklift - Propane" description="Forklift - Propane Powered."/>
              <Product productId="FORKLIFT_BATTERY" productTypeId="ASSET_USAGE" productName="Forklift - Battery" internalName="Forklift - Battery" description="Forklift - Battery Powered."/>
              <Product productId="COMPANY_VEHICLE" productTypeId="ASSET_USAGE" productName="Company Vehicle" internalName="Company Vehicle" description="Company Vehicle."/>
              <Product productId="HVAC_UNIT" productTypeId="ASSET_USAGE" productName="Heating/Cooling Unit" internalName="Heating/Cooling Unit" description="Heating/Cooling Unit."/>
          

          For instance:

          <Product productId="FORKLIFT_BATTERY" productTypeId="ASSET_USAGE" productName="Forklift - Battery" internalName="Forklift - Battery" description="Forklift - Battery Powered." reservMaxPersons ="1" reserv2ndPPPerc="0" reservNthPPPerc="0"/>
          

          Now I wonder, because doing so you get to a screen where you still need to define a number of persons and rooms which does not make much sense to me (any for rooms). So it could be that the UI should be reviewed as well in relation with the data model to distinguish different types of rented products. Obvisouly when I want to sell or rent/buy a FORKLIFT_BATTERY there can't be a relation with a room... I feel something has beeen hastily dumped (or not envisionned) here and it will more work now to fix it, both at the data model and UI levels...

          So for now I keep this issue open, not even resolved, it needs more thoughts...

          I committed a temporary fix at r1577855 in trunk (only, will see later after discussion for releases)

          jleroux Jacques Le Roux added a comment - - edited Thanks for report Thang, This is quite an old bug that I already fixed in ecommerce side at http://svn.apache.org/viewvc?view=revision&revision=745101 It has been reported for order manager here http://markmail.org/message/vcuypwuh4szmpq3f It's an easy fix, but actually we rather face a data error. For a "Forklift - Propane" these Product entity fields <field name= "reservMaxPersons" type= "fixed-point" ><description>maximum number of persons who can rent this asset at the same time</description></field> <field name= "reserv2ndPPPerc" type= "fixed-point" ><description>percentage of the end price for the 2nd person renting this asset connected to this product</description></field> <field name= "reservNthPPPerc" type= "fixed-point" ><description>percentage of the end price for the Nth person renting this asset connected to this product</description></field> have not been set in demo data. They should obviously be reservMaxPersons =1 reserv2ndPPPerc=0 reservNthPPPerc=0 It's possible to set them at catalog/control/EditProductAssetUsage?productId=FORKLIFT_PROPANE with fields "Max.Nbr. of Persons for rental" "Second person add.price percentage" "Nth person add.price percentage" Thenn the problem vanishes. What I will do: change the default I used in ecommerce to set the values above and use the same in order manager. The logic behind being that these values should be set in data. But if people forgot them then it's because they did not make sense to them and the best default values are those above. What we should do for demo data: add these default values to these products <Product productId= "FORKLIFT_PROPANE" productTypeId= "ASSET_USAGE" productName= "Forklift - Propane" internalName= "Forklift - Propane" description= "Forklift - Propane Powered." /> <Product productId= "FORKLIFT_BATTERY" productTypeId= "ASSET_USAGE" productName= "Forklift - Battery" internalName= "Forklift - Battery" description= "Forklift - Battery Powered." /> <Product productId= "COMPANY_VEHICLE" productTypeId= "ASSET_USAGE" productName= "Company Vehicle" internalName= "Company Vehicle" description= "Company Vehicle." /> <Product productId= "HVAC_UNIT" productTypeId= "ASSET_USAGE" productName= "Heating/Cooling Unit" internalName= "Heating/Cooling Unit" description= "Heating/Cooling Unit." /> For instance: <Product productId= "FORKLIFT_BATTERY" productTypeId= "ASSET_USAGE" productName= "Forklift - Battery" internalName= "Forklift - Battery" description= "Forklift - Battery Powered." reservMaxPersons = "1" reserv2ndPPPerc= "0" reservNthPPPerc= "0" /> Now I wonder, because doing so you get to a screen where you still need to define a number of persons and rooms which does not make much sense to me (any for rooms). So it could be that the UI should be reviewed as well in relation with the data model to distinguish different types of rented products. Obvisouly when I want to sell or rent/buy a FORKLIFT_BATTERY there can't be a relation with a room... I feel something has beeen hastily dumped (or not envisionned) here and it will more work now to fix it, both at the data model and UI levels... So for now I keep this issue open, not even resolved, it needs more thoughts... I committed a temporary fix at r1577855 in trunk (only, will see later after discussion for releases)

          What about planning to remove completely this old, incomplete and never maintained code related to reservMaxPersons, reserv2ndPPPerc... ? We could consider it a move to the "Attic" (we could keep a diff somewhere for reference).
          This will make the code more readable and would simplify its maintenance; in the same time, if there will be future interest, the old code could be always resurrected, enhanced and committed.

          jacopoc Jacopo Cappellato added a comment - What about planning to remove completely this old, incomplete and never maintained code related to reservMaxPersons, reserv2ndPPPerc... ? We could consider it a move to the "Attic" (we could keep a diff somewhere for reference). This will make the code more readable and would simplify its maintenance; in the same time, if there will be future interest, the old code could be always resurrected, enhanced and committed.

          I'd not be against, another solution would be to fix it but I will definitively not do it myself. Hans, you were the committer of this feature, what do you think?

          jleroux Jacques Le Roux added a comment - I'd not be against, another solution would be to fix it but I will definitively not do it myself. Hans, you were the committer of this feature, what do you think?
          diveshdut Divesh Dutta added a comment -

          Hello all community members,

          Either we close this issue because actual problem has been resolved OR we can remove the code of showing "Number of Rooms" and "Number of Persons" in UI because UI is confusing . And simply show "quantity" in UI for adding asset products into the cart similar to other types of products .

          diveshdut Divesh Dutta added a comment - Hello all community members, Either we close this issue because actual problem has been resolved OR we can remove the code of showing "Number of Rooms" and "Number of Persons" in UI because UI is confusing . And simply show "quantity" in UI for adding asset products into the cart similar to other types of products .

          Hi Divesh, I'd go with your 2 solution, but I'd keep the "Number of Rooms" and "Number of Persons" fields in case it's really a room or kinda.

          jleroux Jacques Le Roux added a comment - Hi Divesh, I'd go with your 2 solution, but I'd keep the "Number of Rooms" and "Number of Persons" fields in case it's really a room or kinda.

          For this condition, we can cover into quantity as no of room so that is why we can remove the field of no of room field from GUI.

          jkhasdev jitendra kumar khasdev added a comment - For this condition, we can cover into quantity as no of room so that is why we can remove the field of no of room field from GUI.
          diveshdut Divesh Dutta added a comment -

          When adding Asset products into the cart, we will show Number of Persons field in UI only when reserMaxPersons field is defined in Product table. So this way we are binding Number of Persons field to datbase field. This way we avoid confusing UI that we don't show Number Of Persons field when its not needed. Simillarly Number Of Rooms field is also confusing in UI when Asset product is not room. We don't have any way to figure out which product is Room. So for now we have generalized the field and called it quantity.

          Fixed according to above comment in trunk in revision number 1706591 . Thanks Jitendra kumar khasdev for your patch.

          diveshdut Divesh Dutta added a comment - When adding Asset products into the cart, we will show Number of Persons field in UI only when reserMaxPersons field is defined in Product table. So this way we are binding Number of Persons field to datbase field. This way we avoid confusing UI that we don't show Number Of Persons field when its not needed. Simillarly Number Of Rooms field is also confusing in UI when Asset product is not room. We don't have any way to figure out which product is Room. So for now we have generalized the field and called it quantity. Fixed according to above comment in trunk in revision number 1706591 . Thanks Jitendra kumar khasdev for your patch.
          diveshdut Divesh Dutta added a comment -

          Applied the fix on revision 1706594 on 14.12 branch.

          diveshdut Divesh Dutta added a comment - Applied the fix on revision 1706594 on 14.12 branch.

          Thanks Jitendra and DIvesh

          Good stuff!

          Backported in
          R13.07 r1706659
          R12.04 r1706660

          jleroux Jacques Le Roux added a comment - Thanks Jitendra and DIvesh Good stuff! Backported in R13.07 r1706659 R12.04 r1706660

          People

            diveshdut Divesh Dutta
            thangnguyen.Olbius nguyenthang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: