from odoo import models, fields, api class ResCompany(models.Model): _inherit = 'res.company' google_business_id = fields.Char( string='Google Business Place ID', help=( 'The Google Business Profile Location ID for this branch. ' 'You can find it by running list_locations.py from the ' 'google_map_review crawler project, or from the Google Business ' 'Profile dashboard. Example: 12345678901234567890' ), ) google_review_count = fields.Integer( string='Google Reviews', compute='_compute_google_review_count', ) @api.depends('google_business_id') def _compute_google_review_count(self): Review = self.env['google.map.review'] for company in self: company.google_review_count = Review.search_count([ ('company_id', '=', company.id), ]) def action_view_google_reviews(self): self.ensure_one() return { 'type': 'ir.actions.act_window', 'name': f'Google Reviews – {self.name}', 'res_model': 'google.map.review', 'view_mode': 'list,kanban,form', 'domain': [('company_id', '=', self.id)], 'context': {'default_company_id': self.id}, }