diff --git a/tutorial.py b/tutorial.py index 50e70b9..7b7d200 100644 --- a/tutorial.py +++ b/tutorial.py @@ -46,6 +46,8 @@ class GalateaTutorial(ModelSQL, ModelView): gallery = fields.Boolean('Gallery', help='Active gallery attachments.') comment = fields.Boolean('Comment', help='Active comments.') comments = fields.One2Many('galatea.tutorial.comment', 'tutorial', 'Comments') + total_comments = fields.Function(fields.Integer("Total Comments"), + 'get_totalcomments') attachments = fields.One2Many('ir.attachment', 'resource', 'Attachments') _slug_langs_cache = Cache('galatea_tutorial.slug_langs') @@ -148,6 +150,9 @@ class GalateaTutorial(ModelSQL, ModelView): return slugs + def get_totalcomments(self, name): + return len(self.comments) + class GalateaTutorialWebSite(ModelSQL): 'Galatea Tutorial - Website'