# -*- coding: utf-8 -*-
###############################################################################
#
#    Tech-Receptives Solutions Pvt. Ltd.
#    Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Lesser General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Lesser General Public License for more details.
#
#    You should have received a copy of the GNU Lesser General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################

import time
import datetime
from dateutil.relativedelta import relativedelta
import math

from odoo.osv import expression
from odoo.tools.float_utils import float_round as round
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
from odoo.exceptions import UserError, ValidationError
from odoo import api, fields, models, _
from odoo.tools.misc import formatLang
import json

import urlparse
import uuid

from datetime import date

class ResPartner(models.Model):
    _inherit = ['res.partner']

    @api.one
    def _get_user(self):
        if self.id:
            partner_id = self.id
            users_obj = self.env['res.users'].search([('partner_id','=',partner_id)])
            if len(users_obj) > 0:
                self.is_user = True
            else:
                self.is_user = False

    is_user = fields.Boolean(string='Is user', compute="_get_user", store=True)
	
    @api.model
    def fields_get(self, fields=None, attributes=None):
        """ Hide fields from advanced search
        """
        fields_to_hide = ['tz','bank_ids','credit_limit','barcode','color','partner_share','commercial_partner_id','commercial_company_name','company_name','vat','title','date','create_date','write_date','create_uid','write_uid','message_last_post','opt_out','message_bounce','website_meta_keywords','website_meta_title','website_short_description','website_meta_description','website_description','signup_type','signup_expiration','signup_token','image','image_medium','image_small']
        fields = super(ResPartner, self).fields_get(fields, attributes=attributes)
        for field in fields_to_hide:
            if field in fields:
                fields[field]['selectable'] = False
        return fields

