Exemple #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!")
class wx_location_message_record(models.Model):
    _inherit = 'wx.message_record'
    _name = 'wx.location_message_record'
    message_type = fields.Many2one(
        'wx.messagetype',
        string='消息类型',
        readonly=True,
        default=lambda self: _messagetype_get(self, self.env.cr, self.env.user.
                                              id, 'location'))
    message_locationX = fields.Float(string="地理位置维度")
    message_locationY = fields.Float(string="地理位置经度")
    message_scale = fields.Float(string="地图缩放大小")
    message_label = fields.Char(string="地理位置信息")
    message_msgid = fields.Char("消息ID")
    #toUserName = fields.Many2one('wx.membership',string="接收方/发送方")
    model_id = fields.Many2one(
        'ir.model',
        '应用模型',
        ondelete='cascade',
        copy=False,
        help="Base model on which the server action runs.")
    message_template = fields.Many2one('wx.location_message_template',
                                       string="位置消息模板")
    association_order = fields.Char('关联实体编码或单号')
    qy_toUserName = fields.Many2one('hr.employee', string="企业应用接收方/发送方")
class OpTransportation(models.Model):
    _name = 'op.transportation'

    name = fields.Char('Name', size=64, required=True)
    stop_ids = fields.Many2many('op.stop', string='Stops')
    cost = fields.Float('Cost')
    vehicle_id = fields.Many2one('op.vehicle', 'Vehicle', required=True)
    start_time = fields.Float('Start Time', required=True)
    end_time = fields.Float('End Time', required=True)
    from_stop_id = fields.Many2one('op.stop', 'From', required=True)
    to_stop_id = fields.Many2one('op.stop', 'To', required=True)
    student_ids = fields.Many2many('op.student', string='Student(s)')

    @api.constrains('student_ids', 'vehicle_id')
    def check_capacity(self):
        if len(self.student_ids) > self.vehicle_id.capacity:
            raise ValidationError('Students over than vehicle capacity.')

    @api.constrains('from_stop_id', 'to_stop_id')
    def check_places(self):
        if self.from_stop_id == self.to_stop_id:
            raise ValidationError('To place cannot be equal to From place.')

    @api.constrains('start_time', 'end_time')
    def _check_date_time(self):
        if self.start_time < 0 or self.end_time < 0:
            raise ValidationError("Enter proper Time.")
        elif self.start_time > 24 or self.end_time > 24:
            raise ValidationError("Time can't be greater than 24 hours.")
        elif self.start_time >= self.end_time:
            raise ValidationError(
                'End Time cannot be set before or equal to Start Time.')
Exemple #4
0
class ImLivechatReportOperator(models.Model):
    """ Livechat Support Report on the Operator """

    _name = "im_livechat.report.operator"
    _description = "Livechat Support Report"
    _order = 'livechat_channel_id, partner_id'
    _auto = False

    partner_id = fields.Many2one('res.partner', 'Operator', readonly=True)
    livechat_channel_id = fields.Many2one('im_livechat.channel',
                                          'Channel',
                                          readonly=True)
    nbr_channel = fields.Integer('# of channel',
                                 readonly=True,
                                 group_operator="sum",
                                 help="Number of conversation")
    channel_id = fields.Many2one('mail.channel', 'Conversation', readonly=True)
    start_date = fields.Datetime('Start Date of session',
                                 readonly=True,
                                 help="Start date of the conversation")
    time_to_answer = fields.Float(
        'Time to answer',
        digits=(16, 2),
        readonly=True,
        group_operator="avg",
        help="Average time to give the first answer to the visitor")
    duration = fields.Float('Average duration',
                            digits=(16, 2),
                            readonly=True,
                            group_operator="avg",
                            help="Duration of the conversation (in seconds)")

    def init(self, cr):
        # Note : start_date_hour must be remove when the read_group will allow grouping on the hour of a datetime. Don't forget to change the view !
        tools.drop_view_if_exists(cr, 'im_livechat_report_operator')
        cr.execute("""
            CREATE OR REPLACE VIEW im_livechat_report_operator AS (
                SELECT
                    row_number() OVER () AS id,
                    P.id as partner_id,
                    L.id as livechat_channel_id,
                    count(C.id) as nbr_channel,
                    C.id as channel_id,
                    C.create_date as start_date,
                    EXTRACT('epoch' FROM (max((SELECT (max(M.create_date)) FROM mail_message M JOIN mail_message_mail_channel_rel R ON (R.mail_message_id = M.id) WHERE R.mail_channel_id = C.id))-C.create_date)) as duration,
                    EXTRACT('epoch' from ((SELECT min(M.create_date) FROM mail_message M, mail_message_mail_channel_rel R WHERE M.author_id=P.id AND R.mail_channel_id = C.id AND R.mail_message_id = M.id)-(SELECT min(M.create_date) FROM mail_message M, mail_message_mail_channel_rel R WHERE M.author_id IS NULL AND R.mail_channel_id = C.id AND R.mail_message_id = M.id))) as time_to_answer
                FROM im_livechat_channel_im_user O
                    JOIN res_users U ON (O.user_id = U.id)
                    JOIN res_partner P ON (U.partner_id = P.id)
                    LEFT JOIN im_livechat_channel L ON (L.id = O.channel_id)
                    LEFT JOIN mail_channel C ON (C.livechat_channel_id = L.id)
                GROUP BY P.id, L.id, C.id, C.create_date
            )
        """)
Exemple #5
0
class OpHostelRoomAllocation(models.Model):
    _name = 'op.hostel.room'

    hostel_id = fields.Many2one('op.hostel', 'Hostel', required=True)
    name = fields.Many2one('op.room', 'Room', required=True)
    student_ids = fields.Many2many('res.partner', string='Allocated Students')
    students_per_room = fields.Integer('Students per Room', required=True)
    rent = fields.Float('Rent')
    allocated_date = fields.Date('Allocated Date', default=fields.Date.today())

    @api.constrains('students_per_room')
    def check_capacity(self):
        if self.students_per_room <= 0:
            raise ValidationError("Enter proper Student Per Room")

    @api.onchange('hostel_id')
    def onchange_hostel(self):
        if self.hostel_id:
            self.name = False

    @api.onchange('name')
    def onchange_name(self):
        if self.name:
            self.students_per_room = self.name.capacity

    @api.one
    @api.constrains('student_ids', 'students_per_room')
    def _check_student_capacity(self):
        if len(self.student_ids) > self.students_per_room:
            raise ValidationError('Room capacity Over')
Exemple #6
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"))
Exemple #7
0
class OpPassStatus(models.Model):
    _name = 'op.pass.status'
    _description = 'Pass Status'

    name = fields.Char('Name', size=256)
    number = fields.Float('Minimum Percentage')
    result = fields.Char('Result to Display')
Exemple #8
0
class OpAsset(models.Model):
    _name = 'op.asset'

    asset_id = fields.Many2one('op.classroom', 'Asset')
    product_id = fields.Many2one('product.product', 'Product', required=True)
    code = fields.Char('Code', size=256)
    product_uom_qty = fields.Float('Quantity', required=True)
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!")
Exemple #10
0
class OpResultExamLine(models.Model):
    _name = 'op.result.exam.line'
    _description = 'Result Exam Line'
    _rec_name = "exam_id"

    result_id = fields.Many2one('op.result.template.line', 'Session Template')
    exam_id = fields.Many2one('op.exam', 'Exam')
    pass_marks = fields.Float('Passing Marks',
                              related='exam_id.min_marks',
                              readonly=True)
    total_marks = fields.Float('Total Marks',
                               related='exam_id.total_marks',
                               readonly=True)
    weightage = fields.Float('Weightage')
    result_lines = fields.One2many('op.result.line', 'exam_tmpl_id',
                                   'Result Lines')
Exemple #11
0
class sale_report(models.Model):
    _inherit = 'sale.report'

    margin = fields.Float('Margin')

    def _select(self):
        return super(sale_report, self)._select() + ", SUM(l.margin) AS margin"
Exemple #12
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)
Exemple #13
0
class company(models.Model):
    _inherit = 'res.company'

    security_lead = fields.Float('Sales Safety Days', required=True, default = 0.0,
        help="Margin of error for dates promised to customers. "\
             "Products will be scheduled for procurement and delivery "\
             "that many days earlier than the actual promised date, to "\
             "cope with unexpected delays in the supply chain.")
Exemple #14
0
class SaasPricingPrice(models.Model):
    _name = 'saas_pricing.price'

    name = fields.Char('Price name')
    interval = fields.Char('Price interval')
    price = fields.Float('Price', digits=(16, 2))
    stripe_planid = fields.Char('Stripe Plan id')
    stripe_currency = fields.Many2one('res.currency')
    trial_period_days = fields.Char('Stripe trial period days')
Exemple #15
0
class OpMarksheetLine(models.Model):
    _name = 'op.marksheet.line'
    _rec_name = 'student_id'

    marksheet_reg_id = fields.Many2one('op.marksheet.register',
                                       'Marksheet Register')
    exam_session_id = fields.Many2one('op.result.template.line',
                                      'Session Template')
    student_id = fields.Many2one('op.student', 'Student', required=True)
    result_line = fields.One2many('op.result.line', 'result_id', 'Results')
    total_marks = fields.Float("Total Marks")
    total_per = fields.Float("Total Percentage")
    result = fields.Char("Result", size=256)

    @api.constrains('total_marks', 'total_per')
    def _check_marks(self):
        if (self.total_marks < 0.0) or (self.total_per < 0.0):
            raise ValidationError("Enter proper marks or percentage!")
Exemple #16
0
class mrp_production_workcenter_line_extend(models.Model):
    '''
    派工单(工票)实体扩展
    '''
    _inherit = 'mrp.production.workcenter.line'
    _description = 'Work Order'
    _order = 'sequence'
    plan_qty = fields.Float(digits=(16, 2), string='计划数量')
    actual_qty = fields.Float(digits=(16, 2), string='实际数量')
    qualified_qty = fields.Float(digits=(16, 2), string='实际合格量')
    finish_user = fields.Many2many('res.users',
                                   'finish_plan_user_rel',
                                   'finish_plan_id',
                                   'user_id',
                                   string='操作人员')
    is_comp_point = fields.Boolean(string='完工报告点')
    is_finish_plan = fields.Boolean(string='捕捞计划')
    lot_id = fields.Many2one('stock.production.lot', string='批次')
Exemple #17
0
class wx_location_message_template(models.Model):
    _inherit = 'wx.message_template_base'
    _name = 'wx.location_message_template'
    message_type = fields.Many2one(
        'wx.messagetype',
        string='消息类型',
        readonly=True,
        default=lambda self: _messagetype_get(self, self.env.cr, self.env.user.
                                              id, 'location'))
    message_locationX = fields.Float(string="地理位置维度")
    message_locationY = fields.Float(string="地理位置经度")
    message_scale = fields.Float(string="地图缩放大小")
    message_label = fields.Char(string="地理位置信息")
    model_id = fields.Many2one(
        'ir.model',
        '应用模型',
        ondelete='cascade',
        copy=False,
        help="Base model on which the server action runs.")
Exemple #18
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)
Exemple #19
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='商品')
Exemple #20
0
class OpFacilityLine(models.Model):
    _name = 'op.facility.line'
    _rec_name = 'facility_id'

    facility_id = fields.Many2one('op.facility', 'Facility', required=True)
    quantity = fields.Float('Quantity', required=True)

    @api.constrains('quantity')
    def check_quantity(self):
        if self.quantity <= 0.0:
            raise ValidationError("Enter proper Quantity in Facilities!")
Exemple #21
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'
Exemple #22
0
class wx_product_line(models.Model):
    _name = 'wx.product.line'
    wx_product_id = fields.Many2one('wx.product', '微信商品')
    wx_product_state = fields.Selection(string='微信商品状态',
                                        related='wx_product_id.state')
    product_product_id = fields.Integer(string='产品规格ID')
    spec_name = fields.Char(string='规格名称')
    spec_value = fields.Char(string='属性')
    wx_quantity = fields.Integer(string='微信库存量')
    wx_quantity_offset = fields.Integer(string='库存偏移量', default=0)
    wx_lst_price = fields.Float(string='公开价格', digits=(16, 2))
    # sales_range = fields.Selection([('online', '线上'), ('offline', '线下')], string='销售范围')
    _order = 'product_product_id'
Exemple #23
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
Exemple #24
0
class OpMarksheetRegister(models.Model):
    _name = 'op.marksheet.register'

    exam_session_id = fields.Many2one(
        'op.exam.session', 'Exam', required=True)
    marksheet_line = fields.One2many(
        'op.marksheet.line', 'marksheet_reg_id', 'Marksheets')
    generated_date = fields.Date(
        'Generated Date', required=True, default=fields.Date.today())
    generated_by = fields.Many2one(
        'res.users', 'Generated By',
        default=lambda self: self.env.uid, required=True)
    status = fields.Selection(
        [('draft', 'Draft'), ('validated', 'Validated'),
         ('cancelled', 'Cancelled')], 'Status', default="draft", required=True)
    total_pass = fields.Float('Total Pass')
    total_failed = fields.Float('Total Fail')
    name = fields.Char('Marksheet Register', size=256, required=True)

    @api.constrains('total_pass', 'total_failed')
    def _check_marks(self):
        if (self.total_pass < 0.0) or (self.total_failed < 0.0):
            raise ValidationError('Enter proper pass or fail!')
Exemple #25
0
class ProductTemplate(models.Model):
    _inherit = "product.template"

    uos_id = fields.Many2one(
        'product.uom',
        'Unit of Sale',
        help='Specify a unit of measure here if invoicing is made in another'
        ' unit of measure than inventory. Keep empty to use the default unit of measure.'
    )
    uos_coeff = fields.Float(
        'Unit of Measure -> UOS Coeff',
        digits=dp.get_precision('Product Unit of Measure'),
        help='Coefficient to convert default Unit of Measure to Unit of Sale'
        ' uos = uom * coeff')
Exemple #26
0
class OpResultLine(models.Model):
    _name = 'op.result.line'
    _rec_name = 'marks'

    marksheet_line_id = fields.Many2one('op.marksheet.line', 'Marksheet Line')
    exam_id = fields.Many2one('op.exam', 'Exam', required=True)
    exam_tmpl_id = fields.Many2one('op.result.exam.line', 'Exam Template')
    marks = fields.Float('Marks', required=True)
    per = fields.Float('Percentage', required=True)
    student_id = fields.Many2one('op.student', 'Student', required=True)
    status = fields.Selection([('pass', 'Pass'), ('fail', 'Fail')],
                              'Status',
                              default='pass',
                              required=True)
    result_id = fields.Many2one('op.marksheet.line', 'Marksheet Line')
    total_marks = fields.Float('Total Marks')

    @api.constrains('marks', 'per')
    def _check_marks(self):
        if (self.marks < 0.0) or (self.per < 0.0) or \
                (self.total_marks < 0.0) or (self.per > 100.0):
            raise ValidationError("Enter proper Marks or Percentage!")
        elif self.marks > self.total_marks:
            raise ValidationError("Marks can't be greater than Total Marks")
Exemple #27
0
class company(models.Model):
    _inherit = 'res.company'

    po_lead = fields.Float(string='Purchase Lead Time', required=True,\
        help="Margin of error for vendor lead times. When the system "
             "generates Purchase Orders for procuring products, "
             "they will be scheduled that many days earlier "
             "to cope with unexpected vendor delays.", default=1.0)

    po_double_validation = fields.Selection([
        ('one_step', 'Confirm purchase orders in one step'),
        ('two_step', 'Get 2 levels of approvals to confirm a purchase order')
        ], string="Levels of Approvals", default='one_step',\
        help="Provide a double validation mechanism for purchases")
    po_double_validation_amount = fields.Monetary(string='Double validation amount', default=5000,\
        help="Minimum amount for which a double validation is required")
Exemple #28
0
class OpLibraryCardType(models.Model):
    _name = 'op.library.card.type'
    _description = 'Library Card Type'

    name = fields.Char('Name', size=256, required=True)
    allow_book = fields.Integer('No of Books Allowed', size=10, required=True)
    duration = fields.Integer('Duration',
                              help='Duration in terms of Number of Lead Days',
                              required=True)
    penalty_amt_per_day = fields.Float('Penalty Amount per Day', required=True)

    @api.constrains('allow_book', 'duration', 'penalty_amt_per_day')
    def check_details(self):
        if self.allow_book < 0 or self.duration < 0.0 or \
                self.penalty_amt_per_day < 0.0:
            raise ValidationError('Enter proper value')
Exemple #29
0
class lunch_order_line(models.TransientModel):
    _name = 'lunch.order.line.lucky'

    def _default_supplier(self):
        suppliers_obj = self.env['lunch.product'].search([]).mapped("supplier")
        return [(4, supplier.id) for supplier in suppliers_obj]

    product_id = fields.Many2one('lunch.product', 'Product', store=True)
    supplier_ids = fields.Many2many(
        comodel_name='res.partner',
        string='Vendor',
        domain=lambda self: [("id", "in", self.env['lunch.product'].search([]).
                              mapped("supplier").ids)])
    is_max_budget = fields.Boolean(
        "I'm not feeling rich",
        help="Enable this option to set a maximal budget for your lucky order.",
        store=True)
    max_budget = fields.Float('Max Budget', store=True)

    @api.multi
    def random_pick(self):
        """
        To pick a random product from the selected suppliers, and create an order with this one
        """
        self.ensure_one()
        if self.is_max_budget:
            products_obj = self.env['lunch.product'].search([
                ('supplier', "in", self.supplier_ids.ids),
                ('price', '<=', self.max_budget)
            ])
        else:
            products_obj = self.env['lunch.product'].search([
                ('supplier', "in", self.supplier_ids.ids)
            ])
        if len(products_obj) != 0:
            random_product_obj = self.env['lunch.product'].browse(
                [random.choice(products_obj.ids)])
            order_line = self.env['lunch.order.line'].create({
                'product_id':
                random_product_obj.id,
                'order_id':
                self._context['active_id']
            })
        else:
            raise UserError(
                _('No product is matching your request. Now you will starve to death.'
                  ))
Exemple #30
0
class crm_lead(models.Model):
    _inherit = ['crm.lead']

    @api.one
    @api.depends('order_ids')
    def _get_sale_amount_total(self):
        total = 0.0
        nbr = 0
        for order in self.order_ids:
            if order.state == 'draft':
                nbr += 1
            if order.state not in ('draft', 'cancel'):
                total += order.currency_id.compute(order.amount_untaxed, self.company_currency)
        self.sale_amount_total = total
        self.sale_number = nbr

    sale_amount_total= fields.Float(compute='_get_sale_amount_total', string="Sum of Orders", readonly=True, digits=0)
    sale_number = fields.Integer(compute='_get_sale_amount_total', string="Number of Quotations", readonly=True)
    order_ids = fields.One2many('sale.order', 'opportunity_id', string='Orders')

    def retrieve_sales_dashboard(self, cr, uid, context=None):
        res = super(crm_lead, self).retrieve_sales_dashboard(cr, uid, context=None)

        res['invoiced'] = {
            'this_month': 0,
            'last_month': 0,
        }
        account_invoice_domain = [
            ('state', 'in', ['open', 'paid']),
            ('user_id', '=', uid),
            ('date', '>=', date.today().replace(day=1) - relativedelta(months=+1)),
            ('type', 'in', ['out_invoice', 'out_refund'])
        ]

        invoice_ids = self.pool.get('account.invoice').search_read(cr, uid, account_invoice_domain, ['date', 'amount_untaxed_signed'], context=context)
        for inv in invoice_ids:
            if inv['date']:
                inv_date = datetime.strptime(inv['date'], tools.DEFAULT_SERVER_DATE_FORMAT).date()
                if inv_date <= date.today() and inv_date >= date.today().replace(day=1):
                    res['invoiced']['this_month'] += inv['amount_untaxed_signed']
                elif inv_date < date.today().replace(day=1) and inv_date >= date.today().replace(day=1) - relativedelta(months=+1):
                    res['invoiced']['last_month'] += inv['amount_untaxed_signed']

        res['invoiced']['target'] = self.pool('res.users').browse(cr, uid, uid, context=context).target_sales_invoiced
        return res