From 9a681ebf360561afec7a38cee300c8fbc642a453 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?=
<9664676+pengyuthon@user.noreply.gitee.com>
Date: Thu, 2 Apr 2026 16:53:03 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/yuthon_file_processing.py | 20 +++++++++----------
yuthon_official/models/yuthon_official.py | 18 +++++++++++------
.../models/yuthon_official_branch_party.py | 16 ++++++++-------
.../models/yuthon_official_labor.py | 20 +++++++++----------
.../models/yuthon_official_party.py | 17 ++++++++--------
5 files changed, 48 insertions(+), 43 deletions(-)
diff --git a/yuthon_official/models/yuthon_file_processing.py b/yuthon_official/models/yuthon_file_processing.py
index f230a8631..82858510a 100644
--- a/yuthon_official/models/yuthon_file_processing.py
+++ b/yuthon_official/models/yuthon_file_processing.py
@@ -180,16 +180,16 @@ class YuthonFileProcessing(models.Model):
@api.onchange('is_cold')
def onchange_is_cold(self):
if self.is_cold:
- self.onchange_company_id()
+ self.onchange_company_id1()
else:
self.reference_cold = False
- @api.onchange('company_id')
- def onchange_company_id(self):
+ @api.onchange('company_id1')
+ def onchange_company_id1(self):
current_year = fields.Date.today().year
self.reference_cold = False
- if self.company_id and self.company_id.name:
- company_name = self.company_id.name
+ if self.company_id1 and self.company_id1.name:
+ company_name = self.company_id1.name
prefix_map = {
'集团本部': '穗天投',
'天河粮储': '天粮储司',
@@ -198,18 +198,16 @@ class YuthonFileProcessing(models.Model):
prefix = prefix_map.get(company_name)
if not prefix:
return
- # 构建查询条件:同公司 + 同一年份的文号
year_str = f"〔{current_year}〕"
domain = [
- ('company_id', '=', self.company_id.id),
+ ('company_id1', '=', self.company_id1.id),
('reference_cold', 'like', f"{prefix}{year_str}%")
]
last_record = self.search(domain, order='reference_cold desc', limit=1)
- # 计算下一个序号(格式化为3位数字:001、002...)
- if last_record and last_record.reference_cold:
- # 从现有文号中提取数字部分(如从"穗天物【2025】003号"提取"003")
+ if current_year == 2026 and company_name == '集团本部':
+ next_seq = 27
+ elif last_record and last_record.reference_cold:
try:
- # 截取序号部分(假设格式固定为"前缀【年份】序号号")
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
last_seq = int(seq_str)
next_seq = last_seq + 1
diff --git a/yuthon_official/models/yuthon_official.py b/yuthon_official/models/yuthon_official.py
index cee50ac44..fd59d4769 100644
--- a/yuthon_official/models/yuthon_official.py
+++ b/yuthon_official/models/yuthon_official.py
@@ -176,8 +176,15 @@ class YuthonOfficial(models.Model):
}
}
+ @api.onchange('is_cold')
+ def onchange_is_cold(self):
+ if self.is_cold:
+ self.onchange_company_id1()
+ else:
+ self.reference_cold = False
+
@api.onchange('company_id1')
- def onchange_company_id(self):
+ def onchange_company_id1(self):
current_year = fields.Date.today().year
self.reference_cold = False
if self.company_id1 and self.company_id1.name:
@@ -192,15 +199,14 @@ class YuthonOfficial(models.Model):
return
year_str = f"〔{current_year}〕"
domain = [
- ('company_id', '=', self.company_id1.id),
+ ('company_id1', '=', self.company_id1.id),
('reference_cold', 'like', f"{prefix}{year_str}%")
]
last_record = self.search(domain, order='reference_cold desc', limit=1)
- # 计算下一个序号(格式化为3位数字:001、002...)
- if last_record and last_record.reference_cold:
- # 从现有文号中提取数字部分(如从"穗天物【2025】003号"提取"003")
+ if current_year == 2026 and company_name == '集团本部':
+ next_seq = 27
+ elif last_record and last_record.reference_cold:
try:
- # 截取序号部分(假设格式固定为"前缀【年份】序号号")
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
last_seq = int(seq_str)
next_seq = last_seq + 1
diff --git a/yuthon_official/models/yuthon_official_branch_party.py b/yuthon_official/models/yuthon_official_branch_party.py
index 310196a47..ca37b19d9 100644
--- a/yuthon_official/models/yuthon_official_branch_party.py
+++ b/yuthon_official/models/yuthon_official_branch_party.py
@@ -77,16 +77,16 @@ class YuthonOfficialBranchParty(models.Model):
@api.onchange('is_cold')
def onchange_is_cold(self):
if self.is_cold:
- self.onchange_company_id()
+ self.onchange_company_id1()
else:
self.reference_cold = False
- @api.onchange('company_id')
- def onchange_company_id(self):
+ @api.onchange('company_id1')
+ def onchange_company_id1(self):
current_year = fields.Date.today().year
self.reference_cold = False
- if self.company_id and self.company_id.name:
- company_name = self.company_id.name
+ if self.company_id1 and self.company_id1.name:
+ company_name = self.company_id1.name
prefix_map = {
'集团本部': '穗天投',
'天河粮储': '天粮储司',
@@ -97,11 +97,13 @@ class YuthonOfficialBranchParty(models.Model):
return
year_str = f"〔{current_year}〕"
domain = [
- ('company_id', '=', self.company_id.id),
+ ('company_id1', '=', self.company_id1.id),
('reference_cold', 'like', f"{prefix}{year_str}%")
]
last_record = self.search(domain, order='reference_cold desc', limit=1)
- if last_record and last_record.reference_cold:
+ if current_year == 2026 and company_name == '集团本部':
+ next_seq = 27
+ elif last_record and last_record.reference_cold:
try:
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
last_seq = int(seq_str)
diff --git a/yuthon_official/models/yuthon_official_labor.py b/yuthon_official/models/yuthon_official_labor.py
index 984156327..9fde758fb 100644
--- a/yuthon_official/models/yuthon_official_labor.py
+++ b/yuthon_official/models/yuthon_official_labor.py
@@ -77,16 +77,16 @@ class YuthonOfficialLabor(models.Model):
@api.onchange('is_cold')
def onchange_is_cold(self):
if self.is_cold:
- self.onchange_company_id()
+ self.onchange_company_id1()
else:
self.reference_cold = False
- @api.onchange('company_id')
- def onchange_company_id(self):
+ @api.onchange('company_id1')
+ def onchange_company_id1(self):
current_year = fields.Date.today().year
self.reference_cold = False
- if self.company_id and self.company_id.name:
- company_name = self.company_id.name
+ if self.company_id1 and self.company_id1.name:
+ company_name = self.company_id1.name
prefix_map = {
'集团本部': '穗天投',
'天河粮储': '天粮储司',
@@ -95,18 +95,16 @@ class YuthonOfficialLabor(models.Model):
prefix = prefix_map.get(company_name)
if not prefix:
return
- # 构建查询条件:同公司 + 同一年份的文号
year_str = f"〔{current_year}〕"
domain = [
- ('company_id', '=', self.company_id.id),
+ ('company_id1', '=', self.company_id1.id),
('reference_cold', 'like', f"{prefix}{year_str}%")
]
last_record = self.search(domain, order='reference_cold desc', limit=1)
- # 计算下一个序号(格式化为3位数字:001、002...)
- if last_record and last_record.reference_cold:
- # 从现有文号中提取数字部分(如从"穗天物【2025】003号"提取"003")
+ if current_year == 2026 and company_name == '集团本部':
+ next_seq = 27
+ elif last_record and last_record.reference_cold:
try:
- # 截取序号部分(假设格式固定为"前缀【年份】序号号")
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
last_seq = int(seq_str)
next_seq = last_seq + 1
diff --git a/yuthon_official/models/yuthon_official_party.py b/yuthon_official/models/yuthon_official_party.py
index 00e274278..df812cebf 100644
--- a/yuthon_official/models/yuthon_official_party.py
+++ b/yuthon_official/models/yuthon_official_party.py
@@ -85,16 +85,16 @@ class YuthonOfficialParty(models.Model):
@api.onchange('is_cold')
def onchange_is_cold(self):
if self.is_cold:
- self.onchange_company_id()
+ self.onchange_company_id1()
else:
self.reference_cold = False
- @api.onchange('company_id')
- def onchange_company_id(self):
+ @api.onchange('company_id1')
+ def onchange_company_id1(self):
current_year = fields.Date.today().year
self.reference_cold = False
- if self.company_id and self.company_id.name:
- company_name = self.company_id.name
+ if self.company_id1 and self.company_id1.name:
+ company_name = self.company_id1.name
prefix_map = {
'集团本部': '穗天投',
'天河粮储': '天粮储司',
@@ -103,14 +103,15 @@ class YuthonOfficialParty(models.Model):
prefix = prefix_map.get(company_name)
if not prefix:
return
- # 构建查询条件:同公司 + 同一年份的文号
year_str = f"〔{current_year}〕"
domain = [
- ('company_id', '=', self.company_id.id),
+ ('company_id1', '=', self.company_id1.id),
('reference_cold', 'like', f"{prefix}{year_str}%")
]
last_record = self.search(domain, order='reference_cold desc', limit=1)
- if last_record and last_record.reference_cold:
+ if current_year == 2026 and company_name == '集团本部':
+ next_seq = 27
+ elif last_record and last_record.reference_cold:
try:
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
last_seq = int(seq_str)
From 7732f6bb2b3a7c6f4ff02924c17e4b4571cc54c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?=
<9664676+pengyuthon@user.noreply.gitee.com>
Date: Thu, 2 Apr 2026 17:19:12 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/yuthon_file_processing.py | 8 +++++---
yuthon_official/models/yuthon_official.py | 18 +++++++++++-------
.../models/yuthon_official_branch_party.py | 8 +++++---
.../models/yuthon_official_labor.py | 18 +++++++++++-------
.../models/yuthon_official_party.py | 8 +++++---
.../models/property_bank_statements.py | 12 ++++++++++++
.../views/property_bank_statements_views.xml | 9 ++++++++-
.../wizard/property_statements_wizard.py | 1 -
8 files changed, 57 insertions(+), 25 deletions(-)
diff --git a/yuthon_official/models/yuthon_file_processing.py b/yuthon_official/models/yuthon_file_processing.py
index 82858510a..a386a2bea 100644
--- a/yuthon_official/models/yuthon_file_processing.py
+++ b/yuthon_official/models/yuthon_file_processing.py
@@ -198,16 +198,18 @@ class YuthonFileProcessing(models.Model):
prefix = prefix_map.get(company_name)
if not prefix:
return
+ # 构建查询条件:同公司 + 同一年份的文号
year_str = f"〔{current_year}〕"
domain = [
('company_id1', '=', self.company_id1.id),
('reference_cold', 'like', f"{prefix}{year_str}%")
]
last_record = self.search(domain, order='reference_cold desc', limit=1)
- if current_year == 2026 and company_name == '集团本部':
- next_seq = 27
- elif last_record and last_record.reference_cold:
+ # 计算下一个序号(格式化为3位数字:001、002...)
+ if last_record and last_record.reference_cold:
+ # 从现有文号中提取数字部分(如从"穗天物【2025】003号"提取"003")
try:
+ # 截取序号部分(假设格式固定为"前缀【年份】序号号")
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
last_seq = int(seq_str)
next_seq = last_seq + 1
diff --git a/yuthon_official/models/yuthon_official.py b/yuthon_official/models/yuthon_official.py
index fd59d4769..4703ed1d3 100644
--- a/yuthon_official/models/yuthon_official.py
+++ b/yuthon_official/models/yuthon_official.py
@@ -203,19 +203,23 @@ class YuthonOfficial(models.Model):
('reference_cold', 'like', f"{prefix}{year_str}%")
]
last_record = self.search(domain, order='reference_cold desc', limit=1)
- if current_year == 2026 and company_name == '集团本部':
- next_seq = 27
- elif last_record and last_record.reference_cold:
+ if last_record and last_record.reference_cold:
try:
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
last_seq = int(seq_str)
next_seq = last_seq + 1
except (IndexError, ValueError):
- next_seq = 1
+ if current_year == 2026 and company_name == '集团本部':
+ next_seq = 27
+ else:
+ next_seq = 1
else:
- next_seq = 1
- seq_str = f"{next_seq}"
- self.reference_cold = f"{prefix}{year_str}{seq_str}号"
+ if current_year == 2026 and company_name == '集团本部':
+ next_seq = 27
+ else:
+ next_seq = 1
+
+ self.reference_cold = f"{prefix}{year_str}{next_seq}号"
def supervising_button(self):
return {
diff --git a/yuthon_official/models/yuthon_official_branch_party.py b/yuthon_official/models/yuthon_official_branch_party.py
index ca37b19d9..419e36120 100644
--- a/yuthon_official/models/yuthon_official_branch_party.py
+++ b/yuthon_official/models/yuthon_official_branch_party.py
@@ -95,16 +95,18 @@ class YuthonOfficialBranchParty(models.Model):
prefix = prefix_map.get(company_name)
if not prefix:
return
+ # 构建查询条件:同公司 + 同一年份的文号
year_str = f"〔{current_year}〕"
domain = [
('company_id1', '=', self.company_id1.id),
('reference_cold', 'like', f"{prefix}{year_str}%")
]
last_record = self.search(domain, order='reference_cold desc', limit=1)
- if current_year == 2026 and company_name == '集团本部':
- next_seq = 27
- elif last_record and last_record.reference_cold:
+ # 计算下一个序号(格式化为3位数字:001、002...)
+ if last_record and last_record.reference_cold:
+ # 从现有文号中提取数字部分(如从"穗天物【2025】003号"提取"003")
try:
+ # 截取序号部分(假设格式固定为"前缀【年份】序号号")
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
last_seq = int(seq_str)
next_seq = last_seq + 1
diff --git a/yuthon_official/models/yuthon_official_labor.py b/yuthon_official/models/yuthon_official_labor.py
index 9fde758fb..95d3b7077 100644
--- a/yuthon_official/models/yuthon_official_labor.py
+++ b/yuthon_official/models/yuthon_official_labor.py
@@ -101,19 +101,23 @@ class YuthonOfficialLabor(models.Model):
('reference_cold', 'like', f"{prefix}{year_str}%")
]
last_record = self.search(domain, order='reference_cold desc', limit=1)
- if current_year == 2026 and company_name == '集团本部':
- next_seq = 27
- elif last_record and last_record.reference_cold:
+ if last_record and last_record.reference_cold:
try:
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
last_seq = int(seq_str)
next_seq = last_seq + 1
except (IndexError, ValueError):
- next_seq = 1
+ if current_year == 2026 and company_name == '集团本部':
+ next_seq = 27
+ else:
+ next_seq = 1
else:
- next_seq = 1
- seq_str = f"{next_seq}"
- self.reference_cold = f"{prefix}{year_str}{seq_str}号"
+ if current_year == 2026 and company_name == '集团本部':
+ next_seq = 27
+ else:
+ next_seq = 1
+
+ self.reference_cold = f"{prefix}{year_str}{next_seq}号"
@api.onchange('is_meet')
def _onchange_is_meet(self):
diff --git a/yuthon_official/models/yuthon_official_party.py b/yuthon_official/models/yuthon_official_party.py
index df812cebf..9cc910ae8 100644
--- a/yuthon_official/models/yuthon_official_party.py
+++ b/yuthon_official/models/yuthon_official_party.py
@@ -103,16 +103,18 @@ class YuthonOfficialParty(models.Model):
prefix = prefix_map.get(company_name)
if not prefix:
return
+ # 构建查询条件:同公司 + 同一年份的文号
year_str = f"〔{current_year}〕"
domain = [
('company_id1', '=', self.company_id1.id),
('reference_cold', 'like', f"{prefix}{year_str}%")
]
last_record = self.search(domain, order='reference_cold desc', limit=1)
- if current_year == 2026 and company_name == '集团本部':
- next_seq = 27
- elif last_record and last_record.reference_cold:
+ # 计算下一个序号(格式化为3位数字:001、002...)
+ if last_record and last_record.reference_cold:
+ # 从现有文号中提取数字部分(如从"穗天物【2025】003号"提取"003")
try:
+ # 截取序号部分(假设格式固定为"前缀【年份】序号号")
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
last_seq = int(seq_str)
next_seq = last_seq + 1
diff --git a/yuthon_property/models/property_bank_statements.py b/yuthon_property/models/property_bank_statements.py
index d706e5e2c..c88708386 100644
--- a/yuthon_property/models/property_bank_statements.py
+++ b/yuthon_property/models/property_bank_statements.py
@@ -68,6 +68,18 @@ class PropertyBankStatements(models.Model):
elif record.your_own_unit in ['天河粮储']:
record.company_id = self.env['res.company'].search([('name', '=', '天河粮储')], limit=1)
+
+ def update_your_own_unit(self):
+ selected_records = self.env["property.bank.statements"].browse(
+ self._context.get('active_ids', self._context.get('active_id'))
+ )
+ for record in selected_records:
+ company_config = self.env['yuthon.property.company'].sudo().search(
+ [('rent_account', '=', record.your_own_account)], limit=1
+ )
+ if company_config and company_config.referred:
+ record.your_own_unit = company_config.referred
+
def update_record(self):
selected_records = self.env["property.bank.statements"].browse(
self._context.get('active_ids', self._context.get('active_id'))
diff --git a/yuthon_property/views/property_bank_statements_views.xml b/yuthon_property/views/property_bank_statements_views.xml
index 6a67acaf6..e0d967729 100644
--- a/yuthon_property/views/property_bank_statements_views.xml
+++ b/yuthon_property/views/property_bank_statements_views.xml
@@ -33,7 +33,7 @@
@@ -223,4 +223,11 @@
code
action = model.update_company_id()
+
+ 更新账号单位
+
+
+ code
+ action = model.update_your_own_unit()
+
\ No newline at end of file
diff --git a/yuthon_property/wizard/property_statements_wizard.py b/yuthon_property/wizard/property_statements_wizard.py
index e6a2983da..87ed9c75a 100644
--- a/yuthon_property/wizard/property_statements_wizard.py
+++ b/yuthon_property/wizard/property_statements_wizard.py
@@ -475,7 +475,6 @@ class PropertyStatementsWizard(models.Model):
return False
def classify_by_last_four(self, input_str):
- """根据本方账号匹配 yuthon.property.company 中的收租公司账号,返回简称"""
if not isinstance(input_str, str) or not input_str.strip():
return ''
account = input_str.strip()
From abd9a53599ef371fe382a9a0e2fbcdcc02b9e335 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?=
<9664676+pengyuthon@user.noreply.gitee.com>
Date: Thu, 2 Apr 2026 17:25:14 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
yuthon_official/models/yuthon_official.py | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/yuthon_official/models/yuthon_official.py b/yuthon_official/models/yuthon_official.py
index 4703ed1d3..86c3e940c 100644
--- a/yuthon_official/models/yuthon_official.py
+++ b/yuthon_official/models/yuthon_official.py
@@ -197,28 +197,23 @@ class YuthonOfficial(models.Model):
prefix = prefix_map.get(company_name)
if not prefix:
return
+
year_str = f"〔{current_year}〕"
domain = [
('company_id1', '=', self.company_id1.id),
('reference_cold', 'like', f"{prefix}{year_str}%")
]
last_record = self.search(domain, order='reference_cold desc', limit=1)
+ base_num = 27 if (current_year == 2026 and company_name == "集团本部") else 1
+ max_seq = 0
if last_record and last_record.reference_cold:
try:
seq_str = last_record.reference_cold.split(year_str)[1].rsplit('号', 1)[0]
- last_seq = int(seq_str)
- next_seq = last_seq + 1
- except (IndexError, ValueError):
- if current_year == 2026 and company_name == '集团本部':
- next_seq = 27
- else:
- next_seq = 1
- else:
- if current_year == 2026 and company_name == '集团本部':
- next_seq = 27
- else:
- next_seq = 1
+ max_seq = int(seq_str)
+ except:
+ max_seq = 0
+ next_seq = max(max_seq + 1, base_num)
self.reference_cold = f"{prefix}{year_str}{next_seq}号"
def supervising_button(self):