diff --git a/appstore/Amos_Demo/__manifest__.py b/appstore/Amos_Demo/__manifest__.py index 5a4260a3176c3fe6588abc7e395c8351cdcefca2..829273eba0bcf2c5d5c15ceeb1cb0709e8a318ae 100644 --- a/appstore/Amos_Demo/__manifest__.py +++ b/appstore/Amos_Demo/__manifest__.py @@ -24,10 +24,13 @@ 'data': [ 'security/ir.model.access.csv', 'data/amos_demo_data.xml', + 'data/amos_demo_selection_data.xml', 'views/amos_demo.xml', # 'views/amos_a.xml', # 'report/report.xml', + 'views/amos_demo_selection.xml', + ], 'demo': [ ], diff --git a/appstore/Amos_Demo/data/amos_demo_selection_data.xml b/appstore/Amos_Demo/data/amos_demo_selection_data.xml new file mode 100644 index 0000000000000000000000000000000000000000..cc65269275e4cc0d72c5cdb82825a49bca1a5435 --- /dev/null +++ b/appstore/Amos_Demo/data/amos_demo_selection_data.xml @@ -0,0 +1,21 @@ + + + + + + + issue_filter_one + + + + issue_filter_two + + + + issue_filter_three + + + + + + diff --git a/appstore/Amos_Demo/models/__init__.py b/appstore/Amos_Demo/models/__init__.py index a3f04ebb147d52d40cc48bd2b3050f116cb5645f..7560a63134eba537b238b774b00067c3ded88500 100644 --- a/appstore/Amos_Demo/models/__init__.py +++ b/appstore/Amos_Demo/models/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- from .import amos_demo from .import amos_a +from . import amos_demo_selection \ No newline at end of file diff --git a/appstore/Amos_Demo/models/amos_demo_selection.py b/appstore/Amos_Demo/models/amos_demo_selection.py new file mode 100644 index 0000000000000000000000000000000000000000..6b337d42aaa738ca57ee05214cacbd7c38ce5684 --- /dev/null +++ b/appstore/Amos_Demo/models/amos_demo_selection.py @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- +# &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +# DTCloud 每年9月9日发布下一代版本 +# QQ:35350428 +# 邮件:35350428@qq.com +# 手机:13584935775 +# 作者:'Amos' +# 公司网址: www.dtcloud360.com +# 视频教程: http://i.youku.com/amoserp +# Copyright 中亿丰信息科技(苏州)有限公司 2012-2022 Amos +# :2022-09-09 +# &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +import base64 +# from docx2pdf import convert +import os +import subprocess +from datetime import datetime, timedelta, date +import time +from docxtpl import DocxTemplate +from dtcloud import api, fields, models, SUPERUSER_ID, _ +from dtcloud.exceptions import AccessError, UserError, ValidationError +import uuid +from dtcloud.tools import date_utils + +#::::::::::字段属性 +""" +required=True 必填 +index=True 索引 +default=fields.Datetime.now() 长日期 +string='年度' 字段中文名称 +tracking=True 启用社交后记录字段历史变更信息 +copy=False 数据被复制时是否同时复制当前字段 +readonly=True 视图字段为只读,不可编辑,但如果在视图中定义属性以视图为准 +""" + + +DEMO_SELECTION = [ + ('draft', '草稿'), + ('math', '数学'), + ('chinese', '语文'), + ('english', '英文'), +] + + +class amos_demo_selection(models.Model): + _name = "amos.demo.selection" + _description = "选择字段" + + name = fields.Char(string='名称') + state = fields.Selection(selection=DEMO_SELECTION, string='普通选择项', default='draft') + + # 根据权限组显示不同的selection内容 Selection需对应函数 + filter = fields.Selection(selection='_selection_filter', string="权限组过滤选择项") + + @api.model + def _selection_filter(self): + """ + 根据权限组显示不同的Selection值 + """ + res_filter = [ + ('math', '数学'), + ('chinese', '语文'), + ] + # 系统用户 + if self.user_has_groups('base.group_system'): + res_filter += [('english', '英语')] + # 内部用户 + elif self.user_has_groups('base.group_user'): + res_filter = res_filter + else: + res_filter = [] + return res_filter + + # 动态创建selection内容 Selection需对应函数 + filter_create = fields.Selection(string=u'动态创建选择项', selection='_selection_filter2') + + @api.model + def _selection_filter2(self): + res_filter = [] + # 从系统参数中查询 + filter_list = self.sudo().env['ir.config_parameter'].search([('key', 'like', 'issue_filter_')]) + for filter in filter_list: + res_filter.append((filter.key[13:], _(filter.value))) + return res_filter + + diff --git a/appstore/Amos_Demo/security/ir.model.access.csv b/appstore/Amos_Demo/security/ir.model.access.csv index 92e1df54f4ad60cff3a1bafcc6dd991502bdd8db..56f7cbd8bcc97f6bd1d8546d732b5747d1960c01 100644 --- a/appstore/Amos_Demo/security/ir.model.access.csv +++ b/appstore/Amos_Demo/security/ir.model.access.csv @@ -3,6 +3,7 @@ access_amos_demo_user,amos_demo,model_amos_demo,base.group_user,1,1,1,1 access_amos_demo_line_user,amos_demo_line,model_amos_demo_line,base.group_user,1,1,1,1 access_amos_demo_tag_user,amos_demo_tag,model_amos_demo_tag,base.group_user,1,1,1,1 access_amos_a_user,amos_a,model_amos_a,base.group_user,1,1,1,1 +access_amos.demo.selection_user,amos.demo.selection,model_amos_demo_selection,base.group_user,1,1,1,1 diff --git a/appstore/Amos_Demo/views/amos_demo_selection.xml b/appstore/Amos_Demo/views/amos_demo_selection.xml new file mode 100644 index 0000000000000000000000000000000000000000..cd57beb7bc0e521c2c6720e1cfbd60ab072a7b0a --- /dev/null +++ b/appstore/Amos_Demo/views/amos_demo_selection.xml @@ -0,0 +1,53 @@ + + + + + + amos.demo.selection.form + amos.demo.selection + +
+ + + + + + +
+
+
+ + + amos.demo.selection.tree + amos.demo.selection + 1 + + + + + + + + + + + + + 选择项测试 + ir.actions.act_window + amos.demo.selection + tree,form + +

+ 创建单据. +

+

+

+
+
+ + + +
+