提交 32de84af authored 作者: 贺阳's avatar 贺阳

同一提单,同一托盘号,使用日期必须一致

上级 1af63629
......@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-07 07:52+0000\n"
"PO-Revision-Date: 2025-02-07 15:53+0800\n"
"POT-Creation-Date: 2025-02-08 01:29+0000\n"
"PO-Revision-Date: 2025-02-08 09:30+0800\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: zh_CN\n"
......@@ -455,6 +455,15 @@ msgstr "大包"
msgid "Big Package No"
msgstr "大包号"
#. module: ccs_base
#. odoo-python
#: code:addons/ccs_base/wizard/associate_pallet_wizard.py:0
#, python-format
msgid ""
"Big Package No :%s ,The same bill of lading, same pallet number, and usage "
"date must be consistent!"
msgstr "大包号:%s ,同一提单、同一托盘号的使用日期必须一致!"
#. module: ccs_base
#: model:ir.model.fields,field_description:ccs_base.field_cc_big_package__big_package_no
#: model_terms:ir.ui.view,arch_db:ccs_base.form_cc_big_package_view
......
......@@ -65,6 +65,8 @@ class CcBigPackage(models.Model):
], default='unprocessed_goods', string='Tally Status', index=True) # 理货状态 未理货/已理货/尾程交接
tally_user_id = fields.Many2one('res.users', 'Tally User', index=True) # 理货人
tally_time = fields.Datetime('Tally Time') # 理货时间
delivery_user_id = fields.Many2one('res.users', string='Delivery User', index=True) # 尾程交货人
delivery_time = fields.Datetime(string='Delivery Time') # 尾程交货时间
exception_info_ids = fields.Many2many('cc.exception.info', 'bigpackage_exception_info_rel',
string='Exception Information')
......@@ -78,6 +80,16 @@ class CcBigPackage(models.Model):
self.pallet_usage_date = pallet_usage_date
self.pallet_number = pallet_number
def update_exception_info(self, exception_info_ids, is_send=False, email_language='zh_CN'):
"""
大包回写异常原因,发送邮件
:param exception_info_ids:
:return:
"""
self.exception_info_ids = [(6, 0, exception_info_ids)]
if is_send:
pass
# 创建显示包裹的action
def action_show_ship_package(self):
# 返回一个action,显示包裹
......@@ -397,6 +409,16 @@ class CcShipPackage(models.Model):
exception_info_ids = fields.Many2many('cc.exception.info', 'shippackage_exception_info_rel',
string='Exception Information')
def update_exception_info(self, exception_info_ids, is_send=False, email_language='zh_CN'):
"""
小包回写异常原因,发送邮件
:param exception_info_ids:
:return:
"""
self.exception_info_ids = [(6, 0, exception_info_ids)]
if is_send:
pass
# 重载write方法,在进度状态变化时,将is_sync置为False, 同时检查is_sync为false时,不允许修改进度状态
def write(self, vals):
# if not self.is_sync and 'state' in vals:
......
......@@ -14,9 +14,11 @@
<field name="is_cancel" string="Cancelled"/>
<field name="pallet_number"/>
<field name="pallet_usage_date"/>
<field name="tally_state" optional="show"/>
<field name="tally_user_id" optional="show"/>
<field name="tally_time" optional="show"/>
<field name="tally_state" optional="show"/>
<field name="delivery_user_id" optional="show"/>
<field name="delivery_time" optional="show"/>
</tree>
</field>
</record>
......@@ -69,6 +71,8 @@
<field name="tally_state" readonly="1"/>
<field name="tally_user_id" readonly="1" options="{'no_create':True}"/>
<field name="tally_time" readonly="1"/>
<field name="delivery_user_id" readonly="1" options="{'no_create':True}"/>
<field name="delivery_time" readonly="1"/>
</group>
<group>
<field name="ship_package_qty" string="Package Qty"/>
......
......@@ -43,7 +43,7 @@ class AddExceptionInfoWizard(models.TransientModel):
exception_objs = record.exception_ids
package_objs = self.get_order()
for package in package_objs:
package.exception_info_ids = [(6, 0, exception_objs.ids)] # 回写小包的异常信息
package.update_exception_info(exception_objs.ids) # 回写小包的异常信息
# 发送邮件通知
if record.send_email:
self.send_email_notification(record, package_objs, exception_objs)
......
......@@ -66,10 +66,12 @@ class AssociatePalletWizard(models.TransientModel):
# 同一提单,同一托盘号,使用日期必须一致
related_packages = package.bl_id.big_package_ids.filtered(
lambda p: p.pallet_number == new_pallet_number) # 查找对应提单下相同托盘号的所有大包
for related_package in related_packages:
if related_package.pallet_usage_date != record.usage_date:
warning_package_arr = [related_package.big_package_no for related_package in related_packages if
related_package.pallet_usage_date != record.usage_date]
if warning_package_arr:
raise ValidationError(
_('The same bill of lading, same pallet number, and usage date must be consistent!')) # 同一提单,同一托盘号,使用日期必须一致
_('Big Package No :%s ,The same bill of lading, same pallet number, and usage date must be consistent!') % (
'\n'.join(warning_package_arr))) # 大包号关联的同一提单,同一托盘号,使用日期必须一致
package.update_pallet_info(new_pallet_number, record.usage_date)
if old_pallet_number:
# %s %s更改了托盘号,由%s变更为%s,托盘使用日期%s变更为%s
......
......@@ -17,6 +17,10 @@ bill_null_msg_dic = {
'en': 'The bill of lading number cannot be empty',
'zh': '提单号不能为空'
}
bill_state_msg_dic = {
'en': 'No information was found in the system regarding the bill of lading that has not completed customs clearance',
'zh': '没有在系统中找到未完成清关的该提单信息'
}
class OrderController(http.Controller):
......@@ -68,7 +72,7 @@ class OrderController(http.Controller):
@http.route('/api/bl/info', type='json', auth='public', methods=['GET', 'POST'], csrf=False)
def bl_info(self):
"""
查看提单以及大包信息
查看提单以及大包,小包和托盘信息
:param kwargs:
:return:
"""
......@@ -77,14 +81,17 @@ class OrderController(http.Controller):
res = {'state': 201, 'message': ''}
try:
logging.info('bl_info kwargs:%s' % kwargs)
if kwargs.get('bl_no'):
bl_no = kwargs['bl_no']
bl_obj = request.env['cc.bl'].sudo().search([('bl_no', '=', bl_no)]) # 提单
# bl_obj = request.env['cc.bl'].sudo().search([('bl_no', '=', bl_no)]) # 提单
state_arr = ['draft', 'ccing']
bl_obj = request.env['cc.bl'].sudo().deal_bl_no(bl_no) # 提单号去掉杠和空格,并转换为小写
if bl_obj:
if bl_obj.state in state_arr:
res['bl_info'] = bl_obj.search_bl_info(pda_lang=pda_lang)
res['state'] = 200
else:
res['message'] = bill_state_msg_dic[pda_lang] # 没有在系统中找到未完成清关的该提单信息
else:
res['state'] = 404
res['message'] = bill_noexist_msg_dic[pda_lang] # _('Bill of lading does not exist') # 提单不存在
......@@ -113,34 +120,69 @@ class OrderController(http.Controller):
kwargs = json.loads(request.httprequest.data)
pda_lang = kwargs.get('pda_lang') or 'zh'
res = {'state': 201, 'message': ''}
action_type = kwargs.get('action_type') or 'tally' # tally / handover
try:
logging.info('update_big_package_tally_detail kw:%s' % kwargs)
if kwargs.get('bl_no') and kwargs.get('big_package_arr'):
if kwargs.get('bl_no') and action_type and (
kwargs.get('big_package_arr') or kwargs.get('ship_package_arr') or kwargs.get('pallet_arr')):
bl_no = kwargs['bl_no']
bl_obj = request.env['cc.bl'].sudo().search([('bl_no', '=', bl_no)]) # 提单
# bl_obj = request.env['cc.bl'].sudo().search([('bl_no', '=', bl_no)]) # 提单
state_arr = ['draft', 'ccing']
bl_obj = request.env['cc.bl'].sudo().deal_bl_no(bl_no) # 提单号去掉杠和空格,并转换为小写
big_package_arr = kwargs['big_package_arr']
if bl_obj:
if bl_obj.state in state_arr:
ship_package_ids = []
big_package_exception_arr = {}
ship_package_exception_arr = {}
# 小包
if kwargs.get('ship_package_arr'):
ship_package_arr = kwargs['ship_package_arr']
error_no_arr = [] # 不存在小包的物流订单号
for package_item in ship_package_arr:
logistic_order_no = package_item.get('logistic_order_no') # 物流订单号
exception_cause_ids = package_item.get('exception_cause_ids') # 异常原因id数组
ship_package_obj = request.env['cc.ship.package'].sudo().search(
[('logistic_order_no', '=', logistic_order_no)]) # 大包号
if ship_package_obj:
ship_package_ids.append(ship_package_obj.id)
for excep_item in exception_cause_ids:
ship_package_exception_arr[excep_item] = [ship_package_obj.id]
ship_package_obj.update_exception_info(exception_cause_ids) # 修改异常信息
else:
error_no_arr.append(logistic_order_no)
if len(error_no_arr) > 0:
error_no_str = ','.join(list(set(error_no_arr)))
noexist_msg_dic = {
'en': 'Ship package number [%s] does not exist' % error_no_str,
'zh': '小包物流订单号[%s]不存在' % error_no_str
}
res['message'] = noexist_msg_dic[pda_lang]
else:
res['state'] = 200
# 大包
if kwargs.get('big_package_arr'):
big_package_arr = kwargs['big_package_arr']
# 该箱号的大包存在, 且状态为已扫, 则提示已扫;
# 该箱号的大包不存在, 则提示该箱号在系统中不存在;
tally_no_arr = [] # 已理货大包号
error_no_arr = [] # 不存在大包号
for package_item in big_package_arr:
big_package_no = package_item.get('big_package_no') # 大包号
tally_state = package_item.get('tally_state') # 理货状态
tally_user_id = package_item.get('tally_user_id') # 理货人
tally_time = package_item.get('tally_time') # 理货时间
exception_cause_ids = package_item.get('exception_cause_ids') # 异常原因id数组
big_package_obj = request.env['cc.big.package'].sudo().search(
[('big_package_no', '=', big_package_no)]) # 大包号
if big_package_obj:
ship_package_arr += big_package_obj.ship_package_ids # 小包
for excep_item in exception_cause_ids:
big_package_exception_arr[excep_item] = [big_package_obj.id]
if big_package_obj.tally_state == 'unprocessed_goods':
big_package_obj.update_big_package_info(tally_state=tally_state,
big_package_obj.update_big_package_info(action_type=action_type,
tally_state=tally_state,
tally_user_id=tally_user_id,
tally_time=tally_time) # 修改理货信息
# else:
# tally_no_arr.append(big_package_no)
big_package_obj.update_exception_info(exception_cause_ids) # 修改异常信息
else:
error_no_arr.append(big_package_no)
if len(error_no_arr) > 0:
......@@ -153,26 +195,61 @@ class OrderController(http.Controller):
pda_lang] # _('Big package number [%s] does not exist',','.join(list(set(error_no_arr)))) # 大包号[%s]不存在
else:
res['state'] = 200
# if len(tally_no_arr) > 0:
# res['message'] = '大包号[%s]已理货,无需重新理货!' % ','.join(list(set(tally_no_arr)))
# 托盘
if kwargs.get('pallet_arr'):
pallet_arr = kwargs['pallet_arr']
error_no_arr = []
for pallet_item in pallet_arr:
pallet_number = pallet_item.get('pallet_number') # 托盘号
tally_state = pallet_item.get('tally_state') # 理货状态
tally_user_id = pallet_item.get('tally_user_id') # 理货人
tally_time = pallet_item.get('tally_time') # 理货时间
exception_cause_ids = package_item.get('exception_cause_ids') # 异常原因ids
# 找出该提单下托盘号对应的所有大包
big_package_obj = request.env['cc.big.package'].sudo().search(
[('pallet_number', '=', pallet_number), ('bl_id', '=', bl_obj.id)])
if big_package_obj:
for big_package_item in big_package_obj:
for excep_item in exception_cause_ids:
big_package_exception_arr[excep_item].append(big_package_item.id)
if big_package_item.tally_state == 'unprocessed_goods':
big_package_item.update_big_package_info(action_type=action_type,
tally_state=tally_state,
tally_user_id=tally_user_id,
tally_time=tally_time) # 修改理货信息
big_package_item.update_exception_info(exception_cause_ids) # 修改异常信息
else:
error_no_arr.append(pallet_number)
if len(error_no_arr) > 0:
error_no_str = ','.join(list(set(error_no_arr)))
noexist_msg_dic = {
'en': 'Tray number [%s] does not have a corresponding big package' % error_no_str,
'zh': '托盘[%s]没有对应的大包' % error_no_str
}
res['message'] = noexist_msg_dic[pda_lang]
else:
res['state'] = 200
# 同一批异常原因的,同一种类型(大包/小包)发送一封邮件,发送给异常原因上配置的邮箱。
logging.info('big:%s' % big_package_exception_arr)
logging.info('ship:%s' % ship_package_exception_arr)
else:
res['message'] = bill_state_msg_dic[pda_lang] # 没有在系统中找到未完成清关的该提单信息
else:
res['message'] = bill_noexist_msg_dic[pda_lang] # 提单不存在
else:
null_msg_dic = {
'en': 'The bill of lading number and package data cannot be empty',
'zh': '提单号和大包数据不能为空'
'en': 'The bill of lading number and action type must be provided; at least one of the following is required: big package data, ship package data, or pallet data.',
'zh': '提单号和类型必须提供;以下三者中至少需要提供一个:大包数据、小包数据或托盘数据。'
}
res['message'] = null_msg_dic[
pda_lang] # _('The bill of lading number and package data cannot be empty') # 提单号和大包数据不能为空
res['message'] = null_msg_dic[pda_lang]
except Exception as e:
logging.info('update_big_package_tally_detail error:%s' % e)
exceptions_msg_dic = {
'en': 'System parsing error, the reason for the error is %s' % e,
'zh': '系统解析错误,错误原因是%s' % e
}
res['message'] = exceptions_msg_dic[
pda_lang] # _('System parsing error, the reason for the error is %s', e) # 系统解析错误,错误原因是
res['message'] = exceptions_msg_dic[pda_lang]
logging.info('res:%s' % res)
return res
......
......@@ -360,7 +360,7 @@ class CcBl(models.Model):
return [{'pallet_number': k, 'pallet_usage_time': v} for k, v in pallet_info.items()]
def deal_bl_no(self, bl_no):
def deal_bl_no(self, bl_no, state_arr=[]):
"""
处理提单号:去掉杠和空格,并转换为小写
:param bl_no:
......@@ -368,7 +368,8 @@ class CcBl(models.Model):
"""
processed_bl_no = bl_no.replace('-', '').replace(' ', '').lower()
# 查询所有提单并处理它们的 bl_no
all_bl_obj = self.env['cc.bl'].sudo().search([])
domain = [('state', 'in', state_arr)] if state_arr else []
all_bl_obj = self.env['cc.bl'].sudo().search(domain)
bl_obj = all_bl_obj.filtered(
lambda r: r.bl_no.replace('-', '').replace(' ', '').lower() == processed_bl_no) # 提单
return bl_obj
......@@ -420,8 +421,10 @@ class CcBigPackage(models.Model):
def update_big_package_info(self, **kwargs):
"""
理货
理货 tally/尾程交接 handover
"""
action_type = kwargs.get('action_type')
if action_type == 'tally':
if self.tally_state == 'unprocessed_goods':
if kwargs.get('tally_state'):
self.tally_state = kwargs['tally_state']
......@@ -429,3 +432,9 @@ class CcBigPackage(models.Model):
self.tally_user_id = kwargs['tally_user_id']
if kwargs.get('tally_time'):
self.tally_time = kwargs['tally_time']
elif action_type == 'handover':
if self.tally_state != 'handover_completed':
if kwargs.get('tally_user_id'):
self.delivery_user_id = kwargs['tally_user_id']
if kwargs.get('tally_time'):
self.delivery_time = kwargs['tally_time']
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论