It is not possible to change the default quantity pieces

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LuckyLouie
    Senior Member
    • Nov 2017
    • 172

    It is not possible to change the default quantity pieces

    Hello,
    I tried on my Espo and demo.espocrm.com to change the default quantity from 1 to 2 pcs. After saving the changes, the default quantity is still 1 pc.
  • item
    Active Community Member
    • Mar 2017
    • 1476

    #2
    Hello,

    i just looked the code .. and there are this in of part of code : quantity: 1,
    i can't post the code.. you can search in files theses word.

    Regards
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • Maximus
      Senior Member
      • Nov 2018
      • 2731

      #3
      Hi there,
      There is no such abilityt to change it through UI cause it always will be changed by the system logic to 1. Basically item is right. It is enough to change quantity: 1, to quantity: 2, in the file/client/modules/sales/src/views/quote/fields/item-list.js and it became to work. It is the fastest but not safe way to achieve this. For safe way do this:
      1. Create the file /client/custom/src/views/quote/fields/item-list.js with the code:
      Code:
      Espo.define('custom:views/quote/fields/item-list', 'sales:views/quote/fields/item-list', function (Dep, Model) {
      
          return Dep.extend({
      
              addItem: function () {
                  var currency = this.model.get('amountCurrency');
      
                  if (!currency) {
                      if (this.getFieldView('currency')) {
                          currency = this.getFieldView('currency').fetch().currency;
                      }
                  }
      
                  var id = 'cid' + this.generateId();
                  var data = {
                      id: id,
      [COLOR=#c0392b]                quantity: 2,[/COLOR]
                      listPriceCurrency: currency,
                      unitPriceCurrency: currency,
                      isTaxable: true,
                      taxRate: this.model.get('taxRate') || 0
                  };
                  var itemList = Espo.Utils.clone(this.fetchItemList());
                  itemList.push(data);
                  this.model.set('itemList', itemList);
                  this.calculateAmount();
              }
          });
      });
      2. Create the file /client/custom/src/views/quote/record/panels/items.js with the code:
      Code:
      Espo.define('custom:views/quote/record/panels/items', 'sales:views/quote/record/panels/items', function (Dep) {
      
          return Dep.extend({
      
              setup: function () {
                  Dep.prototype.setup.call(this);
      
                  this.createView('itemList', 'custom:views/quote/fields/item-list', {
                      model: this.model,
                      el: this.options.el + ' .field-itemList',
                      defs: {
                          name: 'itemList'
                      },
                      mode: this.mode
                  });
              }
          });
      });
      3. Open the file /custom/Espo/Custom/Resources/metadata/entityDefs/Quote.json and add the code:
      Code:
      {
          "fields": {
              "itemList": {
                  "view" : "custom:views/quote/fields/item-list"
              }
          },
          ......
      }
      4. Administration -> Clear Cache
      5. Refresh a web page
      6. Try to add new Item to the Quote Item List.
      Last edited by Maximus; 08-17-2020, 01:17 PM.

      Comment

      • LuckyLouie
        Senior Member
        • Nov 2017
        • 172

        #4
        Thank You!

        Comment

        Working...