DigitalSignage/controllers/website_form.py

41 lines
1.5 KiB
Python
Executable File

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import tools
from odoo.addons.phone_validation.tools import phone_validation
from odoo.addons.website.controllers import form
from odoo.http import request
import logging
from odoo.http import request
_logger = logging.getLogger(__name__)
class WebsiteForm(form.WebsiteForm):
def _get_country(self):
visitor_partner = request.env['website.visitor']._get_visitor_from_request().partner_id
if visitor_partner:
# match same behaviour as in partner._phone_format()
country = visitor_partner.country_id or request.env.company.country_id
if country:
return country
country_code = request.geoip.get('country_code')
if country_code:
return request.env['res.country'].sudo().search([('code', '=', country_code)], limit=1)
return request.env['res.country']
def _get_phone_fields_to_validate(self):
return ['phone', 'mobile']
# Check and insert values from the form on the model <model> + validation phone fields
def _handle_website_form(self, model_name, **kwargs):
_logger.info('Im Form Handling 0')
result = True
return result
def insert_record(self, request, model, values, custom, meta=None):
_logger.info('Im Form Handling 1')
result = True
# super(WebsiteForm, self).insert_record(request, model, values, custom, meta=meta)
return result