提交 f3de60bd authored 作者: 贺阳's avatar 贺阳

1、小包和推送日志增加快速筛选以及默认近30日日志

2、发送邮件的异常原因根据语言,未发送成功的邮件生成的日志改为发送失败 3、关联托盘时,修改了托盘使用日期需要重新生成托盘号
上级 f819cef1
...@@ -6,8 +6,8 @@ msgid "" ...@@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 16.0\n" "Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-24 07:48+0000\n" "POT-Creation-Date: 2025-02-06 06:23+0000\n"
"PO-Revision-Date: 2025-01-24 15:50+0800\n" "PO-Revision-Date: 2025-02-06 14:27+0800\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"Language: zh_CN\n" "Language: zh_CN\n"
...@@ -17,6 +17,20 @@ msgstr "" ...@@ -17,6 +17,20 @@ msgstr ""
"Plural-Forms: nplurals=1; plural=0;\n" "Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 3.5\n" "X-Generator: Poedit 3.5\n"
#. module: ccs_base
#. odoo-python
#: code:addons/ccs_base/wizard/associate_pallet_wizard.py:0
#, python-format
msgid "%s The package does not exist, please check the input information!"
msgstr "%s 不存在该大包,请检查输入信息!"
#. module: ccs_base
#. odoo-python
#: code:addons/ccs_base/wizard/associate_pallet_wizard.py:0
#, python-format
msgid "%s at %s associated tray %s, with a tray usage date of %s"
msgstr "%s %s关联了托盘%s,托盘使用日期为%s"
#. module: ccs_base #. module: ccs_base
#. odoo-python #. odoo-python
#: code:addons/ccs_base/wizard/associate_pallet_wizard.py:0 #: code:addons/ccs_base/wizard/associate_pallet_wizard.py:0
...@@ -35,6 +49,15 @@ msgid "" ...@@ -35,6 +49,15 @@ msgid ""
"is: %s, %s %s email" "is: %s, %s %s email"
msgstr "%s %s 操作了异常信息,异常原因:%s,%s%s邮件" msgstr "%s %s 操作了异常信息,异常原因:%s,%s%s邮件"
#. module: ccs_base
#. odoo-python
#: code:addons/ccs_base/wizard/add_exception_info_wizard.py:0
#, python-format
msgid ""
"%s at %s manipulated abnormal information, the reason for the abnormality "
"is: %s, not sent %s email"
msgstr "%s %s 操作了异常信息,异常原因:%s,未发送%s邮件"
#. module: ccs_base #. module: ccs_base
#: model:mail.template,body_html:ccs_base.email_template_exception_notification_en #: model:mail.template,body_html:ccs_base.email_template_exception_notification_en
msgid "" msgid ""
...@@ -651,12 +674,6 @@ msgstr "区县" ...@@ -651,12 +674,6 @@ msgstr "区县"
msgid "COUNTY(EN)" msgid "COUNTY(EN)"
msgstr "区县(EN)" msgstr "区县(EN)"
#. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.view_add_exception_info_wizard
#: model_terms:ir.ui.view,arch_db:ccs_base.view_associate_pallet_wizard
msgid "Cancel"
msgstr ""
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_bl__cancel_reason #: model:ir.model.fields,field_description:ccs_base.field_cc_bl__cancel_reason
#: model:ir.model.fields,field_description:ccs_base.field_cc_ship_package__cancel_reason #: model:ir.model.fields,field_description:ccs_base.field_cc_ship_package__cancel_reason
...@@ -719,6 +736,8 @@ msgid "Clearance Files" ...@@ -719,6 +736,8 @@ msgid "Clearance Files"
msgstr "清关文件" msgstr "清关文件"
#. module: ccs_base #. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.view_add_exception_info_wizard
#: model_terms:ir.ui.view,arch_db:ccs_base.view_associate_pallet_wizard
#: model_terms:ir.ui.view,arch_db:ccs_base.view_batch_input_ship_package_wizard #: model_terms:ir.ui.view,arch_db:ccs_base.view_batch_input_ship_package_wizard
#: model_terms:ir.ui.view,arch_db:ccs_base.view_export_bl_big_package_xlsx_wizard #: model_terms:ir.ui.view,arch_db:ccs_base.view_export_bl_big_package_xlsx_wizard
msgid "Close" msgid "Close"
...@@ -766,6 +785,11 @@ msgstr "联系人" ...@@ -766,6 +785,11 @@ msgstr "联系人"
msgid "Container No" msgid "Container No"
msgstr "集装箱编号" msgstr "集装箱编号"
#. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_node__tally_state
msgid "Corresponding to the status of the big package"
msgstr "对应大包状态"
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_last_mile_provider__name #: model:ir.model.fields,field_description:ccs_base.field_cc_last_mile_provider__name
msgid "Courier Name" msgid "Courier Name"
...@@ -1200,7 +1224,7 @@ msgstr "高度" ...@@ -1200,7 +1224,7 @@ msgstr "高度"
#: model:ir.model.fields.selection,name:ccs_base.selection__cc_big_package__tally_state__handover_completed #: model:ir.model.fields.selection,name:ccs_base.selection__cc_big_package__tally_state__handover_completed
#: model:ir.model.fields.selection,name:ccs_base.selection__cc_node__tally_state__handover_completed #: model:ir.model.fields.selection,name:ccs_base.selection__cc_node__tally_state__handover_completed
msgid "Handover Completed" msgid "Handover Completed"
msgstr "" msgstr "尾程交接"
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_progress__handover_type #: model:ir.model.fields,field_description:ccs_base.field_cc_progress__handover_type
...@@ -1421,6 +1445,16 @@ msgstr "长度" ...@@ -1421,6 +1445,16 @@ msgstr "长度"
msgid "LSPTaxed" msgid "LSPTaxed"
msgstr "" msgstr ""
#. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_ship_package_view
msgid "Last 30 days Ship Package"
msgstr "近30日小包"
#. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_ship_package_view
msgid "Last 7 days ship package"
msgstr "近7日小包"
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields.selection,name:ccs_base.selection__cc_progress__handover_type__last_mile_pick_up #: model:ir.model.fields.selection,name:ccs_base.selection__cc_progress__handover_type__last_mile_pick_up
msgid "Last Mile PickUp" msgid "Last Mile PickUp"
...@@ -1511,6 +1545,16 @@ msgstr "最后更新人" ...@@ -1511,6 +1545,16 @@ msgstr "最后更新人"
msgid "Last Updated on" msgid "Last Updated on"
msgstr "最后更新时间" msgstr "最后更新时间"
#. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_ship_package_view
msgid "Last month ship package"
msgstr "上月小包"
#. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_ship_package_view
msgid "Last week ship package"
msgstr "上周小包"
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_package_good__item_link #: model:ir.model.fields,field_description:ccs_base.field_cc_package_good__item_link
#: model_terms:ir.ui.view,arch_db:ccs_base.form_cc_package_good_view #: model_terms:ir.ui.view,arch_db:ccs_base.form_cc_package_good_view
...@@ -1524,7 +1568,6 @@ msgstr "链接" ...@@ -1524,7 +1568,6 @@ msgstr "链接"
#. odoo-python #. odoo-python
#: code:addons/ccs_base/models/cc_bill_loading.py:0 #: code:addons/ccs_base/models/cc_bill_loading.py:0
#: code:addons/ccs_base/static/src/views/list.xml:0 #: code:addons/ccs_base/static/src/views/list.xml:0
#: model_terms:ir.ui.view,arch_db:ccs_base.form_cc_big_package_view
#, python-format #, python-format
msgid "Link Pallet" msgid "Link Pallet"
msgstr "关联托盘" msgstr "关联托盘"
...@@ -1563,7 +1606,7 @@ msgstr "主数据" ...@@ -1563,7 +1606,7 @@ msgstr "主数据"
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_last_mile_provider__matching_value #: model:ir.model.fields,field_description:ccs_base.field_cc_last_mile_provider__matching_value
msgid "Matching Value" msgid "Matching Value"
msgstr "尾程快递匹配值" msgstr "尾程服务商匹配值"
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_big_package__message_has_error #: model:ir.model.fields,field_description:ccs_base.field_cc_big_package__message_has_error
...@@ -1725,13 +1768,6 @@ msgstr "节点类型" ...@@ -1725,13 +1768,6 @@ msgstr "节点类型"
msgid "Normal" msgid "Normal"
msgstr "正常" msgstr "正常"
#. module: ccs_base
#. odoo-python
#: code:addons/ccs_base/wizard/add_exception_info_wizard.py:0
#, python-format
msgid "Not Sent"
msgstr "未发送"
#. module: ccs_base #. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_bl_view #: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_bl_view
#: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_ship_package_view #: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_ship_package_view
...@@ -2309,6 +2345,13 @@ msgstr "发货人税号" ...@@ -2309,6 +2345,13 @@ msgstr "发货人税号"
msgid "Sent" msgid "Sent"
msgstr "已发送" msgstr "已发送"
#. module: ccs_base
#. odoo-python
#: code:addons/ccs_base/wizard/add_exception_info_wizard.py:0
#, python-format
msgid "Sent Fail"
msgstr "发送失败"
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields.selection,name:ccs_base.selection__cc_package_good__item_tax_status__sentinel #: model:ir.model.fields.selection,name:ccs_base.selection__cc_package_good__item_tax_status__sentinel
#: model:ir.model.fields.selection,name:ccs_base.selection__cc_ship_package__tax_mark__sentinel #: model:ir.model.fields.selection,name:ccs_base.selection__cc_ship_package__tax_mark__sentinel
...@@ -2463,7 +2506,6 @@ msgstr "已理货大包数量" ...@@ -2463,7 +2506,6 @@ msgstr "已理货大包数量"
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_big_package__tally_state #: model:ir.model.fields,field_description:ccs_base.field_cc_big_package__tally_state
#: model:ir.model.fields,field_description:ccs_base.field_cc_node__tally_state
msgid "Tally Status" msgid "Tally Status"
msgstr "理货状态" msgstr "理货状态"
...@@ -2557,11 +2599,26 @@ msgstr "托盘号只能输入数字!" ...@@ -2557,11 +2599,26 @@ msgstr "托盘号只能输入数字!"
msgid "The usage date cannot be later than the current date!" msgid "The usage date cannot be later than the current date!"
msgstr "使用日期不能大于当前日期!" msgstr "使用日期不能大于当前日期!"
#. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_ship_package_view
msgid "This month ship package"
msgstr "本月小包"
#. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_ship_package_view
msgid "This week ship package"
msgstr "本周小包"
#. module: ccs_base #. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_bl_view #: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_bl_view
msgid "Today Deadline" msgid "Today Deadline"
msgstr "今天截止" msgstr "今天截止"
#. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_ship_package_view
msgid "Today's ship package"
msgstr "今日小包"
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_bl__bl_total_amount #: model:ir.model.fields,field_description:ccs_base.field_cc_bl__bl_total_amount
#: model_terms:ir.ui.view,arch_db:ccs_base.form_cc_bl_view #: model_terms:ir.ui.view,arch_db:ccs_base.form_cc_bl_view
...@@ -2709,7 +2766,7 @@ msgstr "更新小包状态" ...@@ -2709,7 +2766,7 @@ msgstr "更新小包状态"
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_associate_pallet_wizard__usage_date #: model:ir.model.fields,field_description:ccs_base.field_associate_pallet_wizard__usage_date
msgid "Usage Date" msgid "Usage Date"
msgstr "" msgstr "使用日期"
#. module: ccs_base #. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_ship_package__user_track_note #: model:ir.model.fields,field_description:ccs_base.field_cc_ship_package__user_track_note
...@@ -2769,6 +2826,18 @@ msgstr "是否分大包导出" ...@@ -2769,6 +2826,18 @@ msgstr "是否分大包导出"
msgid "YES" msgid "YES"
msgstr "是" msgstr "是"
#. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.search_cc_ship_package_view
msgid "Yesterday's ship package"
msgstr "昨日小包"
#. module: ccs_base
#. odoo-python
#: code:addons/ccs_base/models/cc_bill_loading.py:0
#, python-format
msgid "You have no expense to report"
msgstr ""
#. module: ccs_base #. module: ccs_base
#: model_terms:ir.actions.act_window,help:ccs_base.action_cc_big_package #: model_terms:ir.actions.act_window,help:ccs_base.action_cc_big_package
msgid "" msgid ""
......
...@@ -392,7 +392,7 @@ class CcShipPackage(models.Model): ...@@ -392,7 +392,7 @@ class CcShipPackage(models.Model):
default=lambda self: self.env['cc.node'].search( default=lambda self: self.env['cc.node'].search(
[('node_type', '=', 'package'), ('is_default', '=', True)], limit=1)) [('node_type', '=', 'package'), ('is_default', '=', True)], limit=1))
node_exception_reason_id = fields.Many2one('cc.node.exception.reason', 'Exception Reason') node_exception_reason_id = fields.Many2one('cc.node.exception.reason', 'Exception Reason')
process_time = fields.Datetime('Process Time') process_time = fields.Datetime('Process Time', index=True)
exception_info_ids = fields.Many2many('cc.exception.info', 'shippackage_exception_info_rel', exception_info_ids = fields.Many2many('cc.exception.info', 'shippackage_exception_info_rel',
string='Exception Information') string='Exception Information')
......
...@@ -9,4 +9,4 @@ class CCLastMileProvider(models.Model): ...@@ -9,4 +9,4 @@ class CCLastMileProvider(models.Model):
abbreviation = fields.Char(string='Abbreviation', required=True) # 简称 abbreviation = fields.Char(string='Abbreviation', required=True) # 简称
tape_color_value = fields.Char(string='Tape Color Value') # 胶带色值 tape_color_value = fields.Char(string='Tape Color Value') # 胶带色值
active = fields.Boolean('Active', default=True) # 有效☑️ active = fields.Boolean('Active', default=True) # 有效☑️
matching_value = fields.Float(string='Matching Value') # 尾程快递匹配值 matching_value = fields.Float(string='Matching Value') # 尾程服务商匹配值
...@@ -47,4 +47,4 @@ class CcNode(models.Model): ...@@ -47,4 +47,4 @@ class CcNode(models.Model):
('unprocessed_goods', 'Unprocessed goods'), ('unprocessed_goods', 'Unprocessed goods'),
('checked_goods', 'Checked goods'), ('checked_goods', 'Checked goods'),
('handover_completed', 'Handover Completed') ('handover_completed', 'Handover Completed')
], default='unprocessed_goods', string='Tally Status', index=True) # 理货状态 未理货/已理货/尾程交接 ], default='', string='Corresponding to the status of the big package', index=True) # 对应大包状态 未理货/已理货/尾程交接
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
<group> <group>
<field name="name"/> <!-- 快递名称 --> <field name="name"/> <!-- 快递名称 -->
<field name="abbreviation"/> <!-- 简称 --> <field name="abbreviation"/> <!-- 简称 -->
<field name="tape_color_value"/> <!-- 胶带色值 --> <field name="tape_color_value" required="1"/> <!-- 胶带色值 -->
<field name="matching_value"/> <!-- 尾程快递匹配值 --> <field name="matching_value"/> <!-- 尾程服务商匹配值 -->
</group> </group>
<group> <group>
<field name="active"/> <!-- 有效☑️ --> <field name="active"/> <!-- 有效☑️ -->
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<field name="name"/> <!-- 快递名称 --> <field name="name"/> <!-- 快递名称 -->
<field name="abbreviation"/> <!-- 简称 --> <field name="abbreviation"/> <!-- 简称 -->
<field name="tape_color_value"/> <!-- 胶带色值 --> <field name="tape_color_value"/> <!-- 胶带色值 -->
<field name="matching_value"/> <!-- 尾程快递匹配值 --> <field name="matching_value"/> <!-- 尾程服务商匹配值 -->
<field name="active"/> <!-- 有效☑️ --> <field name="active"/> <!-- 有效☑️ -->
</tree> </tree>
</field> </field>
......
...@@ -206,7 +206,28 @@ ...@@ -206,7 +206,28 @@
<field name="tracking_no" string="Search" <field name="tracking_no" string="Search"
filter_domain="['|', ('tracking_no', 'ilike', self), ('trade_no', 'ilike', self)]"/> filter_domain="['|', ('tracking_no', 'ilike', self), ('trade_no', 'ilike', self)]"/>
<separator/> <separator/>
<filter string="Today's ship package"
domain="[('create_date', '&gt;=',time.strftime('%%Y-%%m-%%d 00:00:00')),('create_date', '&lt;=',time.strftime('%%Y-%%m-%%d 24:00:00'))]"
name="today_ship"/>
<filter string="Yesterday's ship package"
domain="[('create_date','&gt;=', (context_today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d 00:00:00')),('create_date','&lt;=', (context_today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d 24:00:00'))]"
name="last_24h"/>
<filter string="Last 7 days ship package"
domain="[('create_date','&lt;=', (context_today() - datetime.timedelta(days=7)).strftime('%Y-%m-%d 24:00:00'))]"
name="last_7d"/>
<filter string="This week ship package" name="this_week_ship"
domain="[('create_date', '&gt;=', ((datetime.date.today() - datetime.timedelta(days=datetime.date.today().weekday()))).strftime('%Y-%m-%d')),
('create_date', '&lt;=', ((datetime.date.today() + datetime.timedelta(days=6-datetime.date.today().weekday()))).strftime('%Y-%m-%d'))]"/>
<filter string="Last week ship package" name="last_week_ship"
domain="[('create_date', '&gt;=', ((datetime.date.today() - datetime.timedelta(days=7+datetime.date.today().weekday()))).strftime('%Y-%m-%d')),
('create_date', '&lt;=', ((datetime.date.today() - datetime.timedelta(days=datetime.date.today().weekday()+1))).strftime('%Y-%m-%d'))]"/>
<filter string="This month ship package" name="this_month_ship"
domain="[('create_date','&gt;=', time.strftime('%Y-%m-1 00:00:00')),('create_date','&lt;',(context_today() + relativedelta(months=1)).strftime('%Y-%m-1 00:00:00'))]"/>
<filter string="Last month ship package" name="last_month_ship"
domain="[('create_date','&lt;', time.strftime('%Y-%m-1 00:00:00')),('create_date','&gt;=',(context_today() - relativedelta(months=1)).strftime('%Y-%m-1 00:00:00'))]"/>
<filter string="Last 30 days Ship Package" name="last_30d"
domain="[('create_date','&gt;=', (context_today() - datetime.timedelta(days=30)).strftime('%Y-%m-%d 00:00:00'))]"/>
<separator/>
<field name="tracking_no" string="Tracking No."/> <field name="tracking_no" string="Tracking No."/>
<field name="trade_no" string="Trade No"/> <field name="trade_no" string="Trade No"/>
<field name="user_track_note" string="User Tracking Note"/> <field name="user_track_note" string="User Tracking Note"/>
...@@ -295,9 +316,9 @@ ...@@ -295,9 +316,9 @@
<record model="ir.actions.act_window" id="action_cc_ship_package"> <record model="ir.actions.act_window" id="action_cc_ship_package">
<field name="name">Ship Package</field> <field name="name">Ship Package</field>
<field name="res_model">cc.ship.package</field> <field name="res_model">cc.ship.package</field>
<field name="view_mode">tree,form,pivot,graph</field> <field name="view_mode">tree,form,search,pivot,graph</field>
<field name="domain">[]</field> <field name="domain">[]</field>
<field name="context">{}</field> <field name="context">{'search_default_last_30d':1}</field>
<field name="help" type="html"> <field name="help" type="html">
<p class="o_view_nocontent_smiling_face"> <p class="o_view_nocontent_smiling_face">
[Ship Package] Not yet! Click the Create button in the top left corner and the sofa is yours! [Ship Package] Not yet! Click the Create button in the top left corner and the sofa is yours!
......
...@@ -44,18 +44,16 @@ class AddExceptionInfoWizard(models.TransientModel): ...@@ -44,18 +44,16 @@ class AddExceptionInfoWizard(models.TransientModel):
package_objs = self.get_order() package_objs = self.get_order()
for package in package_objs: for package in package_objs:
package.exception_info_ids = [(6, 0, exception_objs.ids)] # 回写小包的异常信息 package.exception_info_ids = [(6, 0, exception_objs.ids)] # 回写小包的异常信息
# 回写sns %s %s 操作了异常信息,异常原因:%s,%s发送%s邮件 # 发送邮件通知
if record.send_email:
self.send_email_notification(record, package_objs, exception_objs)
else:
body = _( body = _(
'%s at %s manipulated abnormal information, the reason for the abnormality is: %s, %s %s email') % ( '%s at %s manipulated abnormal information, the reason for the abnormality is: %s, not sent %s email') % (
self.env.user.name, fields.Datetime.now(), self.env.user.name, fields.Datetime.now(),
'/'.join([exception.reason for exception in exception_objs]), '/'.join([exception.reason for exception in exception_objs]),
_('Sent') if record.send_email else _('Not Sent'), _('Chinese') if record.email_language == 'zh_CN' else _('English'))
(_('Chinese') if record.email_language == 'zh_CN' else _(
'English')) if record.send_email else '')
package.message_post(body=body) package.message_post(body=body)
# 发送邮件通知
if record.send_email:
self.send_email_notification(record, package_objs, exception_objs)
def send_email_notification(self, wizard_obj, package_objs, exception_objs): def send_email_notification(self, wizard_obj, package_objs, exception_objs):
""" """
...@@ -74,10 +72,22 @@ class AddExceptionInfoWizard(models.TransientModel): ...@@ -74,10 +72,22 @@ class AddExceptionInfoWizard(models.TransientModel):
email_to = ','.join(set(email_arr)) # 取 异常信息里的邮箱 email_to = ','.join(set(email_arr)) # 取 异常信息里的邮箱
logging.info('email_to:%s' % email_to) logging.info('email_to:%s' % email_to)
default_email_from = self.env["ir.config_parameter"].sudo().get_param("default_email_from") default_email_from = self.env["ir.config_parameter"].sudo().get_param("default_email_from")
template_id.send_mail(wizard_obj.id, force_send=True, local_context = {'lang': self.email_language}
email_values={ mail_id = template_id.with_context(local_context).send_mail(wizard_obj.id, force_send=True,
'email_from': default_email_from, email_values={
'email_to': email_to 'email_from': default_email_from,
}) 'email_to': email_to
})
mail = self.env['mail.mail'].sudo().browse(mail_id)
for package in package_objs:
# 回写sns %s %s 操作了异常信息,异常原因:%s,%s发送%s邮件
body = _(
'%s at %s manipulated abnormal information, the reason for the abnormality is: %s, %s %s email') % (
self.env.user.name, fields.Datetime.now(),
'/'.join([exception.reason for exception in exception_objs]),
_('Sent Fail') if mail.exists() and mail.state == 'exception' else _('Sent'),
(_('Chinese') if wizard_obj.email_language == 'zh_CN' else _(
'English')) if wizard_obj.send_email else '')
package.message_post(body=body)
else: else:
raise UserError(_("Email template not found.")) raise UserError(_("Email template not found."))
...@@ -10,16 +10,20 @@ class AssociatePalletWizard(models.TransientModel): ...@@ -10,16 +10,20 @@ class AssociatePalletWizard(models.TransientModel):
_name = 'associate.pallet.wizard' _name = 'associate.pallet.wizard'
_description = 'Associate Pallet Wizard' _description = 'Associate Pallet Wizard'
def get_pallet_number(self): @api.onchange('usage_date')
def change_usage_date(self):
for item in self:
if item.usage_date:
item.pallet_number = item.get_pallet_number(item.usage_date)
def get_pallet_number(self, usage_date):
""" """
生成托盘号 从001开始,如果 生成托盘号 从001开始,如果
:return: 新的托盘号 :return: 新的托盘号
""" """
try: try:
# 获取当前日期
current_date = fields.Date.today()
# 查找大包中最新的托盘号 # 查找大包中最新的托盘号
latest_pallet = self.env['cc.big.package'].search([('pallet_usage_date', '=', str(current_date))], latest_pallet = self.env['cc.big.package'].search([('pallet_usage_date', '=', str(usage_date))],
order='pallet_number desc', limit=1) order='pallet_number desc', limit=1)
# 生成新的托盘号 # 生成新的托盘号
if latest_pallet: if latest_pallet:
...@@ -31,7 +35,7 @@ class AssociatePalletWizard(models.TransientModel): ...@@ -31,7 +35,7 @@ class AssociatePalletWizard(models.TransientModel):
raise ValidationError(str(e)) raise ValidationError(str(e))
usage_date = fields.Date(string='Usage Date', default=fields.Date.today) # 使用日期 usage_date = fields.Date(string='Usage Date', default=fields.Date.today) # 使用日期
pallet_number = fields.Char(string='Pallet Number', required=True, default=get_pallet_number) # 托盘号 pallet_number = fields.Char(string='Pallet Number', required=True) # 托盘号
big_package_numbers = fields.Text(string='Big Package Numbers') # 大包号(可输入多个) big_package_numbers = fields.Text(string='Big Package Numbers') # 大包号(可输入多个)
def confirm(self): def confirm(self):
...@@ -42,18 +46,32 @@ class AssociatePalletWizard(models.TransientModel): ...@@ -42,18 +46,32 @@ class AssociatePalletWizard(models.TransientModel):
raise ValidationError(_('The usage date cannot be later than the current date!')) # 使用日期不能大于当前日期! raise ValidationError(_('The usage date cannot be later than the current date!')) # 使用日期不能大于当前日期!
# 处理大包号 # 处理大包号
big_package_ids = record.big_package_numbers.splitlines() big_package_ids = record.big_package_numbers.splitlines()
success_package = []
fail_package = []
for package_number in big_package_ids: for package_number in big_package_ids:
package = self.env['cc.big.package'].search([('big_package_no', '=', package_number)], limit=1) package = self.env['cc.big.package'].search([('big_package_no', '=', package_number)], limit=1)
if package: if package:
success_package.append(package)
else:
fail_package.append(package_number)
if fail_package:
raise ValidationError(_('%s The package does not exist, please check the input information!') % (
'\n'.join(fail_package))) # 不存在该大包,请检查输入信息
if success_package:
for package in success_package:
# 回写大包的托盘号和使用日期 # 回写大包的托盘号和使用日期
old_pallet_number = package.pallet_number old_pallet_number = package.pallet_number
old_usage_date = package.pallet_usage_date old_usage_date = package.pallet_usage_date
package.update_pallet_info(record.pallet_number, record.usage_date) package.update_pallet_info(record.pallet_number, record.usage_date)
# %s %s更改了托盘号,由%s变更为%s,托盘使用日期%s变更为%s
if old_pallet_number: if old_pallet_number:
# %s %s更改了托盘号,由%s变更为%s,托盘使用日期%s变更为%s
body = _( body = _(
'%s at %s changed the pallet number from %s to %s, and the pallet usage date from %s to %s') % ( '%s at %s changed the pallet number from %s to %s, and the pallet usage date from %s to %s') % (
self.env.user.name, fields.Datetime.now(), old_pallet_number, record.pallet_number, self.env.user.name, fields.Datetime.now(), old_pallet_number, record.pallet_number,
old_usage_date, old_usage_date,
record.usage_date) record.usage_date)
package.message_post(body=body) else:
# 某人某时关联了托盘xxx,托盘使用日期xxxx
body = _('%s at %s associated tray %s, with a tray usage date of %s') % (
self.env.user.name, fields.Datetime.now(), record.pallet_number, record.usage_date)
package.message_post(body=body)
...@@ -41,15 +41,62 @@ ...@@ -41,15 +41,62 @@
</field> </field>
</record> </record>
<record model="ir.ui.view" id="search_ao_tt_api_log_view">
<field name="name">search.ao.tt.api.log</field>
<field name="model">ao.tt.api.log</field>
<field name="arch" type="xml">
<search string="TIKTOK推送日志">
<filter string="今日日志"
domain="[('create_date', '&gt;=',time.strftime('%%Y-%%m-%%d 00:00:00')),('create_date', '&lt;=',time.strftime('%%Y-%%m-%%d 24:00:00'))]"
name="create_date"/>
<filter string="昨日日志"
domain="[('create_date','&gt;=', (context_today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d 00:00:00')),('create_date','&lt;=', (context_today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d 24:00:00'))]"
name="last_24h"/>
<filter string="近7日日志"
domain="[('create_date','&lt;=', (context_today() - datetime.timedelta(days=7)).strftime('%Y-%m-%d 24:00:00'))]"
name="last_7d"/>
<filter string="本周日志" name="this_week_log"
domain="[('create_date', '&gt;=', ((datetime.date.today() - datetime.timedelta(days=datetime.date.today().weekday()))).strftime('%Y-%m-%d')),
('create_date', '&lt;=', ((datetime.date.today() + datetime.timedelta(days=6-datetime.date.today().weekday()))).strftime('%Y-%m-%d'))]"/>
<filter string="上周日志" name="last_week_log"
domain="[('create_date', '&gt;=', ((datetime.date.today() - datetime.timedelta(days=7+datetime.date.today().weekday()))).strftime('%Y-%m-%d')),
('create_date', '&lt;=', ((datetime.date.today() - datetime.timedelta(days=datetime.date.today().weekday()+1))).strftime('%Y-%m-%d'))]"/>
<filter string="本月日志" name="this_month_log"
domain="[('create_date','&gt;=', time.strftime('%Y-%m-1 00:00:00')),('create_date','&lt;',(context_today() + relativedelta(months=1)).strftime('%Y-%m-1 00:00:00'))]"/>
<filter string="上月日志" name="last_month_log"
domain="[('create_date','&lt;', time.strftime('%Y-%m-1 00:00:00')),('create_date','&gt;=',(context_today() - relativedelta(months=1)).strftime('%Y-%m-1 00:00:00'))]"/>
<filter string="近30日日志" name="last_30d"
domain="[('create_date','&gt;=', (context_today() - datetime.timedelta(days=30)).strftime('%Y-%m-%d 00:00:00'))]"/>
<separator/>
<field name="big_bag_no"/>
<field name="data_text"/>
<separator/>
<filter name="filter_success_bl" string="成功" domain="[('success_bl','=',True)]"/>
<filter name="filter_not_success_bl" string="失败" domain="[('success_bl','=',False)]"/>
<separator/>
<group expand="0" string="分组">
<filter domain="[]" name="groupby_success_bl" string="是否成功"
context="{'group_by': 'success_bl'}"/>
<filter domain="[]" name="groupby_big_bag_no" string="业务信息"
context="{'group_by': 'big_bag_no'}"/>
<filter domain="[]" name="groupby_source" string="类型"
context="{'group_by': 'source'}"/>
</group>
<searchpanel>
<field icon="fa-users" select="multi" name="source"/>
</searchpanel>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_ao_tt_api_log"> <record model="ir.actions.act_window" id="action_ao_tt_api_log">
<field name="name">TIKTOK推送日志</field> <field name="name">TIKTOK推送日志</field>
<field name="res_model">ao.tt.api.log</field> <field name="res_model">ao.tt.api.log</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form,search</field>
<field name="domain">[]</field> <field name="domain">[]</field>
<field name="context">{}</field> <field name="context">{'search_default_last_30d':1}</field>
</record> </record>
<menuitem <menuitem
id="menu_ao_flight_tt_api_log" id="menu_ao_flight_tt_api_log"
name="TIKTOK推送日志" name="TIKTOK推送日志"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论