Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I'm creating a module for student management in "Odoo9", in a part of that module I want to compute the average mark that a student get in a subject like "maths".I'm tryingto achieve that using this code, but I have a problem computing the "Avg-Maths" immediately after filling "Maths-1" and "Maths-2", it can only be computed after saving the student profile.Can someone help me please realizing the issue here? and how can I fix this?
[![enter image description here]]
result_ids = fields.One2many("schoolresults.detail", "student_id", "School Results")
_name = "schoolresults.detail"
_description = "Student's results."
student_id = fields.Many2one("student.student", "Student", ondelete="cascade")
subject_id = fields.Many2one("schoolresults.subject", "Subject")
result_manual = fields.Float("Result")
result = fields.Float(compute='_compute_value',store=True)
manual = fields.Boolean(compute='_is_manual', default=False)
self.manual = self.subject_id.my_id
results = self.env['schoolresults.detail'].search()
total = 0
for data in results:
total += data.result_manual
for data in results:
#if the subject is the average of others
data.result = total
_name = "schoolresults.subject"
_description = "Student's subjects."
my_id = fields.Integer(default=0)
name = fields.Char("Subject")
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 8/10/16, 1:38 PM|
|Seen: 209 times|
|Last updated: 8/11/16, 7:53 AM|