提交 2127e306 authored 作者: 刘擎阳's avatar 刘擎阳

1.优化bug

上级 799749cb
...@@ -8,6 +8,20 @@ class CCNode(models.Model): ...@@ -8,6 +8,20 @@ class CCNode(models.Model):
_name = 'cc.node' _name = 'cc.node'
_inherit = 'cc.node' _inherit = 'cc.node'
def name_get(self):
# 1. 如果 XML 视图里没有传这个 context,就走系统默认逻辑(只显示名字)
if not self.env.context.get('show_code_in_name'):
return super(CCNode, self).name_get()
# 2. 如果传了 context,说明是在预警配置页面,执行拼接逻辑
result = []
for record in self:
if record.tk_code:
name = f"{record.name}-{record.tk_code}"
else:
name = record.name
result.append((record.id, name))
return result
tk_code = fields.Char('TK Code', help='TK Code') tk_code = fields.Char('TK Code', help='TK Code')
interval_minutes = fields.Integer('Predecessor Node Interval (Minutes)', default=20, interval_minutes = fields.Integer('Predecessor Node Interval (Minutes)', default=20,
help='Default interval time between predecessor nodes in minutes.') # 前序节点间隔时间,默认20分钟 help='Default interval time between predecessor nodes in minutes.') # 前序节点间隔时间,默认20分钟
......
...@@ -76,7 +76,7 @@ class WarningConfig(models.Model): ...@@ -76,7 +76,7 @@ class WarningConfig(models.Model):
utc_dt = dt.astimezone(timezone.utc) utc_dt = dt.astimezone(timezone.utc)
# 3. 返回格式化后的字符串 # 3. 返回格式化后的字符串
return datetime.strptime(utc_dt.strftime("%Y-%m-%d %H:%M:%S"), '%d/%m/%Y %H:%M:%S') return datetime.strptime(utc_dt.strftime("%Y-%m-%d %H:%M:%S"), "%Y-%m-%d %H:%M:%S")
# def cron_warn_cc_order(self): # def cron_warn_cc_order(self):
# # 获取最近几天的提单 未完成的 # # 获取最近几天的提单 未完成的
...@@ -288,12 +288,15 @@ class WarningConfig(models.Model): ...@@ -288,12 +288,15 @@ class WarningConfig(models.Model):
# c_time = utc_time - timedelta(days=warn_days) # c_time = utc_time - timedelta(days=warn_days)
end_date = fields.Date.today() end_date = fields.Date.today()
start_date = end_date - timedelta(days=warn_days) start_date = end_date - timedelta(days=warn_days)
print(start_date)
config_objs = self.env['warning.config'].sudo().search([]) config_objs = self.env['warning.config'].sudo().search([])
bl_objs = self.env['cc.bl'].sudo().search([ bl_objs = self.env['cc.bl'].sudo().search([
('bl_date', '>=', start_date), ('bl_date', '>=', start_date),
('state', '!=', 'done') ('state', '!=', 'done')
]) ])
# bl_objs = self.env['cc.bl'].sudo().search([
# ('id', '=', 71)
# ])
if not config_objs or not bl_objs: if not config_objs or not bl_objs:
return return
# 2. 获取包裹及预计算提单的 ETA (避免重复转换时间) # 2. 获取包裹及预计算提单的 ETA (避免重复转换时间)
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
id="menu_tt_api_log" id="menu_tt_api_log"
name="TIKTOK推送日志" parent="" name="TIKTOK推送日志" parent=""
groups="ccs_base.group_clearance_of_customs_user,ccs_base.group_clearance_of_customs_manager" groups="ccs_base.group_clearance_of_customs_user,ccs_base.group_clearance_of_customs_manager"
sequence="21" action="action_ao_tt_api_log"/> sequence="22" action="action_ao_tt_api_log"/>
<!-- 菜单项 --> <!-- 菜单项 -->
<menuitem id="menu_bl_patrol" <menuitem id="menu_bl_patrol"
name="提单巡查" name="提单巡查"
action="action_bl_patrol" action="action_bl_patrol"
sequence="22" sequence="23"
groups="ccs_base.group_clearance_of_customs_user,ccs_base.group_clearance_of_customs_manager"/> groups="ccs_base.group_clearance_of_customs_user,ccs_base.group_clearance_of_customs_manager"/>
......
...@@ -19,14 +19,14 @@ ...@@ -19,14 +19,14 @@
attrs="{ attrs="{
'invisible': [('time_type', '=', 'flight_landing')], 'invisible': [('time_type', '=', 'flight_landing')],
'required': [('time_type', '=', 'clearance_node')] 'required': [('time_type', '=', 'clearance_node')]
}"/> }" context="{'show_code_in_name': True}"/>
<field name="flight_landing_time" <field name="flight_landing_time"
attrs="{'invisible': [('time_type', '=', 'clearance_node')]}"/> attrs="{'invisible': [('time_type', '=', 'clearance_node')]}"/>
<field name="remaining_time"/> <field name="remaining_time"/>
</group> </group>
<group> <group>
<field name="unsynced_node_id"/> <field name="unsynced_node_id" context="{'show_code_in_name': True}"/>
<field name="active" invisible="1"/> <field name="active" invisible="1"/>
</group> </group>
</group> </group>
...@@ -85,5 +85,5 @@ ...@@ -85,5 +85,5 @@
<menuitem id="menu_warning_config" <menuitem id="menu_warning_config"
name="预警配置" name="预警配置"
action="action_warning_config" action="action_warning_config"
sequence="10"/> sequence="21" groups="base.group_system"/>
</odoo> </odoo>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论