import logging
from odoo import api, fields, models
from odoo.exceptions import UserError

_logger = logging.getLogger(__name__)


class WxworkApproval(models.Model):
    _name = 'wxwork.approval'
    _description = "审批"
    inherit = ['mail.thread', 'mail.activity.mixin']
    _order = 'id desc'

    template_id = fields.Many2one('wxwork.approval.template', string='审批模板')
    business_model = fields.Many2many('sale.order', 'sale_approval_rel', 'sale_id', 'approval_id', string='业务类型')
    approve_history_ids = fields.One2many('wxwork.approval.history', 'approve_id', string='审批流程')
    state = fields.Char(string='状态')


class WxworkApprovalHistory(models.Model):
    _name = 'wxwork.approval.history'
    _description = "审批历史记录"

    approve_id = fields.Many2one('wxwork.approval', string='审批')
