wxapp_company.py 928 B

123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: utf-8 -*-
  2. from odoo import models, fields, api
  3. class WxappCompany(models.Model):
  4. _name = 'wxapp.company'
  5. _description = u'小程序公司'
  6. name = fields.Char(string='公司名称', required=True)
  7. number = fields.Char(string=u'识别码', required=True)
  8. code = fields.Char(string=u'编码', required=True)
  9. remark = fields.Char(string=u'摘要')
  10. _sql_constraints = [(
  11. 'wxapp_user_union_id_unique',
  12. 'UNIQUE (name)',
  13. u'已存在同名公司!'
  14. ),
  15. (
  16. 'wxapp_user_open_id_unique',
  17. 'UNIQUE (code)',
  18. u'已存在相同编码!'
  19. ),
  20. ]
  21. def query_code(self, company_name, company_number):
  22. domain = [('name', '=', company_name), ('number', '=', company_number)]
  23. _company_list = self.search(domain)
  24. if not _company_list:
  25. return None
  26. return _company_list[0].code