Copy quote make fields editable / update calculated fields

Hi,

for a customer who uses the quotes module a lot we want to be able to copy an existing quote and update the products on the copy with new data from the producttemplate ( they change prices etc on the producttemplate, they don't create new templates..). I got it working so far that when I click the duplicate button the lines are copied and the data is being updated using a ajax request for the various templates. This does work by validating in the create.js if we have a copy context and if so we copy all the data needed from the producttemplates. 

I currently have two issues left: 

- When I copy a quote the productbundle items are copied but the calculated fields are not updated until I save the quote

- Certain fields are readonly. 

Could someone point me into the right direction so I can solve both issues? 

if(options.context.get('copy') === true && !_.isEmpty(options.context.get("relatedRecords"))){
            _.each(options.context.get("relatedRecords"), function(entry){
                if(entry._module  === "ProductBundles"){
                    _.each(entry.product_bundle_items,function(bundleItem){
                        var productTemplateId = bundleItem.get("product_template_id");
                        if(!_.isEmpty(productTemplateId)){

                            var url = app.api.buildURL('ProductTemplates/'+productTemplateId, '', {}, {});
                            app.api.call('read',url,{},{
                                success: _.bind(function(bundleItem,response){
                                    console.log('succesfully retrieved data from template??');
                                    bundleItem.set('name',response.name);
                                    bundleItem.set('category_id',response.category_id);
                                    bundleItem.set('category_name',response.category_name);
                                    bundleItem.set('mft_part_num',response.mft_part_num);
                                    bundleItem.set('list_price',response.list_price);
                                    bundleItem.set('cost_price',response.cost_price);
                                    bundleItem.set('discount_price',response.discount_price);
                                    bundleItem.set('list_usdollar',response.list_usdollar);
                                    bundleItem.set('cost_usdollar',response.cost_usdollar);
                                    bundleItem.set('discount_usdollar',response.discount_usdollar);
                                    bundleItem.set('tax_class',response.tax_class);
                                    bundleItem.set('weight',response.weight);
                                    bundleItem.set('type_id',response.type_id);
                                    bundleItem.set('type_name',response.type_name);
                                    bundleItem.set('manufacturer_id',response.manufacturer_id);
                                    bundleItem.set('manufacturer_name',response.manufacturer_name);
                                    bundleItem.set('currency_id',response.currency_id);
                                    bundleItem.set('base_rate',response.base_rate);
                                    bundleItem.set('isCopied',false);
                                },this,bundleItem)
                            });
                        }
                    });
                }
            });
        }

Parents
  • Hi Jeroen,

    Regarding your first question:

    It is the desired behavior in Sugar. Whenever we added a calculated field in Sugar or modify the existing calculating field then it is the limitation to perform save click action to recalculate it. But this is a time-consuming operation for a large number of records. So you can do the following steps if you are an administrator or have developer-level access:

    1. Navigate to the Quote's list view and select those you wish to update.
    2. From the Actions menu, choose to Recalculate Value.
    This will trigger a recalculation of all calculated fields in the selected record. 
    For your second question:
    There is a need to look into the code implementation. Maybe there is some dependency apply to these fields. You can contact my Sugar certified team at support@rolustech.com for further assistance. You can also check out our SugarCRM e-book for more insight on your current problem.
    Hopefully, this will help you sort out your issue!
  • Hi 

    thanks for the answer but this does not really answer my questions. I wonder if someone else has found how the various fields in the product bundle list are set readonly. I can't seem to find a dependency of some sort 

Reply Children
No Data