google_map_review/models/res_company.py
2026-06-11 14:13:20 +07:00

40 lines
1.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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},
}