中国本土应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1KB

  1. # -*- coding: utf-8 -*-
  2. import html2text
  3. from odoo import api, models, tools, _
  4. class WecomApiToolsTypeConvert(models.AbstractModel):
  5. _name = "wecomapi.tools.convert"
  6. _description = "Wecom API Tools - Type convert"
  7. def html2text_handle(self, body_html):
  8. # 转换markdown格式
  9. if bool(body_html):
  10. return html2text.html2text(body_html)
  11. else:
  12. return None
  13. def str2bool(self):
  14. """
  15. 字符串转布尔值
  16. :param val: 字符串
  17. :return: 布尔值
  18. """
  19. # return self.value.lower() in ("yes", "true", "t", "1")
  20. if self.value.lower() in ["true", "t", "1"]:
  21. return True
  22. elif self.value.lower() in ["false", "f", "0"]:
  23. return False
  24. else:
  25. return False
  26. def sex2gender(self, sex):
  27. """
  28. 性别转换
  29. """
  30. if sex == "1":
  31. return "male"
  32. elif sex == "2":
  33. return "female"
  34. else:
  35. return "other"
  36. def gendge2sex(self, gender):
  37. if gender == "male":
  38. return "1"
  39. elif gender == "female":
  40. return "2"
上海开阖软件有限公司 沪ICP备12045867号-1