Esempio n. 1
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!")
Esempio n. 2
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必须唯一!')]
Esempio n. 3
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)', '域名必须唯一!')]
Esempio n. 4
0
class wx_message_record(models.AbstractModel):
    _name = 'wx.message_record'

    message_event = fields.Selection([('receive', '收'), ('send', '发')],
                                     require=True,
                                     string="消息事件类型")
    association_user = fields.Many2one('res.partner', string="关联用户")
    message_type = fields.Many2one('wx.messagetype', string='消息类型')
    officialaccount = fields.Many2one('wx.officialaccount', '微信服务号/企业号应用')
    createTime = fields.Datetime("消息创建时间")
    session_id = fields.Char("会话ID")
    message_status = fields.Selection([('draft', '草稿'), ('approving', '审核中'),
                                       ('approved', '审核通过'),
                                       ('sending', '发送中'),
                                       ('use_sucess', '已接受'),
                                       ('use_block', '已拒绝'),
                                       ('system_fail', '发送失败')],
                                      require=True,
                                      string="消息状态",
                                      default='draft')
    usergroup = fields.Many2many('res.users',
                                 'usergroup_id',
                                 'user_id',
                                 string="群发企业用户")
    official_username = fields.Many2one('wx.customer', string="接收方/发送方")
    send_event = fields.Many2one('wx.message.send_event', string="消息发送事件")
Esempio n. 5
0
class ProductTemplate(models.Model):
    _inherit = 'product.template'
    track_service = fields.Selection([('manual', 'Manually set quantities on order')], string='Track Service', default='manual')

    @api.multi
    @api.depends('product_variant_ids.sales_count')
    def _sales_count(self):
        for product in self:
            product.sales_count = sum([p.sales_count for p in product.product_variant_ids])

    @api.multi
    def action_view_sales(self):
        self.ensure_one()
        action = self.env.ref('sale.action_product_sale_list')
        product_ids = self.product_variant_ids.ids

        return {
            'name': action.name,
            'help': action.help,
            'type': action.type,
            'view_type': action.view_type,
            'view_mode': action.view_mode,
            'target': action.target,
            'context': "{'search_default_product_id': " + ','.join(map(str, product_ids)) + ", 'default_product_id': " + str(product_ids[0]) + "}",
            'res_model': action.res_model,
            'domain': action.domain,
        }

    sales_count = fields.Integer(compute='_sales_count', string='# Sales')
    invoice_policy = fields.Selection(
        [('order', 'Ordered quantities'),
         ('delivery', 'Delivered quantities'),
         ('cost', 'Invoice based on time and material')],
        string='Invoicing Policy', default='order')
Esempio n. 6
0
class OpStudent(models.Model):
    _name = 'op.student'
    _inherits = {'res.partner': 'partner_id'}

    @api.one
    @api.depends('roll_number_line', 'batch_id', 'course_id')
    def _get_curr_roll_number(self):
        # TO_DO:: Improve the logic by adding sequence field in course.
        if self.roll_number_line:
            for roll_no in self.roll_number_line:
                if roll_no.course_id == self.course_id and \
                        roll_no.batch_id == self.batch_id:
                    self.roll_number = roll_no.roll_number
        else:
            self.roll_number = 0

    middle_name = fields.Char('Middle Name', size=128)
    last_name = fields.Char('Last Name', size=128, required=True)
    birth_date = fields.Date('Birth Date', 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')
    gender = fields.Selection([('m', 'Male'), ('f', 'Female'), ('o', 'Other')],
                              'Gender',
                              required=True)
    nationality = fields.Many2one('res.country', 'Nationality')
    emergency_contact = fields.Many2one('res.partner', 'Emergency Contact')
    visa_info = fields.Char('Visa Info', size=64)
    id_number = fields.Char('ID Card Number', size=64)
    photo = fields.Binary('Photo')
    course_id = fields.Many2one('op.course', 'Course', required=True)
    batch_id = fields.Many2one('op.batch', 'Batch', required=True)
    roll_number_line = fields.One2many('op.roll.number', 'student_id',
                                       'Roll Number')
    partner_id = fields.Many2one('res.partner',
                                 'Partner',
                                 required=True,
                                 ondelete="cascade")
    roll_number = fields.Char('Current Roll Number',
                              compute='_get_curr_roll_number',
                              size=8,
                              store=True)
    gr_no = fields.Char("GR Number", size=20)

    @api.one
    @api.constrains('birth_date')
    def _check_birthdate(self):
        if self.birth_date > fields.Date.today():
            raise ValidationError(
                "Birth Date can't be greater than current date!")

    @api.onchange('course_id')
    def onchange_course(self):
        self.batch_id = False
Esempio n. 7
0
class plm_document_relation(models.Model):
    _name           =   'plm.document.relation'
    _inherit        =   'plm.document.relation'
    
    parent_preview  =   fields.Binary   (related="parent_id.preview",       string=_("Preview"),    store=False)
    parent_state    =   fields.Selection(related="parent_id.state",         string=_("Status"),     store=False)
    parent_revision =   fields.Integer  (related="parent_id.revisionid",    string=_("Revision"),   store=False)
    child_preview   =   fields.Binary   (related="child_id.preview",        string=_("Preview"),    store=False)
    child_state     =   fields.Selection(related="child_id.state",          string=_("Status"),     store=False)
    child_revision  =   fields.Integer  (related="child_id.revisionid",     string=_("Revision"),   store=False)
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')
Esempio n. 9
0
class OpFaculty(models.Model):
    _name = 'op.faculty'
    _inherits = {'res.partner': 'partner_id'}

    partner_id = fields.Many2one('res.partner',
                                 'Partner',
                                 required=True,
                                 ondelete="cascade")
    middle_name = fields.Char('Middle Name', size=128)
    last_name = fields.Char('Last Name', size=128, required=True)
    birth_date = fields.Date('Birth Date', 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')
    gender = fields.Selection([('male', 'Male'), ('female', 'Female')],
                              'Gender',
                              required=True)
    nationality = fields.Many2one('res.country', 'Nationality')
    emergency_contact = fields.Many2one('res.partner', 'Emergency Contact')
    visa_info = fields.Char('Visa Info', size=64)
    id_number = fields.Char('ID Card Number', size=64)
    photo = fields.Binary('Photo')
    login = fields.Char('Login',
                        related='partner_id.user_id.login',
                        readonly=1)
    last_login = fields.Datetime('Latest Connection',
                                 related='partner_id.user_id.login_date',
                                 readonly=1)
    faculty_subject_ids = fields.Many2many('op.subject', string='Subject(s)')
    emp_id = fields.Many2one('hr.employee', 'Employee')

    @api.one
    @api.constrains('birth_date')
    def _check_birthdate(self):
        if self.birth_date > fields.Date.today():
            raise ValidationError(
                "Birth Date can't be greater than current date!")

    @api.one
    def create_employee(self):
        vals = {
            'name':
            self.name + ' ' + (self.middle_name or '') + ' ' + self.last_name,
            'country_id': self.nationality.id,
            'gender': self.gender,
            'address_home_id': self.partner_id.id
        }
        emp_id = self.env['hr.employee'].create(vals)
        self.write({'emp_id': emp_id.id})
        self.partner_id.write({'supplier': True, 'employee': True})
Esempio n. 10
0
class OpLibraryCard(models.Model):
    _name = 'op.library.card'
    _rec_name = 'number'
    _description = 'Library Card'

    partner_id = fields.Many2one('res.partner',
                                 'Student/Faculty',
                                 required=True)
    number = fields.Char('Number', size=256, required=True)
    library_card_type_id = fields.Many2one('op.library.card.type',
                                           'Card Type',
                                           required=True)
    issue_date = fields.Date('Issue Date',
                             required=True,
                             default=fields.Date.today())
    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')

    _sql_constraints = [
        ('unique_library_card_number', 'unique(number)',
         'Library card Number should be unique per card!'),
    ]
Esempio n. 11
0
class product_template(models.Model):
    _inherit = "product.template"
    project_id = fields.Many2one('project.project',
                                 string='Project',
                                 ondelete='set null')
    track_service = fields.Selection(
        selection_add=[('task', 'Create a task and track hours')])
Esempio n. 12
0
class wx_customer_subscribe(models.Model):
    _name = 'wx.customer.subscribe'
    subscribe_type = fields.Selection([('subscribe', '关注'),
                                       ('cancel_ subscribe', '取消关注')],
                                      string='类型',
                                      readonly=True)
    subscribe_source = fields.Selection([('manual', '手工关注'), ('scan', '扫码关注')],
                                        string='来源',
                                        readonly=True)
    subscribe_time = fields.Datetime(string='操作时间', readonly=True)
    subscribe_key = fields.Char(string='Key', readonly=True)
    wx_customer_id = fields.Many2one('wx.customer',
                                     string='微信用户',
                                     readonly=True)
    #store_id =fields.Many2one('ycloud.o2o.store',string='门店',readonly=True)
    _order = 'subscribe_time desc'
Esempio n. 13
0
class OpPlacementOffer(models.Model):
    _name = 'op.placement.offer'
    _inherit = 'mail.thread'
    _description = 'Placement Offer'

    name = fields.Char('Company Name', required=True)
    student_id = fields.Many2one('op.student', 'Student Name', required=True)
    join_date = fields.Date('Join Date', default=fields.Date.today())
    offer_package = fields.Char('Offered Package', size=256)
    training_period = fields.Char('Training Period', size=256)
    state = fields.Selection(
        [('draft', 'Draft'), ('offer', 'Offer'), ('join', 'Join'),
         ('reject', 'Rejected'), ('cancel', 'Cancel')], 'State',
        default='draft', track_visibility='onchange')

    @api.one
    def placement_offer(self):
        self.state = 'offer'

    @api.one
    def placement_join(self):
        self.state = 'join'

    @api.one
    def confirm_rejected(self):
        self.state = 'reject'

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

    @api.one
    def confirm_cancel(self):
        self.state = 'cancel'
Esempio n. 14
0
class AccountInvoiceLine(models.Model):
    _inherit = 'account.invoice.line'

    saas_portal_client_id = fields.Many2one(
        'saas_portal.client',
        string='SaaS client',
        help=
        'reference to the SaaS client if this invoice line is created for a SaaS product'
    )
    plan_id = fields.Many2one('saas_portal.plan',
                              related='product_id.plan_id',
                              readonly=True)
    period = fields.Integer(string='Subscription period',
                            help='subsciption period in days',
                            readonly=True,
                            default=0)
    state = fields.Selection(related='invoice_id.state', readonly=True)

    @api.model
    def create(self, vals):
        product_obj = self.env['product.product'].browse(
            vals.get('product_id'))

        attribute_value_obj = product_obj.attribute_value_ids.filtered(
            lambda r: r.attribute_id.saas_code == 'SUBSCRIPTION_PERIOD')
        period = attribute_value_obj and int(
            attribute_value_obj[0].saas_code_value) or 0
        vals.update({'period': period})

        return super(AccountInvoiceLine, self).create(vals)
Esempio n. 15
0
class OpBookPurchase(models.Model):
    _name = 'op.book.purchase'
    _inherit = 'mail.thread'
    _description = 'Book Purchase Request'

    name = fields.Char('Title', size=128, required=True)
    author = fields.Char(
        'Author(s)', size=256, required=True, track_visibility='onchange')
    edition = fields.Char('Edition')
    publisher = fields.Char('Publisher(s)', size=256)
    course_ids = fields.Many2one(
        'op.course', 'Course', required=True, track_visibility='onchange')
    subject_ids = fields.Many2one(
        'op.subject', 'Subject', required=True, track_visibility='onchange')
    requested_id = fields.Many2one(
        'res.partner', 'Requested By',
        default=lambda self: self.env['res.partner'].search(
            [('user_id', '=', self.env.uid)]))
    state = fields.Selection(
        [('draft', 'Draft'), ('request', 'Requested'), ('reject', 'Rejected'),
         ('accept', 'Accepted')], 'State', select=True, readonly=True,
        default='draft', track_visibility='onchange')

    @api.one
    def act_requested(self):
        self.state = 'request'

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

    @api.one
    def act_reject(self):
        self.state = 'reject'
Esempio n. 16
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!")
Esempio n. 17
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"))
Esempio n. 18
0
class Vote(models.Model):
    _name = 'forum.post.vote'
    _description = 'Vote'

    post_id = fields.Many2one('forum.post', string='Post', ondelete='cascade', required=True)
    user_id = fields.Many2one('res.users', string='User', required=True, default=lambda self: self._uid)
    vote = fields.Selection([('1', '1'), ('-1', '-1'), ('0', '0')], string='Vote', required=True, default='1')
    create_date = fields.Datetime('Create Date', select=True, readonly=True)
    forum_id = fields.Many2one('forum.forum', string='Forum', related="post_id.forum_id", store=True)
    recipient_id = fields.Many2one('res.users', string='To', related="post_id.create_uid", store=True)

    def _get_karma_value(self, old_vote, new_vote, up_karma, down_karma):
        _karma_upd = {
            '-1': {'-1': 0, '0': -1 * down_karma, '1': -1 * down_karma + up_karma},
            '0': {'-1': 1 * down_karma, '0': 0, '1': up_karma},
            '1': {'-1': -1 * up_karma + down_karma, '0': -1 * up_karma, '1': 0}
        }
        return _karma_upd[old_vote][new_vote]

    @api.model
    def create(self, vals):
        vote = super(Vote, self).create(vals)

        # own post check
        if vote.user_id.id == vote.post_id.create_uid.id:
            raise UserError(_('Not allowed to vote for its own post'))
        # karma check
        if vote.vote == '1' and not vote.post_id.can_upvote:
            raise KarmaError('Not enough karma to upvote.')
        elif vote.vote == '-1' and not vote.post_id.can_downvote:
            raise KarmaError('Not enough karma to downvote.')

        if vote.post_id.parent_id:
            karma_value = self._get_karma_value('0', vote.vote, vote.forum_id.karma_gen_answer_upvote, vote.forum_id.karma_gen_answer_downvote)
        else:
            karma_value = self._get_karma_value('0', vote.vote, vote.forum_id.karma_gen_question_upvote, vote.forum_id.karma_gen_question_downvote)
        vote.recipient_id.sudo().add_karma(karma_value)
        return vote

    @api.multi
    def write(self, values):
        if 'vote' in values:
            for vote in self:
                # own post check
                if vote.user_id.id == vote.post_id.create_uid.id:
                    raise UserError(_('Not allowed to vote for its own post'))
                # karma check
                if (values['vote'] == '1' or vote.vote == '-1' and values['vote'] == '0') and not vote.post_id.can_upvote:
                    raise KarmaError('Not enough karma to upvote.')
                elif (values['vote'] == '-1' or vote.vote == '1' and values['vote'] == '0') and not vote.post_id.can_downvote:
                    raise KarmaError('Not enough karma to downvote.')

                # karma update
                if vote.post_id.parent_id:
                    karma_value = self._get_karma_value(vote.vote, values['vote'], vote.forum_id.karma_gen_answer_upvote, vote.forum_id.karma_gen_answer_downvote)
                else:
                    karma_value = self._get_karma_value(vote.vote, values['vote'], vote.forum_id.karma_gen_question_upvote, vote.forum_id.karma_gen_question_downvote)
                vote.recipient_id.sudo().add_karma(karma_value)
        res = super(Vote, self).write(values)
        return res
Esempio n. 19
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)
Esempio n. 20
0
class UserBadge(models.Model):
    _inherit = 'gamification.badge.user'

    level = fields.Selection([('bronze', 'bronze'), ('silver', 'silver'),
                              ('gold', 'gold')],
                             string='Forum Badge Level',
                             related="badge_id.level",
                             store=True)
Esempio n. 21
0
class SaleConfiguration(models.TransientModel):
    _inherit = 'sale.config.settings'

    module_delivery = fields.Selection(
        [(0, 'No shipping costs on sales orders'),
         (1, 'Allow adding shipping costs')], "Shipping")
    default_picking_policy = fields.Selection(
        [(0, 'Ship products when some are available, and allow back orders'),
         (1, 'Ship all products at once, without back orders')],
        "Default Shipping Policy")
    group_mrp_properties = fields.Selection(
        [(0, "Don't use manufacturing properties (recommended as its easier)"),
         (1,
          'Allow setting manufacturing order properties per order line (advanced)'
          )],
        "Properties on SO Lines",
        implied_group='sale.group_mrp_properties',
        help="Allows you to tag sales order lines with properties.")
    group_route_so_lines = fields.Selection(
        [(0, 'No order specific routes like MTO or drop shipping'),
         (1, 'Choose specific routes on sales order lines (advanced)')],
        "Order Routing",
        implied_group='sale_stock.group_route_so_lines')

    @api.multi
    def get_default_sale_config(self):
        default_picking_policy = self.env['ir.values'].get_default(
            'sale.order', 'picking_policy')
        return {
            'default_picking_policy':
            1 if default_picking_policy == 'one' else 0,
        }

    @api.multi
    def set_sale_defaults(self):
        self.ensure_one()
        if not self.env.user._is_admin():
            raise AccessError(_("Only administrators can change the settings"))

        default_picking_policy = 'one' if self.default_picking_policy else 'direct'
        self.env['ir.values'].sudo().set_default('sale.order',
                                                 'picking_policy',
                                                 default_picking_policy)
        res = super(SaleConfiguration, self).set_sale_defaults()
        return res
Esempio n. 22
0
class ycloud_wx_thirdplatform(models.Model):
    _name = 'wx.third_platform'
    _rec_name = 'auth_component_platformname'
    auth_component_appid=fields.Char("第三方平台Appid")
    auth_component_appsecret=fields.Char("第三方平台Appsecret")
    auth_component_token=fields.Char("第三方平台Token")
    auth_component_encodingasekey=fields.Char("第三方平台消息加解密密钥")
    auth_component_platformname=fields.Char("第三方平台名称")
    auth_component_platfromtype=fields.Selection([('openplatform', '公众号开放平台'), ('thirdpart', '企业号第三方应用'), ('session_service', '企业号会话服务'), ('customer_service', '企业号客服服务')],string="第三方平台类型")
Esempio n. 23
0
class ProductAttributeSaaS(models.Model):
    _inherit = "product.attribute"

    saas_code = fields.Selection('_get_saas_codes')

    def _get_saas_codes(self):
        return [('SUBSCRIPTION_PERIOD', 'SUBSCRIPTION_PERIOD'),
                ('MAX_USERS', 'MAX_USERS'),
                ('INSTALL_MODULES', 'INSTALL_MODULES'),
                ('STORAGE_LIMIT', 'STORAGE_LIMIT')]
Esempio n. 24
0
class ProductProduct(models.Model):
    _inherit = "product.template"

    expense_policy = fields.Selection(
        [('cost', 'At Cost'), ('sales_price', 'At Sales Price')],
        string='Expense Invoice Policy',
        help=
        "If you invoice at cost, the expense will be invoiced on the sale order at the cost of the analytic line;"
        "if you invoice at sales price, the price of the product will be used instead.",
        default='cost')
Esempio n. 25
0
class auth_oauth_provider(models.Model):
    _inherit = 'auth.oauth.provider'

    provider_type = [
        ('qq', 'for QQ'),
        ('pc_weixin', 'for Openplatform'),
        ('weixin', 'for Weixin'),
        ('weixin_qy', 'for Weixin_qy'),
        ('weibo', 'for Weibo'),
        ('other', 'for Other'),
    ]
    provider_type = fields.Selection(provider_type,
                                     'Provider Type',
                                     required=True)
    provider_browser = fields.Selection([('pc', '网页浏览器'), ('weixin', '微信浏览器'),
                                         ('mobile', '手机浏览器')], '支持浏览器')
    client_sercret = fields.Char("Client Sercret")
    _defaults = {
        'provider_type': 'other',
    }
Esempio n. 26
0
class OpBookQueue(models.Model):
    _name = 'op.book.queue'
    _inherit = 'mail.thread'
    _rec_name = 'user_id'
    _description = 'Book Queue Request'

    name = fields.Char("Sequence No", readonly=True, copy=False, default='/')
    partner_id = fields.Many2one('res.partner', 'Student/Faculty')
    book_id = fields.Many2one('op.book',
                              'Book',
                              required=True,
                              track_visibility='onchange')
    date_from = fields.Date('From Date',
                            required=True,
                            default=fields.Date.today())
    date_to = fields.Date('To Date', required=True)
    user_id = fields.Many2one('res.users',
                              'User',
                              readonly=True,
                              default=lambda self: self.env.uid)
    state = fields.Selection([('request', 'Request'), ('accept', 'Accepted'),
                              ('reject', 'Rejected')],
                             'Status',
                             copy=False,
                             default='request',
                             track_visibility='onchange')

    @api.onchange('user_id')
    def onchange_user(self):
        self.partner_id = self.user_id.partner_id.id

    @api.constrains('date_from', 'date_to')
    def _check_date(self):
        if self.date_from > self.date_to:
            raise ValidationError('To Date cannot be set before From Date.')

    @api.model
    def create(self, vals):
        if vals.get('name', '/') == '/':
            vals['name'] = self.env['ir.sequence'].next_by_code(
                'op.book.queue') or '/'
        return super(OpBookQueue, self).create(vals)

    @api.one
    def do_reject(self):
        self.state = 'reject'

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

    @api.one
    def do_request_again(self):
        self.state = 'request'
Esempio n. 27
0
class OpSubject(models.Model):
    _name = 'op.subject'

    name = fields.Char('Name', size=128, required=True)
    code = fields.Char('Code', size=256, required=True)
    course_id = fields.Many2one('op.course', 'Course')
    grade_weightage = fields.Float('Grade Weightage')
    type = fields.Selection(
        [('theory', 'Theory'), ('practical', 'Practical'),
         ('both', 'Both'), ('other', 'Other')],
        'Type', default="theory", required=True)
Esempio n. 28
0
class RecruitmentSettings(models.TransientModel):
    _name = 'hr.recruitment.config.settings'
    _inherit = ['res.config.settings', 'fetchmail.config.settings']

    module_document = fields.Selection(
        selection=[(0, "Do not manage CVs and motivation letter"),
                   (1, 'Allow the automatic indexation of resumes')],
        string='Resumes',
        help=
        'Manage your CV\'s and motivation letter related to all applicants.\n'
        '-This installs the module document_ftp. This will install the knowledge management  module in order to allow you to search using specific keywords through  the content of all documents (PDF, .DOCx...)'
    )
Esempio n. 29
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("备注")
Esempio n. 30
0
class OpPeriod(models.Model):
    _name = 'op.period'
    _description = 'Period'
    _order = 'sequence'

    name = fields.Char('Name', size=16, required=True)
    hour = fields.Selection([('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'),
                             ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8'),
                             ('9', '9'), ('10', '10'), ('11', '11'),
                             ('12', '12')],
                            'Hours',
                            required=True)
    minute = fields.Selection([('00', '00'), ('15', '15'), ('30', '30'),
                               ('45', '45')],
                              'Minute',
                              required=True)
    duration = fields.Float('Duration')
    am_pm = fields.Selection([('am', 'AM'), ('pm', 'PM')],
                             'AM/PM',
                             required=True)
    sequence = fields.Integer('Sequence')