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):