11788: Always set is_billable if timeaccount is billable
authorsstamer <s.stamer@metaways.de>
Fri, 15 Apr 2016 10:15:30 +0000 (12:15 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 19 Apr 2016 15:39:41 +0000 (17:39 +0200)
https://forge.tine20.org/view.php?id=11788

- This is needed for copied sheets

Change-Id: I0513c4ef7057d91b9a014aa1c9e1d5d81cb308c6
Reviewed-on: http://gerrit.tine20.com/customers/3050
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Timetracker/js/TimesheetEditDialog.js

index 33fcdd2..ec8c133 100644 (file)
@@ -80,6 +80,17 @@ Tine.Timetracker.TimesheetEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
             this.getForm().findField('is_billable').setValue(timeaccount.data.is_billable);
         }
     },
             this.getForm().findField('is_billable').setValue(timeaccount.data.is_billable);
         }
     },
+    
+    /**
+     * Always set is_billable if timeaccount is billable. This is needed for copied sheets where the
+     * original is set to not billable
+     */
+    onAfterRecordLoad: function() {
+        Tine.Timetracker.TimesheetEditDialog.superclass.onAfterRecordLoad.call(this);
+        if (this.record.id == 0 && this.record.get('timeaccount_id') && this.record.get('timeaccount_id').is_billable) {
+            this.getForm().findField('is_billable').setValue(this.record.get('timeaccount_id').is_billable);
+        }
+    },
 
     /**
      * this gets called when initializing and if cleared checkbox is changed
 
     /**
      * this gets called when initializing and if cleared checkbox is changed