123456789101112131415161718192021222324252627282930313233 |
- # -*- coding: utf-8 -*-
- from odoo import models, fields, api
- class WxappCompany(models.Model):
- _name = 'wxapp.company'
- _description = u'小程序公司'
- name = fields.Char(string='公司名称', required=True)
- number = fields.Char(string=u'识别码', required=True)
- code = fields.Char(string=u'编码', required=True)
- remark = fields.Char(string=u'摘要')
- _sql_constraints = [(
- 'wxapp_user_union_id_unique',
- 'UNIQUE (name)',
- u'已存在同名公司!'
- ),
- (
- 'wxapp_user_open_id_unique',
- 'UNIQUE (code)',
- u'已存在相同编码!'
- ),
- ]
- def query_code(self, company_name, company_number):
- domain = [('name', '=', company_name), ('number', '=', company_number)]
- _company_list = self.search(domain)
- if not _company_list:
- return None
- return _company_list[0].code
|