# -*- coding: utf-8 -*-
from odoo import models, api, fields, _

class ResPartner(models.Model):
    _inherit = "res.partner"

    line_ID = fields.Char(string='LINE ID', track_visibility='onchange')
    source_of_intelligence = fields.Many2one(comodel_name='source.intelligence', string='情報來源', track_visibility='onchange')
    first_visit_date = fields.Date(string='初次來訪日期', track_visibility='onchange')
    first_transaction_date = fields.Date(string='初次成交日期', track_visibility='onchange')
    birthday = fields.Date(string='生日', track_visibility='onchange')
    sex = fields.Selection(selection=[('1', '男'), ('2', '女')],string='性別', track_visibility='onchange')
    identity = fields.Many2one(comodel_name='identity', string='來客身分', track_visibility='onchange')
    member_id = fields.Char(string='會員編號(舊CRM)')
    japanese_level = fields.Selection(selection=[('1', '未學過'), ('2', '初學者'), ('3', 'N5'), ('4', 'N4'), ('5', 'N3'), ('6', 'N2'), ('7', 'N1'), ('8', '不清楚'), ('9', '未提供')], default='1',string='日語程度', track_visibility='onchange')
    experience = fields.Many2one(comodel_name='experience', string='學經歷', track_visibility='onchange')
    highest_education_school = fields.Char(string='最高學歷校名', track_visibility='onchange')
    highest_education_department = fields.Char(string='最高學歷科系', track_visibility='onchange')
    old_CRM = fields.One2many(comodel_name='old.crm', inverse_name='partner_id',string='舊CRM')
    old__CRM_transaction_record = fields.One2many(comodel_name='old.crm.transaction', inverse_name='partner_id',string='舊CRM系統交易紀錄')
    old__CRM_tags = fields.Text(string='舊CRM標籤')

    is_vendor = fields.Boolean(string='請求書廠商')
    is_student = fields.Boolean(string='學生')
    is_member = fields.Boolean(string='會員')

    highest_education = fields.Char(string='最高學歷')
    status = fields.Char(string='學籍')
    birth_date = fields.Char(string='出生年')
    new1 = fields.Char(string='預設1')
    new2 = fields.Char(string='預設2')
    new3 = fields.Char(string='預設3')
    new4 = fields.Char(string='預設4')
    new5 = fields.Char(string='預設5')
    active = fields.Boolean(track_visibility='onchange')
    mobile = fields.Char(track_visibility='onchange')
    phone = fields.Char(track_visibility='onchange')
    email = fields.Char(track_visibility='onchange')
    street = fields.Char(track_visibility='onchange')
    street2 = fields.Char(track_visibility='onchange')
    zip = fields.Char(track_visibility='onchange')
    city = fields.Char(track_visibility='onchange')
    state_id = fields.Many2one("res.country.state", string='State', ondelete='restrict', track_visibility='onchange')
    company_id = fields.Many2one('res.company', 'Company', index=True, track_visibility='onchange')

class OldCRM(models.Model):
    _name='old.crm'

    partner_id = fields.Many2one(comodel_name='res.partner')
    name = fields.Char(string='備註名稱')
    specialist = fields.Char(string='負責人')
    day = fields.Datetime(string='日期')
    situation = fields.Text(string='描述')

class OldCRMTransaction(models.Model):
    _name='old.crm.transaction'

    partner_id = fields.Many2one(comodel_name='res.partner')
    name = fields.Char(string='訂單編號')
    transaction_record = fields.Char(string='購買內容')
    jptip_class = fields.Char(string='班級')
    course = fields.Char(string='課程')
    amount = fields.Float(string='繳費合計')

class SourceIntelligence(models.Model):
    _name="source.intelligence"

    name = fields.Char(string="情報來源")

class Experience(models.Model):
    _name="experience"

    name = fields.Char(string="學經歷")

class Identity(models.Model):
    _name="identity"

    name = fields.Char(string="身分")

class Identity(models.Model):
    _inherit="jt.student"

    experience = fields.Many2one(comodel_name='experience', string='學經歷')