Files
gzth/wecom_api/tools/string.py
T
2024-06-27 21:46:29 +08:00

43 lines
1.0 KiB
Python

# -*- coding: utf-8 -*-
import random
from odoo import api, models, tools, _
import logging
_logger = logging.getLogger(__name__)
class WecomApiToolsString(models.AbstractModel):
_name = "wecomapi.tools.string"
_description = "Wecom API Tools - Fields"
def str2bool(self):
"""
字符串转布尔值
:param val: 字符串
:return: 布尔值
"""
# return self.value.lower() in ("yes", "true", "t", "1")
if self.value.lower() in ["true", "t", "1"]: # type: ignore
return True
elif self.value.lower() in ["false", "f", "0"]: # type: ignore
return False
else:
return False
# def int2bool(self):
# """
# 整形转布尔值
# :param val: 整形
# :return: 布尔值
# """
# if self.value.lower() in ["true", "t", "1"]:
# return True
# elif self.value.lower() in ["false", "f", "0"]:
# return False
# else:
# return False