优化代码结构

This commit is contained in:
mgw
2023-11-20 13:23:37 +08:00
parent 5bdd3982ae
commit 718b1f9edf
11 changed files with 63 additions and 76 deletions

View File

@@ -13,8 +13,6 @@ from odoo.http import request
from odoo.exceptions import ValidationError
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
@@ -44,9 +42,3 @@ class WxWorkApproval(models.Model):
# ], string='请假类型')
# leave_days = fields.Float(string='Leave Days')
# overtime_hours = fields.Float(string='Overtime Hours')

View File

@@ -80,7 +80,8 @@ class WxSettings(models.Model):
# 'control_type': child_data.get('property', {}).get('control', None),
# 'unique_control_id': child_data.get('property', {}).get('id', None),
# 'title': child_data.get('property', {}).get('title', [{}])[0].get('text', None),
# 'placeholder': child_data.get('property', {}).get('placeholder', [{}])[0].get('text', None),
# 'placeholder': child_data.get('property', {}).get('placeholder', [{}])[0].
# get('text', None),
# 'require': child_data.get('property', {}).get('require', None),
# 'un_print': child_data.get('property', {}).get('un_print', None),
# 'un_replace': child_data.get('property', {}).get('un_replace', None),
@@ -99,7 +100,8 @@ class WxSettings(models.Model):
# 例如:
config_id_data = {
'date_type': [(0, 0, {'date_type': child_data.get('config', {}).get('date', {}).get('type',
None)})] if 'date' in child_data.get(
None)})]
if 'date' in child_data.get(
'config', {}) else [],
'selector_type': [(0, 0, {
'selector_type': 'single',
@@ -108,26 +110,14 @@ class WxSettings(models.Model):
'contact_type': [
(0, 0, {'contact_type': config_data.get('contact', {}).get('type', None),
'contact_mode': config_data.get('contact', {}).get('mode',
None)})] if 'contact' in child_data.get(
None)})] if 'contact' in
child_data.get(
'config', {}).get('contact', {}) else [],
'file_type': [
(0, 0, {'is_only_photo': config_data.get('file', {}).get('is_only_photo',
None)})] if 'file' in child_data.get(
None)})] if 'file' in
child_data.get(
'config', {}).get('file', {}) else [],
# 'table_type': [(0, 0, {
# 'table_children': [
# (0, 0, {'control_type': config_data.get('table', {}).get('children', None)[0].get('property', {}).get('control', None),
# 'unique_control_id': config_data.get('table', {}).get('children', None)[0].get('property', {}).get('id', None),
# 'title': config_data.get('table', {}).get('children', None)[0].get('property', {}).get('title', None)[0].get('text', None),
# 'placeholder': config_data.get('table', {}).get('children', None)[0].get('property', {}).get('placeholder', None)[0].get('text', None),
# 'require': config_data.get('table', {}).get('children', None)[0].get('property', {}).get('require', None),
# 'un_print': config_data.get('table', {}).get('children', None)[0].get('property', {}).get('un_print', None),
# 'un_replace': config_data.get('table', {}).get('children', None)[0].get('property', {}).get('un_replace', None),
# 'display': config_data.get('table', {}).get('children', None)[0].get('property', {}).get('display', None),
# })],
# })] if 'table' in config_data else [],
# 'attendance_type': [(0, 0, {'attendance_type': '1',
# 'attendance_date_range_type': 'hour'})] if 'attendance' in config_data else [],
}
# 将config_id_data添加到property_data中如果有的话
@@ -152,16 +142,9 @@ class WxSettings(models.Model):
'display': property_data.get('display', None),
})],
'config_id': [(0, 0, {
'date_type': [(0, 0, {'date_type': config_data.get('date', {}).get('type',
None)})] if 'date' in config_data else [],
# 'selector_type': [(0, 0, {
# 'selector_type': config_data['table']['children'][0].get('config', {}).get(
# 'selector', {}).get('type', None),
# 'options': [
# (0, 0, {'key': option['key'], 'text': option['value'][0]['text']})
# for option in config_data['table']['children'][0].get('config', {}).get('selector', {}).get('options', [])
# ],
# })] if 'selector' in config_data else [],
'date_type': [(0, 0, {'date_type':
config_data.get('date', {}).get(
'type', None)})] if 'date' in config_data else [],
'selector_type': [
(0, 0, {
'selector_type': child.get('config', {}).get('selector', {}).get('type', None),
@@ -177,10 +160,12 @@ class WxSettings(models.Model):
'contact_type': [
(0, 0, {'contact_type': config_data.get('contact', {}).get('type', None),
'contact_mode': config_data.get('contact', {}).get('mode',
None)})] if 'contact' in config_data else [],
None)})]
if 'contact' in config_data else [],
'file_type': [
(0, 0, {'is_only_photo': config_data.get('file', {}).get('is_only_photo',
None)})] if 'file' in config_data else [],
None)})]
if 'file' in config_data else [],
'table_type': [(0, 0, {
'table_children': table_children_records,
})] if 'table' in config_data else [],
@@ -200,7 +185,8 @@ class WxSettings(models.Model):
# # 'title': '文本框2'})]
'attendance_type': [(0, 0, {'attendance_type': '1',
'attendance_date_range_type': 'hour'})] if 'attendance' in config_data else [],
'attendance_date_range_type': 'hour'})]
if 'attendance' in config_data else [],
})],
}),
# 在这里添加更多的控件数据