Compare commits

...

90 Commits

Author SHA1 Message Date
胡尧
20069d5336 Merge branch refs/heads/develop into refs/heads/release/release_2.15 2025-07-01 17:57:06 +08:00
禹翔辉
0e7d6fac4e Accept Merge Request #2264: (feature/请购明细 -> develop)
Merge Request: 采购申请批量转采购按钮显示优化

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2264
2025-06-30 15:20:56 +08:00
yuxianghui
70113cb3c5 采购申请批量转采购按钮显示优化 2025-06-30 09:20:09 +08:00
禹翔辉
272e424975 Accept Merge Request #2263: (feature/采购订单-委外-坯料 -> develop)
Merge Request: 处理 由采购订单-委外加工类型生成的同一个补货组的坯料采购申请单据没有合并 问题

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2263
2025-06-27 10:17:42 +08:00
yuxianghui
1fd9900e41 处理 由采购订单-委外加工类型生成的同一个补货组的坯料采购申请单据没有合并 问题 2025-06-27 09:39:11 +08:00
yuxianghui
a68d6d4d06 处理 采购订单确认时,一补货组的补货单没有合并问题 2025-06-26 16:55:38 +08:00
胡尧
c630074f4a Accept Merge Request #2262: (feature/根据项目组区分sf代码 -> develop)
Merge Request: 撤回_run_manufacturing方法

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2262?initial=true
2025-06-26 10:27:04 +08:00
胡尧
4bea169327 撤回_run_manufacturing方法 2025-06-26 10:26:39 +08:00
禹翔辉
e2ddac4fb0 Accept Merge Request #2261: (feature/调拨单验证 -> develop)
Merge Request: 调拨单验证时,对没有完成通过的质检单不进行出厂检验报告检测

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2261
2025-06-26 10:24:21 +08:00
yuxianghui
e52ec3982f 调拨单验证时,对没有完成通过的质检单不进行出厂检验报告检测 2025-06-26 10:03:19 +08:00
胡尧
160bd117b7 Accept Merge Request #2260: (feature/根据项目组区分sf代码 -> develop)
Merge Request: 没有model_id的制造订单不请求编程

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2260
2025-06-26 09:35:42 +08:00
胡尧
a19cf5d894 解决冲突 2025-06-26 09:35:26 +08:00
胡尧
885064fb12 没有model_id的制造订单不请求编程 2025-06-26 09:29:02 +08:00
胡尧
8f7e785760 Accept Merge Request #2259: (feature/根据项目组区分sf代码 -> develop)
Merge Request: 修复加工面报错的问题

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2259?initial=true
2025-06-25 17:36:14 +08:00
胡尧
8123885c71 修复加工面报错的问题 2025-06-25 17:35:18 +08:00
禹翔辉
c2f346571d Accept Merge Request #2258: (feature/委外加工采购订单 -> develop)
Merge Request: 完成 委外加工采购订单增加BOM内物料的采购申请与采购订单 需求

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2258
2025-06-25 16:13:04 +08:00
yuxianghui
e3494ce8b7 完成 委外加工采购订单增加BOM内物料的采购申请与采购订单 需求 2025-06-25 16:09:32 +08:00
禹翔辉
d75cff0a5d Accept Merge Request #2257: (feature/库存路线 -> develop)
Merge Request: 完成  物料需求计划主数据准备:库存路线  需求

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2257
2025-06-25 14:37:28 +08:00
yuxianghui
28ade4ac72 完成 物料需求计划主数据准备:库存路线 需求 2025-06-25 13:57:56 +08:00
胡尧
372f95d812 Accept Merge Request #2256: (feature/6711 -> develop)
Merge Request: 待完工工单明细,控制时间为大于48小时,小于当前时间

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2256?initial=true
2025-06-25 09:43:11 +08:00
胡尧
f165bec662 待完工工单明细,控制时间为大于48小时,小于当前时间 2025-06-25 09:42:53 +08:00
胡尧
4099756d15 Accept Merge Request #2255: (feature/6711 -> develop)
Merge Request: 日计划量对工单id去重

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2255?initial=true
2025-06-25 08:44:32 +08:00
胡尧
133eac4a5c 日计划量对工单id去重 2025-06-25 08:43:59 +08:00
禹翔辉
91bad533c3 Accept Merge Request #2254: (feature/调拨验证优化 -> develop)
Merge Request: 调拨单需验证质检单数量方法优化

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2254
2025-06-24 17:10:41 +08:00
yuxianghui
f5ed94866b 调拨单需验证质检单数量方法优化 2025-06-24 16:59:38 +08:00
胡尧
b70f280c6e Accept Merge Request #2253: (feature/6711 -> develop)
Merge Request: 修复明细接口bug

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2253?initial=true
2025-06-24 15:56:52 +08:00
胡尧
9922402b3b 修复明细接口bug 2025-06-24 15:56:33 +08:00
胡尧
152657e41b Accept Merge Request #2252: (feature/6711 -> develop)
Merge Request: 修改未完成订单明细的判断逻辑

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2252?initial=true
2025-06-24 15:51:17 +08:00
胡尧
0a79a4e336 修改未完成订单明细的判断逻辑 2025-06-24 15:50:45 +08:00
胡尧
174af13a58 Accept Merge Request #2251: (feature/6711 -> develop)
Merge Request: 修改工单状态对应名字

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2251?initial=true
2025-06-24 15:35:42 +08:00
胡尧
00922e3674 修改工单状态对应名字 2025-06-24 15:35:19 +08:00
胡尧
832b06be1f Merge branch 'develop' into feature/根据项目组区分sf代码 2025-06-24 15:06:31 +08:00
胡尧
3b60db56de Accept Merge Request #2250: (feature/6711 -> develop)
Merge Request: 修改大屏获取订单详情接口

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2250
2025-06-24 14:52:47 +08:00
胡尧
2a330a4bd8 修改大屏获取订单详情接口 2025-06-24 14:52:03 +08:00
yuxianghui
579b7138e7 需求 调拨单关联校验是否完成质量检查时,可先排除欠单量后再校验 开发 2025-06-24 14:41:49 +08:00
yuxianghui
98f8430c45 Revert "需求 调拨单关联校验是否完成质量检查时,可先排除欠单量后再校验 开发"
This reverts commit 912847ae33.
2025-06-24 14:32:40 +08:00
yuxianghui
912847ae33 需求 调拨单关联校验是否完成质量检查时,可先排除欠单量后再校验 开发 2025-06-24 14:32:21 +08:00
胡尧
33647fa3e0 修改明细接口 2025-06-24 14:18:27 +08:00
管欢
d1f9f8cf8c Accept Merge Request #2249: (feature/齐套检查与下达生产 -> develop)
Merge Request: 坯料尺寸显示修改

Created By: @管欢
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @管欢
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2249
2025-06-24 11:44:41 +08:00
guanhuan
7d1f7b11eb 坯料尺寸显示修改 2025-06-24 11:39:47 +08:00
胡尧
72f737c370 Accept Merge Request #2248: (feature/6711 -> develop)
Merge Request: 解决大屏bug

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2248?initial=true
2025-06-23 17:54:56 +08:00
胡尧
a2a652eea4 解决大屏bug 2025-06-23 17:54:38 +08:00
管欢
98c5b3b013 Accept Merge Request #2247: (feature/齐套检查与下达生产 -> develop)
Merge Request: 需求计划修改

Created By: @管欢
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @管欢
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2247
2025-06-23 14:26:02 +08:00
guanhuan
0d76d1a7d3 需求计划修改 2025-06-23 13:59:37 +08:00
胡尧
b177bd95ff 将fetchCNC移动到sf_mrs_connect模块 2025-06-23 11:04:44 +08:00
胡尧
a5bb686708 Accept Merge Request #2245: (feature/根据项目组区分sf代码 -> develop)
Merge Request: 将sf_manufacturing模块中stock.py的_run_manufacture方法进行拆分

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2245?initial=true
2025-06-23 10:54:27 +08:00
胡尧
c1bafef1aa Merge branch 'develop' into feature/根据项目组区分sf代码 2025-06-23 10:49:47 +08:00
胡尧
46125dc44b Accept Merge Request #2244: (feature/6711 -> develop)
Merge Request: 修复时间显示问题

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2244?initial=true
2025-06-23 09:22:55 +08:00
胡尧
05c5c0ef81 修复时间显示问题 2025-06-23 09:22:37 +08:00
胡尧
d0d3215bf3 Accept Merge Request #2243: (feature/6711 -> develop)
Merge Request: 修改日产量时间

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2243
2025-06-23 09:11:51 +08:00
胡尧
35e80266d7 修改日产量时间 2025-06-23 08:59:02 +08:00
禹翔辉
92a0c15708 Accept Merge Request #2242: (feature/委外加工bug修复 -> develop)
Merge Request: Merge branch 'feature/委外加工采购订单原生BUG修复' into feature/委外加工bug修复

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2242
2025-06-23 08:50:21 +08:00
yuxianghui
0013f9f8c9 Merge branch 'feature/委外加工采购订单原生BUG修复' into feature/委外加工bug修复 2025-06-23 08:34:14 +08:00
禹翔辉
149d8e287b Accept Merge Request #2241: (feature/出厂检验报告模版 -> develop)
Merge Request: 撤销出厂检验报告模版-页脚优化

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2241
2025-06-20 17:44:00 +08:00
yuxianghui
3f65742add 撤销出厂检验报告模版-页脚优化 2025-06-20 17:42:39 +08:00
管欢
b56e3545a1 Accept Merge Request #2239: (feature/齐套检查与下达生产 -> develop)
Merge Request: 需求计划

Created By: @管欢
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @管欢
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2239
2025-06-20 17:37:21 +08:00
禹翔辉
fd7080a332 Accept Merge Request #2240: (feature/出厂检验报告模版 -> develop)
Merge Request: 页脚条件判断条件优化

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2240
2025-06-20 17:37:12 +08:00
yuxianghui
85fb64ed55 页脚条件判断条件优化 2025-06-20 17:36:12 +08:00
guanhuan
9ad06b4361 需求计划 2025-06-20 17:34:17 +08:00
guanhuan
f9c13341e6 Merge branch 'refs/heads/develop' into feature/齐套检查与下达生产 2025-06-20 17:33:26 +08:00
guanhuan
d2a61c79d0 需求计划 2025-06-20 17:29:41 +08:00
禹翔辉
5f80b377e5 Accept Merge Request #2238: (feature/出厂检验报告模版 -> develop)
Merge Request: 添加页脚页码数据测试

Created By: @禹翔辉
Reviewed By: @胡尧 @秦圣
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2238
2025-06-20 17:28:20 +08:00
yuxianghui
ab2e685004 添加页脚页码数据测试 2025-06-20 17:24:48 +08:00
guanhuan
dcc5eef006 需求计划 2025-06-20 17:21:06 +08:00
guanhuan
7e8b2adb3d 需求计划 2025-06-20 17:19:33 +08:00
禹翔辉
9aa870065b Accept Merge Request #2237: (feature/出厂检验报告模版 -> develop)
Merge Request: 页脚优化

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2237
2025-06-20 17:03:52 +08:00
yuxianghui
60c39929b2 页脚优化 2025-06-20 17:02:31 +08:00
禹翔辉
9a5b8a2627 Accept Merge Request #2236: (feature/出厂检验报告模版 -> develop)
Merge Request: 出厂检验报告-页脚优化

Created By: @禹翔辉
Reviewed By: @秦圣
Approved By: @秦圣 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2236
2025-06-20 16:56:08 +08:00
yuxianghui
73696eb72c 出厂检验报告-页脚优化 2025-06-20 16:50:59 +08:00
禹翔辉
55babb8a35 Accept Merge Request #2235: (feature/出厂检验报告模版 -> develop)
Merge Request: 出厂检验报告模版-页脚优化

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2235
2025-06-20 16:42:02 +08:00
yuxianghui
6682dbfb7d 出厂检验报告模版-页脚优化 2025-06-20 16:40:38 +08:00
禹翔辉
e0b8e5fe07 Accept Merge Request #2234: (feature/出厂检验报告模版 -> develop)
Merge Request: 出厂检验报告-页脚优化

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2234
2025-06-20 16:19:18 +08:00
yuxianghui
800f2eb6a7 出厂检验报告-页脚优化 2025-06-20 16:03:13 +08:00
禹翔辉
3cc633131e Accept Merge Request #2233: (feature/出厂检验报告模版 -> develop)
Merge Request: 出厂检验报告-页脚修改

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2233
2025-06-20 15:57:55 +08:00
yuxianghui
e3fb266890 出厂检验报告-页脚修改 2025-06-20 15:55:58 +08:00
胡尧
844f7de1ab Accept Merge Request #2232: (feature/6711 -> develop)
Merge Request: 修改计划量字段为–qty_production

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2232?initial=true
2025-06-20 15:39:28 +08:00
胡尧
13d33488dc 修改计划量字段为–qty_production 2025-06-20 15:39:11 +08:00
禹翔辉
266601cf84 Accept Merge Request #2231: (feature/出厂检验报告模版 -> develop)
Merge Request: 出厂检验报告模版-页脚优化

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2231
2025-06-20 15:36:51 +08:00
yuxianghui
2e168a4ba7 出厂检验报告模版-页脚优化 2025-06-20 15:35:07 +08:00
胡尧
68ba47ed70 Accept Merge Request #2230: (feature/7151 -> develop)
Merge Request: 修改依赖

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2230?initial=true
2025-06-20 15:03:57 +08:00
胡尧
5bb6fcd4f7 修改依赖 2025-06-20 15:03:42 +08:00
胡尧
9a05bbd82c Accept Merge Request #2229: (feature/7151 -> develop)
Merge Request: 修改需求计划,下达生成的方法

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2229?initial=true
2025-06-20 14:52:34 +08:00
胡尧
b33c992b25 修改需求计划,下达生成的方法 2025-06-20 14:51:58 +08:00
yuxianghui
5947b3dfe9 回退出厂检验报告模版 2025-06-20 14:26:29 +08:00
禹翔辉
95e43b0fba Accept Merge Request #2228: (feature/出厂检验报告模版 -> develop)
Merge Request: 出厂检验报告模版优化

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2228
2025-06-20 14:07:56 +08:00
yuxianghui
e7afc76753 出厂检验报告模版优化 2025-06-20 14:01:56 +08:00
胡尧
788183e239 修改批量大小 2025-06-20 13:52:37 +08:00
胡尧
f38f60a6a8 计划增加队列 2025-06-20 11:24:39 +08:00
yuxianghui
71a0f39ec9 新增如果采购订单类型为委外加工,则不进行供应商校验直接生成补给单 2025-06-18 10:50:13 +08:00
胡尧
92f591c3e7 将sf_manufacturing模块中stock.py的_run_manufacture方法进行拆分 2025-06-18 09:25:44 +08:00
29 changed files with 597 additions and 127 deletions

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models

View File

@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
{
'name': '机企猫 需求计划排程队列',
'version': '1.0',
'summary': """ 使用队列进行排程 """,
'author': 'fox',
'website': '',
'category': '',
'depends': ['queue_job_batch', 'sf_demand_plan'],
'data': [
],
'application': True,
'installable': True,
'auto_install': False,
'license': 'LGPL-3',
}

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import production_demand_plan

View File

@@ -0,0 +1,20 @@
from odoo import models, fields
class ProductionDemandPlan(models.Model):
_inherit = 'sf.production.demand.plan'
def _do_production_schedule(self, pro_plan_list):
"""使用队列进行排程"""
batch_size = 10
current_time = fields.Datetime.now().strftime('%Y%m%d%H%M%S')
index = 1
for i in range(0, len(pro_plan_list), batch_size):
batch = self.env['queue.job.batch'].get_new_batch('plan-%s-%s' % (current_time, index))
pro_plans = pro_plan_list[i:i+batch_size]
pro_plans.with_context(
job_batch=batch
).with_delay().do_production_schedule()
index += 1
batch.enqueue()

View File

@@ -10,6 +10,7 @@
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'views/sale_order_view.xml', 'views/sale_order_view.xml',
'views/purchase_order.xml',
'views/mrp_production.xml', 'views/mrp_production.xml',
'views/purchase_request_view.xml', 'views/purchase_request_view.xml',
'wizard/purchase_request_line_make_purchase_order_view.xml', 'wizard/purchase_request_line_make_purchase_order_view.xml',

View File

@@ -16,6 +16,69 @@ class PurchaseOrder(models.Model):
('rejected', '已驳回') ('rejected', '已驳回')
], string='Status', readonly=True, index=True, copy=False, default='draft', tracking=True) ], string='Status', readonly=True, index=True, copy=False, default='draft', tracking=True)
# 成品采购订单对应的坯料采购申请单和采购订单数量
purchase_request_count = fields.Integer('子·采购申请数量', compute='_compute_purchase_request')
purchase_order_count = fields.Integer('子·采购订单数量', compute='_compute_purchase_request')
@api.depends('state')
def _compute_purchase_request(self):
for record in self:
purchase_request_ids, purchase_order_ids = record.get_purchase_request_order()
record.purchase_request_count = len(purchase_request_ids)
record.purchase_order_count = len(purchase_order_ids)
def action_view_preform_body_purchase_request(self):
self.ensure_one()
name_list = self._get_pinking_name()
purchase_request_ids = self.env['purchase.request'].search([('origin', 'in', name_list)])
action = {
'res_model': 'purchase.request',
'type': 'ir.actions.act_window',
}
if len(purchase_request_ids) == 1:
action.update({
'view_mode': 'form',
'res_id': purchase_request_ids[0].id,
})
else:
action.update({
'name': _("子·采购申请"),
'domain': [('id', 'in', purchase_request_ids.ids)],
'view_mode': 'tree,form',
})
return action
def action_view_preform_body_purchase_order(self):
self.ensure_one()
name_list = self._get_pinking_name()
purchase_order_ids = self.env['purchase.order'].search([('origin', 'in', name_list)])
action = {
'res_model': 'purchase.order',
'type': 'ir.actions.act_window',
}
if len(purchase_order_ids) == 1:
action.update({
'view_mode': 'form',
'res_id': purchase_order_ids[0].id,
})
else:
action.update({
'name': _("子·采购订单"),
'domain': [('id', 'in', purchase_order_ids.ids)],
'view_mode': 'tree,form',
})
return action
def get_purchase_request_order(self):
name_list = self._get_pinking_name()
purchase_request_ids = self.env['purchase.request'].search([('origin', 'in', name_list)])
purchase_order_ids = self.env['purchase.order'].search([('origin', 'in', name_list)])
return purchase_request_ids, purchase_order_ids
def _get_pinking_name(self):
return [picking_id.name for picking_id in self.picking_ids if picking_id.name]
def button_confirm(self): def button_confirm(self):
res = super(PurchaseOrder, self).button_confirm() res = super(PurchaseOrder, self).button_confirm()

View File

@@ -16,6 +16,7 @@ class PurchaseRequest(models.Model):
) )
rule_new_add = fields.Boolean('采购请求为规则创建', default=False, compute='_compute_state', store=True) rule_new_add = fields.Boolean('采购请求为规则创建', default=False, compute='_compute_state', store=True)
rule_purchase_to_request = fields.Boolean('采购单根据规则创建坯料采购申请', default=False)
@api.depends('state') @api.depends('state')
def _compute_state(self): def _compute_state(self):

View File

@@ -45,3 +45,14 @@ class StockPicking(models.Model):
(4, x.id) for x in backorder_ids.move_ids if x.product_id.id in purchase_request_lines.mapped('product_id.id') (4, x.id) for x in backorder_ids.move_ids if x.product_id.id in purchase_request_lines.mapped('product_id.id')
] ]
return res return res
def _subcontracted_produce(self, subcontract_details):
super()._subcontracted_produce(subcontract_details)
# 判断是否根据规则生成新的采购申请单据,如果生成则修改状态为 approved
if self:
pr_ids = self.env["purchase.request"].sudo().search(
[('origin', 'like', self.name), ('rule_purchase_to_request', '=', True), ('state', '=', 'draft')])
if pr_ids:
pr_ids.write({'need_validation': False})
pr_ids.write({"state": "approved", 'need_validation': True, 'rule_new_add': False})

View File

@@ -26,7 +26,7 @@ class StockRule(models.Model):
request_data = rule._prepare_purchase_request( request_data = rule._prepare_purchase_request(
procurement.origin, procurement.values procurement.origin, procurement.values
) )
request_data.update({'rule_new_add': True}) request_data = self._update_request_data(procurement, request_data)
pr = purchase_request_model.create(request_data) pr = purchase_request_model.create(request_data)
cache[domain] = pr cache[domain] = pr
elif ( elif (
@@ -44,6 +44,18 @@ class StockRule(models.Model):
request_line_data.update({'origin': procurement.origin}) request_line_data.update({'origin': procurement.origin})
purchase_request_line_model.create(request_line_data) purchase_request_line_model.create(request_line_data)
def _update_request_data(self, procurement, request_data):
sp = self.env['stock.picking'].sudo().search([('name', '=', procurement.origin)])
if len(sp) == 1:
po = self.env['purchase.order'].sudo().search(
[('name', '=', sp.origin), ('purchase_type', '=', 'outsourcing')])
if po:
request_data.update({'rule_purchase_to_request': True})
else:
request_data.update({'rule_new_add': True})
return request_data
def _run_buy(self, procurements): def _run_buy(self, procurements):
# 如果补货组相同,并且产品相同,则合并 # 如果补货组相同,并且产品相同,则合并
procurements_dict = defaultdict() procurements_dict = defaultdict()

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="purchase_order_form_jikimo_purchase_request" model="ir.ui.view">
<field name="name">purchase.order.inherited.form.jikimo.purchase.request</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="mrp_subcontracting_purchase.purchase_order_form_mrp_subcontracting_purchase"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('oe_button_box')]/button[@name='action_view_subcontracting_resupply']" position="before">
<button
class="oe_stat_button" name="action_view_preform_body_purchase_order"
type="object" icon="fa-truck" attrs="{'invisible': [('purchase_order_count', '=', 0)]}" groups="stock.group_stock_user">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field name="purchase_order_count"/></span>
<span class="o_stat_text">子·采购订单</span>
</div>
</button>
<button
class="oe_stat_button" name="action_view_preform_body_purchase_request"
type="object" icon="fa-truck" attrs="{'invisible': [('purchase_request_count', '=', 0)]}" groups="stock.group_stock_user">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field name="purchase_request_count"/></span>
<span class="o_stat_text">子·采购申请</span>
</div>
</button>
</xpath>
</field>
</record>
</odoo>

View File

@@ -67,6 +67,16 @@
<field name="part_number"/> <field name="part_number"/>
<field name="part_name" invisible="1"/> <field name="part_name" invisible="1"/>
</xpath> </xpath>
<xpath expr="//tree" position="inside">
<header>
<button
name="%(purchase_request.action_purchase_request_line_make_purchase_order)d"
string="创建询价单"
type="action"
class="btn-primary"
/>
</header>
</xpath>
</field> </field>
</record> </record>

View File

@@ -13,7 +13,9 @@
'depends': ['sf_plan','jikimo_printing'], 'depends': ['sf_plan','jikimo_printing'],
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'data/stock_route_group.xml',
'views/demand_plan.xml', 'views/demand_plan.xml',
'views/stock_route.xml',
'wizard/sf_demand_plan_print_wizard_view.xml', 'wizard/sf_demand_plan_print_wizard_view.xml',
], ],
'demo': [ 'demo': [

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data noupdate="0">
<record id="stock_route_group_automation_sf" model="stock.route.group">
<field name="name">自动化产线加工</field>
<field name="code">automation</field>
</record>
<record id="stock_route_group_manual_sf" model="stock.route.group">
<field name="name">人工线下加工</field>
<field name="code">manual</field>
</record>
<record id="stock_route_group_purchase_sf" model="stock.route.group">
<field name="name">外购</field>
<field name="code">purchase</field>
</record>
<record id="stock_route_group_outsourcing_sf" model="stock.route.group">
<field name="name">委外加工</field>
<field name="code">outsourcing</field>
</record>
</data>
</odoo>

View File

@@ -2,3 +2,4 @@
from . import sf_production_demand_plan from . import sf_production_demand_plan
from . import sale_order from . import sale_order
from . import stock_route

View File

@@ -89,6 +89,9 @@ class SfProductionDemandPlan(models.Model):
string='订单状态', string='订单状态',
related='sale_order_line_id.state') related='sale_order_line_id.state')
route_id = fields.Many2one('stock.route', string='路线', related='sale_order_line_id.route_id', store=True) route_id = fields.Many2one('stock.route', string='路线', related='sale_order_line_id.route_id', store=True)
route_ids = fields.Many2many('stock.route', 'stock_route_demand_plan', 'demand_plan_id', 'route_id', '路线',
domain=[('demand_plan_selectable', '=', True)], compute='_compute_route_ids',
store=True)
contract_date = fields.Date('合同日期', related='sale_order_id.contract_date') contract_date = fields.Date('合同日期', related='sale_order_id.contract_date')
date_order = fields.Datetime('下单日期', related='sale_order_id.date_order') date_order = fields.Datetime('下单日期', related='sale_order_id.date_order')
contract_code = fields.Char('合同号', related='sale_order_id.contract_code', store=True) contract_code = fields.Char('合同号', related='sale_order_id.contract_code', store=True)
@@ -136,6 +139,18 @@ class SfProductionDemandPlan(models.Model):
outsourcing_purchase_request = fields.Char('委外采购申请单') outsourcing_purchase_request = fields.Char('委外采购申请单')
@api.depends('supply_method')
def _compute_route_ids(self):
for pdp in self:
if pdp.supply_method:
group_id = self.env['stock.route.group'].sudo().search([('code', '=', pdp.supply_method)])
route_ids = self.env['stock.route'].sudo().search(
[('demand_plan_selectable', '=', True), ('stock_route_group_ids', '=', group_id.id)])
if route_ids:
pdp.route_ids = route_ids.ids
break
pdp.route_ids = None
@api.depends('sale_order_id.state', 'sale_order_id.mrp_production_ids.schedule_state', 'sale_order_id.order_line', @api.depends('sale_order_id.state', 'sale_order_id.mrp_production_ids.schedule_state', 'sale_order_id.order_line',
'sale_order_id.mrp_production_ids.state') 'sale_order_id.mrp_production_ids.state')
def _compute_status(self): def _compute_status(self):
@@ -327,6 +342,9 @@ class SfProductionDemandPlan(models.Model):
date_planned_start = datetime.combine(date_part, time_part) date_planned_start = datetime.combine(date_part, time_part)
pro_plan_list.production_line_id = sf_production_line.id pro_plan_list.production_line_id = sf_production_line.id
pro_plan_list.date_planned_start = date_planned_start pro_plan_list.date_planned_start = date_planned_start
self._do_production_schedule(pro_plan_list)
def _do_production_schedule(self, pro_plan_list):
for pro_plan in pro_plan_list: for pro_plan in pro_plan_list:
pro_plan.do_production_schedule() pro_plan.do_production_schedule()

View File

@@ -0,0 +1,49 @@
from odoo import models, fields, api, _
class SfStockRoute(models.Model):
_inherit = 'stock.route'
demand_plan_selectable = fields.Boolean("需求计划行")
stock_route_group_ids = fields.Many2many('stock.route.group', 'route_to_group', string='路线组')
demand_plan_ids = fields.Many2many('sf.production.demand.plan', 'stock_route_demand_plan', 'route_id',
'demand_plan_id', '需求计划', copy=False, compute='_compute_demand_plan_ids',
store=True)
@api.depends('demand_plan_selectable', 'stock_route_group_ids')
def _compute_demand_plan_ids(self):
for sr in self:
if sr.demand_plan_selectable:
stock_route_group = [srg.code for srg in sr.stock_route_group_ids]
demand_plan_ids = self.env['sf.production.demand.plan'].sudo().search(
[('supply_method', 'in', stock_route_group)])
if demand_plan_ids:
sr.demand_plan_ids = demand_plan_ids.ids
break
sr.demand_plan_ids = None
# def name_get(self):
# res = super().name_get()
# if self.env.context.get('demand_plan_search_stock_route_id'):
# demand_plan_id = self.env['sf.production.demand.plan'].sudo().browse(
# int(self.env.context.get('demand_plan_search_stock_route_id')))
# if demand_plan_id and demand_plan_id.supply_method:
# supply_method = self._set_supply_method(demand_plan_id.supply_method)
# res = [(item[0], f'{item[1]}-{supply_method}') for item in res if len(item) == 2]
# return res
#
# def _set_supply_method(self, supply_method):
# return {
# 'automation': "自动化产线加工",
# 'manual': "人工线下加工",
# 'purchase': "外购",
# 'outsourcing': "委外加工"
# }.get(supply_method)
class SfStockRouteGroup(models.Model):
_name = 'stock.route.group'
_description = '路线组'
name = fields.Char('名称')
code = fields.Char('编码')

View File

@@ -4,3 +4,6 @@ access_sf_production_demand_plan_for_dispatch,sf.production.demand.plan for disp
access_sf_demand_plan_print_wizard,sf.demand.plan.print.wizard,model_sf_demand_plan_print_wizard,base.group_user,1,0,0,0 access_sf_demand_plan_print_wizard,sf.demand.plan.print.wizard,model_sf_demand_plan_print_wizard,base.group_user,1,0,0,0
access_sf_demand_plan_print_wizard_for_dispatch,sf.demand.plan.print.wizard for dispatch,model_sf_demand_plan_print_wizard,sf_base.group_plan_dispatch,1,1,0,0 access_sf_demand_plan_print_wizard_for_dispatch,sf.demand.plan.print.wizard for dispatch,model_sf_demand_plan_print_wizard,sf_base.group_plan_dispatch,1,1,0,0
access_stock_route_group,stock.route.group,model_stock_route_group,base.group_user,1,0,0,0
access_stock_route_group_dispatch,stock.route.group.dispatch,model_stock_route_group,sf_base.group_plan_dispatch,1,1,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
4 access_sf_demand_plan_print_wizard sf.demand.plan.print.wizard model_sf_demand_plan_print_wizard base.group_user 1 0 0 0
5 access_sf_demand_plan_print_wizard_for_dispatch sf.demand.plan.print.wizard for dispatch model_sf_demand_plan_print_wizard sf_base.group_plan_dispatch 1 1 0 0
6 access_stock_route_group stock.route.group model_stock_route_group base.group_user 1 0 0 0
7 access_stock_route_group_dispatch stock.route.group.dispatch model_stock_route_group sf_base.group_plan_dispatch 1 1 0 0
8
9

View File

@@ -38,7 +38,8 @@
<field name="sale_order_id" optional="hide"/> <field name="sale_order_id" optional="hide"/>
<field name="sale_order_line_number" optional="hide"/> <field name="sale_order_line_number" optional="hide"/>
<field name="order_state"/> <field name="order_state"/>
<field name="route_id" optional="hide"/> <field name="route_ids" widget="many2many_tags" optional="hide" readonly="0"
context="{'demand_plan_search_stock_route_id': id}"/>
<field name="contract_date"/> <field name="contract_date"/>
<field name="date_order"/> <field name="date_order"/>
<field name="contract_code"/> <field name="contract_code"/>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="sf_stock_location_route_form_view" model="ir.ui.view">
<field name="name">stock.route.form</field>
<field name="model">stock.route</field>
<field name="inherit_id" ref="stock.stock_location_route_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='packaging_selectable']" position="after">
<field name="demand_plan_selectable"/>
</xpath>
<xpath expr="//group[@name='route_selector']" position="after">
<group name="group_category" string="组类">
<group>
<field name="stock_route_group_ids" options="{'no_create': True}" widget="many2many_tags"/>
<field name="demand_plan_ids" invisible="1" options="{'no_create': True}" widget="many2many_tags"/>
</group>
</group>
</xpath>
</field>
</record>
</odoo>

View File

@@ -437,7 +437,7 @@ class Sf_Dashboard_Connect(http.Controller):
('state', 'in', ['ready', 'progress', 'done']) ('state', 'in', ['ready', 'progress', 'done'])
]) ])
plan_data_total_counts = sum(plan_data_total.mapped('qty_produced')) plan_data_total_counts = sum(plan_data_total.mapped('qty_production'))
# # 工单完成量 # # 工单完成量
# plan_data_finish_counts = plan_obj.search_count( # plan_data_finish_counts = plan_obj.search_count(
@@ -601,8 +601,11 @@ class Sf_Dashboard_Connect(http.Controller):
line_list = ast.literal_eval(kw['line_list']) line_list = ast.literal_eval(kw['line_list'])
begin_time_str = kw['begin_time'].strip('"') begin_time_str = kw['begin_time'].strip('"')
end_time_str = kw['end_time'].strip('"') end_time_str = kw['end_time'].strip('"')
begin_time = datetime.strptime(begin_time_str, '%Y-%m-%d %H:%M:%S') # 将时间减去8小时UTC+8转UTC
end_time = datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S') begin_time = (datetime.strptime(begin_time_str, '%Y-%m-%d %H:%M:%S') - timedelta(hours=8))
end_time = (datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S') - timedelta(hours=8))
# begin_time = datetime.strptime(begin_time_str, '%Y-%m-%d %H:%M:%S')
# end_time = datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S')
# print('line_list: %s' % line_list) # print('line_list: %s' % line_list)
print('kw', kw) print('kw', kw)
time_unit = kw.get('time_unit', 'day').strip('"') # 默认单位为天 time_unit = kw.get('time_unit', 'day').strip('"') # 默认单位为天
@@ -637,6 +640,15 @@ class Sf_Dashboard_Connect(http.Controller):
if time_unit == 'hour': if time_unit == 'hour':
# 计划量目前只能从mail.message中筛选出
plan_order_messages = request.env['mail.message'].sudo().search([
('model', '=', 'mrp.workorder'),
('create_date', '>=', begin_time.strftime('%Y-%m-%d %H:%M:%S')),
('create_date', '<=', end_time.strftime('%Y-%m-%d %H:%M:%S')),
('tracking_value_ids.field_desc', '=', '状态'),
('tracking_value_ids.new_value_char', '=', '就绪')
])
for line in line_list: for line in line_list:
date_field_name = 'date_finished' # 替换为你模型中的实际字段名 date_field_name = 'date_finished' # 替换为你模型中的实际字段名
order_counts = [] order_counts = []
@@ -678,19 +690,10 @@ class Sf_Dashboard_Connect(http.Controller):
) )
# 使用小时和分钟作为键,确保每个小时的数据有独立的键 # 使用小时和分钟作为键,确保每个小时的数据有独立的键
key = start_time.strftime('%H:%M:%S') # 只取小时:分钟:秒作为键 key = (start_time + timedelta(hours=8)).strftime('%H:%M:%S') # 只取小时:分钟:秒作为键
# time_count_dict[key] = len(orders) # time_count_dict[key] = len(orders)
time_count_dict[key] = sum(interval_orders.mapped('qty_produced')) time_count_dict[key] = sum(interval_orders.mapped('qty_produced'))
# 计划量目前只能从mail.message中筛选出
plan_order_messages = request.env['mail.message'].sudo().search([
('model', '=', 'mrp.workorder'),
('create_date', '>=', begin_time.strftime('%Y-%m-%d %H:%M:%S')),
('create_date', '<=', end_time.strftime('%Y-%m-%d %H:%M:%S')),
('tracking_value_ids.field_desc', '=', '状态'),
('tracking_value_ids.new_value_char', '=', '就绪')
])
for time_interval in time_intervals: for time_interval in time_intervals:
start_time, end_time = time_interval start_time, end_time = time_interval
@@ -706,7 +709,9 @@ class Sf_Dashboard_Connect(http.Controller):
and o.create_date <= end_time and o.create_date <= end_time
) )
interval_orders = request.env['mrp.workorder'].sudo().browse(interval_plan_orders.mapped('res_id')) interval_order_ids = set(interval_plan_orders.mapped('res_id'))
interval_orders = request.env['mrp.workorder'].sudo().browse(interval_order_ids)
if line == '业绩总览': if line == '业绩总览':
interval_orders = interval_orders.filtered(lambda o: o.routing_type in ['人工线下加工', 'CNC加工']) interval_orders = interval_orders.filtered(lambda o: o.routing_type in ['人工线下加工', 'CNC加工'])
elif line == '人工线下加工中心': elif line == '人工线下加工中心':
@@ -715,9 +720,9 @@ class Sf_Dashboard_Connect(http.Controller):
interval_orders = interval_orders.filtered(lambda o: o.routing_type == 'CNC加工' and o.production_line_id.name == line) interval_orders = interval_orders.filtered(lambda o: o.routing_type == 'CNC加工' and o.production_line_id.name == line)
# 使用小时和分钟作为键,确保每个小时的数据有独立的键 # 使用小时和分钟作为键,确保每个小时的数据有独立的键
key = start_time.strftime('%H:%M:%S') # 只取小时:分钟:秒作为键 key = (start_time + timedelta(hours=8)).strftime('%H:%M:%S') # 只取小时:分钟:秒作为键
# time_count_dict[key] = len(orders) # time_count_dict[key] = len(orders)
plan_count_dict[key] = sum(interval_orders.mapped('qty_produced')) plan_count_dict[key] = sum(interval_orders.mapped('qty_production'))
# order_counts.append() # order_counts.append()
res['data'][line] = { res['data'][line] = {
@@ -859,21 +864,37 @@ class Sf_Dashboard_Connect(http.Controller):
""" """
# res = {'status': 1, 'message': '成功', 'not_done_data': [], 'done_data': []} # res = {'status': 1, 'message': '成功', 'not_done_data': [], 'done_data': []}
res = {'status': 1, 'message': '成功', 'data': {}} res = {'status': 1, 'message': '成功', 'data': {}}
# 解决产品名称取到英文的问题
request.update_context(lang='zh_CN')
plan_obj = request.env['sf.production.plan'].sudo() plan_obj = request.env['sf.production.plan'].sudo()
work_order_obj = request.env['mrp.workorder'].sudo() work_order_obj = request.env['mrp.workorder'].sudo()
# 获取mrp.workorder的state字段的selection内容
state_dict = dict(request.env['mrp.workorder'].sudo()._fields['state'].selection)
line_list = ast.literal_eval(kw['line_list']) line_list = ast.literal_eval(kw['line_list'])
begin_time_str = kw['begin_time'].strip('"') begin_time_str = kw['begin_time'].strip('"')
end_time_str = kw['end_time'].strip('"') end_time_str = kw['end_time'].strip('"')
begin_time = datetime.strptime(begin_time_str, '%Y-%m-%d %H:%M:%S') begin_time = datetime.strptime(begin_time_str, '%Y-%m-%d %H:%M:%S')
end_time = datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S') end_time = datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S')
# print('line_list: %s' % line_list) # print('line_list: %s' % line_list)
not_done_data = []
done_data = []
final_data = {} final_data = {}
not_done_index = 1
done_index = 1 # 获取当前时间并计算24小时前的时间
current_time = datetime.now()
time_48_hours_ago = current_time - timedelta(hours=48)
# # 计划量目前只能从mail.message中筛选出
# plan_order_messages = request.env['mail.message'].sudo().search([
# ('model', '=', 'mrp.workorder'),
# ('create_date', '>=', time_48_hours_ago.strftime('%Y-%m-%d %H:%M:%S')),
# ('tracking_value_ids.field_desc', '=', '状态'),
# ('tracking_value_ids.new_value_char', 'in', ['就绪', '生产中'])
# ])
for line in line_list: for line in line_list:
not_done_data = []
done_data = []
not_done_index = 1
done_index = 1
if line == '业绩总览': if line == '业绩总览':
work_order_domain = [('routing_type', 'in', ['人工线下加工', 'CNC加工'])] work_order_domain = [('routing_type', 'in', ['人工线下加工', 'CNC加工'])]
@@ -889,21 +910,24 @@ class Sf_Dashboard_Connect(http.Controller):
# [('production_line_id.name', '=', line), ('state', 'not in', ['finished']), # [('production_line_id.name', '=', line), ('state', 'not in', ['finished']),
# ('production_id.state', 'not in', ['cancel', 'done']), ('active', '=', True) # ('production_id.state', 'not in', ['cancel', 'done']), ('active', '=', True)
# ]) # ])
not_done_orders = work_order_obj.search(work_order_domain + not_done_orders = work_order_obj.search(work_order_domain + [
[('state', 'in', ['ready', 'progress'])], order='id asc' ('state', 'in', ['ready', 'progress']),
('date_planned_start', '>=', time_48_hours_ago),
('date_planned_start', '<=', current_time)
], order='id asc'
) )
# 完成订单 # 完成订单
# 获取当前时间并计算24小时前的时间 # 获取当前时间并计算24小时前的时间
current_time = datetime.now() # current_time = datetime.now()
time_24_hours_ago = current_time - timedelta(hours=24) # time_24_hours_ago = current_time - timedelta(hours=24)
finish_orders = work_order_obj.search(work_order_domain + [ finish_orders = work_order_obj.search(work_order_domain + [
('state', 'in', ['finished']), ('state', 'in', ['done']),
('production_id.state', 'not in', ['cancel']), ('production_id.state', 'not in', ['cancel']),
('date_finished', '>=', time_24_hours_ago) ('date_finished', '>=', time_48_hours_ago)
], order='id asc') ], order='id asc')
# print(finish_orders) # logging.info('完成订单: %s' % finish_orders)
# 获取所有未完成订单的ID列表 # 获取所有未完成订单的ID列表
order_ids = [order.id for order in not_done_orders] order_ids = [order.id for order in not_done_orders]
@@ -939,14 +963,6 @@ class Sf_Dashboard_Connect(http.Controller):
material_match = re.search(material_pattern, blank_name) material_match = re.search(material_pattern, blank_name)
material = material_match.group(1) if material_match else 'No match found' material = material_match.group(1) if material_match else 'No match found'
state_dict = {
'draft': '待排程',
'done': '已排程',
'processing': '生产中',
'finished': '已完成',
'ready': '待加工',
'progress': '生产中',
}
line_dict = { line_dict = {
'sequence': not_done_index, 'sequence': not_done_index,
@@ -962,8 +978,6 @@ class Sf_Dashboard_Connect(http.Controller):
not_done_index += 1 not_done_index += 1
for finish_order in finish_orders: for finish_order in finish_orders:
if not finish_order.actual_end_time:
continue
blank_name = '' blank_name = ''
try: try:
blank_name = finish_order.production_id.move_raw_ids[0].product_id.name blank_name = finish_order.production_id.move_raw_ids[0].product_id.name
@@ -979,13 +993,13 @@ class Sf_Dashboard_Connect(http.Controller):
line_dict = { line_dict = {
'sequence': done_index, 'sequence': done_index,
'workorder_name': finish_order.name, 'workorder_name': finish_order.production_id.name,
'blank_name': blank_name, 'blank_name': blank_name,
'material': material, 'material': material,
'dimensions': dimensions, 'dimensions': dimensions,
'order_qty': order.qty_produced, 'order_qty': finish_order.qty_produced,
'finish_time': finish_order.actual_end_time.strftime( 'finish_time': finish_order.date_finished.strftime(
'%Y-%m-%d %H:%M:%S') if finish_order.actual_end_time else ' ' '%Y-%m-%d %H:%M:%S') if finish_order.date_finished else ' '
} }
done_data.append(line_dict) done_data.append(line_dict)

View File

@@ -18,4 +18,5 @@ from . import quick_easy_order
from . import purchase_order from . import purchase_order
from . import quality_check from . import quality_check
from . import purchase_request_line from . import purchase_request_line
from . import bom
# from . import stock_warehouse_orderpoint # from . import stock_warehouse_orderpoint

View File

@@ -0,0 +1,16 @@
from odoo import models
from odoo.osv.expression import AND
class MrpBom(models.Model):
_inherit = 'mrp.bom'
def _bom_subcontract_find(self, product, picking_type=None, company_id=False, bom_type='subcontract', subcontractor=False):
domain = self._bom_find_domain(product, picking_type=picking_type, company_id=company_id, bom_type=bom_type)
if self.env.context.get('stock_picking') == 'outsourcing':
return self.search(domain, order='sequence, product_id, id', limit=1)
if subcontractor:
domain = AND([domain, [('subcontractor_ids', 'parent_of', subcontractor.ids)]])
return self.search(domain, order='sequence, product_id, id', limit=1)
else:
return self.env['mrp.bom']

View File

@@ -1709,6 +1709,7 @@ class MrpProduction(models.Model):
vals['procurement_group_id'] = product_group_id[product_id.id] vals['procurement_group_id'] = product_group_id[product_id.id]
else: else:
vals['procurement_group_id'] = is_custemer_group_id[key] vals['procurement_group_id'] = is_custemer_group_id[key]
return super(MrpProduction, self).create(vals_list) return super(MrpProduction, self).create(vals_list)
@api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id', @api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id',

View File

@@ -35,7 +35,7 @@ class ResProductMo(models.Model):
model_volume = fields.Float('模型体积(m³)') model_volume = fields.Float('模型体积(m³)')
model_area = fields.Float('模型表面积(m²)') model_area = fields.Float('模型表面积(m²)')
model_machining_precision = fields.Selection(selection=_get_machining_precision, string='加工精度') model_machining_precision = fields.Selection(selection=_get_machining_precision, string='加工精度')
model_processing_panel = fields.Char('模型加工面板') model_processing_panel = fields.Char('模型加工面板', default='')
model_remark = fields.Char('模型备注说明') model_remark = fields.Char('模型备注说明')
length = fields.Float('长(mm)', digits=(16, 3)) length = fields.Float('长(mm)', digits=(16, 3))
width = fields.Float('宽(mm)', digits=(16, 3)) width = fields.Float('宽(mm)', digits=(16, 3))
@@ -913,7 +913,7 @@ class ResProductMo(models.Model):
(item['model_height'] + embryo_redundancy_id.height))) if not blank_bool else ( (item['model_height'] + embryo_redundancy_id.height))) if not blank_bool else (
item.get('blank_length') * item.get('blank_width') * item.get('blank_height')), item.get('blank_length') * item.get('blank_width') * item.get('blank_height')),
'product_model_type_id': model_type.id, 'product_model_type_id': model_type.id,
'model_processing_panel': item['processing_panel_detail'], 'model_processing_panel': item['processing_panel_detail'] if item['processing_panel_detail'] else '',
'model_machining_precision': item['model_machining_precision'], 'model_machining_precision': item['model_machining_precision'],
'model_code': item['barcode'], 'model_code': item['barcode'],
'length': item['model_long'], 'length': item['model_long'],

View File

@@ -21,6 +21,7 @@ from odoo.addons.sf_base.commons.common import Common
from odoo.exceptions import UserError from odoo.exceptions import UserError
from io import BytesIO from io import BytesIO
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
from dateutil.relativedelta import relativedelta
class stockWarehouse(models.Model): class stockWarehouse(models.Model):
@@ -95,35 +96,36 @@ class StockRule(models.Model):
precision_rounding=proc[ precision_rounding=proc[
0].product_uom.rounding) > 0) 0].product_uom.rounding) > 0)
list2 = [] list2 = []
for item in procurements: for procurement, rule in procurements:
num = int(item[0].product_qty) num = int(procurement.product_qty)
product = self.env['product.product'].search( warehouse_id = rule.warehouse_id
[("id", '=', item[0].product_id.id)]) if not warehouse_id:
product_tmpl = self.env['product.template'].search( warehouse_id = rule.location_dest_id.warehouse_id
["&", ("id", '=', product.product_tmpl_id.id), ('single_manufacturing', "!=", False)]) manu_rule = rule.route_id.rule_ids.filtered(lambda r: r.action == 'manufacture' and r.warehouse_id == warehouse_id)
if product_tmpl:
if procurement.product_id.product_tmpl_id.single_manufacturing and manu_rule:
if num > 1: if num > 1:
for no in range(1, num + 1): for no in range(1, num + 1):
Procurement = namedtuple('Procurement', ['product_id', 'product_qty', Procurement = namedtuple('Procurement', ['product_id', 'product_qty',
'product_uom', 'location_id', 'name', 'origin', 'product_uom', 'location_id', 'name', 'origin',
'company_id', 'company_id',
'values']) 'values'])
s = Procurement(product_id=item[0].product_id, product_qty=1.0, product_uom=item[0].product_uom, s = Procurement(product_id=procurement.product_id, product_qty=1.0, product_uom=procurement.product_uom,
location_id=item[0].location_id, location_id=procurement.location_id,
name=item[0].name, name=procurement.name,
origin=item[0].origin, origin=procurement.origin,
company_id=item[0].company_id, company_id=procurement.company_id,
values=item[0].values, values=procurement.values,
) )
item1 = list(item) # item1 = list(item)
item1[0] = s # item1[0] = s
list2.append(tuple(item1)) list2.append((s, rule))
else: else:
list2.append(item) list2.append((procurement, rule))
else: else:
list2.append(item) list2.append((procurement, rule))
for procurement, rule in list2: for procurement, rule in list2:
procure_method = rule.procure_method procure_method = rule.procure_method
@@ -183,18 +185,6 @@ class StockRule(models.Model):
'''创建制造订单''' '''创建制造订单'''
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create( productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
productions_values) productions_values)
# 将这一批制造订单的采购组根据成品设置为不同的采购组
# product_group_id = {}
# for index, production in enumerate(productions):
# if production.product_id.id not in product_group_id.keys():
# product_group_id[production.product_id.id] = production.procurement_group_id.id
# else:
# productions_values[index].update({'name': production.name})
# procurement_group_vals = production._prepare_procurement_group_vals(productions_values[index])
# production.procurement_group_id = self.env["procurement.group"].create(procurement_group_vals).id
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
# self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
''' '''
创建工单 创建工单
@@ -738,6 +728,33 @@ class StockPicking(models.Model):
production.workorder_ids.write({'back_button_display': False}) production.workorder_ids.write({'back_button_display': False})
return res return res
def _prepare_subcontract_mo_vals(self, subcontract_move, bom):
subcontract_move.ensure_one()
group = self.env['procurement.group'].sudo().search([('name', '=', self.name)])
if not group:
group = self.env['procurement.group'].create({
'name': self.name,
'partner_id': self.partner_id.id,
})
product = subcontract_move.product_id
warehouse = self._get_warehouse(subcontract_move)
vals = {
'company_id': subcontract_move.company_id.id,
'procurement_group_id': group.id,
'subcontractor_id': subcontract_move.picking_id.partner_id.commercial_partner_id.id,
'picking_ids': [subcontract_move.picking_id.id],
'product_id': product.id,
'product_uom_id': subcontract_move.product_uom.id,
'bom_id': bom.id,
'location_src_id': subcontract_move.picking_id.partner_id.with_company(subcontract_move.company_id).property_stock_subcontractor.id,
'location_dest_id': subcontract_move.picking_id.partner_id.with_company(subcontract_move.company_id).property_stock_subcontractor.id,
'product_qty': subcontract_move.product_uom_qty,
'picking_type_id': warehouse.subcontracting_type_id.id,
'date_planned_start': subcontract_move.date - relativedelta(days=product.produce_delay)
}
return vals
# 创建 外协出库入单 # 创建 外协出库入单
def create_outcontract_picking(self, workorders, item, sorted_workorders): def create_outcontract_picking(self, workorders, item, sorted_workorders):
production = workorders[0].production_id production = workorders[0].production_id
@@ -1216,6 +1233,20 @@ class ReStockMove(models.Model):
res['lot_id'] = self.subcontract_workorder_id.production_id.move_raw_ids.move_line_ids[0].lot_id.id res['lot_id'] = self.subcontract_workorder_id.production_id.move_raw_ids.move_line_ids[0].lot_id.id
return res return res
def _get_subcontract_bom(self):
self.ensure_one()
purchase_type = getattr(self.picking_id.purchase_id, 'purchase_type', False)
if purchase_type:
self = self.with_context(stock_picking=purchase_type)
bom = self.env['mrp.bom'].sudo()._bom_subcontract_find(
self.product_id,
picking_type=self.picking_type_id,
company_id=self.company_id.id,
bom_type='subcontract',
subcontractor=self.picking_id.partner_id
)
return bom
class ReStockQuant(models.Model): class ReStockQuant(models.Model):
_inherit = 'stock.quant' _inherit = 'stock.quant'

View File

@@ -200,8 +200,8 @@
<p></p> <p></p>
</div> </div>
</div> --> </div> -->
<!-- 页脚固定在底部 --> <!-- 页脚固定在底部 -->
<!-- <div style="position: absolute; bottom: 0; left: 0; right: 0;"> --> <!-- <div style="position: absolute; bottom: 0; left: 0; right: 0;"> -->
<t t-call="sf_quality.report_quality_footer"/> <t t-call="sf_quality.report_quality_footer"/>
<!-- </div> --> <!-- </div> -->
@@ -329,9 +329,11 @@
</div> --> </div> -->
<!-- 页脚固定在底部 --> <!-- 页脚固定在底部 -->
<!-- <t t-if="loop.index == len(docs) - 1">-->
<!-- <div style="position: absolute; bottom: 0; left: 0; right: 0;"> --> <!-- <div style="position: absolute; bottom: 0; left: 0; right: 0;"> -->
<t t-call="sf_quality.html_report_quality_footer"/> <t t-call="sf_quality.html_report_quality_footer"/>
<!-- </div> --> <!-- </div> -->
<!-- </t>-->
</div> </div>
</t> </t>
</t> </t>

View File

@@ -1,49 +1,81 @@
import logging
from odoo import api, models from odoo import api, models
from odoo.exceptions import ValidationError, UserError
class StockPicking(models.Model): class StockPicking(models.Model):
_inherit = 'stock.picking' _inherit = 'stock.picking'
def _compute_check(self):
super()._compute_check()
for picking in self:
picking_to_quality = picking.get_picking_to_quality()
if not picking_to_quality:
picking.quality_check_todo = False
break
else:
need_quality_line = picking.get_need_quality_line(picking_to_quality)
if not need_quality_line or all(not line.get('need_done_check_ids') for line in need_quality_line):
picking.quality_check_todo = False
def check_quality(self):
self.ensure_one()
# checkable_products = self.mapped('move_line_ids').mapped('product_id')
# checks = self.check_ids.filtered(lambda check: check.quality_state == 'none' and (
# check.product_id in checkable_products or check.measure_on == 'operation'))
checks = self.env['quality.check']
picking_to_quality = self._get_picking_to_quality()
need_quality_line = self.get_need_quality_line(picking_to_quality)
if need_quality_line and any(line.get('need_done_check_ids') for line in need_quality_line):
for item in need_quality_line:
checks += item.get('need_done_check_ids')
if checks:
return checks.action_open_quality_check_wizard()
return False
def button_validate(self): def button_validate(self):
""" """=
出厂检验报告上传 出厂检验报告上传
""" """
out_quality_checks = self.env['quality.check'].search( out_quality_checks = self.env['quality.check'].search(
[('picking_id', '=', self.id), ('test_type_id.name', '=', '出厂检验报告')]) [('picking_id', '=', self.id), ('test_type_id.name', '=', '出厂检验报告'),
('quality_state', '=', 'pass')])
# out_quality_checks 可能存在多个 # out_quality_checks 可能存在多个
if out_quality_checks: if out_quality_checks:
for out_quality_check in out_quality_checks: for out_quality_check in out_quality_checks:
if not out_quality_check.is_factory_report_uploaded: if not out_quality_check.is_factory_report_uploaded:
if out_quality_check and self.state == 'assigned': if out_quality_check and self.state == 'assigned':
out_quality_check.upload_factory_report() out_quality_check.upload_factory_report()
quality_action = self.pinking_checkout_quality()
if quality_action:
return quality_action
res = super(StockPicking, self).button_validate()
return res
def pinking_checkout_quality(self):
""" """
调拨单若关联了质量检查单,验证调拨单时,应校验是否有不合格品,若存在,应弹窗提示: 调拨单若关联了质量检查单,验证调拨单时,应校验是否有不合格品,若存在,应弹窗提示:
“警告存在不合格产品XXXX n 件、YYYYY m件继续调拨请点“确认”否则请取消 “警告存在不合格产品XXXX n 件、YYYYY m件继续调拨请点“确认”否则请取消
""" """
try:
self.ensure_one()
context = self.env.context context = self.env.context
if not context.get('again_validate') and self.quality_check_ids.filtered(lambda qc: qc.quality_state == 'fail'): if not context.get('pinking_checkout_quality'):
picking_to_quality = self._get_picking_to_quality()
if not picking_to_quality: return False
need_quality_val = self.get_need_quality_line(picking_to_quality)
if any(line.get('fail_check_ids') for line in need_quality_val):
# 回滚事务,为二次确认/取消做准备 # 回滚事务,为二次确认/取消做准备
self.env.cr.rollback() self.env.cr.rollback()
quality_check_ids = self.quality_check_ids.filtered(lambda qc: qc.quality_state == 'fail') # 获取存在失败的 质检单 调拨单明细行
product_list = list(set([quality_check_id.product_id for quality_check_id in quality_check_ids])) check_list = [item for item in need_quality_val if item.get('fail_check_ids')]
fail_check_text = '' fail_check_text = ''
for product_id in product_list: for item in check_list:
check_ids = quality_check_ids.filtered(lambda qc: qc.product_id == product_id) move_id, pre_done_qty = item.get('move_id'), item.get('pre_done_qty')
if all(check_id.measure_on == 'move_line' for check_id in check_ids): fail_check_text = (f'{fail_check_text}{move_id.product_id.display_name} {pre_done_qty}'
number = sum(check_ids.mapped('qty_line')) if fail_check_text != '' else f'{move_id.product_id.display_name} {pre_done_qty}')
else:
number = sum(self.move_ids_without_package.filtered(
lambda ml: ml.product_id == product_id).mapped('quantity_done'))
if number == 0:
number = sum(self.move_ids_without_package.filtered(
lambda ml: ml.product_id == product_id).mapped('reserved_availability'))
if number == 0:
number = sum(self.move_ids_without_package.filtered(
lambda ml: ml.product_id == product_id).mapped('product_uom_qty'))
fail_check_text = (f'{fail_check_text}{product_id.display_name} {number}'
if fail_check_text != '' else f'{product_id.display_name} {number}')
return { return {
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'picking.validate.check.wizard', 'res_model': 'picking.validate.check.wizard',
@@ -53,7 +85,96 @@ class StockPicking(models.Model):
'context': { 'context': {
'default_picking_id': self.id, 'default_picking_id': self.id,
'default_fail_check_text': f'警告:存在不合格产品{fail_check_text},继续调拨请点“确认”,否则请取消?', 'default_fail_check_text': f'警告:存在不合格产品{fail_check_text},继续调拨请点“确认”,否则请取消?',
'again_validate': True} 'pinking_checkout_quality': True}
} }
res = super(StockPicking, self).button_validate() else:
return False
except Exception as e:
logging.info('pinking_checkout_quality()方法报错:%s' % e)
raise ValidationError('调拨单验证质检单是否合格时报错,请联系管理员处理!!')
def get_need_quality_line(self, picking_to_quality):
"""
# 对需要进行质检,还没有质检完成的明细行进行统计
# 1、当【质量标准_控制方式】=“产品、作业”,仅校验“预完成数量”>0的产品行对应的质检单必须处理。
2、当【质量标准_控制方式】=“数量”时,仅校验“预完成数量”>0的产品行对应的质检单必须处理
1每一类的“总单数”=【调拨单_需求】时则已处理的质检单“单数”≥“预完成数量”时可执行调拨单验证
2每一类的“总单数”<【调拨单_需求】时则已处理的质检单“单数”≥0时可执行调拨单验证
"""
res = []
for item in picking_to_quality:
need_done_check_ids = self.env['quality.check']
fail_check_ids = self.env['quality.check']
move_id, pre_done_qty, check_ids = item.values()
check_ids_1 = check_ids.filtered(lambda qc: qc.measure_on in ('operation', 'product'))
if check_ids_1:
check_ids_1_done = check_ids_1.filtered(lambda qc: qc.quality_state in ('pass', 'fail'))
check_ids_1_fail = check_ids_1.filtered(lambda qc: qc.quality_state == 'fail')
check_ids_1_none = check_ids_1.filtered(lambda qc: qc.quality_state == 'none')
if check_ids_1 and not check_ids_1_done:
need_done_check_ids += check_ids_1_none
if check_ids_1_fail:
fail_check_ids += check_ids_1_fail
check_ids_2 = check_ids.filtered(lambda qc: qc.measure_on == 'move_line')
if check_ids_2:
check_ids_2_done = check_ids_2.filtered(lambda qc: qc.quality_state in ('pass', 'fail'))
check_ids_2_fail = check_ids_2.filtered(lambda qc: qc.quality_state == 'fail')
check_ids_2_none = check_ids_2.filtered(lambda qc: qc.quality_state == 'none')
# 每一类的“总单数”=【调拨单_需求】时则已处理的质检单“单数”≥“预完成数量”时可执行调拨单验证
if len(check_ids_2) >= move_id.product_uom_qty and len(check_ids_2_done) < pre_done_qty:
need_done_check_ids += check_ids_2_none
# 每一类的“总单数”<【调拨单_需求】时则已处理的质检单“单数”≥0时可执行调拨单验证
elif len(check_ids_2) < move_id.product_uom_qty and len(check_ids_2_done) == 0:
need_done_check_ids += check_ids_2_none
if check_ids_2_fail:
fail_check_ids += check_ids_2_fail
if need_done_check_ids or fail_check_ids:
res.append({'move_id': move_id,
'pre_done_qty': pre_done_qty,
'check_ids': check_ids,
'fail_check_ids': fail_check_ids,
'need_done_check_ids': need_done_check_ids})
return res return res
def get_picking_to_quality(self):
self.ensure_one()
return self._get_picking_to_quality()
def _get_picking_to_quality(self):
"""
对需要质检的明细行进行统计(针对“预完成数量”>0的行)
"""
quality_piking_line_list = []
pre_done_qty_lines = self._get_pinking_pre_done_qty()
for line in pre_done_qty_lines:
move_id, pre_done_qty = line.values()
if pre_done_qty == 0:
continue
product_id = move_id.product_id
check_ids = self.check_ids.filtered(lambda c: c.product_id == product_id)
quality_piking_line_list.append({'move_id': move_id, 'pre_done_qty': pre_done_qty, 'check_ids': check_ids})
return quality_piking_line_list
def _get_pinking_pre_done_qty(self):
"""
return: 明细行 及 预完成数量
1、若调拨单所有明细行的【完成】=0且任意行的【预留】<【需求】,则验证时将会话是否需创建欠单。
---->此时“预完成数量”=【预留】
2、若调拨单任意行的0<【完成】<【需求】,且则验证时将会话是否需创建欠单
---->此时“预完成数量”=【完成】
"""
# if all(move_id.quantity_done == 0 for move_id in self.move_ids_without_package):
# pre_done_qty = [{'move_id': move_id, 'pre_done_qty': move_id.reserved_availability} for move_id in
# self.move_ids_without_package]
# else:
# pre_done_qty = [{'move_id': move_id, 'pre_done_qty': move_id.quantity_done} for move_id in
# self.move_ids_without_package]
pre_done_qty = []
for move_id in self.move_ids_without_package:
if move_id.quantity_done > 0:
pre_done_qty.append({'move_id': move_id, 'pre_done_qty': move_id.quantity_done})
else:
pre_done_qty.append({'move_id': move_id, 'pre_done_qty': move_id.reserved_availability})
return pre_done_qty