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

1.优化动作跳转

2.日志
上级 b6695019
...@@ -105,7 +105,8 @@ class CcBigPackage(models.Model): ...@@ -105,7 +105,8 @@ class CcBigPackage(models.Model):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'cc.package.good', 'res_model': 'cc.package.good',
'view_mode': 'tree,form', 'view_mode': 'tree,form',
'domain': [('big_package_id', '=', self.id), ('is_cancel', '=', False)], # 'domain': [('big_package_id', '=', self.id), ('is_cancel', '=', False)],
'domain': [('bl_line_id', 'in', self.ship_package_ids.ids), ('is_cancel', '=', False)],
} }
def action_link_pallet(self): def action_link_pallet(self):
...@@ -865,12 +866,19 @@ class CcBL(models.Model): ...@@ -865,12 +866,19 @@ class CcBL(models.Model):
# 创建显示商品的action # 创建显示商品的action
def action_show_package_good(self): def action_show_package_good(self):
# 返回一个action,显示商品 # 返回一个action,显示商品
sql = "select id from cc_ship_package where bl_id=%s" % self.id
self._cr.execute(sql)
result = self._cr.fetchall()
ids = []
if result:
ids = [i[0] for i in result]
return { return {
'name': _('Goods'), 'name': _('Goods'),
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'cc.package.good', 'res_model': 'cc.package.good',
'view_mode': 'tree,form', 'view_mode': 'tree,form',
'domain': [('bl_id', '=', self.id), ('is_cancel', '=', False)], # 'domain': [('bl_id', '=', self.id), ('is_cancel', '=', False)],
'domain': [('bl_line_id', 'in', ids), ('is_cancel', '=', False)],
} }
# 增加清关截止日期 # 增加清关截止日期
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
'security/ir.model.access.csv', 'security/ir.model.access.csv',
# data # data
'data/data.xml', 'data/data.xml',
'data/timer.xml',
# wizard # wizard
'wizard/batch_input_ship_package_statu_wizard.xml', 'wizard/batch_input_ship_package_statu_wizard.xml',
'wizard/update_bl_status_wizard.xml', 'wizard/update_bl_status_wizard.xml',
......
<odoo>
<data>
<record id="cron_delete_log" model="ir.cron">
<field name="name">定时删除历史日志</field>
<field name="model_id" ref="ccs_connect_tiktok.model_ao_tt_api_log"/>
<field name="state">code</field>
<field name="code">model.cron_delete_log()</field>
<field name='interval_number'>2</field>
<field name='interval_type'>hours</field>
<field name="numbercall">-1</field>
<field name="active" eval="False"/>
</record>
</data>
</odoo>
\ No newline at end of file
...@@ -4,6 +4,7 @@ from datetime import datetime ...@@ -4,6 +4,7 @@ from datetime import datetime
from odoo import models, fields, api, _ from odoo import models, fields, api, _
from odoo.exceptions import ValidationError, Warning from odoo.exceptions import ValidationError, Warning
import logging import logging
from datetime import timedelta
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
...@@ -14,7 +15,7 @@ class TTErrorLog(models.Model): ...@@ -14,7 +15,7 @@ class TTErrorLog(models.Model):
_order = 'id desc' _order = 'id desc'
big_bag_no = fields.Char('业务信息', index=True) big_bag_no = fields.Char('业务信息', index=True)
push_time = fields.Datetime('产生时间', index=True) push_time = fields.Datetime('产生时间')
error_msg = fields.Char('失败原因') error_msg = fields.Char('失败原因')
success_bl = fields.Boolean('是否成功', default=False, index=True) success_bl = fields.Boolean('是否成功', default=False, index=True)
data_text = fields.Text('传输数据') data_text = fields.Text('传输数据')
...@@ -42,3 +43,24 @@ class TTErrorLog(models.Model): ...@@ -42,3 +43,24 @@ class TTErrorLog(models.Model):
def deal_tt_error_log(self): def deal_tt_error_log(self):
for item in self: for item in self:
item.state = '已处理' item.state = '已处理'
def cron_delete_log(self):
history_days = self.env['ir.config_parameter'].sudo().get_param('history_days') or 180
history_limit_log = self.env['ir.config_parameter'].sudo().get_param('history_limit_log') or 10000
history_limit_log = int(history_limit_log)
history_days = int(history_days)
current_date = datetime.utcnow()
# 计算180天之前的日期
past_date = current_date - timedelta(days=history_days)
sql = 'select id from ao_tt_api_log where create_date < %s order by create_date asc limit %s;'
self._cr.execute(sql, (past_date, history_limit_log))
result = self._cr.fetchall()
tk_log_ids = []
if result:
tk_log_ids = [i[0] for i in result]
if tk_log_ids:
log_ids = '(%s)' % str(tk_log_ids)[1:-1]
delete_api_log_sql = 'delete from ao_tt_api_log where id in %s' % log_ids
self._cr.execute(delete_api_log_sql)
self._cr.commit()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论