# item_naming_recycle **Repository Path**: Deroc/item_naming_recycle ## Basic Information - **Project Name**: item_naming_recycle - **Description**: ERPNext物料编码回收 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2026-03-01 - **Last Updated**: 2026-04-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Item Naming Recycle Plugin ## 简介 Item Naming Recycle 是一款专为 Frappe/ERPNext 开发的插件,实现删除商品时自动回收商品编码的功能。当创建新商品时,系统会优先复用回收池中编号最小的可用编码,从而实现商品编码的循环利用。 ## 功能特性 - **自动回收**:删除商品时,系统自动将商品编码保存到回收池中 - **智能复用**:创建新商品时,优先使用回收池中编号最小的可用编码 - **无缝集成**:与文档命名规则(Document Naming Rules)完美兼容 - **零配置**:安装后即可使用,无需额外配置 ## 安装方法 ```bash # 获取应用 bench get-app item_naming_recycle https://gitee.com/Deroc/item_naming_recycle.git # 安装应用到站点 bench --site your-site install-app item_naming_recycle # 执行数据迁移 bench migrate # 重启服务 bench restart ``` ## 使用前提 在使用此插件前,需要为商品组配置文档命名规则: 1. 进入 **库存设置**(Stock Settings),将 **商品命名方式**(Item Naming By)设置为 **命名序列**(Naming Series) 2. 进入 **文档命名规则**(Document Naming Rule),为每个商品组创建相应的命名规则 **配置示例**: - 文档类型:Item(商品) - 前缀:`YL-` - 前缀位数:5 - 条件:`item_group = Raw Material`(原材料) ## 工作原理 ### 1. 删除流程(Delete) 当商品被删除时,其商品编码会被存储到"回收商品编码"(Recycled Item Code)池中。 ### 2. 创建流程(Create) 创建新商品时,系统会检查回收池中是否存在编号更小的可用回收编码。 ### 3. 交换流程(Swap) 如果找到可用的回收编码,新商品将被重命名为该回收编码,同时自动调整命名计数器。 ## 系统要求 - Frappe Framework >= 16.0.0 - ERPNext >= 16.0.0 ## 许可证 [MIT](LICENSE)