QuoteItem fields readonly after selected

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • worldmiros
    Senior Member
    • Dec 2015
    • 120

    QuoteItem fields readonly after selected

    In Quoteitems, when item has been selected from the scope, "name" input becomes readonly. I want to make quantity, listprice, and unitprice readonly when item has been selected.

    //name.js
    Code:
    
    
    
    
    
     [COLOR=#7a7a43]handleNameAvailability[/COLOR]: [COLOR=#000080][B]function [/B][/COLOR]() {     [COLOR=#000080][B]if [/B][/COLOR]([COLOR=#000080][B]this[/B][/COLOR].[COLOR=#660e7a][B]model[/B][/COLOR].[COLOR=#7a7a43]get[/COLOR]([COLOR=#008000][B]'productId'[/B][/COLOR])) {         [COLOR=#000080][B]this[/B][/COLOR].[COLOR=#660e7a][B]$element[/B][/COLOR].[COLOR=#7a7a43]attr[/COLOR]([COLOR=#008000][B]'readonly'[/B][/COLOR][COLOR=#cc7832], [/COLOR][COLOR=#000080][B]true[/B][/COLOR])[COLOR=#cc7832]; [/COLOR][COLOR=#660e7a][B]$[/B][/COLOR]([COLOR=#008000][B]".field-listPrice"[/B][/COLOR]).[COLOR=#7a7a43]find[/COLOR]([COLOR=#008000][B]'input[name="listPrice"]'[/B][/COLOR]).[COLOR=#7a7a43]attr[/COLOR]([COLOR=#008000][B]'readonly'[/B][/COLOR][COLOR=#cc7832],[/COLOR][COLOR=#000080][B]true[/B][/COLOR])[COLOR=#cc7832]; [/COLOR][COLOR=#660e7a][B]$[/B][/COLOR]([COLOR=#008000][B]".field-unitPrice"[/B][/COLOR]).[COLOR=#7a7a43]find[/COLOR]([COLOR=#008000][B]'input[name="unitPrice"]'[/B][/COLOR]).[COLOR=#7a7a43]attr[/COLOR]([COLOR=#008000][B]'readonly'[/B][/COLOR][COLOR=#cc7832],[/COLOR][COLOR=#000080][B]true[/B][/COLOR])[COLOR=#cc7832]; [/COLOR][COLOR=#660e7a][B]$[/B][/COLOR]([COLOR=#008000][B]".field-quantity"[/B][/COLOR]).[COLOR=#7a7a43]find[/COLOR]([COLOR=#008000][B]'input[name="quantity"]'[/B][/COLOR]).[COLOR=#7a7a43]attr[/COLOR]([COLOR=#008000][B]'readonly'[/B][/COLOR][COLOR=#cc7832],[/COLOR][COLOR=#000080][B]true[/B][/COLOR])[COLOR=#cc7832]; [/COLOR]}
    Quantity, listprice, and unitprice changes to readonly="true" when items exist and i'm another adding another one. When I update/save, and then i go back to add a item, the fields are no longer readonly.
  • worldmiros
    Senior Member
    • Dec 2015
    • 120

    #2
    PHP Code:
      chrisMethod: function(){     if(!!this.model.get('productId')){         $(".field-listPrice").find('input[name="listPrice"]').attr('readonly',true);         $(".field-unitPrice").find('input[name="unitPrice"]').attr('readonly',true);         $(".field-quantity").find('input[name="quantity"]').attr('readonly',true);     } } 
    
    Try the code above as well, fields doesn't stay readonly after save and adding an item after another.

    Comment

    • yuri
      Member
      • Mar 2014
      • 8627

      #3
      client/modules/advanced/src/views/quote/record/item.js

      PHP Code:
                  this.createView('listPrice', 'Advanced:QuoteItem.Fields.UnitPrice', {
                      model: this.model,
                      defs: {
                          name: 'listPrice',
                      },
                      mode: this.mode,
                      el: this.options.el + ' .field-listPrice',
                      inlineEditDisabled: true
                      readOnly: true // this
                  }, function (view) {
                      this.listenTo(view, 'change', function () {
                          setTimeout(function () {
                              this.trigger('change');
                          }.bind(this), 50);
                      }, this);
                  }.bind(this)); 
      
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • worldmiros
        Senior Member
        • Dec 2015
        • 120

        #4
        yuri If I want to get a template, as far writing the directory, is this correct?

        Code:
        var getTemp = this.getTemplate().get('clientDefs.res.templates.fields.float');
        The directory is, clientDefs/res/templates/fields/float/edit.tpl

        Comment

        • yuri
          Member
          • Mar 2014
          • 8627

          #5
          No.

          You can use regular ajax call to get template content.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

          • dreginald
            Senior Member
            • Sep 2018
            • 106

            #6
            Please advise on how to make the Quote Item (Item List) read-only when the quote gets approved?

            Comment

            Working...