Exemplo n.º 1
0
class cloudserver_domain(models.Model):
    '''
    实体:域名管理
    '''
    _name = 'oa.cloudserver.domain'
    provider = fields.Selection([('ali', '阿里'), ('tencent', '腾讯')],
                                string='提供商')
    name = fields.Char(string='域名')
    owner = fields.Char(string='域名所有者')
    endtime = fields.Datetime(string='到期时间')
    state = fields.Selection([('normal', '正常'), ('disabled', '已停用')],
                             string='域名状态')
    dns = fields.Char('DNS服务器')
    contact_person = fields.Char('联系人')
    country = fields.Many2one('res.country', string='国家')
    province = fields.Many2one('res.country.state', string='省份')
    city = fields.Char(string='城市')
    address = fields.Char(string='通讯地址')
    zip = fields.Char(string='邮编')
    mail = fields.Char(string='联系人邮箱')
    phone1 = fields.Char(string='联系电话1')
    phone2 = fields.Char(string='联系电话2')
    fax = fields.Char(string='传真')
    description = fields.Text(string="描述")
    account4domain = fields.Char(string='申请账号')
    record_provider = fields.Selection([('ali', '阿里'), ('tencent', '腾讯')],
                                       string='备案系统')
    record_sys_account = fields.Char(string='备案系统账号')
    record_sys_pwd = fields.Char(string='备案系统密码')
    record_no = fields.Char(string='备案号')
    record_pwd = fields.Char(string='备案密码')
    record_description = fields.Text(string='备案描述')

    _sql_constraints = [('name_uniq', 'unique(name)', '域名必须唯一!')]
Exemplo n.º 2
0
class OpHealth(models.Model):
    _name = 'op.health'
    _rec_name = 'student_id'
    _description = """Health Detail for Students and Faculties"""

    type = fields.Selection([('student', 'Student'), ('faculty', 'Faculty')],
                            'Type',
                            default='student',
                            required=True)
    student_id = fields.Many2one('op.student', 'Student')
    faculty_id = fields.Many2one('op.faculty', 'Faculty')
    height = fields.Float('Height(C.M.)', required=True)
    weight = fields.Float('Weight', required=True)
    blood_group = fields.Selection([('A+', 'A+ve'), ('B+', 'B+ve'),
                                    ('O+', 'O+ve'), ('AB+', 'AB+ve'),
                                    ('A-', 'A-ve'), ('B-', 'B-ve'),
                                    ('O-', 'O-ve'), ('AB-', 'AB-ve')],
                                   'Blood Group',
                                   required=True)
    physical_challenges = fields.Boolean('Physical Challenge?', default=False)
    physical_challenges_note = fields.Text('Physical Challenge')
    major_diseases = fields.Boolean('Major Diseases?', default=False)
    major_diseases_note = fields.Text('Major Diseases')
    eyeglasses = fields.Boolean('Eye Glasses?')
    eyeglasses_no = fields.Char('Eye Glasses', size=64)
    regular_checkup = fields.Boolean('Any Regular Checkup Required?',
                                     default=False)
    health_line = fields.One2many('op.health.line', 'health_id',
                                  'Checkup Lines')

    @api.constrains('height', 'weight')
    def check_height_weight(self):
        if self.height <= 0.0 or self.weight <= 0.0:
            raise ValidationError("Enter proper height and weight!")
Exemplo n.º 3
0
class OpHealthLine(models.Model):
    _name = 'op.health.line'

    health_id = fields.Many2one('op.health', 'Health')
    date = fields.Date('Date', default=lambda self: fields.Date.today())
    name = fields.Text('Checkup Detail', required=True)
    recommendation = fields.Text('Checkup Recommendation')
Exemplo n.º 4
0
class pos_cache(models.Model):
    _name = 'pos.cache'

    cache = fields.Binary()
    product_domain = fields.Text(required=True)
    product_fields = fields.Text(required=True)

    config_id = fields.Many2one('pos.config',
                                ondelete='cascade',
                                required=True)
    compute_user_id = fields.Many2one('res.users',
                                      'Cache compute user',
                                      required=True)

    @api.model
    def refresh_all_caches(self):
        self.env['pos.cache'].search([]).refresh_cache()

    @api.one
    def refresh_cache(self):
        products = self.env['product.product'].search(
            self.get_product_domain())
        prod_ctx = products.with_context(
            pricelist=self.config_id.pricelist_id.id,
            display_default_code=False)
        prod_ctx = prod_ctx.sudo(self.compute_user_id.id)
        res = prod_ctx.read(self.get_product_fields())
        datas = {
            'cache': cPickle.dumps(res, protocol=cPickle.HIGHEST_PROTOCOL),
        }

        self.write(datas)

    @api.model
    def get_product_domain(self):
        return literal_eval(self.product_domain)

    @api.model
    def get_product_fields(self):
        return literal_eval(self.product_fields)

    @api.model
    def get_cache(self, domain, fields):
        if not self.cache or domain != self.get_product_domain(
        ) or fields != self.get_product_fields():
            self.product_domain = str(domain)
            self.product_fields = str(fields)
            self.refresh_cache()

        return cPickle.loads(self.cache)
Exemplo n.º 5
0
class OpAssignmentSubLine(models.Model):
    _name = 'op.assignment.sub.line'
    _inherit = 'mail.thread'
    _rec_name = 'assignment_id'
    _description = 'Assignment Submission'

    assignment_id = fields.Many2one('op.assignment',
                                    'Assignment',
                                    required=True)
    student_id = fields.Many2one('op.student',
                                 'Student',
                                 default=lambda self: self.env['op.student'].
                                 search([('user_id', '=', self.env.uid)]),
                                 required=True)
    description = fields.Text('Description', track_visibility='onchange')
    state = fields.Selection([('draft', 'Draft'), ('submit', 'Submitted'),
                              ('reject', 'Rejected'),
                              ('change', 'Change Req.'),
                              ('accept', 'Accepted')],
                             'State',
                             default='draft',
                             track_visibility='onchange')
    submission_date = fields.Datetime(
        'Submission Date',
        readonly=True,
        default=lambda self: fields.Datetime.now(),
        required=True)
    note = fields.Text('Note')

    @api.one
    def act_draft(self):
        self.state = 'draft'

    @api.one
    def act_submit(self):
        self.state = 'submit'

    @api.one
    def act_accept(self):
        self.state = 'accept'

    @api.one
    def act_change_req(self):
        self.state = 'change'

    @api.one
    def act_reject(self):
        self.state = 'reject'
Exemplo n.º 6
0
class OpBook(models.Model):
    _name = 'op.book'

    name = fields.Char('Title', size=128, required=True)
    isbn = fields.Char('ISBN Code', size=64)
    tags = fields.Many2many('op.tag', string='Tag(s)')
    author_ids = fields.Many2many(
        'op.author', string='Author(s)', required=True)
    edition = fields.Char('Edition')
    description = fields.Text('Description')
    publisher_ids = fields.Many2many(
        'op.publisher', string='Publisher(s)', required=True)
    course_ids = fields.Many2many('op.course', string='Course', required=True)
    movement_line = fields.One2many('op.book.movement', 'book_id', 'Movements')
    subject_ids = fields.Many2many(
        'op.subject', string='Subjects', required=True)
    internal_code = fields.Char('Internal Code', size=64)
    queue_ids = fields.One2many('op.book.queue', 'book_id', 'Book Queue')
    unit_ids = fields.One2many('op.book.unit', 'book_id', 'Units')

    _sql_constraints = [
        ('unique_name_isbn',
         'unique(isbn)',
         'ISBN code must be unique per book!'),
        ('unique_name_internal_code',
         'unique(internal_code)',
         'Internal Code must be unique per book!'),
    ]
Exemplo n.º 7
0
class OpExamAttendees(models.Model):
    _name = 'op.exam.attendees'
    _rec_name = 'student_id'

    student_id = fields.Many2one('op.student', 'Student', required=True)
    status = fields.Selection([('present', 'Present'), ('absent', 'Absent')],
                              'Status',
                              default="present",
                              required=True)
    marks = fields.Float('Marks')
    note = fields.Text('Note')
    exam_id = fields.Many2one('op.exam', 'Exam', required=True)
    course_id = fields.Many2one('op.course', 'Course', readonly=True)
    batch_id = fields.Many2one('op.batch', 'Batch', readonly=True)

    @api.onchange('exam_id')
    def onchange_exam(self):
        self.course_id = self.exam_id.session_id.course_id
        self.batch_id = self.exam_id.session_id.batch_id
        self.student_id = False

    @api.constrains('marks')
    def _check_marks(self):
        if self.marks < 0.0:
            raise ValidationError("Enter proper marks!")
Exemplo n.º 8
0
class plm_relation_line(models.Model):
    _name       = 'mrp.bom.line'
    _inherit    = 'mrp.bom.line'
    _order      = "itemnum"

    @api.one
    def _get_child_bom_lines(self):
        """
            If the BOM line refers to a BOM, return the ids of the child BOM lines
        """
        bom_obj = self.env['mrp.bom']
        for bom_line in self:
            bom_id = bom_obj._bom_find(
                                        product_tmpl_id=bom_line.product_id.product_tmpl_id.id,
                                        product_id=bom_line.product_id.id, 
                                        bomType=bom_line.type)
            if bom_id:
                child_bom = bom_obj.browse(bom_id)
                for childBomLine in child_bom.bom_line_ids:
                    childBomLine._get_child_bom_lines()
                self.child_line_ids = [x.id for x in child_bom.bom_line_ids]
            else:
                self.child_line_ids = False

    state                   =   fields.Selection    (related="product_id.state",                string=_("Status"),     help=_("The status of the product in its LifeCycle."),  store=False)
    engineering_revision    =   fields.Integer      (related="product_id.engineering_revision", string=_("Revision"),   help=_("The revision of the product."),                 store=False)
    description             =   fields.Text         (related="product_id.description",          string=_("Description"),                                                        store=False)
    weight_net              =   fields.Float        (related="product_id.weight",               string=_("Weight Net"),                                                         store=False)
    child_line_ids          =   fields.One2many     ("mrp.bom.line",compute=_get_child_bom_lines,string=_("BOM lines of the referred bom"))
Exemplo n.º 9
0
class ResPartnerIDtype(models.Model):
    _name = 'res.partner.idtype'
    _description = 'Identificacion Tipo de Documento'
    _order = 'sequence'

    name = fields.Char(required=True)
    code = fields.Char(required=True)
    sequence = fields.Integer()
    active = fields.Boolean(default=True)
    note = fields.Text()
    on_company = fields.Boolean(
        string=u'On Company?',
        default=True,
        help="Id type for use on Company"
    )
    on_contact = fields.Boolean(
        string=u'On Contact?',
        default=True,
        help="Id type for use on Contacts"
    )
    on_merchant = fields.Boolean(
        string=u'On Merchants?',
        default=True,
        help="Id type for use on Merchants"
    )
Exemplo n.º 10
0
class DocumentPageShowDiff(models.TransientModel):
    """Display Difference for History."""

    _name = 'wizard.document.page.history.show_diff'

    def get_diff(self):
        """Return the Difference between two document."""
        history = self.env["document.page.history"]
        ids = self.env.context.get('active_ids', [])

        diff = ""
        if len(ids) == 2:
            if ids[0] > ids[1]:
                diff = history.getDiff(ids[1], ids[0])
            else:
                diff = history.getDiff(ids[0], ids[1])
        elif len(ids) == 1:
            old = history.browse(ids[0])
            nids = history.search([('page_id', '=', old.page_id.id)],
                                  order='id DESC',
                                  limit=1)
            diff = history.getDiff(ids[0], nids.id)
        else:
            raise exceptions.Warning(
                _("Select one or maximum two history revisions!"))
        return diff

    diff = fields.Text('Diff', readonly=True, default=get_diff)
Exemplo n.º 11
0
class cloudserver_server(models.Model):
    '''
    实体:
    '''
    _name = 'oa.cloudserver.server'
    provider = fields.Selection([('ali', '阿里'), ('tencent', '腾讯')],
                                string='提供商')
    uses = fields.Selection([('app', '应用'), ('db', '数据库'),
                             ('app+db', '应用+数据库'), ('mail', '邮箱')],
                            string='用途')
    server_id = fields.Char(string='服务器ID')
    server_name = fields.Char(string='服务器名称')
    local = fields.Char(string='地域')
    area = fields.Char(string='所在可用区')
    use_desp = fields.Char('用途简述')
    description = fields.Text('描述')
    cpu = fields.Char(string='CPU')
    memory = fields.Char(string='内存(G)')
    disk = fields.Char(string='硬盘(G)')
    os = fields.Selection([('windows', 'Windows Server'),
                           ('ubuntu', 'Ubuntu')],
                          string='操作系统')
    ip_internet = fields.Char(string='公网IP')
    ip_intranet = fields.Char(string='内网IP')
    # bill_method = fields.Char(string='带宽计费方式')
    bandwidth = fields.Char(string='带宽(M)')
    # pay_method = fields.Selection([('pack_year_month', '包年包月'), ('flow_rate', '按流量')],string='付费方式')
    createon = fields.Datetime(string='创建时间')
    endon = fields.Datetime(string='到期时间')
    domain_name = fields.Char(string='域名')
    account4app = fields.Char(string='申请账号')
    login_name = fields.Char(string='用户名')
    login_pwd = fields.Char(string='密码')
    data_disk = fields.Char(string='数据盘(G)')
    _sql_constraints = [('server_id_uniq', 'unique(server_id)', '服务器ID必须唯一!')]
Exemplo n.º 12
0
class OpActivity(models.Model):
    _name = 'op.activity'
    _rec_name = 'student_id'
    _inherit = 'mail.thread'

    student_id = fields.Many2one('op.student', 'Student', required=True)
    faculty_id = fields.Many2one('op.faculty', 'Faculty')
    type_id = fields.Many2one('op.activity.type', 'Activity Type')
    description = fields.Text('Description')
    date = fields.Date('Date', default=fields.Date.today())
Exemplo n.º 13
0
class intrastat_transaction(models.Model):
    _name = 'l10n_be_intrastat.transaction'
    _rec_name = 'code'

    code = fields.Char('Code', required=True, readonly=True)
    description = fields.Text('Description', readonly=True)

    _sql_constraints = [
        ('l10n_be_intrastat_trcodeunique', 'UNIQUE (code)',
         'Code must be unique.'),
    ]
Exemplo n.º 14
0
class product_product_functionlist(models.Model):
    '''
    功能:新增产品子表,“功能清单”
    '''
    _name = 'product.product.function'
    #名称,描述,是否必选,标准价格
    name=fields.Char(string='名称')
    description=fields.Text(string='描述')
    must_choose=fields.Boolean(string='是否必选')
    standard_price=fields.Float(digits=(12, 2),string='标准价格')
    product_id=fields.Many2one('product.product',string='商品')
Exemplo n.º 15
0
class MailMessageSubtype(models.Model):
    """ Class holding subtype definition for messages. Subtypes allow to tune
        the follower subscription, allowing only some subtypes to be pushed
        on the Wall. """
    _name = 'mail.message.subtype'
    _description = 'Message subtypes'
    _order = 'sequence, id'

    name = fields.Char(
        'Message Type',
        required=True,
        translate=True,
        help='Message subtype gives a more precise type on the message, '
        'especially for system notifications. For example, it can be '
        'a notification related to a new record (New), or to a stage '
        'change in a process (Stage change). Message subtypes allow to '
        'precisely tune the notifications the user want to receive on its wall.'
    )
    description = fields.Text(
        'Description',
        translate=True,
        help='Description that will be added in the message posted for this '
        'subtype. If void, the name will be added instead.')
    internal = fields.Boolean(
        'Internal Only',
        help=
        'Messages with internal subtypes will be visible only by employees, aka members of base_user group'
    )
    parent_id = fields.Many2one(
        'mail.message.subtype',
        string='Parent',
        ondelete='set null',
        help=
        'Parent subtype, used for automatic subscription. This field is not '
        'correctly named. For example on a project, the parent_id of project '
        'subtypes refers to task-related subtypes.')
    relation_field = fields.Char(
        'Relation field',
        help='Field used to link the related model to the subtype model when '
        'using automatic subscription on a related document. The field '
        'is used to compute getattr(related_document.relation_field).')
    res_model = fields.Char(
        'Model',
        help=
        "Model the subtype applies to. If False, this subtype applies to all models."
    )
    default = fields.Boolean('Default',
                             default=True,
                             help="Activated by default when subscribing.")
    sequence = fields.Integer('Sequence',
                              default=1,
                              help="Used to order subtypes.")
    hidden = fields.Boolean('Hidden',
                            help="Hide the subtype in the follower options")
Exemplo n.º 16
0
class OpAchievement(models.Model):
    _name = 'op.achievement'
    _rec_name = 'student_id'

    student_id = fields.Many2one('op.student', 'Student', required=True)
    faculty_id = fields.Many2one('op.faculty', 'Faculty', required=True)
    achievement_type = fields.Many2one(
        'op.achievement.type', 'Achievement Type', required=True)
    description = fields.Text('Description', required=True)
    achievement_date = fields.Date(
        'Date', required=True, default=fields.Date.today())
Exemplo n.º 17
0
class HrEquipmentCategory(models.Model):
    _name = 'hr.equipment.category'
    _inherits = {"mail.alias": "alias_id"}
    _inherit = ['mail.thread']
    _description = 'Asset Category'

    @api.one
    @api.depends('equipment_ids')
    def _compute_fold(self):
        self.fold = False if self.equipment_count else True

    name = fields.Char('Category Name', required=True, translate=True)
    user_id = fields.Many2one('res.users', 'Responsible', track_visibility='onchange', default=lambda self: self.env.uid)
    color = fields.Integer('Color Index')
    note = fields.Text('Comments', translate=True)
    equipment_ids = fields.One2many('hr.equipment', 'category_id', string='Equipments', copy=False)
    equipment_count = fields.Integer(string="Equipment", compute='_compute_equipment_count')
    maintenance_ids = fields.One2many('hr.equipment.request', 'category_id', copy=False)
    maintenance_count = fields.Integer(string="Maintenance", compute='_compute_maintenance_count')
    alias_id = fields.Many2one(
        'mail.alias', 'Alias', ondelete='cascade', required=True,
        help="Email alias for this equipment category. New emails will automatically "
        "create new maintenance request for this equipment category.")
    fold = fields.Boolean(string='Folded in Maintenance Pipe', compute='_compute_fold', store=True)

    @api.multi
    def _compute_equipment_count(self):
        equipment_data = self.env['hr.equipment'].read_group([('category_id', 'in', self.ids)], ['category_id'], ['category_id'])
        mapped_data = dict([(m['category_id'][0], m['category_id_count']) for m in equipment_data])
        for category in self:
            category.equipment_count = mapped_data.get(category.id, 0)

    @api.multi
    def _compute_maintenance_count(self):
        maintenance_data = self.env['hr.equipment.request'].read_group([('category_id', 'in', self.ids)], ['category_id'], ['category_id'])
        mapped_data = dict([(m['category_id'][0], m['category_id_count']) for m in maintenance_data])
        for category in self:
            category.maintenance_count = mapped_data.get(category.id, 0)

    @api.model
    def create(self, vals):
        self = self.with_context(alias_model_name='hr.equipment.request', alias_parent_model_name=self._name)
        category_id = super(HrEquipmentCategory, self).create(vals)
        category_id.alias_id.write({'alias_parent_thread_id': category_id.id, 'alias_defaults': {'category_id': category_id.id}})
        return category_id

    @api.multi
    def unlink(self):
        for category in self:
            if category.equipment_ids or category.maintenance_ids:
                raise UserError(_("You cannot delete an equipment category containing equipments or maintenance requests."))
        res = super(HrEquipmentCategory, self).unlink()
        return res
Exemplo n.º 18
0
class base_apppartner(models.Model):
    _name = 'base.apppartner'

    key = fields.Char(string='关键字', required=True, readonly=True, default=lambda self: uuid.uuid4())
    user = fields.Many2one('res.users', '用户')
    apppartner_type = fields.Selection(
        [('officalaccount', '微信公众号'), ('enterpriseaccount', '微信企业号应用'),('third_platform','微信第三方平台'), ('youzan', '有赞平台'),
         ('taobao', '淘宝平台')], string="接入平台类型")
    officalaccount=fields.Many2one('wx.officialaccount',string="微信公众号")
    enterpriseaccount=fields.Many2one('wx.officialaccount',string="微信企业号应用")
    third_platform=fields.Many2one('wx.third_platform',string="微信第三方平台")
    apppartner_desc=fields.Text("备注")
Exemplo n.º 19
0
class SaleWorkflowProcess(models.Model):
    """ A workflow process is the setup of the automation of a sales order.

    Each sales order can be linked to a workflow process.
    Then, the options of the workflow will change how the sales order
    behave, and how it is automatized.

    A workflow process may be linked with a Sales payment method, so
    each time a payment method is used, the workflow will be applied.
    """
    _name = "sale.workflow.process"
    _description = "Sale Workflow Process"

    name = fields.Char()
    picking_policy = fields.Selection(
        selection=[('direct', 'Deliver each product when available'),
                   ('one', 'Deliver all products at once')],
        string='Shipping Policy',
        default='direct',
    )
    order_policy = fields.Selection(
        selection=[('prepaid', 'Before Delivery'), ('manual', 'On Demand'),
                   ('picking', 'On Delivery Order')],
        string='Invoice Policy',
        default='manual',
    )
    invoice_quantity = fields.Selection(
        selection=[('order', 'Ordered Quantities'),
                   ('procurement', 'Shipped Quantities')],
        string='Invoice on',
        default='order',
    )
    validate_order = fields.Boolean(string='Validate Order')
    create_invoice_on = fields.Selection(
        selection=[('manual', 'No automatic invoice'),
                   ('on_order_confirm', 'On confirmation of Sale Order'),
                   ('on_picking_done', 'After Delivery')],
        required=True,
        string='Create Invoice',
        default='manual',
    )
    validate_invoice = fields.Boolean(string='Validate Invoice')
    validate_picking = fields.Boolean(string='Confirm and Close Picking')
    invoice_date_is_order_date = fields.Boolean(
        string='Force Invoice Date',
        help="When checked, the invoice date will be "
        "the same than the order's date")
    warning = fields.Text('Warning Message',
                          translate=True,
                          help='If set, display the message when a '
                          'user selects the process on a sale order')
    section_id = fields.Many2one(comodel_name='crm.case.section',
                                 string='Sales Team')
Exemplo n.º 20
0
class OpAssignment(models.Model):
    _name = 'op.assignment'
    _inherit = 'mail.thread'
    _description = 'Assignment'

    name = fields.Char('Name', size=16, required=True)
    course_id = fields.Many2one('op.course', 'Course', required=True)
    batch_id = fields.Many2one('op.batch', 'Batch', required=True)
    subject_id = fields.Many2one('op.subject', 'Subject', required=True)
    faculty_id = fields.Many2one(
        'op.faculty', 'Faculty', default=lambda self: self.env[
            'op.faculty'].search([('user_id', '=', self.env.uid)]),
        required=True)
    assignment_type_id = fields.Many2one(
        'op.assignment.type', 'Assignment Type', required=True)
    marks = fields.Float('Marks', track_visibility='onchange')
    description = fields.Text('Description', required=True)
    state = fields.Selection(
        [('draft', 'Draft'), ('publish', 'Published'),
         ('finish', 'Finished')], 'State', required=True, default='draft',
        track_visibility='onchange')
    issued_date = fields.Datetime(
        'Issued Date', required=True,
        default=lambda self: fields.Datetime.now())
    submission_date = fields.Datetime(
        'Submission Date', required=True,
        track_visibility='onchange')
    allocation_ids = fields.Many2many('op.student', string='Allocated To')
    assignment_sub_line = fields.One2many(
        'op.assignment.sub.line', 'assignment_id', 'Submissions')
    reviewer = fields.Many2one('op.faculty', 'Reviewer')

    @api.one
    @api.constrains('issued_date', 'submission_date')
    def check_dates(self):
        issued_date = fields.Date.from_string(self.issued_date)
        submission_date = fields.Date.from_string(self.submission_date)
        if issued_date > submission_date:
            raise ValidationError(
                "Submission Date cannot be set before Issue Date.")

    @api.onchange('course_id')
    def onchange_course(self):
        self.batch_id = False

    @api.one
    def act_publish(self):
        self.state = 'publish'

    @api.one
    def act_finish(self):
        self.state = 'finish'
Exemplo n.º 21
0
class training(models.Model):
    '''
    实体:培训记录
    '''
    _name = 'hr.training.record'

    lession_id = fields.Many2one(
        'hr.training.lession',
        string='培训课程',
        required=True,
    )
    date = fields.Date(required=True, string='培训日期')
    time = fields.Char(required=True, string='培训时间')
    address = fields.Char(required=True, string='培训地点')
    teacher = fields.Char(required=True, string='培训讲师')
    student = fields.Many2many('hr.employee',
                               'training_employee_rel',
                               'training_id',
                               'employee_id',
                               required=True,
                               string='培训学员')
    price = fields.Float(digits=(16, 2), string='培训费用', default=0.0)
    description = fields.Text(string='培训描述')

    @api.onchange('lession_id')
    def change_lession(self):
        '''
        功能:默认根据课程获取培训费用、培训讲师
        :return:
        '''
        if self.lession_id:
            self.price = self.lession_id.price
            teachers = ''
            if self.lession_id.external_teacher:
                teachers = self.lession_id.external_teacher + ','

            #取内聘讲师
            sql_str = '''select emp.name_related from lession_teacher_rel as r join hr_employee as emp on r.teacher_id=emp.id
                              where r.lession_id=%s
                              ''' % (self.lession_id.id)

            _logger.info('根据培训课程ID,查找讲师=%s' % sql_str)
            self._cr.execute(sql_str)
            res = self._cr.fetchall()
            for r in res:
                teachers += r[0] + ','
            if len(teachers) > 0:
                teachers = teachers[0:-1]

            self.teacher = teachers
            self.description = self.lession_id.description
Exemplo n.º 22
0
class wx_product_image(models.Model):
    _name = 'wx.product.images'
    wx_product_id = fields.Many2one('wx.product', '微信商品')
    image_uses = fields.Selection([('main_image', '主图'),
                                   ('other_image', '其它图片'),
                                   ('detail_image', '详情图片')],
                                  string='图片用途',
                                  default='detail_image')
    serial_number = fields.Integer(string='序号')
    image = fields.Binary("图片")
    text = fields.Text(string="文字")
    image_url = fields.Char(string='图片地址')
    sync_upload = fields.Boolean(string='同步时需上传', help='同步商品时有效')
    _order = 'serial_number'
Exemplo n.º 23
0
class ir_model_fields(models.Model):
    """Addition of text fields to fields."""
    _inherit = "ir.model.fields"

    notes = fields.Text('Notes to developers.')
    helper = fields.Text('Helper')
    # TODO: Make column1 and 2 required if a model has a m2m to itself
    column1 = fields.Char(
        'Column1',
        help=_("name of the column referring to 'these' records in the "
               "relation table"),
    )
    column2 = fields.Char(
        'Column2',
        help=_("name of the column referring to 'those' records in the "
               "relation table"),
    )
    limit = fields.Integer('Read limit', help=_("Read limit"))
    client_context = fields.Char(
        'Context',
        help=_("Context to use on the client side when handling the field "
               "(python dictionary)"),
    )
Exemplo n.º 24
0
class news(models.Model):
    _name = 'wx.message_mpnews_template'
    news_id = fields.Many2one('wx.mpnews_message_template')
    message_title = fields.Text(string="图文消息标题")
    message_description = fields.Char(string="图文消息描述")
    message_picurl = fields.Char(string="图片链接")  # 较好的效果为大图360*200,小图200*200
    message_url = fields.Char(string="消息跳转链接")
    message_imagedata = fields.Binary(string="图片信息")
    model_id = fields.Many2one(
        'ir.model',
        '应用模型',
        ondelete='cascade',
        copy=False,
        help="Base model on which the server action runs.")
Exemplo n.º 25
0
class invocie_type(models.Model):
    '''
    模型:发票类型(档案),
    使用者:日常流水
    '''
    _name = 'oa_journal.invoice.type'
    _description = 'OA Journal Invoice Type'
    name = fields.Char(string='发票类型', required=True)
    active = fields.Boolean(string='生效', help='不生效时,将不显示')
    note = fields.Text(string='备注')
    invoicing_method = fields.Selection([('simple', '没分组'),
                                         ('grouped', '已分组')],
                                        '开票方式',
                                        required=True)
Exemplo n.º 26
0
class oa_journal(models.Model):
    '''
    模型:日常流水
    '''
    _name = 'oa.journal'
    _description = 'OA Journal'
    name = fields.Char('单号', required=True, select=True, copy=False, default=lambda obj: '/')
    item = fields.Many2one('product.product', string='料品')
    spec = fields.Char(string='规格')
    description = fields.Text(string='描述')
    total_debit = fields.Float(digits=(12, 2), string='金额', required=True)
    invoice_type = fields.Many2one('oa_journal.invoice.type', string='发票类型')
    mode_of_payment = fields.Selection(
        [('Cash', '现金'), ('Tenpay', '财付通支付'), ('Alipay', '支付宝支付'), ('Transfer', '网银转账'),
         ('Credit', '信用卡支付'), ('Wechat', '微信支付')], string='支付方式', required=True)
    payer_employee = fields.Many2one('hr.employee', string="付款人", required=True,
                                     default=lambda self: _employee_get(self, self.env.cr, self.env.user.id))
    paidon = fields.Datetime(string='付款时间', required=True, default=lambda self: datetime.datetime.now())
    supplier = fields.Many2one('res.partner', string='供应商')
    supplier_order = fields.Char(string='供应商单号')
    receivedon = fields.Datetime(string='收货时间')
    storage_location = fields.Char(string='存储地点')
    collar_employee = fields.Many2one("hr.employee", string='领用人')
    address = fields.Char(string='地址')
    expense_claim = fields.Many2one('hr.expense.expense', string='报销单')
    claim_amount = fields.Float(digits=(12, 2),string='销抵金额')
    state = fields.Selection([('draft', '草稿'), ('paid', '已付款'), ('received', '已收货'), ('expensed', '已报销'),
                              ('closed', '已关闭')], string='状态', readonly=True, default='draft')
    ec_platform = fields.Many2one("oa_journal.ecplatform", string='电商平台')
    extend_col1 = fields.Char(string='扩展字段1')
    company_id = fields.Many2one("res.company", string='公司')

    _sql_constraints = [
        ('name_uniq', 'unique(name, company_id)', '单号必须唯一!')
    ]
    _order = "name desc"

    @api.model
    def create(self, vals):
        if vals.get('name', '/') == '/':
            vals['name'] = self.env['ir.sequence'].get('oa.journal') or '/'

        _defaults = {
            'name': '/',
        }
        return super(oa_journal, self).create(vals)
Exemplo n.º 27
0
class wx_text_message_template(models.Model):
    _inherit = 'wx.message_template_base'
    _name = 'wx.text_message_template'

    message_type = fields.Many2one(
        'wx.messagetype',
        string='消息类型',
        readonly=True,
        default=lambda self: _messagetype_get(self, self.env.cr, self.env.user.
                                              id, 'text'))
    message_content = fields.Text("文字消息内容")
    model_id = fields.Many2one(
        'ir.model',
        '应用模型',
        ondelete='cascade',
        copy=False,
        help="Base model on which the server action runs.")
Exemplo n.º 28
0
class RecruitmentStage(models.Model):
    _name = "hr.recruitment.stage"
    _description = "Stage of Recruitment"
    _order = 'sequence'

    name = fields.Char("Stage name", required=True, translate=True)
    sequence = fields.Integer(
        "Sequence", default=1,
        help="Gives the sequence order when displaying a list of stages.")
    job_ids = fields.Many2many(
        'hr.job', 'job_stage_rel', 'stage_id', 'job_id',
        string='Job Stages',
        default=lambda self: [(4, self._context['default_job_id'])] if self._context.get('default_job_id') else None)
    requirements = fields.Text("Requirements")
    template_id = fields.Many2one(
        'mail.template', "Use template",
        help="If set, a message is posted on the applicant using the template when the applicant is set to the stage.")
    fold = fields.Boolean(
        "Folded in Recruitment Pipe",
        help="This stage is folded in the kanban view when there are no records in that stage to display.")
Exemplo n.º 29
0
class wx_mpnews_message_record(models.Model):
    _inherit = 'wx.message_record'
    _name = 'wx.mpnews_message_record'
    message_type = fields.Many2one(
        'wx.messagetype',
        string='消息类型',
        default=lambda self: _messagetype_get(self, self.env.cr, self.env.user.
                                              id, 'imagetext'))
    message_news = fields.One2many('wx.message_mpnews_record',
                                   'news_id',
                                   string="图文消息")
    #toUserName = fields.Many2one('wx.membership',string="接收方/发送方")
    message_template = fields.Many2one('wx.mpnews_message_template',
                                       string="链接消息模板")
    message_title = fields.Text(string="图文消息标题")
    message_description = fields.Char(string="图文消息描述")
    message_picurl = fields.Char(string="图片链接")  # 较好的效果为大图360*200,小图200*200
    message_url = fields.Char(string="消息跳转链接")
    isList = fields.Boolean("是否列表")
    association_order = fields.Char('关联实体编码或单号')
    qy_toUserName = fields.Many2one('hr.employee', string="企业应用接收方/发送方")
Exemplo n.º 30
0
class wx_mpnews_message_template(models.Model):
    _inherit = 'wx.message_template_base'
    _name = 'wx.mpnews_message_template'
    message_type = fields.Many2one(
        'wx.messagetype',
        string='消息类型',
        default=lambda self: _messagetype_get(self, self.env.cr, self.env.user.
                                              id, 'imagetext'))
    message_news = fields.One2many('wx.message_mpnews_template',
                                   'news_id',
                                   string="图文消息")
    message_title = fields.Text(string="图文消息标题")
    message_description = fields.Char(string="图文消息描述")
    message_picurl = fields.Char(string="图片链接")  # 较好的效果为大图360*200,小图200*200
    message_url = fields.Char(string="消息跳转链接")
    message_imagedata = fields.Binary(string="图片信息")
    model_id = fields.Many2one(
        'ir.model',
        '应用模型',
        ondelete='cascade',
        copy=False,
        help="Base model on which the server action runs.")