Last active
August 12, 2017 13:55
-
-
Save aadimator/a944b368b4187914ee70ed183c61c3a5 to your computer and use it in GitHub Desktop.
Student Discount
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create(self, cr, uid, vals, context=None, check=True): | |
# Calculate the acutal_fee and discounts again as readonly fields aren't | |
# stored in the database. | |
std_id = vals.get('student_id') | |
res = self.onchange_get_actual_fee(cr, uid, std_id, std_id, vals.get('fee_type'), context) | |
acutal_fee = res.get('value').get('actual_fee') | |
discounted_fee = acutal_fee - (vals.get('discount') * acutal_fee/100) | |
vals.update({'actual_fee':acutal_fee}) | |
vals.update({'discounted_fee':discounted_fee}) | |
result = super(osv.osv, self).create(cr, uid, vals, context) | |
return result | |
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): | |
# Calculate the acutal_fee and discounts again as readonly fields aren't | |
# stored in the database. | |
std_id = vals.get('student_id') | |
res = self.onchange_get_actual_fee(cr, uid, std_id, std_id, vals.get('fee_type'), context) | |
acutal_fee = res.get('value').get('actual_fee') | |
discounted_fee = acutal_fee - (vals.get('discount') * acutal_fee/100) | |
vals.update({'actual_fee':acutal_fee}) | |
vals.update({'discounted_fee':discounted_fee}) | |
result = super(osv.osv, self).write(cr, uid, ids, vals, context) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment