提交 5d87cc51 authored 作者: 贺阳's avatar 贺阳

Merge branch 'develop' into feature/ocr识别pdf并删除指定内容

# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
......@@ -58,7 +58,7 @@ class CcBigPackage(models.Model):
# 提货相关字段
pickup_user_id = fields.Many2one('res.users', 'Pickup User', index=True) # 提货人
pickup_time = fields.Datetime('Pickup Time') # 提货时间
tally_state = fields.Selection([
('unprocessed_goods', 'Unprocessed goods'),
('picked_up', 'Picked Up'),
......@@ -650,7 +650,8 @@ class CcBL(models.Model):
big_package_qty = fields.Integer(string='Big Package Qty')
# 已提货大包数量
picked_up_big_package_qty = fields.Integer(string='Picked Up Big Package Qty', compute='cal_picked_up_big_package_qty',
picked_up_big_package_qty = fields.Integer(string='Picked Up Big Package Qty',
compute='cal_picked_up_big_package_qty',
store=True)
# 理货大包数量
tally_big_package_qty = fields.Integer(string='Tally Big Package Qty', compute='cal_tally_big_package_qty',
......@@ -782,6 +783,58 @@ class CcBL(models.Model):
# 定义清关国家,关联到国家字段
cc_country_id = fields.Many2one('res.country', string='CC Country')
# 新增尾程快递,many2many,cc.last.mile.provider
last_mile_provider_ids = fields.Many2many('cc.last.mile.provider', 'cc_bill_loading_last_mile_provider_rel',
'bl_id', 'last_mile_provider_id', string='Last Mile Providers',
compute='_compute_last_mile_provider_ids', store=True)
@api.depends('big_package_ids', 'big_package_ids.next_provider_name')
def _compute_last_mile_provider_ids(self):
"""
提单关联的大包对应下一个尾程快递匹配到到尾程快递
"""
# 一次性获取所有尾程快递,避免重复查询
all_providers = self.env['cc.last.mile.provider'].sudo().search([])
# 预构建匹配值映射,提高查找效率
provider_matching_map = {}
for provider in all_providers:
if provider.matching_value:
# 预处理匹配值,避免重复split和lower操作
matching_values = [value.lower().strip() for value in provider.matching_value.split('\n') if
value.strip()]
for value in matching_values:
if value not in provider_matching_map:
provider_matching_map[value] = []
provider_matching_map[value].append(provider.id)
for bl in self:
# 先清空现有记录
bl.last_mile_provider_ids = [(6, 0, [])]
if not bl.big_package_ids:
continue
# 获取所有大包的下一个快递名称(去重)
provider_names = bl.big_package_ids.filtered('next_provider_name').mapped('next_provider_name')
if not provider_names:
continue
# 去重provider名称
provider_names = list(set(provider_names))
# 使用集合存储匹配的provider ID,避免重复
matched_provider_ids = set()
# 使用预构建的映射进行快速查找
for provider_name in provider_names:
provider_name_lower = provider_name.lower().strip()
if provider_name_lower in provider_matching_map:
matched_provider_ids.update(provider_matching_map[provider_name_lower])
# 更新字段值
if matched_provider_ids:
bl.last_mile_provider_ids = [(6, 0, list(matched_provider_ids))]
def push_clear_customs_start(self, utc_time):
# 创建向导
push_node_obj = self.env['cc.node'].sudo().search(
......@@ -873,17 +926,17 @@ class CcBL(models.Model):
}
}
def check_is_done(self, is_email=False,**kwargs):
def check_is_done(self, is_email=False, **kwargs):
# 如果提单所有小包的清关节点变成"是完成节点",则该提单状态变成已完成.tk模块有继承
if all(line.state.is_done for line in
self.ship_package_ids) and self.customs_clearance_status.is_done and self.is_bl_sync:
self.done_func(is_email,**kwargs)
self.done_func(is_email, **kwargs)
else:
if not is_email:
raise ValidationError(
_('The small package node or bill of lading node is not in the completed node, and the bill of lading cannot be changed to completed!')) # 小包节点或提单节点不在已完成节点,提单不能变为已完成!
def done_func(self, is_email=False,**kwargs):
def done_func(self, is_email=False, **kwargs):
"""
变为已完成
"""
......@@ -893,7 +946,7 @@ class CcBL(models.Model):
# 如果选择了忽略节点异常,则记录异常原因
if kwargs.get('exception_reason'):
exception_reason = kwargs['exception_reason']
#输出当前用户是什么语言
# 输出当前用户是什么语言
if self.env.user.lang == 'zh_CN':
message = '提单已完成,但存在节点异常,原因是:%s!' % exception_reason
else:
......
......@@ -13,6 +13,7 @@
<field optional="show" name="customs_clearance_status" string="Customs Clearance Status"/>
<field optional="show" name="bl_no" string="Bill of Loading No."/>
<field optional="show" name="bl_date" string="B/L Date"/>
<field optional="show" name="last_mile_provider_ids" string="Last Mile Providers" widget="many2many_tags"/>
<field optional="hide" name="transfer_bl_no" string="Transfer Bill of Loading No."/>
<field optional="show" name="customer_id" string="Customer"/>
<field optional="show" name="customs_bl_no" string="Customs Bill of Loading No."/>
......@@ -140,6 +141,7 @@
<group>
<group>
<field name="bl_date" string="B/L Date"/>
<field name="last_mile_provider_ids" string="Last Mile Providers" widget="many2many_tags"/>
<field name="transfer_bl_no"/>
<field name="customer_id" string="Customer"/>
<field name="customs_bl_no" string="Customs Bill of Loading No."/>
......@@ -308,6 +310,8 @@
domain="[('cc_deadline', '&lt;', time.strftime('%Y-%m-%d'))]"/>
<separator/>
<group expand="0" string="Group By">
<!-- <filter domain="[]" name="groupby_last_mile_provider_ids" string="Last Mile Providers"
context="{'group_by': 'last_mile_provider_ids'}"/> -->
<filter domain="[]" name="groupby_customer_id" string="Customer"
context="{'group_by': 'customer_id'}"/>
<filter domain="[]" name="groupby_cc_company_id" string="CC Company"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论