[IMP] Improve ospp_base and ospp_slide modules
							parent
							
								
									7a71e08cb3
								
							
						
					
					
						commit
						42851bf5ab
					
				|  | @ -159,6 +159,31 @@ class ChannelInstance(models.Model): | ||||||
|     demo_data = fields.Boolean('Demo Data', default=True) |     demo_data = fields.Boolean('Demo Data', default=True) | ||||||
|     is_notified = fields.Boolean('Is Notified', default=False) |     is_notified = fields.Boolean('Is Notified', default=False) | ||||||
| 
 | 
 | ||||||
|  |     def action_post_instance(self): | ||||||
|  |         for rec in self: | ||||||
|  |             subject = f"通知: 《{rec.channel_id.name}》实训环境已经生成" | ||||||
|  |             html_body = f""" | ||||||
|  |             @{', '.join([x.partner_id.name for x in rec.user_scope])} 您的实训环境已经创建!\n | ||||||
|  |             环境: {rec.service_url} \n | ||||||
|  |             账号: {rec.admin_account} \n | ||||||
|  |             密码: {rec.admin_password} \n | ||||||
|  |             课程: https://www.newbizpaas.cn/slides/{rec.channel_id.id} \n | ||||||
|  |              | ||||||
|  |             预祝学习愉快! | ||||||
|  |             """ | ||||||
|  |             partner_ids = [x.partner_id.id for x in rec.user_scope] | ||||||
|  |             kwargs = {} | ||||||
|  |             rec.channel_id.with_context(mail_create_nosubscribe=True).message_post( | ||||||
|  |                 subject=subject, | ||||||
|  |                 body=html_body, | ||||||
|  |                 subtype_xmlid='website_slides.mt_channel_slide_published', | ||||||
|  |                 email_layout_xmlid='mail.mail_notification_light', | ||||||
|  |                 partner_ids=partner_ids, | ||||||
|  |                 **kwargs, | ||||||
|  |             ) | ||||||
|  |             return True | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     def action_generate_instance(self): |     def action_generate_instance(self): | ||||||
|         for rec in self: |         for rec in self: | ||||||
|             if rec.instance_created: |             if rec.instance_created: | ||||||
|  |  | ||||||
|  | @ -37,6 +37,9 @@ | ||||||
|                             <button name="action_generate_instance" data-hotkey="v" |                             <button name="action_generate_instance" data-hotkey="v" | ||||||
|                                     string="Create" type="object" |                                     string="Create" type="object" | ||||||
|                                     attrs="{'invisible': [('instance_created', '=', True)]}"/> |                                     attrs="{'invisible': [('instance_created', '=', True)]}"/> | ||||||
|  |                             <button name="action_post_instance" data-hotkey="v" | ||||||
|  |                                     string="Notify" type="object" | ||||||
|  |                                     attrs="{'invisible': [('instance_created', '!=', True)]}"/> | ||||||
|                         </tree> |                         </tree> | ||||||
|                         <form> |                         <form> | ||||||
|                             <group> |                             <group> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Oliver Yuan
						Oliver Yuan