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 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" )
class KnowledgeConfigSettings(models.TransientModel): """This class in needed to activate document management.""" _name = 'knowledge.config.settings' _inherit = 'res.config.settings' module_document = fields.Boolean( 'Manage documents', help='Document indexation, full text search of attachements.\n' '- This installs the module document.') module_document_page = fields.Boolean( 'Manage document pages (Wiki)', help='Provide document page and category as a wiki.\n' '- This installs the module document_page.') module_document_page_approval = fields.Boolean( 'Manage documents approval', help='Add workflow on documents per category.\n' '- This installs the module document_page_approval.') module_cmis_read = fields.Boolean( 'Attach files from an external DMS into YuanCloud', help='Connect YuanCloud with a CMIS compatible server to attach files\n' 'to an YuanCloud record.\n' '- This installs the module cmis_read.') module_cmis_write = fields.Boolean( 'Store attachments in an external DMS instead of the YuanCloud Filestore', help='Connect YuanCloud with a CMIS compatible server to store files.\n' '- This installs the module cmis_write.')
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")
class HrEquipmentStage(models.Model): """ Model for case stages. This models the main stages of a Maintenance Request management flow. """ _name = 'hr.equipment.stage' _description = 'Maintenance Stage' _order = 'sequence, id' name = fields.Char('Name', required=True, translate=True) sequence = fields.Integer('Sequence', default=20) fold = fields.Boolean('Folded in Recruitment Pipe') done = fields.Boolean('Request Done')
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')
class sale_order_line(models.Model): ''' 功能:增加产品分类id,用来排序 ''' _inherit = 'sale.order.line' # saas报价单使用 categ_id = fields.Many2one('product.category', string='产品分类') categ_count = fields.Integer(string='分类数') categ_rowcount = fields.Integer(string='分类合并行数') add_td = fields.Boolean(string='是否增加TD') must_choose = fields.Boolean(string='是否必选') _order = 'order_id desc,categ_id ,must_choose desc,sequence, id'
class website_config_settings(models.TransientModel): _inherit = 'website.config.settings' salesperson_id = fields.Many2one('res.users', related='website_id.salesperson_id', string='Salesperson') salesteam_id = fields.Many2one('crm.team', related='website_id.salesteam_id', string='Sales Team') module_delivery_dhl = fields.Boolean("DHL integration") module_delivery_fedex = fields.Boolean("Fedex integration") module_delivery_ups = fields.Boolean("UPS integration") module_delivery_usps = fields.Boolean("USPS integration") module_sale_ebay = fields.Boolean("eBay connector")
class product_template_extend(models.Model): ''' 功能:为产品增加子表:功能清单 ''' _inherit = 'product.template' must_choose=fields.Boolean(string='必选') function_ids=fields.One2many('product.template.function','product_id',string='功能清单')
class SaasPortalDatabase(models.Model): _inherit = 'saas_portal.database' backup = fields.Boolean('Backup on Modify', help="Backs up first before deleting \ or upgrading", default=True)
class SaasPortalClient(models.Model): _inherit = 'saas_portal.client' backup = fields.Boolean('Backup on Modify', help="Backs up first before deleting \ or upgrading", default=True) @api.multi def action_backup(self): self.ensure_one() self._backup() @api.multi def delete_database(self): for database_obj in self: if database_obj.backup: database_obj._backup() return super(SaasPortalClient, self).delete_database() @api.multi def upgrade(self, payload=None): for database_obj in self: if database_obj.backup: # backup won't be done for upgrades through saas.config.do_upgrade_database # TODO: replace all saas.config.do_upgrade_database to self.upgrade database_obj._backup() return super(SaasPortalClient, self).upgrade(payload=payload)
class OpAttendanceLine(models.Model): _name = 'op.attendance.line' _rec_name = 'attendance_id' attendance_id = fields.Many2one( 'op.attendance.sheet', 'Attendance Sheet', required=True) student_id = fields.Many2one('op.student', 'Student', required=True) present = fields.Boolean('Present ?', default=True) course_id = fields.Many2one( 'op.course', 'Course', related='attendance_id.register_id.course_id', store=True, readonly=True) batch_id = fields.Many2one( 'op.batch', 'Batch', related='attendance_id.register_id.batch_id', store=True, readonly=True) remark = fields.Char('Remark', size=256) attendance_date = fields.Date( 'Date', related='attendance_id.attendance_date', store=True, readonly=True) _sql_constraints = [ ('unique_student', 'unique(student_id,attendance_id,attendance_date)', 'Student must be unique per Attendance.'), ]
class OpAdmission(models.Model): _inherit = 'op.admission' _description = "Admission" religion_id = fields.Many2one('op.religion', 'Religion', states={'done': [('readonly', True)]}) category_id = fields.Many2one('op.category', 'Category', states={'done': [('readonly', True)]}) is_old_student = fields.Boolean('Old Student?') gr_no_old = fields.Char('GR Number old', size=10) gr_no = fields.Char('GR Number new', size=10) @api.multi def get_student_vals(self): vals = super(OpAdmission, self).get_student_vals() gr = self.gr_no if self.is_old_student: gr = self.gr_no_old vals.update({ 'gr_no': gr, 'category': self.category_id and self.category_id.id or False, 'religion': self.religion_id and self.religion_id.id or False }) return vals
class OpResultTemplateLine(models.Model): _name = 'op.result.template.line' _rec_name = 'exam_session_id' _description = 'Result Template Line' exam_session_id = fields.Many2one('op.exam.session', 'Exam Session') detailed_report = fields.Boolean('Detailed Report') course_id = fields.Many2one('op.course', 'Course', related='exam_session_id.course_id', readonly=True) batch_id = fields.Many2one('op.batch', 'Batch', related='exam_session_id.batch_id', readonly=True) result_id = fields.Many2one('op.result.template', 'Result Template Line') exam_lines = fields.One2many('op.result.exam.line', 'result_id', 'Exam Lines') @api.onchange('exam_session_id') def onchange_exam_session(self): for exam_obj in self.exam_session_id.exam_ids: self.exam_lines += self.exam_lines.create({ 'exam_id': exam_obj.id, 'weightage': 100 })
class EventMailRegistration(models.Model): _name = 'event.mail.registration' _description = 'Registration Mail Scheduler' _rec_name = 'scheduler_id' _order = 'scheduled_date DESC' scheduler_id = fields.Many2one('event.mail', 'Mail Scheduler', required=True, ondelete='cascade') registration_id = fields.Many2one('event.registration', 'Attendee', required=True, ondelete='cascade') scheduled_date = fields.Datetime('Scheduled Time', compute='_compute_scheduled_date', store=True) mail_sent = fields.Boolean('Mail Sent') @api.one def execute(self): if self.registration_id.state in ['open', 'done'] and not self.mail_sent: self.scheduler_id.template_id.send_mail(self.registration_id.id) self.write({'mail_sent': True}) @api.one @api.depends('registration_id', 'scheduler_id.interval_unit', 'scheduler_id.interval_type') def _compute_scheduled_date(self): if self.registration_id: date_open = self.registration_id.date_open date_open_datetime = date_open and datetime.strptime(date_open, tools.DEFAULT_SERVER_DATETIME_FORMAT) or fields.datetime.now() self.scheduled_date = date_open_datetime + _INTERVALS[self.scheduler_id.interval_unit](self.scheduler_id.interval_nbr) else: self.scheduled_date = False
class OpAlumni(models.Model): _inherit = 'op.student' alumni_boolean = fields.Boolean('Alumni Student') passing_year = fields.Many2one('op.batch', 'Passing Year') current_position = fields.Char('Current Position', size=256) current_job = fields.Char('Current Job', size=256)
class SaasPortalCreateClient(models.TransientModel): _name = 'saas_portal.create_client' def _default_plan_id(self): return self._context.get('active_id') def _default_name(self): plan_id = self._default_plan_id() if plan_id: plan = self.env['saas_portal.plan'].browse(plan_id) return plan.generate_dbname(raise_error=False)[0] return '' name = fields.Char('Database name', required=True, default=_default_name) plan_id = fields.Many2one('saas_portal.plan', string='Plan', readonly=True, default=_default_plan_id) partner_id = fields.Many2one('res.partner', string='Partner') user_id = fields.Many2one('res.users', string='User') notify_user = fields.Boolean(help='Notify user by email when database will have been created', default=False) support_team_id = fields.Many2one('saas_portal.support_team', 'Support Team', default=lambda self: self.env.user.support_team_id) async_creation = fields.Boolean('Asynchronous', default=False, help='Asynchronous creation of client base') @api.onchange('user_id') def update_partner(self): if self.user_id: self.partner_id = self.user_id.partner_id @api.multi def apply(self): wizard = self[0] res = wizard.plan_id.create_new_database(dbname=wizard.name, partner_id=wizard.partner_id.id, user_id=self.user_id.id, notify_user=self.notify_user, support_team_id=self.support_team_id.id, async=self.async_creation) if self.async_creation: return client = self.env['saas_portal.client'].browse(res.get('id')) client.server_id.action_sync_server() return { 'type': 'ir.actions.act_window', 'view_type': 'form', 'view_mode': 'form', 'res_model': 'saas_portal.client', 'res_id': client.id, 'target': 'current', }
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='批次')
class Rating(models.Model): _inherit = 'rating.rating' # Add this related field to mail.message for performance reason # This field may one day be deplaced to another module (like 'website_rating') if it is required for # another usage not related to website_sale. website_published = fields.Boolean(related='message_id.website_published', store=True)
class wx_message_template(models.AbstractModel): _name = 'wx.message_template_base' _rec_name = "template_code" template_name = fields.Char("模板名称", required=True) template_code = fields.Char("模板编码", required=True) message_type = fields.Many2one('wx.messagetype', string='消息类型') #officialaccount = fields.Many2one('wx.officialaccount', string='微信服务号') iseffective = fields.Boolean('是否生效')
class ChannelPartner(models.Model): _name = 'mail.channel.partner' _description = 'Last Seen Many2many' _table = 'mail_channel_partner' _rec_name = 'partner_id' partner_id = fields.Many2one('res.partner', string='Recipient', ondelete='cascade') channel_id = fields.Many2one('mail.channel', string='Channel', ondelete='cascade') seen_message_id = fields.Many2one('mail.message', string='Last Seen') fold_state = fields.Selection([('open', 'Open'), ('folded', 'Folded'), ('closed', 'Closed')], string='Conversation Fold State', default='open') is_minimized = fields.Boolean("Conversation is minimied") is_pinned = fields.Boolean("Is pinned on the interface", default=True)
class SaasClient(models.AbstractModel): _name = 'saas_base.client' users_len = fields.Integer('Count users', readonly=True) max_users = fields.Char('Max users allowed', readonly=True) file_storage = fields.Integer('File storage (MB)', readonly=True) db_storage = fields.Integer('DB storage (MB)', readonly=True) total_storage_limit = fields.Integer('Total storage limit (MB)', readonly=True, default=0) expiration_datetime = fields.Datetime('Expiration', track_visibility='onchange') trial = fields.Boolean('Trial', help='indication of trial clients', default=False, readonly=True)
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='商品')
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
class ecplatform(models.Model): ''' 模型:电商平台(档案), 使用者:日常流水 ''' _name = 'oa_journal.ecplatform' _description = 'OA Journal EC Platform' _rec_name = 'platform_name' platform_code = fields.Char(string='编码', required=True) platform_name = fields.Char(string='名称', required=True) platform_url = fields.Char(string='网址') enabled = fields.Boolean(string='生效', default=True)
class EventQuestion(models.Model): _name = 'event.question' _rec_name = 'title' _order = 'sequence,id' title = fields.Char(required=True, translate=True) event_id = fields.Many2one('event.event', required=True, ondelete='cascade') answer_ids = fields.One2many('event.answer', 'question_id', "Answers", required=True) sequence = fields.Integer(default=10) is_individual = fields.Boolean('Ask each attendee', help="If True, this question will be asked for every attendee of a reservation. If " "not it will be asked only once and its value propagated to every attendees.")
class OpVehicle(models.Model): _name = 'op.vehicle' name = fields.Char('Name', size=16, required=True) reg_number = fields.Char('Registration Number', size=16, required=True) capacity = fields.Integer('Capacity', required=True) active = fields.Boolean('Active', default=True) partner_id = fields.Many2one('res.partner', 'Driver') @api.constrains('capacity') def check_capacity(self): if self.capacity <= 0: raise ValidationError('Enter proper Capacity.')
class SaasConfigParam(models.TransientModel): _name = 'saas.config.param' def _get_keys(self): return [ ('saas_client.max_users', 'Max Users'), ('saas_client.suspended', 'Suspended'), ('saas_client.total_storage_limit', 'Total storage limit'), ] key = fields.Selection(selection=_get_keys, string='Key', required=1, size=64) value = fields.Char('Value', required=1, size=64) config_id = fields.Many2one('saas.config', 'Config') hidden = fields.Boolean('Hidden parameter', default=True)
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)
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'