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

Merge branch 'develop' of https://e.coding.net/yizuo/hh_ccs/hh_ccs into develop

......@@ -31,7 +31,7 @@ class ExportBlAndPackageXlsx(http.Controller):
if good_ids:
for good_item in good_ids:
good_index += 1
sheet1.write(good_index, 0, package_item.logistic_order_no or '') # 物流订单号 ITEM ID
sheet1.write(good_index, 0, package_item.logistic_order_no or '') # 物流订单号 CUSTOMS PROVIDER ORDER ID
sheet1.write(good_index, 1, package_item.big_package_id.big_package_no or '') # 小包商品对应的大包号 BIG BAG NO
sheet1.write(good_index, 2, package_item.tracking_no or '') # 小包追踪号 TRACKING NO
sheet1.write(good_index, 3, package_item.customer_ref or '') # CUSTOMER REF
......@@ -52,26 +52,27 @@ class ExportBlAndPackageXlsx(http.Controller):
sheet1.write(good_index, 18, package_item.receiver_county or '') # RECEIPIENT COUNTY
sheet1.write(good_index, 19, package_item.receiver_postcode or '') # RECEIPIENT POSTCODE
sheet1.write(good_index, 20, package_item.receiver_email or '') # RECEPIENT EMAIL
sheet1.write(good_index, 21, package_item.receiver_phone or '') # PHONE NUMBER
sheet1.write(good_index, 22, package_item.gross_weight or 0) # GROSS WEIGHT (KG)
sheet1.write(good_index, 23, package_item.weight_unit or 0) # NET WEIGHT (KG)
sheet1.write(good_index, 24, package_item.currency or '') # Currency
sheet1.write(good_index, 25, good_item.sku_id or '') # SKU NUMBER
sheet1.write(good_index, 26, good_item.item_name_en or '') # ITEM DESCRIPTION
sheet1.write(good_index, 27, good_item.export_hs_code or '') # ITEM HS CODE
sheet1.write(good_index, 28, good_item.quantity) # ITEM QUANTITY
sheet1.write(good_index, 29, good_item.quantity_unit or '') # UNITS
sheet1.write(good_index, 30, good_item.item_total_price) # TOTAL VALUE
sheet1.write(good_index, 31, good_item.item_vat or '') # VAT
sheet1.write(good_index, 32, '') # SKU NUMBER
sheet1.write(good_index, 33, good_item.item_link or '') # PRODUCT LINK
sheet1.write(good_index, 34, '') # LENGTH
sheet1.write(good_index, 35, '') # WIDTH
sheet1.write(good_index, 36, '') # HEIGHT
sheet1.write(good_index, 37, package_item.receiver_detailed_address or '') # Detailed Address
sheet1.write(good_index, 38, package_item.next_provider_name or '') # Last Mile Service Provider 关联的小包的下一个服务商名称
sheet1.write(good_index, 39, sum(package_item.good_ids.mapped('item_total_price'))) # GOODS VALUE 小包上的所有商品的货物总价之和
sheet1.write(good_index, 40, good_item.import_hs_code or '') # HSCODE IMPORT 取商品上的进口hscode
sheet1.write(good_index, 21, package_item.receiver_detailed_address or '') # Detailed Address
sheet1.write(good_index, 22, package_item.receiver_phone or '') # PHONE NUMBER
sheet1.write(good_index, 23, package_item.gross_weight or 0) # GROSS WEIGHT
sheet1.write(good_index, 24, package_item.weight_unit or 0) # Weight Unit
sheet1.write(good_index, 25, package_item.currency or '') # Currency
sheet1.write(good_index, 26, good_item.item_id or '') # ITEM ID
sheet1.write(good_index, 27, good_item.sku_id or '') # SKU NUMBER
sheet1.write(good_index, 28, good_item.item_name_en or '') # ITEM DESCRIPTION
sheet1.write(good_index, 29, good_item.export_hs_code or '') # ITEM HS CODE
sheet1.write(good_index, 30, good_item.quantity) # ITEM QUANTITY
sheet1.write(good_index, 31, good_item.quantity_unit or '') # UNITS
sheet1.write(good_index, 32, good_item.item_total_price) # TOTAL VALUE
sheet1.write(good_index, 33, good_item.item_vat or '') # VAT
sheet1.write(good_index, 34, '') # ONLINE SELLING PLACE
sheet1.write(good_index, 35, good_item.item_link or '') # PRODUCT LINK
sheet1.write(good_index, 36, '') # LENGTH
sheet1.write(good_index, 37, '') # WIDTH
sheet1.write(good_index, 38, '') # HEIGHT
sheet1.write(good_index, 39, package_item.next_provider_name or '') # Last Mile Service Provider 关联的小包的下一个服务商名称
sheet1.write(good_index, 40, sum(package_item.good_ids.mapped('item_total_price'))) # GOODS VALUE 小包上的所有商品的货物总价之和
sheet1.write(good_index, 41, good_item.import_hs_code or '') # HSCODE IMPORT 取商品上的进口hscode
if good_index == int(parcel_export_num):
num += 1
sheet1 = self.get_package_title(worksheet, font_style, num)
......@@ -87,7 +88,7 @@ class ExportBlAndPackageXlsx(http.Controller):
for i in range(41):
sheet1.col(i).width = 500 * 11
sheet1.col(8).width = 600 * 11
sheet1.write(index, 0, u'ITEM ID', font_style) # ITEM ID
sheet1.write(index, 0, u'CUSTOMS PROVIDER ORDER ID ', font_style) # CUSTOMS PROVIDER ORDER ID
sheet1.write(index, 1, u'BIG BAG NO', font_style) # BIG BAG NO
sheet1.write(index, 2, u'TRACKING NO', font_style) # TRACKING NO
sheet1.write(index, 3, u'CUSTOMER REF', font_style) # CUSTOMER REF
......@@ -108,26 +109,27 @@ class ExportBlAndPackageXlsx(http.Controller):
sheet1.write(index, 18, u'RECEIPIENT COUNTY', font_style) # RECEIPIENT COUNTY
sheet1.write(index, 19, u'RECEIPIENT POSTCODE', font_style) # RECEIPIENT POSTCODE
sheet1.write(index, 20, u'RECEPIENT EMAIL', font_style) # RECEPIENT EMAIL
sheet1.write(index, 21, u'PHONE NUMBER', font_style) # PHONE NUMBER
sheet1.write(index, 22, u'GROSS WEIGHT (KG)', font_style) # GROSS WEIGHT (KG)
sheet1.write(index, 23, u'NET WEIGHT (KG)', font_style) # NET WEIGHT (KG)
sheet1.write(index, 24, u'Currency', font_style) # CURRENCY
sheet1.write(index, 25, u'SKU NUMBER', font_style) # SKU NUMBER
sheet1.write(index, 26, u'ITEM DESCRIPTION', font_style) # ITEM DESCRIPTION
sheet1.write(index, 27, u'ITEM HS CODE', font_style) # ITEM HS CODE
sheet1.write(index, 28, u'ITEM QUANTITY', font_style) # ITEM QUANTITY
sheet1.write(index, 29, u'UNITS', font_style) # UNITS
sheet1.write(index, 30, u'TOTAL VALUE', font_style) # TOTAL VALUE
sheet1.write(index, 31, u'VAT', font_style) # VAT
sheet1.write(index, 32, u'ONLINE SELLING PLACE', font_style) # ONLINE SELLING PLACE
sheet1.write(index, 33, u'PRODUCT LINK', font_style) # PRODUCT LINK
sheet1.write(index, 34, u'LENGTH', font_style) # LENGTH
sheet1.write(index, 35, u'WIDTH', font_style) # WIDTH
sheet1.write(index, 36, u'HEIGHT', font_style) # HEIGHT
sheet1.write(index, 37, u'Detailed Address', font_style) # Detailed Address
sheet1.write(index, 38, u'Last Mile Service Provider', font_style) # Last Mile Service Provider
sheet1.write(index, 39, u'GOODS VALUE', font_style) # GOODS VALUE
sheet1.write(index, 40, u'HSCODE IMPORT', font_style) # HSCODE IMPORT
sheet1.write(index, 21, u'Detailed Address', font_style) # Detailed Address
sheet1.write(index, 22, u'PHONE NUMBER', font_style) # PHONE NUMBER
sheet1.write(index, 23, u'GROSS WEIGHT', font_style) # GROSS WEIGHT
sheet1.write(index, 24, u'Weight Unit', font_style) # Weight Unit
sheet1.write(index, 25, u'Currency', font_style) # CURRENCY
sheet1.write(index, 26, u'ITEM ID', font_style) # ITEM ID
sheet1.write(index, 27, u'SKU NUMBER', font_style) # SKU NUMBER
sheet1.write(index, 28, u'ITEM DESCRIPTION', font_style) # ITEM DESCRIPTION
sheet1.write(index, 29, u'ITEM HS CODE', font_style) # ITEM HS CODE
sheet1.write(index, 30, u'ITEM QUANTITY', font_style) # ITEM QUANTITY
sheet1.write(index, 31, u'UNITS', font_style) # UNITS
sheet1.write(index, 32, u'TOTAL VALUE', font_style) # TOTAL VALUE
sheet1.write(index, 33, u'VAT', font_style) # VAT
sheet1.write(index, 34, u'ONLINE SELLING PLACE', font_style) # ONLINE SELLING PLACE
sheet1.write(index, 35, u'PRODUCT LINK', font_style) # PRODUCT LINK
sheet1.write(index, 36, u'LENGTH', font_style) # LENGTH
sheet1.write(index, 37, u'WIDTH', font_style) # WIDTH
sheet1.write(index, 38, u'HEIGHT', font_style) # HEIGHT
sheet1.write(index, 39, u'Last Mile Service Provider', font_style) # Last Mile Service Provider
sheet1.write(index, 40, u'GOODS VALUE', font_style) # GOODS VALUE
sheet1.write(index, 41, u'HSCODE IMPORT', font_style) # HSCODE IMPORT
return sheet1
# 运单导出包裹清关数据 每个运单导出一个文件 生成压缩包
......
# -*- coding: utf-8 -*-
import datetime
import re
import pytz
from odoo import fields, models, exceptions, api, tools
import logging
import pytz
from odoo import models
from .redis_connection import redis_connection
__author__ = 'zd'
r = redis_connection()
_logger = logging.getLogger(__name__)
......@@ -14,6 +16,110 @@ class CommonCommon(models.Model):
_name = 'common.common'
_description = u'公用基础类'
def get_local_time(self, local_time=None):
"""获取Odoo时区的时间
Args:
local_time: 本地时间,如果不提供则使用当前时间
Returns:
datetime: Odoo时区的时间
"""
if not local_time:
local_time = datetime.datetime.now()
try:
# 获取Odoo配置的时区
user_tz = self.env.user.tz or 'UTC'
timezone_offset = self.env['common.common'].sudo().get_time_zone(user_tz)
local_time = local_time + datetime.timedelta(hours=int(timezone_offset))
return local_time.strftime('%Y-%m-%d %H:%M:%S'), timezone_offset
except Exception as e:
# 如果出现任何错误,返回UTC时间
logging.warning(f"获取Odoo时区失败,使用UTC时间: {str(e)}")
return self.get_utc_time(), '+0'
def get_timezone_offset(self):
"""
Get UTC offset from Odoo's timezone configuration
Returns format like: UTC+8, UTC-5, etc.
"""
try:
tz = self.env.user.tz or 'UTC'
if self.env.user.name == 'OdooBot':
tz = 'Asia/Shanghai'
user_tz = int(self.init_timezone_data(tz))
return user_tz
except Exception as e:
_logger.error("Timezone offset calculation error: %s", str(e))
return "UTC+0" # Default t
def get_local_rfc3339_time(self, local_time=None):
"""获取Odoo本地时区的RFC3339格式时间
Args:
local_time: 本地时间,如果不提供则使用当前时间
Returns:
str: RFC3339格式的时间字符串
"""
if not local_time:
local_time = datetime.datetime.now()
# 获取Odoo配置的时区
user_tz = self.env.user.tz or 'UTC'
local_tz = pytz.timezone(user_tz)
# 确保时间是本地时区
if local_time.tzinfo is None:
local_time = local_tz.localize(local_time)
# 转换为RFC3339格式
rfc3339_time = local_time.isoformat(timespec='seconds')
logging.info('rfc3339_time:%s' % rfc3339_time)
return rfc3339_time
def get_rfc339_time(self, utc_time=None):
if not utc_time:
# 获取当前时间的UTC时间
utc_time = datetime.datetime.utcnow()
# 创建+8时区的对象
target_timezone = pytz.timezone('Asia/Shanghai')
# 将UTC时间转换为目标时区时间
local_time = utc_time.replace(
tzinfo=pytz.utc).astimezone(target_timezone)
# 格式化为RFC 3339格式
rfc3339_time = local_time.isoformat(timespec='seconds')
return rfc3339_time
# 定义一个方法,将时间的时区转为UTC时间
def get_utc_rfc339_time(self, local_time=None):
"""获取Odoo本地时区的RFC3339格式时间
Args:
local_time: 本地时间,如果不提供则使用当前时间
Returns:
str: RFC3339格式的时间字符串
"""
if not local_time:
# 获取当前时间的UTC时间
local_time = datetime.datetime.now()
# 将本地时间转换为UTC时间
utc_time = local_time.astimezone(pytz.utc)
# 格式化为RFC 3339格式
# rfc3339_time = utc_time.isoformat(timespec='seconds')
logging.info('utc_time:%s' % utc_time)
if not local_time:
# 获取当前时间的UTC时间
local_time = datetime.datetime.now()
# 将本地时间转换为UTC时间
utc_time = local_time.astimezone(pytz.utc)
# 格式化为RFC 3339格式
rfc3339_time = utc_time.isoformat(timespec='seconds')
return rfc3339_time
# 定义一个方法,将时间的时区转为UTC时间
def get_utc_time(self, local_time=None):
if not local_time:
# 获取当前时间的UTC时间
local_time = datetime.datetime.now()
# 将本地时间转换为UTC时间
utc_time = local_time.astimezone(pytz.utc)
# 格式化为RFC 3339格式
# rfc3339_time = utc_time.isoformat(timespec='seconds')
return utc_time.strftime('%Y-%m-%d %H:%M:%S')
def get_format_time(self, parse_time):
"""
把时间加上8小时
......
......@@ -3,6 +3,7 @@
import logging
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
_logger = logging.getLogger(__name__)
......@@ -11,6 +12,7 @@ class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
before_min = fields.Integer('清关时间取值(早于清关结束)')
package_scan_min = fields.Integer('一键全扫完成时间(min)', help='输入示范:10,即表示在10分钟内大包时间随机分配,并不能重复')
@api.model
def get_values(self):
......@@ -21,9 +23,11 @@ class ResConfigSettings(models.TransientModel):
values = super(ResConfigSettings, self).get_values()
config = self.env['ir.config_parameter'].sudo()
before_min = config.get_param('before_min', default=10)
package_scan_min = config.get_param('package_scan_min', default=10)
values.update(
before_min=before_min,
package_scan_min=package_scan_min,
)
return values
......@@ -31,3 +35,4 @@ class ResConfigSettings(models.TransientModel):
super(ResConfigSettings, self).set_values()
ir_config = self.env['ir.config_parameter'].sudo()
ir_config.set_param("before_min", self.before_min or 10)
ir_config.set_param("package_scan_min", self.package_scan_min or 10)
......@@ -10,7 +10,7 @@
<field name="arch" type="xml">
<tree string="Package Good" decoration-warning="is_cancel==True">
<!-- # decoration-muted="opening_debit == 0 and opening_credit == 0" 根据条件显示每行的颜色 muted-->
<field optional="hide" name="item_id" string="Item ID"/>
<field optional="show" name="item_id" string="Item ID"/>
<field optional="show" name="sku_id" string="SKU ID"/>
<field optional="show" name="item_name_en" string="Name EN"/>
<field optional="show" name="item_name_cn" string="Name CN"/>
......
......@@ -21,6 +21,20 @@
</div>
</div>
</div>
<div>
<h2>pda扫码配置</h2>
<div class="row mt16 o_settings_container" id="pda_scan">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane"/>
<div class="o_setting_right_pane">
<div class="text-muted">
<label for="package_scan_min"/>
<field name="package_scan_min"/>
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
......
......@@ -89,6 +89,7 @@ class OrderController(http.Controller):
if bl_obj:
if bl_obj.state in state_arr:
res['bl_info'] = bl_obj.search_bl_info(pda_lang=pda_lang, type=action_type)
res['package_scan_min'] = int(request.env['res.config.settings'].sudo().get_values().get('package_scan_min'))
res['state'] = 200
else:
res['message'] = bill_state_msg_dic[pda_lang] # 没有在系统中找到未完成清关的该提单信息
......
......@@ -23,6 +23,33 @@ def get_rfc339_time(utc_time=None):
return rfc3339_time
# 定义一个方法,将时间的时区转为UTC时间
def get_utc_rfc339_time(local_time=None):
"""获取Odoo本地时区的RFC3339格式时间
Args:
local_time: 本地时间,如果不提供则使用当前时间
Returns:
str: RFC3339格式的时间字符串
"""
if not local_time:
# 获取当前时间的UTC时间
local_time = datetime.now()
# 将本地时间转换为UTC时间
utc_time = local_time.astimezone(pytz.utc)
# 格式化为RFC 3339格式
# rfc3339_time = utc_time.isoformat(timespec='seconds')
logging.info('utc_time:%s' % utc_time)
if not local_time:
# 获取当前时间的UTC时间
local_time = datetime.now()
# 将本地时间转换为UTC时间
utc_time = local_time.astimezone(pytz.utc)
# 格式化为RFC 3339格式
rfc3339_time = utc_time.isoformat(timespec='seconds')
logging.info('rfc3339_time:%s' % rfc3339_time)
return rfc3339_time
# 定义一个方法,将时间的时区转为UTC时间
def get_utc_time(local_time=None):
if not local_time:
......@@ -156,13 +183,16 @@ class CcShipPackage(models.Model):
def get_callback_track_data(self):
"""小包上传数据."""
# 获取该提单下的所有同步状态为未同步的小包
operate_time, timezone = self.env['common.common'].get_local_time(self.process_time)
push_data = {
"provider_order_id": self.logistic_order_no,
"track_list": [
{
"shipping_method_code": self.state.tk_code,
"operate_time": get_utc_time(self.process_time),
"time_zone": "UTC+0",
"operate_time": operate_time,
"time_zone": 'UTC%s' % timezone,
# "operate_time": get_utc_time(self.process_time),
# "time_zone": "UTC+0",
"action_code": self.state.tk_code,
"operation_desc": self.state.desc,
"reason_code": self.node_exception_reason_id.name or "" # 异常原因
......@@ -482,8 +512,9 @@ class CcBl(models.Model):
"customs_waybill_id": self.customs_bl_no or '', # 关务提单号取海关装货单号
"track_detail":
{
"operate_time": get_rfc339_time(self.process_time), # "2025-03-19T09:28:00+00:00",
# "#get_utc_time(self.process_time), # 事件发⽣时间,RFC3339格式(实操时间)
"operate_time": self.env['common.common'].get_local_rfc3339_time(self.process_time),
# "2025-03-19T09:28:00+00:00",
# get_utc_rfc339_time(self.process_time), # "2025-03-19T09:28:00+00:00", "#get_utc_time(self.process_time), # 事件发⽣时间,RFC3339格式(实操时间)
"waybill_status_code": self.customs_clearance_status.tk_code, # 提单关务状态编码
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论