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? 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX