Compare commits
474 Commits
feature/me
...
release/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab692dfb25 | ||
|
|
6f9cea2759 | ||
|
|
0601e123fb | ||
|
|
08e4541a96 | ||
|
|
66acc19e89 | ||
|
|
5b94a0624c | ||
|
|
1b5b2fd6f9 | ||
|
|
54c502dd64 | ||
|
|
e3db40ae25 | ||
|
|
52ab962ace | ||
|
|
05247ee8d9 | ||
|
|
dbf75684ee | ||
|
|
cb2319492b | ||
|
|
731e6abc90 | ||
|
|
58b33b6c8d | ||
|
|
43c8bbda71 | ||
|
|
e011e4cfd6 | ||
|
|
c8fd2d69bd | ||
|
|
ef1f7b1d08 | ||
|
|
5f12976d8f | ||
|
|
ef60f36c90 | ||
|
|
c8ed45b1a7 | ||
|
|
57fe68bae8 | ||
|
|
aa32fdcd07 | ||
|
|
d0d59135e3 | ||
|
|
27ec5b1b74 | ||
|
|
2c1caabce6 | ||
|
|
8f3cd9ff36 | ||
|
|
6366904c91 | ||
|
|
7f3e6de127 | ||
|
|
5b43cceb94 | ||
|
|
d933416b2d | ||
|
|
e260ef01f0 | ||
|
|
0fef3d7a63 | ||
|
|
dc5c0b1d1e | ||
|
|
9a1cde6abc | ||
|
|
29864b8bb2 | ||
|
|
aa5294f110 | ||
|
|
4387d343b5 | ||
|
|
ff979aa34b | ||
|
|
21af368068 | ||
|
|
d6afd556d3 | ||
|
|
778d2c4ec5 | ||
|
|
fff29b36ee | ||
|
|
fedb79a142 | ||
|
|
d06816052f | ||
|
|
5739e167f4 | ||
|
|
a249548a20 | ||
|
|
7b6538d01e | ||
|
|
7025bde56e | ||
|
|
3585af0cea | ||
|
|
5406224c6f | ||
|
|
18ff0bba54 | ||
|
|
7c13e57ea2 | ||
|
|
b8605b9a97 | ||
|
|
4baa7a9b44 | ||
|
|
3af2f3e03b | ||
|
|
dc68ecb584 | ||
|
|
421f107728 | ||
|
|
1f1bdd08ed | ||
|
|
1a7059aad1 | ||
|
|
8d461e61b3 | ||
|
|
fa0ca83709 | ||
|
|
a783f9c271 | ||
|
|
b4901e89d6 | ||
|
|
6690d3f2cb | ||
|
|
21d6989182 | ||
|
|
97ad3567e3 | ||
|
|
22a69df31b | ||
|
|
c0ad9d8977 | ||
|
|
a927d0e9cb | ||
|
|
5759ca1ca5 | ||
|
|
9955157dd3 | ||
|
|
d42de42709 | ||
|
|
a7dc3a1227 | ||
|
|
9c5f525e90 | ||
|
|
db8bd659c3 | ||
|
|
0dab394d1b | ||
|
|
9a9e47b4ff | ||
|
|
deb2f6ca64 | ||
|
|
5bce9bb816 | ||
|
|
ccda6b627d | ||
|
|
20cfbf7230 | ||
|
|
805eabd07e | ||
|
|
c42c053d66 | ||
|
|
d8e51f44ac | ||
|
|
0b5645496b | ||
|
|
2c37dbf5c4 | ||
|
|
cd6dc7a47e | ||
|
|
7362f0cd30 | ||
|
|
de2924883c | ||
|
|
942aa469e3 | ||
|
|
d57cc59115 | ||
|
|
f8ff3a18a0 | ||
|
|
96171013d6 | ||
|
|
d741d6ccf5 | ||
|
|
8ff73d5647 | ||
|
|
5d3d04b5d3 | ||
|
|
75ed1a6889 | ||
|
|
9bfbea11db | ||
|
|
5eea260618 | ||
|
|
f1e70d2c66 | ||
|
|
da22cb301e | ||
|
|
2b93f2a253 | ||
|
|
8ab42ff7da | ||
|
|
9bf57005f0 | ||
|
|
a80d498eab | ||
|
|
4847596072 | ||
|
|
d4ba58b55a | ||
|
|
306d5074f2 | ||
|
|
745abaab2e | ||
|
|
c22b91f9d9 | ||
|
|
0bea93ea46 | ||
|
|
ecf683e663 | ||
|
|
0af7ef905d | ||
|
|
c169c0a80b | ||
|
|
878d62f483 | ||
|
|
8a33cea8bd | ||
|
|
d6c194eaa8 | ||
|
|
13d32c26b6 | ||
|
|
df146a4b58 | ||
|
|
4a02034ee3 | ||
|
|
acb24d69e3 | ||
|
|
56cfeac214 | ||
|
|
b86ad6e5bb | ||
|
|
f57c95496a | ||
|
|
826b2c3e94 | ||
|
|
29b43c6ab8 | ||
|
|
a434227807 | ||
|
|
3a7fb81276 | ||
|
|
12224fc892 | ||
|
|
64fdedf726 | ||
|
|
d3b61f320f | ||
|
|
6be7c05415 | ||
|
|
92b924754d | ||
|
|
40ddfdd48f | ||
|
|
afa5ad36f2 | ||
|
|
916a5c1054 | ||
|
|
ea914be4c7 | ||
|
|
e6eb41ad24 | ||
|
|
43ee2d1836 | ||
|
|
3bd4e6723e | ||
|
|
0e763c2ca6 | ||
|
|
34353e3614 | ||
|
|
d91c7b22d7 | ||
|
|
ac4861c76e | ||
|
|
6edd124556 | ||
|
|
f426183d22 | ||
|
|
33db91f799 | ||
|
|
8803380a30 | ||
|
|
b5beaad7bf | ||
|
|
304259c653 | ||
|
|
5ccc836b20 | ||
|
|
087bb0e8fe | ||
|
|
09a476ffa5 | ||
|
|
429ad2b77c | ||
|
|
c215e3dc27 | ||
|
|
0a1da79487 | ||
|
|
42e4e15cdb | ||
|
|
a3e7a23979 | ||
|
|
430a628e18 | ||
|
|
5f70690af5 | ||
|
|
b852933a9e | ||
|
|
074c45aa3d | ||
|
|
a52545d19a | ||
|
|
3e55bb4717 | ||
|
|
be408b98de | ||
|
|
12cc5fd0d2 | ||
|
|
589df289be | ||
|
|
7abc88f2c3 | ||
|
|
f318dc758b | ||
|
|
6628e22ac0 | ||
|
|
c4cf4e2392 | ||
|
|
56dfb98df5 | ||
|
|
4251e6dec7 | ||
|
|
bcc9f0301c | ||
|
|
17f2571be3 | ||
|
|
a9b24f7961 | ||
|
|
321125adf6 | ||
|
|
5c0db45223 | ||
|
|
76cc8845d2 | ||
|
|
38031a2537 | ||
|
|
1fe64e2b5d | ||
|
|
d572529a9d | ||
|
|
cb29baa698 | ||
|
|
696d0e2a40 | ||
|
|
75bbcd23a4 | ||
|
|
25002406b8 | ||
|
|
ed3ea32f45 | ||
|
|
63b1f732db | ||
|
|
84ebce0786 | ||
|
|
ed747ae4d9 | ||
|
|
8a103a7555 | ||
|
|
e8c166be31 | ||
|
|
d887a89988 | ||
|
|
cb02319453 | ||
|
|
7f5f65f07f | ||
|
|
c45200aaee | ||
|
|
d2351a67b0 | ||
|
|
52873021cb | ||
|
|
3f276f4177 | ||
|
|
f01a300aae | ||
|
|
8e11ef6e72 | ||
|
|
52c0df9b83 | ||
|
|
33b9c48e87 | ||
|
|
aa2f562ca8 | ||
|
|
77ce078e91 | ||
|
|
5450c9996f | ||
|
|
70f8aadd66 | ||
|
|
119083ac2b | ||
|
|
dd768e938c | ||
|
|
611aa0fe05 | ||
|
|
73564d574c | ||
|
|
ea5231adff | ||
|
|
2b3da48e9b | ||
|
|
2632c4a5a0 | ||
|
|
2420987f95 | ||
|
|
d80f3c4d5c | ||
|
|
5cb726bb2d | ||
|
|
f6b8fa5665 | ||
|
|
113d0abb4b | ||
|
|
3f3c494f7f | ||
|
|
3632a3f98f | ||
|
|
73402d1c5a | ||
|
|
4e41efd423 | ||
|
|
0b931f8255 | ||
|
|
b49135f5f9 | ||
|
|
ed6d28cc21 | ||
|
|
9857787d5a | ||
|
|
c6e62f65b6 | ||
|
|
6c0b034147 | ||
|
|
c0d520a47f | ||
|
|
de11c57800 | ||
|
|
d4ff4be32e | ||
|
|
48371b01cd | ||
|
|
310d8b33df | ||
|
|
6d61e45028 | ||
|
|
fff22a74b1 | ||
|
|
3588288434 | ||
|
|
7408cc00f9 | ||
|
|
9b3d1170b0 | ||
|
|
a774c74e6a | ||
|
|
1d53f47488 | ||
|
|
60cc49238c | ||
|
|
b415278997 | ||
|
|
ac32494944 | ||
|
|
8c81315c33 | ||
|
|
1d66c1dbea | ||
|
|
085d26669f | ||
|
|
bb7b72b540 | ||
|
|
ded0d06f86 | ||
|
|
fe08ee4173 | ||
|
|
25ee849796 | ||
|
|
bafcf35ac9 | ||
|
|
cc1455b22c | ||
|
|
1d38334c81 | ||
|
|
13d99b1bcc | ||
|
|
269be36d86 | ||
|
|
ebd76afb29 | ||
|
|
a1807e05db | ||
|
|
11866629c5 | ||
|
|
f8f5286568 | ||
|
|
36908f13d3 | ||
|
|
a7ed317b09 | ||
|
|
fe4346b802 | ||
|
|
23da273af1 | ||
|
|
68fdea4520 | ||
|
|
c5ac62060d | ||
|
|
350cf0a74b | ||
|
|
e204d693cf | ||
|
|
a6422330b6 | ||
|
|
230e87a9f1 | ||
|
|
e634e9726f | ||
|
|
e8d07abe05 | ||
|
|
808bbd7b22 | ||
|
|
fabcca1188 | ||
|
|
97c8b1dcc1 | ||
|
|
f99a35932f | ||
|
|
ce7dfdbd36 | ||
|
|
d53f3837c3 | ||
|
|
1cb646ec48 | ||
|
|
c73706555f | ||
|
|
21f961d893 | ||
|
|
08a682143f | ||
|
|
ebdeb95b0e | ||
|
|
0f26cac68d | ||
|
|
45c96276ff | ||
|
|
a2855f1f08 | ||
|
|
e8c006d495 | ||
|
|
9671efeced | ||
|
|
1e3fd6bc09 | ||
|
|
73aa4af118 | ||
|
|
38a8a298b5 | ||
|
|
bc0b8bdecb | ||
|
|
a8e9fe40ac | ||
|
|
5c5606749a | ||
|
|
8add4b5ad1 | ||
|
|
f579c8928c | ||
|
|
9410ca82db | ||
|
|
73c986cd50 | ||
|
|
f8a9a38778 | ||
|
|
9d723c5e00 | ||
|
|
722a044707 | ||
|
|
967effe8f1 | ||
|
|
5f5877699c | ||
|
|
4787cb451d | ||
|
|
811a79c7c1 | ||
|
|
153f599fe8 | ||
|
|
f6f9d14f0a | ||
|
|
018d51e25f | ||
|
|
ac03192119 | ||
|
|
b8d5d655ea | ||
|
|
00f986cdb5 | ||
|
|
5dc5c814c8 | ||
|
|
c64ede58fd | ||
|
|
6e17bb933f | ||
|
|
99aa161834 | ||
|
|
ed641c85b3 | ||
|
|
cf7756f51e | ||
|
|
a75269b3a3 | ||
|
|
6b184d7df3 | ||
|
|
daba7d5155 | ||
|
|
33a1837274 | ||
|
|
6b3e3aa49c | ||
|
|
a7b5fc898e | ||
|
|
9a9bfd198b | ||
|
|
2446065172 | ||
|
|
7565094077 | ||
|
|
ac2708404a | ||
|
|
63b9f495e9 | ||
|
|
012bb9fd54 | ||
|
|
7bcb54861b | ||
|
|
2f64a3a612 | ||
|
|
5365211f49 | ||
|
|
e38407c0a5 | ||
|
|
13ef106c0e | ||
|
|
433f3bd2dc | ||
|
|
ff072a32bb | ||
|
|
de7098a7d4 | ||
|
|
205bfd0538 | ||
|
|
37538141bf | ||
|
|
975ced08cb | ||
|
|
d646019c93 | ||
|
|
efa1e2b60f | ||
|
|
8bbc65ef88 | ||
|
|
e1121cc3b5 | ||
|
|
026bf17a68 | ||
|
|
fdcd825142 | ||
|
|
317f44d6c2 | ||
|
|
7d5c7bceb1 | ||
|
|
359fd40ed3 | ||
|
|
13a930b59c | ||
|
|
359a246793 | ||
|
|
2b658d7be0 | ||
|
|
cd9f485fc0 | ||
|
|
dda627f20a | ||
|
|
e8858559f6 | ||
|
|
d68a9249c6 | ||
|
|
eebb143778 | ||
|
|
a12eb12678 | ||
|
|
f5f67c52af | ||
|
|
3df2306e1b | ||
|
|
5dae0ea973 | ||
|
|
e7b18233f0 | ||
|
|
e55e42fe6b | ||
|
|
741f2ad8b2 | ||
|
|
1b87a81a5a | ||
|
|
7042eb0d7b | ||
|
|
28788e2a81 | ||
|
|
0f37b45b30 | ||
|
|
38c4aba45c | ||
|
|
3b686a8272 | ||
|
|
2798ce6183 | ||
|
|
e981d68805 | ||
|
|
cd3ab04728 | ||
|
|
d419efa3c3 | ||
|
|
8b4eb325ef | ||
|
|
330726007d | ||
|
|
4d7b1f557b | ||
|
|
1699f61d3f | ||
|
|
a0eec00749 | ||
|
|
f5365b4a3a | ||
|
|
8b9aa1c454 | ||
|
|
9a4d7e87ec | ||
|
|
6679c200e1 | ||
|
|
01df55ef35 | ||
|
|
d2b028ed4e | ||
|
|
de1b97bfb7 | ||
|
|
111c0f6dae | ||
|
|
11da893b17 | ||
|
|
b434329fc4 | ||
|
|
72998f04c6 | ||
|
|
23db164452 | ||
|
|
1f11d188c1 | ||
|
|
fa30e0c1da | ||
|
|
5106768330 | ||
|
|
6c0d9486fc | ||
|
|
211d74d9ff | ||
|
|
84db3a92be | ||
|
|
487a2936c3 | ||
|
|
aa9bdfe372 | ||
|
|
6134ac3b4c | ||
|
|
85c24e3d94 | ||
|
|
106945fba7 | ||
|
|
8ea72198ea | ||
|
|
41cd76ad14 | ||
|
|
e20510bc4f | ||
|
|
1d14ab27af | ||
|
|
7d6699fe7a | ||
|
|
fd55abec72 | ||
|
|
76597f6ccb | ||
|
|
d7779e969d | ||
|
|
9d28eccd1b | ||
|
|
27339afaae | ||
|
|
8dc3f2698b | ||
|
|
4fd7ad8d03 | ||
|
|
3bc33fe2fc | ||
|
|
c21319a127 | ||
|
|
02e21a8fde | ||
|
|
2cf578de65 | ||
|
|
bef7376827 | ||
|
|
e73e9d6960 | ||
|
|
892f5d0e70 | ||
|
|
61339da204 | ||
|
|
25db392864 | ||
|
|
745fd429c2 | ||
|
|
5c59a27a81 | ||
|
|
9bac3675f6 | ||
|
|
816623b1fe | ||
|
|
91b913a7bd | ||
|
|
ba8393a8c7 | ||
|
|
06d061165b | ||
|
|
dc545e6d49 | ||
|
|
1467dbf88c | ||
|
|
e9caf78b81 | ||
|
|
aa1353cf99 | ||
|
|
14d49f2944 | ||
|
|
8560069b19 | ||
|
|
8dc23a638f | ||
|
|
537fbf7e14 | ||
|
|
3e684a308c | ||
|
|
3c026004f3 | ||
|
|
651c8f266b | ||
|
|
a3bfbe66c4 | ||
|
|
563e40adc6 | ||
|
|
f88a784a87 | ||
|
|
7227e1e59c | ||
|
|
01df5e86cd | ||
|
|
41f853b6c9 | ||
|
|
906a0ea767 | ||
|
|
6162c731f2 | ||
|
|
06eaebd098 | ||
|
|
8578a9a538 | ||
|
|
b9039ef466 | ||
|
|
a97f581c99 | ||
|
|
036179ec4d | ||
|
|
d33188dedf | ||
|
|
7033f95273 | ||
|
|
00689d76cc | ||
|
|
05a183f46f | ||
|
|
50959d2e9c | ||
|
|
f06842cdcb | ||
|
|
d5a1caad10 | ||
|
|
e51fff4120 | ||
|
|
2fe8e0e356 | ||
|
|
bbe2e5792f | ||
|
|
a1a520ec39 | ||
|
|
1b714a9962 | ||
|
|
9d133096c7 | ||
|
|
69f3453134 | ||
|
|
ac2eba4734 | ||
|
|
b64893436b | ||
|
|
69c63f708d | ||
|
|
3f84972bfd |
@@ -536,3 +536,7 @@ div:has(.o_required_modifier) > label::before {
|
|||||||
position: unset;
|
position: unset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 修复搜索面板checkbox样式
|
||||||
|
.o_search_panel .form-check .form-check-label span {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
@@ -190,7 +190,7 @@ def _create(self, data_list):
|
|||||||
# 如果该用户组被限制创建或更新操作
|
# 如果该用户组被限制创建或更新操作
|
||||||
if rec['is_create_or_update']:
|
if rec['is_create_or_update']:
|
||||||
raise UserError(
|
raise UserError(
|
||||||
_("You are restricted from performing this operation. Please contact the administrator."))
|
_("您没有执行此操作的权限。请联系管理员"))
|
||||||
else:
|
else:
|
||||||
# 如果 'access.right' 模型不存在,可以在这里定义备选逻辑
|
# 如果 'access.right' 模型不存在,可以在这里定义备选逻辑
|
||||||
# 例如,记录日志、发送通知或者简单地跳过这部分逻辑
|
# 例如,记录日志、发送通知或者简单地跳过这部分逻辑
|
||||||
|
|||||||
139
jikimo_sale_multiple_supply_methods/__init__.py
Normal file
139
jikimo_sale_multiple_supply_methods/__init__.py
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from . import models
|
||||||
|
from . import controllers
|
||||||
|
|
||||||
|
from odoo import api, SUPERUSER_ID
|
||||||
|
|
||||||
|
def _data_install(cr, registry):
|
||||||
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
|
# 获取所有需要设置的产品模板
|
||||||
|
env.ref('jikimo_sale_multiple_supply_methods.product_template_purchase').product_variant_id.write({'active': False, 'is_bfm': True})
|
||||||
|
env.ref('jikimo_sale_multiple_supply_methods.product_template_manual_processing').product_variant_id.write({'active': False, 'single_manufacturing': True, 'is_bfm': True})
|
||||||
|
env.ref('jikimo_sale_multiple_supply_methods.product_template_default').product_variant_id.write({'active': False, 'is_bfm': True})
|
||||||
|
env.ref('jikimo_sale_multiple_supply_methods.product_template_embryo_customer_provided').product_variant_id.write({'active': False})
|
||||||
|
env.ref('jikimo_sale_multiple_supply_methods.product_template_outsourcing').product_variant_id.write({'active': False, 'is_bfm': True})
|
||||||
|
|
||||||
|
# 为三步制造增加规则
|
||||||
|
warehouse = env['stock.warehouse'].search([('company_id', '=', env.company.id)], limit=1)
|
||||||
|
product_route_id = warehouse.pbm_route_id
|
||||||
|
# 创建规则:原料存货区 -> 制造前, 坯料存货区 -> 制造前, 制造后 -> 坯料存货区, 制造后 -> 成品存货区
|
||||||
|
raw_material_location_id = env['stock.location'].search([('name', '=', '坯料存货区')], limit=1)
|
||||||
|
picking_type_production = warehouse.pbm_type_id
|
||||||
|
picking_type_stock = warehouse.sam_type_id
|
||||||
|
material_location_id = env['stock.location'].search([('name', '=', '原料存货区')], limit=1)
|
||||||
|
# 为mto增加规则
|
||||||
|
mto_route_id = env.ref('stock.route_warehouse0_mto')
|
||||||
|
# 创建规则:原料存货区 -> 外包位置, 坯料存货区 -> 外包位置
|
||||||
|
subcontracting_location_id = env.company.subcontracting_location_id
|
||||||
|
picking_type_subcontracting = warehouse.subcontracting_resupply_type_id
|
||||||
|
# 为补给外包商增加规则
|
||||||
|
resupply_route_id = warehouse.subcontracting_route_id
|
||||||
|
|
||||||
|
rules_data = [
|
||||||
|
{
|
||||||
|
'name': 'WH: 原料存货区 → 制造前',
|
||||||
|
'location_src_id': material_location_id.id,
|
||||||
|
'location_dest_id': warehouse.pbm_loc_id.id,
|
||||||
|
'route_id': product_route_id.id,
|
||||||
|
'picking_type_id': picking_type_production.id,
|
||||||
|
'action': 'pull',
|
||||||
|
'sequence': 20,
|
||||||
|
'warehouse_id': warehouse.id,
|
||||||
|
'procure_method': 'mts_else_mto',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 坯料存货区 → 制造前',
|
||||||
|
'location_src_id': raw_material_location_id.id,
|
||||||
|
'location_dest_id': warehouse.pbm_loc_id.id,
|
||||||
|
'route_id': product_route_id.id,
|
||||||
|
'picking_type_id': picking_type_production.id,
|
||||||
|
'action': 'pull',
|
||||||
|
'sequence': 21,
|
||||||
|
'warehouse_id': warehouse.id,
|
||||||
|
'procure_method': 'mts_else_mto',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 制造后 → 坯料存货区',
|
||||||
|
'location_src_id': warehouse.sam_loc_id.id,
|
||||||
|
'location_dest_id': raw_material_location_id.id,
|
||||||
|
'route_id': product_route_id.id,
|
||||||
|
'picking_type_id': picking_type_stock.id,
|
||||||
|
'action': 'push',
|
||||||
|
'sequence': 23,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 制造后 → 成品存货区',
|
||||||
|
'location_src_id': warehouse.sam_loc_id.id,
|
||||||
|
'location_dest_id': env['stock.location'].search([('name', '=', '成品存货区')], limit=1).id,
|
||||||
|
'route_id': product_route_id.id,
|
||||||
|
'picking_type_id': picking_type_stock.id,
|
||||||
|
'action': 'push',
|
||||||
|
'sequence': 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 原料存货区 → 外包位置 (MTO)',
|
||||||
|
'location_src_id': material_location_id.id,
|
||||||
|
'location_dest_id': subcontracting_location_id.id,
|
||||||
|
'route_id': mto_route_id.id,
|
||||||
|
'picking_type_id': picking_type_subcontracting.id,
|
||||||
|
'action': 'pull',
|
||||||
|
'sequence': 24,
|
||||||
|
'warehouse_id': warehouse.id,
|
||||||
|
'procure_method': 'mts_else_mto',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 坯料存货区 → 外包位置 (MTO)',
|
||||||
|
'location_src_id': raw_material_location_id.id,
|
||||||
|
'location_dest_id': subcontracting_location_id.id,
|
||||||
|
'route_id': mto_route_id.id,
|
||||||
|
'picking_type_id': picking_type_subcontracting.id,
|
||||||
|
'action': 'pull',
|
||||||
|
'sequence': 25,
|
||||||
|
'warehouse_id': warehouse.id,
|
||||||
|
'procure_method': 'mts_else_mto',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'WH: 坯料存货区 → 外包位置',
|
||||||
|
'location_src_id': raw_material_location_id.id,
|
||||||
|
'location_dest_id': subcontracting_location_id.id,
|
||||||
|
'route_id': resupply_route_id.id,
|
||||||
|
'picking_type_id': picking_type_subcontracting.id,
|
||||||
|
'action': 'pull',
|
||||||
|
'sequence': 26,
|
||||||
|
'warehouse_id': warehouse.id,
|
||||||
|
'procure_method': 'make_to_stock',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
# 遍历每个规则数据,执行创建或更新操作
|
||||||
|
for rule_data in rules_data:
|
||||||
|
_create_or_update_stock_rule(env, rule_data)
|
||||||
|
|
||||||
|
def _create_or_update_stock_rule(env, rule_data):
|
||||||
|
# 尝试查找现有的 stock.rule
|
||||||
|
existing_rule = env['stock.rule'].search([
|
||||||
|
('name', '=', rule_data['name']),
|
||||||
|
('route_id', '=', rule_data.get('route_id'))
|
||||||
|
], limit=1)
|
||||||
|
|
||||||
|
if existing_rule:
|
||||||
|
# 如果存在,更新现有记录
|
||||||
|
existing_rule.write(rule_data)
|
||||||
|
else:
|
||||||
|
# 如果不存在,创建新记录
|
||||||
|
env['stock.rule'].create(rule_data)
|
||||||
|
|
||||||
|
def _data_uninstall(cr, registry):
|
||||||
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
|
warehouse = env['stock.warehouse'].search([('company_id', '=', env.company.id)], limit=1)
|
||||||
|
product_route_id = warehouse.pbm_route_id
|
||||||
|
resupply_route_id = warehouse.subcontracting_route_id
|
||||||
|
mto_route_id = env.ref('stock.route_warehouse0_mto')
|
||||||
|
# Fail unlink means that the route is used somewhere (e.g. route_id on stock.rule). In this case
|
||||||
|
# we don't try to do anything.
|
||||||
|
try:
|
||||||
|
with env.cr.savepoint():
|
||||||
|
env['stock.rule'].search([('name', 'in', ('WH: 原料存货区 → 制造前', 'WH: 坯料存货区 → 制造前', 'WH: 制造后 → 坯料存货区', 'WH: 制造后 → 成品存货区')), ('route_id', '=', product_route_id.id)]).unlink()
|
||||||
|
env['stock.rule'].search([('name', 'in', ('WH: 原料存货区 → 外包位置 (MTO)', 'WH: 坯料存货区 → 外包位置 (MTO)')), ('route_id', '=', mto_route_id.id)]).unlink()
|
||||||
|
env['stock.rule'].search([('name', '=', 'WH: 坯料存货区 → 外包位置'), ('route_id', '=', resupply_route_id.id)]).unlink()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
26
jikimo_sale_multiple_supply_methods/__manifest__.py
Normal file
26
jikimo_sale_multiple_supply_methods/__manifest__.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
{
|
||||||
|
'name': '机企猫 多供货方式',
|
||||||
|
'version': '16.0.1.0.0',
|
||||||
|
'summary': """ 报价单提供(自动化产线加工/人工线下加工/外购/委外加工)多种供货方式选择 """,
|
||||||
|
'author': 'fox',
|
||||||
|
'website': '',
|
||||||
|
'category': '',
|
||||||
|
'depends': ['sf_dlm', 'sale_stock', 'sf_sale', 'sale'],
|
||||||
|
"data": [
|
||||||
|
'security/ir.model.access.csv',
|
||||||
|
'data/stock_routes.xml',
|
||||||
|
'data/product_data.xml',
|
||||||
|
# 'views/product_product_views.xml',
|
||||||
|
],'assets': {
|
||||||
|
# 'web.assets_backend': [
|
||||||
|
# 'jikimo_sale_multiple_supply_methods/static/src/**/*'
|
||||||
|
# ],
|
||||||
|
},
|
||||||
|
'post_init_hook': '_data_install',
|
||||||
|
'uninstall_hook': '_data_uninstall',
|
||||||
|
'application': True,
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': False,
|
||||||
|
'license': 'LGPL-3',
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
98
jikimo_sale_multiple_supply_methods/data/product_data.xml
Normal file
98
jikimo_sale_multiple_supply_methods/data/product_data.xml
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data noupdate="1">
|
||||||
|
<record id="product_template_manual_processing" model="product.template">
|
||||||
|
<field name="name">人工线下加工模板</field>
|
||||||
|
<field name="active" eval="False"/>
|
||||||
|
<field name="categ_id" ref="sf_dlm.product_category_finished_sf"/>
|
||||||
|
<field name="route_ids"
|
||||||
|
eval="[ref('stock.route_warehouse0_mto'), ref('mrp.route_warehouse0_manufacture')]"/>
|
||||||
|
<field name="invoice_policy">delivery</field>
|
||||||
|
<field name="detailed_type">product</field>
|
||||||
|
<field name="purchase_ok">false</field>
|
||||||
|
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||||
|
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||||
|
<field name="company_id" ref="base.main_company"/>
|
||||||
|
<field name="single_manufacturing">true</field>
|
||||||
|
<field name="tracking">serial</field>
|
||||||
|
<!-- <field name="categ_type">成品</field> -->
|
||||||
|
<field name="is_manual_processing">true</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="product_template_purchase" model="product.template">
|
||||||
|
<field name="name">成品外购模板</field>
|
||||||
|
<field name="active" eval="False"/>
|
||||||
|
<field name="categ_id" ref="sf_dlm.product_category_finished_sf"/>
|
||||||
|
<field name="route_ids"
|
||||||
|
eval="[ref('stock.route_warehouse0_mto'), ref('purchase_stock.route_warehouse0_buy')]"/>
|
||||||
|
<field name="tracking">serial</field>
|
||||||
|
<field name="detailed_type">product</field>
|
||||||
|
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||||
|
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||||
|
<field name="company_id" ref="base.main_company"/>
|
||||||
|
<!-- <field name="categ_type">成品</field> -->
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="product_template_outsourcing" model="product.template">
|
||||||
|
<field name="name">成品委外加工模板</field>
|
||||||
|
<field name="active" eval="False"/>
|
||||||
|
<field name="categ_id" ref="sf_dlm.product_category_finished_sf"/>
|
||||||
|
<field name="route_ids"
|
||||||
|
eval="[ref('stock.route_warehouse0_mto'), ref('purchase_stock.route_warehouse0_buy'), ref('mrp_subcontracting.route_resupply_subcontractor_mto')]"/>
|
||||||
|
<field name="tracking">serial</field>
|
||||||
|
<field name="detailed_type">product</field>
|
||||||
|
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||||
|
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||||
|
<field name="company_id" ref="base.main_company"/>
|
||||||
|
<!-- <field name="categ_type">成品</field> -->
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="product_template_default" model="product.template">
|
||||||
|
<field name="name">成品初始化模板</field>
|
||||||
|
<field name="active" eval="False"/>
|
||||||
|
<field name="categ_id" ref="sf_dlm.product_category_finished_sf"/>
|
||||||
|
<field name="route_ids" eval="[]"/>
|
||||||
|
<field name="tracking">serial</field>
|
||||||
|
<field name="detailed_type">product</field>
|
||||||
|
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||||
|
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||||
|
<field name="company_id" ref="base.main_company"/>
|
||||||
|
<!-- <field name="categ_type">成品</field> -->
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- 供应商信息(业务平台),由于数据是python创建,只能指定ID -->
|
||||||
|
<record id="product_supplierinfo_bfm" model="product.supplierinfo">
|
||||||
|
<field name="partner_id" eval="91"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="product_template_embryo_customer_provided" model="product.template">
|
||||||
|
<field name="name">坯料客供料模板</field>
|
||||||
|
<field name="active" eval="False"/>
|
||||||
|
<field name="categ_id" ref="sf_dlm.product_category_embryo_sf"/>
|
||||||
|
<field name="route_ids" eval="[
|
||||||
|
ref('stock.route_warehouse0_mto'),
|
||||||
|
ref('mrp_subcontracting.route_resupply_subcontractor_mto'),
|
||||||
|
ref('jikimo_sale_multiple_supply_methods.route_material_processing')]"/>
|
||||||
|
<field name="sale_ok">false</field>
|
||||||
|
<field name="tracking">serial</field>
|
||||||
|
<field name="detailed_type">product</field>
|
||||||
|
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||||
|
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||||
|
<field name="company_id" ref="base.main_company"/>
|
||||||
|
<!-- <field name="categ_type">坯料</field> -->
|
||||||
|
<field name="seller_ids" eval="[ref('jikimo_sale_multiple_supply_methods.product_supplierinfo_bfm')]"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="sf_dlm.product_embryo_sf_self_machining" model="product.product">
|
||||||
|
<field name="is_manual_processing">true</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="sf_dlm.product_embryo_sf_self_machining" model="product.product">
|
||||||
|
<field name="route_ids" eval="[(4, ref('mrp_subcontracting.route_resupply_subcontractor_mto'))]"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="sf_dlm.product_embryo_sf_purchase" model="product.product">
|
||||||
|
<field name="route_ids" eval="[(4, ref('mrp_subcontracting.route_resupply_subcontractor_mto'))]"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
32
jikimo_sale_multiple_supply_methods/data/stock_routes.xml
Normal file
32
jikimo_sale_multiple_supply_methods/data/stock_routes.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data noupdate="1">
|
||||||
|
<record id="route_material_processing" model="stock.route">
|
||||||
|
<field name="name">带料加工</field>
|
||||||
|
<field name="product_selectable">true</field>
|
||||||
|
<field name="warehouse_selectable">true</field>
|
||||||
|
<field name="warehouse_ids" eval="[ref('stock.warehouse0')]"/>
|
||||||
|
<field name="sequence">16</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="material_picking_in" model="stock.picking.type">
|
||||||
|
<field name="name">客供料入库</field>
|
||||||
|
<field name="code">incoming</field>
|
||||||
|
<field name="active">true</field>
|
||||||
|
<field name="company_id" ref="base.main_company"/>
|
||||||
|
<field name="sequence_code">DL</field>
|
||||||
|
<field name="warehouse_id" ref="stock.warehouse0"/>
|
||||||
|
<field name="default_location_src_id" ref="stock.stock_location_customers"/>
|
||||||
|
<field name="default_location_dest_id" eval="25"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="rule_material_receiving" model="stock.rule">
|
||||||
|
<field name="name">带料收货</field>
|
||||||
|
<field name="route_id" ref="route_material_processing"/>
|
||||||
|
<field name="location_dest_id" ref="stock.stock_location_company"/>
|
||||||
|
<field name="location_src_id" ref="stock.stock_location_customers"/>
|
||||||
|
<field name="picking_type_id" ref="material_picking_in"/>
|
||||||
|
<field name="action">pull</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
3
jikimo_sale_multiple_supply_methods/models/__init__.py
Normal file
3
jikimo_sale_multiple_supply_methods/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from . import product_template
|
||||||
|
from . import mrp_bom
|
||||||
13
jikimo_sale_multiple_supply_methods/models/mrp_bom.py
Normal file
13
jikimo_sale_multiple_supply_methods/models/mrp_bom.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from odoo import models, fields
|
||||||
|
|
||||||
|
class MrpBom(models.Model):
|
||||||
|
_inherit = 'mrp.bom'
|
||||||
|
|
||||||
|
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
|
||||||
|
def bom_create(self, product, bom_type, product_type):
|
||||||
|
bom_id = super(MrpBom, self).bom_create(product, bom_type, product_type)
|
||||||
|
|
||||||
|
# 成品的供应商从模板中获取
|
||||||
|
if product_type == 'product':
|
||||||
|
bom_id.subcontractor_id = product.product_tmpl_id.seller_ids.partner_id.id
|
||||||
|
return bom_id
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
class ProductTemplate(models.Model):
|
||||||
|
_inherit = 'product.template'
|
||||||
|
|
||||||
|
is_manual_processing = fields.Boolean(string='人工线下加工')
|
||||||
|
is_customer_provided = fields.Boolean(string='客供料')
|
||||||
|
|
||||||
|
def copy_template(self, product_template_id):
|
||||||
|
if not isinstance(product_template_id, ProductTemplate):
|
||||||
|
raise ValueError('%s必须是ProductTemplate类型' % product_template_id)
|
||||||
|
|
||||||
|
self.route_ids = product_template_id.route_ids
|
||||||
|
self.categ_id = product_template_id.categ_id
|
||||||
|
self.invoice_policy = product_template_id.invoice_policy
|
||||||
|
self.detailed_type = product_template_id.detailed_type
|
||||||
|
self.purchase_ok = product_template_id.purchase_ok
|
||||||
|
self.uom_id = product_template_id.uom_id
|
||||||
|
self.uom_po_id = product_template_id.uom_po_id
|
||||||
|
self.company_id = product_template_id.company_id
|
||||||
|
self.single_manufacturing = product_template_id.single_manufacturing
|
||||||
|
self.tracking = product_template_id.tracking
|
||||||
|
self.is_bfm = product_template_id.is_bfm
|
||||||
|
self.is_manual_processing = product_template_id.is_manual_processing
|
||||||
|
# 复制 seller_ids
|
||||||
|
self.seller_ids = [(0, 0, {'partner_id': seller.partner_id.id, 'delay': 1.0}) for seller in product_template_id.seller_ids]
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
access_sale_order_group_production_engineer,sale.order_group_production_engineer,sale.model_sale_order,sf_base.group_production_engineer,1,1,0,0
|
||||||
|
access_sale_order_line_group_production_engineer,sale_order_line_group_production_engineer,sale.model_sale_order_line,sf_base.group_production_engineer,1,1,0,0
|
||||||
|
access_product_product_group_production_engineer,product_product_group_production_engineer,product.model_product_product,sf_base.group_production_engineer,1,0,0,0
|
||||||
|
access_product_template_group_production_engineer,product_template_group_production_engineer,product.model_product_template,sf_base.group_production_engineer,1,0,0,0
|
||||||
|
access_stock_picking_group_production_engineer,stock_picking_group_production_engineer,stock.model_stock_picking,sf_base.group_production_engineer,1,0,0,0
|
||||||
|
access_stock_move_group_production_engineer,stock_move_group_production_engineer,stock.model_stock_move,sf_base.group_production_engineer,1,0,0,0
|
||||||
|
access_mrp_bom_group_production_engineer,mrp_bom_group_production_engineer,mrp.model_mrp_bom,sf_base.group_production_engineer,1,0,0,0
|
||||||
|
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<!-- 由于该模块不能依赖sf_dlm_management, 该功能只能在sf_dlm_management中实现,并且依赖该模块-->
|
||||||
|
<record id="view_product_product_form_inherit_sf" model="ir.ui.view">
|
||||||
|
<field name="name">view.product.template.form.inherit.sf</field>
|
||||||
|
<field name="model">product.template</field>
|
||||||
|
<field name="inherit_id" ref="sf_dlm_management.view_sale_product_template_form_inherit_sf"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='manual_quotation']" position="after">
|
||||||
|
<field name="is_customer_provided" attrs="{'invisible': [('categ_type', 'not in', ['成品', '坯料'])], 'readonly': True}" />
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
|
|
||||||
|
|
||||||
@@ -21,4 +21,12 @@ class ProductCategory(models.Model):
|
|||||||
args += [('name', 'not in', ['Saleable', 'Expenses', 'Deliveries'])]
|
args += [('name', 'not in', ['Saleable', 'Expenses', 'Deliveries'])]
|
||||||
|
|
||||||
# 调用父类的 name_search 方法
|
# 调用父类的 name_search 方法
|
||||||
return super(ProductCategory, self).name_search(name, args=args, operator=operator, limit=limit)
|
return super(ProductCategory, self).name_search(name, args=args, operator=operator, limit=limit)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def search(self, args, limit=100, offset=0, order=None, count=False):
|
||||||
|
# 添加过滤条件,确保只返回名称不在指定列表中的记录
|
||||||
|
args += [('name', 'not in', ['Saleable', 'Expenses', 'Deliveries'])]
|
||||||
|
|
||||||
|
# 调用父类的 search 方法
|
||||||
|
return super(ProductCategory, self).search(args, limit=limit, offset=offset, order=order, count=count)
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
<record id="quality_alert_action_check" model="ir.actions.act_window">
|
<record id="quality_alert_action_check" model="ir.actions.act_window">
|
||||||
<field name="name">Quality Alerts</field>
|
<field name="name">Quality Alerts</field>
|
||||||
<field name="res_model">quality.alert</field>
|
<field name="res_model">quality.alert</field>
|
||||||
<field name="view_mode">kanban,tree,form,pivot,graph,calendar</field>
|
<field name="view_mode">tree,kanban,form,pivot,graph,calendar</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_smiling_face">
|
<p class="o_view_nocontent_smiling_face">
|
||||||
Create a new quality alert
|
Create a new quality alert
|
||||||
|
|||||||
@@ -402,3 +402,22 @@ class MachiningAccuracy(models.Model):
|
|||||||
name = fields.Char('一般公差', index=True)
|
name = fields.Char('一般公差', index=True)
|
||||||
standard_tolerance = fields.Char(string="标准公差")
|
standard_tolerance = fields.Char(string="标准公差")
|
||||||
sync_id = fields.Char('同步ID')
|
sync_id = fields.Char('同步ID')
|
||||||
|
|
||||||
|
|
||||||
|
class ReSaleOrder(models.Model):
|
||||||
|
_inherit = 'sale.order'
|
||||||
|
|
||||||
|
person_of_delivery = fields.Char('收货人')
|
||||||
|
telephone_of_delivery = fields.Char('电话号码')
|
||||||
|
address_of_delivery = fields.Char('联系地址')
|
||||||
|
|
||||||
|
|
||||||
|
class EmbryoRedundancy(models.Model):
|
||||||
|
_name = "sf.embryo.redundancy"
|
||||||
|
|
||||||
|
code = fields.Char('编码', required=True)
|
||||||
|
name = fields.Char('名称', required=True)
|
||||||
|
long = fields.Float('长度(mm)', required=True)
|
||||||
|
width = fields.Float('宽度(mm)', required=True)
|
||||||
|
height = fields.Float('高度(mm)', required=True)
|
||||||
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class MrsMaterialModel(models.Model):
|
|||||||
finish_machining = fields.Float("精加工Vc(m/min)")
|
finish_machining = fields.Float("精加工Vc(m/min)")
|
||||||
remark = fields.Text("备注")
|
remark = fields.Text("备注")
|
||||||
gain_way = fields.Selection(
|
gain_way = fields.Selection(
|
||||||
[("自加工", "自加工"), ("外协", "外协"), ("采购", "采购")],
|
[("自加工", "自加工"), ("外协", "委外加工"), ("采购", "采购")],
|
||||||
default="", string="获取方式")
|
default="", string="获取方式")
|
||||||
supplier_ids = fields.One2many('sf.supplier.sort', 'materials_model_id', string='供应商')
|
supplier_ids = fields.One2many('sf.supplier.sort', 'materials_model_id', string='供应商')
|
||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
@@ -100,6 +100,7 @@ class MrsProductionProcess(models.Model):
|
|||||||
travel_day = fields.Float('路途天数/d')
|
travel_day = fields.Float('路途天数/d')
|
||||||
sequence = fields.Integer('排序')
|
sequence = fields.Integer('排序')
|
||||||
|
|
||||||
|
|
||||||
# class MrsProcessingTechnology(models.Model):
|
# class MrsProcessingTechnology(models.Model):
|
||||||
# _name = 'sf.processing.technology'
|
# _name = 'sf.processing.technology'
|
||||||
# _description = '加工工艺'
|
# _description = '加工工艺'
|
||||||
@@ -157,7 +158,9 @@ class MrsProductionProcessParameter(models.Model):
|
|||||||
for parameter in self:
|
for parameter in self:
|
||||||
if parameter.process_id:
|
if parameter.process_id:
|
||||||
name = parameter.process_id.name + '-' + parameter.name
|
name = parameter.process_id.name + '-' + parameter.name
|
||||||
result.append((parameter.id, name))
|
else:
|
||||||
|
name = parameter.name
|
||||||
|
result.append((parameter.id, name))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# 获取表面工艺的获取方式
|
# 获取表面工艺的获取方式
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
<record id="group_quality" model="res.groups">
|
<record id="group_quality" model="res.groups">
|
||||||
<field name="name">质检岗</field>
|
<field name="name">质检岗</field>
|
||||||
<field name="category_id" ref="base.module_category_manufacturing_quality"/>
|
<field name="category_id" ref="base.module_category_manufacturing_quality"/>
|
||||||
</record>
|
</record>
|
||||||
@@ -46,6 +46,11 @@
|
|||||||
<field name="category_id" ref="base.module_category_manufacturing_manufacturing"/>
|
<field name="category_id" ref="base.module_category_manufacturing_manufacturing"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="group_production_engineer" model="res.groups">
|
||||||
|
<field name="name">工艺工程师</field>
|
||||||
|
<field name="implied_ids" eval="[(4, ref('group_sf_mrp_user'))]"/>
|
||||||
|
<field name="category_id" ref="base.module_category_manufacturing_manufacturing"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record model="ir.module.category" id="module_category_plan">
|
<record model="ir.module.category" id="module_category_plan">
|
||||||
<field name="name">计划</field>
|
<field name="name">计划</field>
|
||||||
@@ -65,7 +70,7 @@
|
|||||||
<record id="group_plan_dispatch" model="res.groups">
|
<record id="group_plan_dispatch" model="res.groups">
|
||||||
<field name="name">计划调度岗</field>
|
<field name="name">计划调度岗</field>
|
||||||
<field name="category_id" ref="module_category_plan"/>
|
<field name="category_id" ref="module_category_plan"/>
|
||||||
<!-- <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/> -->
|
<!-- <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/> -->
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="group_plan_director" model="res.groups">
|
<record id="group_plan_director" model="res.groups">
|
||||||
|
|||||||
@@ -251,3 +251,6 @@ access_sf_cutting_tool_type_group_plan_dispatch,sf_cutting_tool_type_group_plan_
|
|||||||
|
|
||||||
access_sf_machining_accuracy,sf_machining_accuracy,model_sf_machining_accuracy,base.group_user,1,0,0,0
|
access_sf_machining_accuracy,sf_machining_accuracy,model_sf_machining_accuracy,base.group_user,1,0,0,0
|
||||||
access_sf_machining_accuracy_admin,sf_machining_accuracy_admin,model_sf_machining_accuracy,base.group_system,1,0,0,0
|
access_sf_machining_accuracy_admin,sf_machining_accuracy_admin,model_sf_machining_accuracy,base.group_system,1,0,0,0
|
||||||
|
|
||||||
|
access_sf_embryo_redundancy,sf_embryo_redundancy,model_sf_embryo_redundancy,base.group_user,1,0,0,0
|
||||||
|
access_sf_embryo_redundancy_admin,sf_embryo_redundancy_admin,model_sf_embryo_redundancy,base.group_system,1,0,0,0
|
||||||
|
|||||||
|
125
sf_base/static/js/customTable.js
Normal file
125
sf_base/static/js/customTable.js
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
// 获取表格数据
|
||||||
|
function getDomData() {
|
||||||
|
const dom = $('div[name=cutting_speed_ids]')
|
||||||
|
if (!dom.length) return
|
||||||
|
const table = dom.find('.o_list_table')
|
||||||
|
const thead = table.children('thead')
|
||||||
|
const tbody = table.children('tbody')
|
||||||
|
const tbody_child = tbody.children()
|
||||||
|
const hideTheadDom = thead.find('[data-name=process_capability]')
|
||||||
|
hideTheadDom.hide().next().hide()
|
||||||
|
hideTheadDom.before('<th customTh>精加工</th><th customTh>粗加工</th>')
|
||||||
|
tbody_child.each(function () {
|
||||||
|
const dom = $(this).children('[name=process_capability]')
|
||||||
|
if(!dom.length) return
|
||||||
|
dom.css('cssText', 'display: none!important').next().css('cssText', 'display: none!important')
|
||||||
|
const isCu = dom.text() == '粗加工' // 是否粗加工
|
||||||
|
const v = dom.next().text() // 切削速度
|
||||||
|
dom.after(`<td customSpeed="1" name="process_capability" is="精加工" val="${ v }">${!isCu ? v : ''}</td><td customSpeed="1" name="process_capability" is="粗加工" val="${ v }">${isCu ? v : ''}</td>`)
|
||||||
|
setListenClick()
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
handleTbody(tbody, newTableData, ΦList, table)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听点击
|
||||||
|
function setListenClick() {
|
||||||
|
$(document).click(function (e) {
|
||||||
|
if ($(e.target).attr('customSpeed')) {
|
||||||
|
const orginV = $('[customInput=1]').children('input').val()
|
||||||
|
$('[customInput=1]').parent().html(orginV)
|
||||||
|
const v = $(e.target).attr('val')
|
||||||
|
const is = $(e.target).attr('is')
|
||||||
|
$(e.target).html('')
|
||||||
|
const input = $('<div customInput="1" is="' + is + '" class="o_field_widget o_field_char"><input class="o_input" type="text" autocomplete="off" maxlength="20"></div>')
|
||||||
|
input.children('input').val(v)
|
||||||
|
$(e.target).append(input)
|
||||||
|
input.children('input').focus()
|
||||||
|
input.children('input').select()
|
||||||
|
} else if ($(e.target).attr('customInput')) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const orginV = $('[customInput=1]').children('input').val()
|
||||||
|
$('[customInput=1]').parent().html(orginV)
|
||||||
|
const v = $(e.target).attr('val')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$(document).off('change') // 防止重复绑定
|
||||||
|
$(document).on('change', '[customInput] input', async function () {
|
||||||
|
$(this).parents('td').attr('val', $(this).val())
|
||||||
|
$(this).parents('td').siblings('[customspeed]').attr('val', $(this).val())
|
||||||
|
var eve1 = new Event('change')
|
||||||
|
var eve2 = new Event('input')
|
||||||
|
var eve3 = new Event('click')
|
||||||
|
let patchSpeedDom = $(this).parents('td').siblings('[name=cutting_speed]')
|
||||||
|
let patchProcessDom = $(this).parents('td').siblings('[name=process_capability]')
|
||||||
|
$(this).parents('td').siblings('[customspeed]').text('') // 清空其他加工类型的数据
|
||||||
|
await timeOut(500)
|
||||||
|
patchProcessDom[0].dispatchEvent(eve3)
|
||||||
|
await timeOut(200)
|
||||||
|
const processVal = $(this).parent().attr('is')
|
||||||
|
patchProcessDom.find('select').val(`"${processVal}"`) // 设置源select的val为“加工类型 is”、
|
||||||
|
patchProcessDom.attr("data-tooltip", `${processVal}`)
|
||||||
|
patchProcessDom.find('select')[0].dispatchEvent(eve1)
|
||||||
|
|
||||||
|
patchSpeedDom[0].dispatchEvent(eve3)
|
||||||
|
await timeOut(200)
|
||||||
|
patchSpeedDom.find('input').val($(this).val())
|
||||||
|
await timeOut(50)
|
||||||
|
patchSpeedDom.find('input')[0].dispatchEvent(eve2)
|
||||||
|
patchSpeedDom.find('input')[0].dispatchEvent(eve1)
|
||||||
|
})
|
||||||
|
$(document).off('blur') // 防止重复绑定
|
||||||
|
$(document).on('blur', '[customInput] input', async function () {
|
||||||
|
if(!$(this).length) return
|
||||||
|
|
||||||
|
$(this).parents('td').siblings('[customspeed]').text('') // 清空其他加工类型的数据
|
||||||
|
let patchProcessDom = $(this).parents('td').siblings('[name=process_capability]')
|
||||||
|
try {
|
||||||
|
patchProcessDom[0].dispatchEvent(new Event('click'))
|
||||||
|
const processVal = $(this).parent().attr('is')
|
||||||
|
patchProcessDom.find('select').val(`"${processVal}"`) // 设置源select的val为“加工类型 is”、
|
||||||
|
patchProcessDom.attr("data-tooltip", `${processVal}`)
|
||||||
|
patchProcessDom.find('select')[0].dispatchEvent(new Event('change'))
|
||||||
|
} catch {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function timeOut(time) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve()
|
||||||
|
}, time)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function listenAdd() {
|
||||||
|
$('td.o_field_x2many_list_row_add a').click(async function () {
|
||||||
|
await timeOut(500)
|
||||||
|
const tr = $('.o_list_table').children('tbody').children('tr').eq(-2)
|
||||||
|
if(tr.children('td').eq(2).text() == '') {
|
||||||
|
const dom = tr.children('[name=process_capability]')
|
||||||
|
if(!dom.length) return
|
||||||
|
dom.css('cssText', 'display: none!important').next().css('cssText', 'display: none!important')
|
||||||
|
const isCu = dom.text() == '粗加工' // 是否粗加工
|
||||||
|
const v = dom.next().text() // 切削速度
|
||||||
|
dom.after(`<td customSpeed="1" name="process_capability" is="精加工" val="${ v }">${!isCu ? v : ''}</td><td customSpeed="1" name="process_capability" is="粗加工" val="${ v }">${isCu ? v : ''}</td>`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function listenSave() {
|
||||||
|
$('.o_form_button_save').click( async function () {
|
||||||
|
await timeOut(1000)
|
||||||
|
if($(this).parent().next().length) return
|
||||||
|
$('th[customTh],td[cusomSpeed]').remove()
|
||||||
|
getDomData()
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
listenAdd()
|
||||||
|
listenSave()
|
||||||
|
getDomData()
|
||||||
47
sf_base/static/js/setTableWidth.js
Normal file
47
sf_base/static/js/setTableWidth.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
// 因为表格可以拖动设置宽度,所以需要用js设置初始宽度
|
||||||
|
function setBasicParamTableWidth() {
|
||||||
|
// const _100px = 'th[data-name="cutting_blade_length"],th[data-name="cutting_blade_length"],th[data-name="name"],th[data-name="tip_handling_size"],th[data-name="cutting_depth_max"],th[data-name="diameter_inner_circle"],th[data-name="diameter_mounting_hole" ],th[data-name="radius_tip_re" ],th[data-name="is_chip_breaker"],th[data-name="chip_breaker_type_code"],th[data-name="blade_profile"]'
|
||||||
|
// const _65px = 'th[data-name="edge_angle"],th[data-name="relief_angle"],[data-name="total_length"],th[data-name="length"],th[data-name="thickness"],th[data-name="blade_number"]'
|
||||||
|
// const _80px = 'th[data-name="arbor_diameter"],th[data-name="head_height"],th[data-name="head_width"],th[data-name="head_length"],th[data-name="blade_diameter"],th[data-name="blade_length"] ,th[data-name="neck_length"] ,th[data-name="neck_diameter"] ,th[data-name="shank_diameter"],th[data-name="shank_length"],th[data-name="tip_diameter"],th[data-name="knife_tip_taper"],th[data-name="blade_helix_angle"] ,th[data-name="blade_width"],th[data-name="blade_depth"]'
|
||||||
|
// const _50px = 'th[data-name="pitch"],th[data-name="width"],th[data-name="height"]'
|
||||||
|
|
||||||
|
const basicParamDom = $('.fixTableCss')
|
||||||
|
// const basicParamDom_100px = basicParamDom.find(_100px) // 四字以上
|
||||||
|
// const basicParamDom_65px = basicParamDom.find(_65px) // 大概三个字加单位
|
||||||
|
// const basicParamDom_80px = basicParamDom.find(_80px) // 大概四个字加单位
|
||||||
|
// const basicParamDom_50px= basicParamDom.find(_50px) // 大概两个字加单位
|
||||||
|
//
|
||||||
|
// basicParamDom_100px.css({'width': '100px', 'max-width': 'auto', ',min-width': 'auto'})
|
||||||
|
// basicParamDom_65px.css({'width': '65px', 'max-width': 'auto', ',min-width': 'auto'})
|
||||||
|
// basicParamDom_80px.css({'width': '80px', 'max-width': 'auto', ',min-width': 'auto'})
|
||||||
|
// basicParamDom_50px.css({'width': '50px', 'max-width': 'auto', ',min-width': 'auto'})
|
||||||
|
let dom = []
|
||||||
|
try {
|
||||||
|
dom = basicParamDom.find('table').find('thead').children().children()
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
dom = []
|
||||||
|
}
|
||||||
|
if (!dom) return
|
||||||
|
dom.each(function () {
|
||||||
|
if ($(this).hasClass('row_no') >= 0) { // 序号列
|
||||||
|
// 不设置 通过css设置
|
||||||
|
}
|
||||||
|
const text = $(this).text().split('(')
|
||||||
|
if ($(this).attr('data-name') == 'name' || text[0].length > 4) {
|
||||||
|
$(this).width('100px')
|
||||||
|
} else if(text[0].length == 4){
|
||||||
|
$(this).width('80px')
|
||||||
|
} else if(text[0].length == 3){
|
||||||
|
$(this).width('65px')
|
||||||
|
} else if(text[0].length == 2){
|
||||||
|
$(this).width('50px')
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
setBasicParamTableWidth()
|
||||||
|
$('.o_field_many2one_selection').on('click', $('#cutting_tool_material_id + ul'), function () {
|
||||||
|
setTimeout(setBasicParamTableWidth, 500)
|
||||||
|
})
|
||||||
159
sf_base/static/js/updateTable.js
Normal file
159
sf_base/static/js/updateTable.js
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
// 获取表格数据
|
||||||
|
function getDomData() {
|
||||||
|
const dom = $('#updateTable').prev()
|
||||||
|
if (!dom.length) return
|
||||||
|
const table = $('#updateTable').prev().find('.o_list_table')
|
||||||
|
const customTable = table.clone()
|
||||||
|
customTable.addClass('customTable')
|
||||||
|
table.parent().append(customTable)
|
||||||
|
table.hide()
|
||||||
|
const thead = customTable.children('thead')
|
||||||
|
const tbody = customTable.children('tbody')
|
||||||
|
const tableData = []
|
||||||
|
const tbody_child = tbody.children()
|
||||||
|
|
||||||
|
const tbody_child_len = tbody_child.length
|
||||||
|
|
||||||
|
for (let v = 0; v < tbody_child_len; v++) { // 将数据取出来到tableData里面
|
||||||
|
const data = tbody_child[v].innerText.split('\t')
|
||||||
|
// console.log('dom data',data)
|
||||||
|
const [index, deep, name, Φ, value] = data
|
||||||
|
tableData.push({index, deep, name, Φ, value})
|
||||||
|
}
|
||||||
|
const ΦList = [...new Set(tableData.map(_ => _.name))] // ΦList去重
|
||||||
|
const newTableData = {}
|
||||||
|
tableData.forEach(_ => {
|
||||||
|
const key = _.deep + '|' + _.Φ
|
||||||
|
!newTableData[key] ? newTableData[key] = {i: _.index} : '';
|
||||||
|
if (_.Φ) { // 去除没有Φ的脏数据
|
||||||
|
newTableData[key]['Φ' + _.Φ] = _.value
|
||||||
|
newTableData[key]['Φ' + _.Φ + 'i'] = _.index
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// console.log('qwdh',tableData, ΦList, newTableData);
|
||||||
|
|
||||||
|
if (ΦList.filter(_ => _).length == 0) return;
|
||||||
|
handleThead(thead, ΦList)
|
||||||
|
|
||||||
|
handleTbody(tbody, newTableData, ΦList, table)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重新设置表头、
|
||||||
|
function handleThead(thead, ΦList) {
|
||||||
|
const dom = thead.children().eq(0).children()
|
||||||
|
const len = dom.length
|
||||||
|
dom.eq(0).attr('rowspan', 2)
|
||||||
|
dom.eq(1).attr('rowspan', 2)
|
||||||
|
len == 5 ? dom.eq(2).attr('rowspan', 2) : ''
|
||||||
|
dom.eq(-2).attr('colspan', ΦList.length)
|
||||||
|
dom.eq(-1).remove()
|
||||||
|
|
||||||
|
const tr = document.createElement('tr')
|
||||||
|
for (let v = 0; v < ΦList.length; v++) {
|
||||||
|
const th = document.createElement('th')
|
||||||
|
th.innerText = 'Φ' + ΦList[v]
|
||||||
|
tr.append(th)
|
||||||
|
}
|
||||||
|
thead.append(tr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重新设置表格
|
||||||
|
function handleTbody(tbody, newTableData, ΦList, table) {
|
||||||
|
console.log(newTableData)
|
||||||
|
tbody.html('')
|
||||||
|
let i = 0
|
||||||
|
const data = Object.keys(newTableData)
|
||||||
|
// data.sort((a, b) => {
|
||||||
|
// a = a.split('=')[1].split('%')[0]
|
||||||
|
// b = b.split('=')[1].split('%')[0]
|
||||||
|
// return a - b
|
||||||
|
// })
|
||||||
|
// console.log('wqoqw ',ΦList)
|
||||||
|
data.forEach(_ => {
|
||||||
|
i++
|
||||||
|
const tr = $('<tr class="o_data_row"></tr>')
|
||||||
|
const td0 = $('<td></td>')
|
||||||
|
td0.text(i)
|
||||||
|
tr.append(td0)
|
||||||
|
const lit = _.split('|')
|
||||||
|
//
|
||||||
|
const td1 = $('<td></td>')
|
||||||
|
const td2 = $('<td></td>')
|
||||||
|
td1.text(lit[0])
|
||||||
|
td2.text(lit[1] || '')
|
||||||
|
tr.append(td1)
|
||||||
|
tr.append(td2)
|
||||||
|
ΦList.forEach(Φ => {
|
||||||
|
const td = $('<td class="o_data_cell cursor-pointer o_field_cell o_list_char"></td>')
|
||||||
|
td.text(newTableData[_]['Φ' + Φ])
|
||||||
|
td.attr('col', newTableData[_]['Φ' + Φ + 'i'])
|
||||||
|
td.attr('val', newTableData[_]['Φ' + Φ])
|
||||||
|
td.attr('coustomTd', 1)
|
||||||
|
tr.append(td)
|
||||||
|
})
|
||||||
|
// // for (let j = 0; j < ΦList.length; j++) {
|
||||||
|
// // const td = document.createElement('td')
|
||||||
|
// // td.innerText = newTableData[data[v]][_]
|
||||||
|
// // th.append(td)
|
||||||
|
// // }
|
||||||
|
tbody.append(tr)
|
||||||
|
})
|
||||||
|
// $(document).click(function (e) {
|
||||||
|
// if ($(e.target).attr('coustomTd')) {
|
||||||
|
// const orginV = $('[coustomInput=1]').children('input').val()
|
||||||
|
// $('[coustomInput=1]').parent().html(orginV)
|
||||||
|
// const v = $(e.target).attr('val')
|
||||||
|
// console.log($(e.target));
|
||||||
|
// $(e.target).html('')
|
||||||
|
// const input = $('<div coustomInput="1" name="feed_per_tooth" class="o_field_widget o_field_char"><input class="o_input" type="text" autocomplete="off" maxlength="20"></div>')
|
||||||
|
// input.children('input').val(v)
|
||||||
|
// $(e.target).append(input)
|
||||||
|
// input.children('input').focus()
|
||||||
|
// input.children('input').select()
|
||||||
|
// } else if ($(e.target).attr('coustomInput')) {
|
||||||
|
//
|
||||||
|
// } else {
|
||||||
|
// const orginV = $('[coustomInput=1]').children('input').val()
|
||||||
|
// $('[coustomInput=1]').parent().html(orginV)
|
||||||
|
// const v = $(e.target).attr('val')
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// $(document).off('change') // 防止重复绑定
|
||||||
|
// $(document).on('change', '[coustomInput] input', function () {
|
||||||
|
// $(this).parents('td').attr('val', $(this).val());
|
||||||
|
// var eve1 = new Event('change');
|
||||||
|
// var eve2 = new Event('input');
|
||||||
|
// var eve3 = new Event('click');
|
||||||
|
// const i = $(this).parents('td').attr('col');
|
||||||
|
// let patchDom = table.find('tbody').children('tr').eq(i - 1);
|
||||||
|
//
|
||||||
|
// if (patchDom.length === 0) {
|
||||||
|
// console.error('No such row found');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// patchDom = patchDom.children().eq(-1);
|
||||||
|
//
|
||||||
|
// setTimeout(() => {
|
||||||
|
// if (patchDom.length === 0) {
|
||||||
|
// console.error('No such cell found');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// patchDom[0].dispatchEvent(eve3); // Simulate click event
|
||||||
|
//
|
||||||
|
// setTimeout(() => {
|
||||||
|
// patchDom = patchDom.find('input');
|
||||||
|
// if (patchDom.length === 0) {
|
||||||
|
// console.error('No input found in the target cell');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// patchDom.val($(this).val());
|
||||||
|
// patchDom[0].dispatchEvent(eve2);
|
||||||
|
// patchDom[0].dispatchEvent(eve1);
|
||||||
|
// }, 200);
|
||||||
|
// }, 500);
|
||||||
|
// });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getDomData()
|
||||||
52
sf_base/static/src/scss/change.scss
Normal file
52
sf_base/static/src/scss/change.scss
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
.o_list_renderer .o_list_table tbody > tr > td:not(.o_list_record_selector):not(.o_handle_cell):not(.o_list_button):not(.o_list_record_remove) {
|
||||||
|
white-space: nowrap !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-truncate {
|
||||||
|
overflow: unset !important;
|
||||||
|
text-overflow: unset !important;
|
||||||
|
white-space: unset !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 设置表格不超出页面宽度
|
||||||
|
.o_form_view .o_field_widget .o_list_renderer {
|
||||||
|
width: calc(100% - 64px) !important;
|
||||||
|
margin:0 auto;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格针对处理
|
||||||
|
.fixTableCss {
|
||||||
|
text-align: center;
|
||||||
|
.o_list_number_th,.o_list_number {
|
||||||
|
text-align: center!important;
|
||||||
|
}
|
||||||
|
.ui-sortable {
|
||||||
|
tr > td:first-child {
|
||||||
|
padding: 0!important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.row_no {
|
||||||
|
padding: 0!important;;
|
||||||
|
width: 35px!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
th[data-name="total_length"],th[data-name="length"],th[data-name="thickness"] {
|
||||||
|
.flex-row-reverse {
|
||||||
|
span {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 其他不能用js处理的表格
|
||||||
|
.otherTableFix {
|
||||||
|
th[data-name="cutting_tool_material_id"] {
|
||||||
|
width: 100px!important;
|
||||||
|
}
|
||||||
|
th[data-name="ramping_angle_max"],th[data-name="ramping_angle_min"] {
|
||||||
|
width: 200px!important;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
.img-fluid {
|
.img-fluid {
|
||||||
max-width: unset !important;
|
max-width: unset !important;
|
||||||
|
width: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.o_inner_group .img-fluid {
|
.o_inner_group .img-fluid {
|
||||||
|
|||||||
@@ -633,4 +633,26 @@
|
|||||||
<field name="res_model">sf.machining.accuracy</field>
|
<field name="res_model">sf.machining.accuracy</field>
|
||||||
<field name="view_mode">tree</field>
|
<field name="view_mode">tree</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
#------------------坯料冗余量------------------
|
||||||
|
<record model="ir.ui.view" id="tree_sf_embryo_redundancy_view">
|
||||||
|
<field name="name">tree.sf.embryo.redundancy</field>
|
||||||
|
<field name="model">sf.embryo.redundancy</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="坯料冗余量" create="0" edit="0" delete="0">
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="code"/>
|
||||||
|
<field name="long"/>
|
||||||
|
<field name="width"/>
|
||||||
|
<field name="height"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_sf_embryo_redundancy" model="ir.actions.act_window">
|
||||||
|
<field name="name">坯料冗余量</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">sf.embryo.redundancy</field>
|
||||||
|
<field name="view_mode">tree</field>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -141,18 +141,25 @@
|
|||||||
sequence="1"
|
sequence="1"
|
||||||
action="action_sf_machine_brand"/>
|
action="action_sf_machine_brand"/>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="menu_sf_embryo_redundancy"
|
||||||
|
parent="menu_sf_base"
|
||||||
|
name="坯料冗余"
|
||||||
|
sequence="2"
|
||||||
|
action="action_sf_embryo_redundancy"/>
|
||||||
|
|
||||||
<menuitem
|
<menuitem
|
||||||
id="menu_sf_machining_accuracy"
|
id="menu_sf_machining_accuracy"
|
||||||
parent="menu_sf_base"
|
parent="menu_sf_base"
|
||||||
name="加工精度"
|
name="加工精度"
|
||||||
sequence="1"
|
sequence="3"
|
||||||
action="action_sf_machining_accuracy"/>
|
action="action_sf_machining_accuracy"/>
|
||||||
|
|
||||||
<menuitem
|
<menuitem
|
||||||
id="menu_sf_machine_control_system"
|
id="menu_sf_machine_control_system"
|
||||||
parent="menu_sf_base"
|
parent="menu_sf_base"
|
||||||
name="数控系统"
|
name="数控系统"
|
||||||
sequence="2"
|
sequence="4"
|
||||||
action="action_sf_machine_control_system"/>
|
action="action_sf_machine_control_system"/>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -360,6 +360,7 @@
|
|||||||
<field name="cooling_jacket"/>
|
<field name="cooling_jacket"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
<script src="/sf_base/static/js/setTableWidth.js?time=3"></script>
|
||||||
</page>
|
</page>
|
||||||
<page string="切削速度Vc"
|
<page string="切削速度Vc"
|
||||||
attrs="{'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀片'))]}">
|
attrs="{'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀片'))]}">
|
||||||
@@ -380,6 +381,9 @@
|
|||||||
<field name="cutting_speed"/>
|
<field name="cutting_speed"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
<script src="/sf_base/static/js/customTable.js?time=3"></script>
|
||||||
|
<script src="/sf_base/static/js/setTableWidth.js?time=3"></script>
|
||||||
|
|
||||||
</page>
|
</page>
|
||||||
<page string="每齿走刀量fz"
|
<page string="每齿走刀量fz"
|
||||||
attrs="{'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀片'))]}">
|
attrs="{'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀片'))]}">
|
||||||
@@ -392,6 +396,8 @@
|
|||||||
<field name="feed_per_tooth"/>
|
<field name="feed_per_tooth"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
<div id="updateTable"></div>
|
||||||
|
<script src="/sf_base/static/js/updateTable.js?time=3"></script>
|
||||||
<field name="feed_per_tooth_ids_3"
|
<field name="feed_per_tooth_ids_3"
|
||||||
attrs="{'invisible': [('cutting_tool_type', 'not in', ('刀片'))]}">
|
attrs="{'invisible': [('cutting_tool_type', 'not in', ('刀片'))]}">
|
||||||
<tree editable="bottom" class="center" create="0" delete="0">
|
<tree editable="bottom" class="center" create="0" delete="0">
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
from odoo import http
|
from odoo import http
|
||||||
from odoo.http import request
|
from odoo.http import request
|
||||||
|
|
||||||
@@ -123,7 +125,8 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
res['factory_order_no'] = order_id.name
|
res['factory_order_no'] = order_id.name
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info('get_bfm_process_order_list error:%s' % e)
|
traceback_error = traceback.format_exc()
|
||||||
|
logging.error('get_bfm_process_order_list error: %s' % traceback_error)
|
||||||
res['status'] = -1
|
res['status'] = -1
|
||||||
res['message'] = '工厂创建销售订单和产品失败,请联系管理员'
|
res['message'] = '工厂创建销售订单和产品失败,请联系管理员'
|
||||||
request.cr.rollback()
|
request.cr.rollback()
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class StatusChange(models.Model):
|
|||||||
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
|
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
|
||||||
try:
|
try:
|
||||||
res = super(StatusChange, self).action_confirm()
|
res = super(StatusChange, self).action_confirm()
|
||||||
|
logging.info('原生方法返回结果:%s' % res)
|
||||||
# 原有方法执行后,进行额外的操作(如调用外部API)
|
# 原有方法执行后,进行额外的操作(如调用外部API)
|
||||||
process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
config = self.env['res.config.settings'].get_values()
|
config = self.env['res.config.settings'].get_values()
|
||||||
@@ -61,6 +62,7 @@ class StatusChange(models.Model):
|
|||||||
traceback_error = traceback.format_exc()
|
traceback_error = traceback.format_exc()
|
||||||
logging.error("工厂加工同步订单状态失败:%s " % traceback_error)
|
logging.error("工厂加工同步订单状态失败:%s " % traceback_error)
|
||||||
raise UserError(e)
|
raise UserError(e)
|
||||||
|
logging.info('最终返回值:%s' % res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def action_cancel(self):
|
def action_cancel(self):
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//form//sheet//notebook//page[@name='operations']" position="after">
|
<xpath expr="//form//sheet//notebook//page[@name='operations']" position="after">
|
||||||
<page string="发货信息" name="tracking">
|
<page string="发货信息" name="tracking" attrs="{'invisible': [('picking_type_code', '!=', 'outgoing')]}">
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="senderNickName" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
|
<field name="senderNickName" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data noupdate="1">
|
||||||
<record id="product_category_embryo_sf" model="product.category">
|
<record id="product_category_embryo_sf" model="product.category">
|
||||||
<field name="name">坯料</field>
|
<field name="name">坯料</field>
|
||||||
<field name="type">坯料</field>
|
<field name="type">坯料</field>
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
from . import product_supplierinfo
|
from . import product_supplierinfo
|
||||||
|
from . import stock_rule_inherit
|
||||||
|
|
||||||
|
|||||||
87
sf_dlm/models/stock_rule_inherit.py
Normal file
87
sf_dlm/models/stock_rule_inherit.py
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import logging
|
||||||
|
from itertools import groupby
|
||||||
|
from odoo import models, fields, api, _
|
||||||
|
|
||||||
|
|
||||||
|
class StockRuleInherit(models.Model):
|
||||||
|
_inherit = 'stock.rule'
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _run_buy(self, procurements):
|
||||||
|
# 判断补货组的采购类型
|
||||||
|
procurements_group = {'standard': [], 'consignment': []}
|
||||||
|
for procurement, rule in procurements:
|
||||||
|
is_consignment = False
|
||||||
|
product = procurement.product_id
|
||||||
|
# 获取主 BOM
|
||||||
|
bom = self.env['mrp.bom'].search([('product_tmpl_id', '=', product.product_tmpl_id.id)], limit=1)
|
||||||
|
|
||||||
|
if bom:
|
||||||
|
# 遍历 BOM 中的组件(即坯料等)
|
||||||
|
for line in bom.bom_line_ids:
|
||||||
|
raw_material = line.product_id
|
||||||
|
# 检查路线
|
||||||
|
for route in raw_material.route_ids:
|
||||||
|
# print('route.name:', route.name)
|
||||||
|
if route.name == '按订单补给外包商':
|
||||||
|
is_consignment = True
|
||||||
|
|
||||||
|
if is_consignment:
|
||||||
|
procurements_group['consignment'].append((procurement, rule))
|
||||||
|
else:
|
||||||
|
procurements_group['standard'].append((procurement, rule))
|
||||||
|
|
||||||
|
for key, value in procurements_group.items():
|
||||||
|
super(StockRuleInherit, self)._run_buy(value)
|
||||||
|
|
||||||
|
if key == 'consignment':
|
||||||
|
for procurement, rule in value:
|
||||||
|
supplier = procurement.values.get('supplier')
|
||||||
|
if supplier:
|
||||||
|
domain = rule._make_po_get_domain(procurement.company_id, procurement.values,
|
||||||
|
supplier.partner_id)
|
||||||
|
logging.info("domain=============: %s", domain)
|
||||||
|
po = self.env['purchase.order'].sudo().search([
|
||||||
|
('partner_id', '=', supplier.partner_id.id),
|
||||||
|
('company_id', '=', procurement.company_id.id), # 保证公司一致
|
||||||
|
('origin', 'like', procurement.origin), # 根据来源匹配
|
||||||
|
('state', '=', 'draft') # 状态为草稿
|
||||||
|
], limit=1)
|
||||||
|
logging.info("po=: %s", po)
|
||||||
|
if po:
|
||||||
|
po.write({'purchase_type': 'consignment'})
|
||||||
|
|
||||||
|
# # 首先调用父类的 _run_buy 方法,以保留原有逻辑
|
||||||
|
# super(StockRuleInherit, self)._run_buy(procurements)
|
||||||
|
|
||||||
|
# 然后在这里添加自定义的逻辑
|
||||||
|
# for procurement, rule in procurements:
|
||||||
|
# product = procurement.product_id
|
||||||
|
# # 获取主 BOM
|
||||||
|
# bom = self.env['mrp.bom'].search([('product_tmpl_id', '=', product.product_tmpl_id.id)], limit=1)
|
||||||
|
|
||||||
|
# if bom:
|
||||||
|
# # 遍历 BOM 中的组件(即坯料等)
|
||||||
|
# for line in bom.bom_line_ids:
|
||||||
|
# raw_material = line.product_id
|
||||||
|
# # 检查路线
|
||||||
|
# for route in raw_material.route_ids:
|
||||||
|
# # print('route.name:', route.name)
|
||||||
|
# if route.name == '按订单补给外包商': # 或者用 route.id 检查精确的路线
|
||||||
|
# print("按订单补给外包商============是")
|
||||||
|
# # 使用 procurement.values['supplier'] 获取供应商
|
||||||
|
# supplier = procurement.values.get('supplier')
|
||||||
|
# if supplier:
|
||||||
|
# domain = rule._make_po_get_domain(procurement.company_id, procurement.values,
|
||||||
|
# supplier.partner_id)
|
||||||
|
# logging.info("domain=============: %s", domain)
|
||||||
|
# po = self.env['purchase.order'].sudo().search([
|
||||||
|
# ('partner_id', '=', supplier.partner_id.id),
|
||||||
|
# ('company_id', '=', procurement.company_id.id), # 保证公司一致
|
||||||
|
# ('origin', '=', procurement.origin), # 根据来源匹配
|
||||||
|
# ('state', '=', 'draft') # 状态为草稿
|
||||||
|
# ], limit=1)
|
||||||
|
# logging.info("po=: %s", po)
|
||||||
|
# if po:
|
||||||
|
# po.write({'purchase_type': 'consignment'})
|
||||||
|
# break
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
<record id="mrp.product_template_action" model="ir.actions.act_window">
|
<record id="mrp.product_template_action" model="ir.actions.act_window">
|
||||||
|
<field name="view_mode">tree,kanban,form,activity</field>
|
||||||
<field name="context">
|
<field name="context">
|
||||||
{"search_default_categ_id":1,"search_default_consumable": 1, 'default_detailed_type': 'product'}
|
{"search_default_categ_id":1,"search_default_consumable": 1, 'default_detailed_type': 'product'}
|
||||||
</field>
|
</field>
|
||||||
@@ -15,8 +16,10 @@
|
|||||||
<field name='categ_id' class="custom_required" attrs="{'readonly': [('id', '!=', False)]}"/>
|
<field name='categ_id' class="custom_required" attrs="{'readonly': [('id', '!=', False)]}"/>
|
||||||
<field name='is_bfm' invisible="1"/>
|
<field name='is_bfm' invisible="1"/>
|
||||||
<field name='categ_type' invisible="1"/>
|
<field name='categ_type' invisible="1"/>
|
||||||
|
<field name='part_name' attrs="{'invisible': [('categ_type', '!=', '成品')]}"/>
|
||||||
<field name='part_number' attrs="{'invisible': [('categ_type', '!=', '成品')]}"/>
|
<field name='part_number' attrs="{'invisible': [('categ_type', '!=', '成品')]}"/>
|
||||||
<field name='manual_quotation' attrs="{'invisible':[('upload_model_file', '=', [])]}"/>
|
<field name='manual_quotation' attrs="{'invisible':[('upload_model_file', '=', [])]}"/>
|
||||||
|
<field name="is_customer_provided" attrs="{'invisible': [('categ_type', 'not in', ['成品', '坯料'])], 'readonly': True}" />
|
||||||
<field name="upload_model_file"
|
<field name="upload_model_file"
|
||||||
widget="many2many_binary"
|
widget="many2many_binary"
|
||||||
attrs="{'invisible': ['|', '|',('categ_type', '!=', '成品'),('categ_type', '=', False),('is_bfm','=', True)]}"/>
|
attrs="{'invisible': ['|', '|',('categ_type', '!=', '成品'),('categ_type', '=', False),('is_bfm','=', True)]}"/>
|
||||||
@@ -63,6 +66,9 @@
|
|||||||
attrs="{'invisible': [('categ_type', '!=', '夹具')],'required': [('categ_type', '=', '夹具')]}"
|
attrs="{'invisible': [('categ_type', '!=', '夹具')],'required': [('categ_type', '=', '夹具')]}"
|
||||||
domain="[('fixture_model_id','=',fixture_model_id)]"/>
|
domain="[('fixture_model_id','=',fixture_model_id)]"/>
|
||||||
</field>
|
</field>
|
||||||
|
<xpath expr="//field[@name='uom_id']" position="before">
|
||||||
|
<field name="is_manual_processing" attrs="{'invisible': [('categ_type', 'not in', ['成品', '坯料'])], 'readonly': True}" />
|
||||||
|
</xpath>
|
||||||
<xpath expr="//label[@for='volume']" position="before">
|
<xpath expr="//label[@for='volume']" position="before">
|
||||||
<label for="length" string="尺寸"
|
<label for="length" string="尺寸"
|
||||||
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>
|
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>
|
||||||
@@ -110,15 +116,13 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//sheet//notebook" position="inside">
|
<xpath expr="//sheet//notebook" position="inside">
|
||||||
<page string="2D加工图纸">
|
<page string="2D加工图纸" attrs="{'invisible': [('categ_type', 'not in', ['成品', '坯料'])]}">
|
||||||
<field name='machining_drawings' attrs="{'invisible': [('categ_type', '!=', '成品')]}"
|
<field name='machining_drawings' widget="adaptive_viewer"/>
|
||||||
widget="adaptive_viewer"/>
|
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//sheet//notebook" position="inside">
|
<xpath expr="//sheet//notebook" position="inside">
|
||||||
<page string="质检标准">
|
<page string="质检标准" attrs="{'invisible': [('categ_type', 'not in', ['成品', '坯料'])]}">
|
||||||
<field name='quality_standard' attrs="{'invisible': [('categ_type', '!=', '成品')]}"
|
<field name='quality_standard' widget="adaptive_viewer"/>
|
||||||
widget="adaptive_viewer"/>
|
|
||||||
|
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
|
|
||||||
from . import hr_employee
|
from . import hr_employee
|
||||||
from . import res_config_setting
|
from . import res_config_setting
|
||||||
|
from . import res_users
|
||||||
|
|||||||
@@ -11,6 +11,42 @@ class JkmPracticeEmployee(models.Model):
|
|||||||
|
|
||||||
we_id = fields.Char(string='企微ID', index=True)
|
we_id = fields.Char(string='企微ID', index=True)
|
||||||
|
|
||||||
|
@api.model_create_multi
|
||||||
|
def create(self, vals_list):
|
||||||
|
for val in vals_list:
|
||||||
|
if 'work_email' in val:
|
||||||
|
val["we_id"] = self._get_we_id(val.get('work_email'))
|
||||||
|
return super(JkmPracticeEmployee, self).create(vals_list)
|
||||||
|
|
||||||
|
def write(self, vals):
|
||||||
|
if 'work_email' in vals:
|
||||||
|
vals["we_id"] = self._get_we_id(vals.get('work_email'))
|
||||||
|
return super(JkmPracticeEmployee, self).write(vals)
|
||||||
|
|
||||||
|
@api.depends('work_contact_id', 'work_contact_id.mobile', 'work_contact_id.email')
|
||||||
|
def _compute_work_contact_details(self):
|
||||||
|
for employee in self:
|
||||||
|
if employee.work_contact_id:
|
||||||
|
employee.mobile_phone = employee.work_contact_id.mobile
|
||||||
|
employee.work_email = employee.work_contact_id.email
|
||||||
|
if employee.work_contact_id.email:
|
||||||
|
employee.we_id = self._get_we_id(employee.work_contact_id.email)
|
||||||
|
|
||||||
|
def _get_we_id(self, work_email):
|
||||||
|
json1 = {
|
||||||
|
'params': {
|
||||||
|
'work_email': work_email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
url = '/api/get/we_id/info'
|
||||||
|
config = self.env['res.config.settings'].get_values()
|
||||||
|
ret = requests.post((config['ims_url'] + url), json=json1, data={})
|
||||||
|
result = ret.json()['result']
|
||||||
|
if result['code'] == 200:
|
||||||
|
if result['we_id']:
|
||||||
|
return result['we_id']
|
||||||
|
return None
|
||||||
|
|
||||||
def _employee_info_sync(self):
|
def _employee_info_sync(self):
|
||||||
url = '/api/get/organization'
|
url = '/api/get/organization'
|
||||||
config = self.env['res.config.settings'].get_values()
|
config = self.env['res.config.settings'].get_values()
|
||||||
|
|||||||
15
sf_hr/models/res_users.py
Normal file
15
sf_hr/models/res_users.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import random
|
||||||
|
from odoo import models, fields, api
|
||||||
|
from odoo.http import request
|
||||||
|
from odoo.exceptions import AccessDenied
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ResUsers(models.Model):
|
||||||
|
_inherit = 'res.users'
|
||||||
|
|
||||||
|
we_employee_id = fields.Char(string=u'企业微信账号', related='employee_id.we_id', default="")
|
||||||
@@ -1264,6 +1264,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
"""
|
"""
|
||||||
获取
|
获取
|
||||||
"""
|
"""
|
||||||
|
logging.info("kw=============:%s" % kw)
|
||||||
res = {'status': 1, 'message': '成功', 'data': {}}
|
res = {'status': 1, 'message': '成功', 'data': {}}
|
||||||
# 连接数据库
|
# 连接数据库
|
||||||
conn = psycopg2.connect(**db_config)
|
conn = psycopg2.connect(**db_config)
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
<searchpanel>
|
<searchpanel>
|
||||||
<field name="routing_type" select="multi" string="工序类型" icon="fa-building" enable_counters="1"/>
|
<field name="routing_type" select="multi" string="工序类型" icon="fa-building" enable_counters="1"/>
|
||||||
<field name="state" select="multi" string="状态" icon="fa-building" enable_counters="1"/>
|
<field name="state" select="multi" string="状态" icon="fa-building" enable_counters="1"/>
|
||||||
|
|
||||||
|
<field name="construction_period_status" select="multi" icon="fa-building" enable_counters="1"/>
|
||||||
|
<field name="tag_type" select="multi" icon="fa-building" enable_counters="1"/>
|
||||||
<!-- <field name="manual_quotation" select="multi" string="" icon="fa-building" enable_counters="1"/>-->
|
<!-- <field name="manual_quotation" select="multi" string="" icon="fa-building" enable_counters="1"/>-->
|
||||||
</searchpanel>
|
</searchpanel>
|
||||||
|
|
||||||
|
|||||||
@@ -689,6 +689,8 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
if next_date < date_now:
|
if next_date < date_now:
|
||||||
next_date = date_now
|
next_date = date_now
|
||||||
else:
|
else:
|
||||||
|
if not equipment.initial_action_date:
|
||||||
|
raise ValidationError('重置保养日期不能为空!!!')
|
||||||
next_date = equipment.initial_action_date + timedelta(days=equipment.period)
|
next_date = equipment.initial_action_date + timedelta(days=equipment.period)
|
||||||
equipment.next_action_date = next_date
|
equipment.next_action_date = next_date
|
||||||
else:
|
else:
|
||||||
@@ -735,6 +737,8 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
if next_date < date_now:
|
if next_date < date_now:
|
||||||
next_date = date_now
|
next_date = date_now
|
||||||
else:
|
else:
|
||||||
|
if not equipment.initial_overhaul_date:
|
||||||
|
raise ValidationError('重置维修日期不能为空')
|
||||||
next_date = equipment.initial_overhaul_date + timedelta(days=equipment.overhaul_period)
|
next_date = equipment.initial_overhaul_date + timedelta(days=equipment.overhaul_period)
|
||||||
equipment.overhaul_date = next_date
|
equipment.overhaul_date = next_date
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
import requests
|
import requests
|
||||||
from odoo import api, fields, models, _
|
from odoo import api, fields, models, _
|
||||||
@@ -62,22 +63,22 @@ class SfMaintenanceEquipmentOEE(models.Model):
|
|||||||
("封存(报废)", "封存(报废)")],
|
("封存(报废)", "封存(报废)")],
|
||||||
default='正常', string="机床状态", related='equipment_id.state')
|
default='正常', string="机床状态", related='equipment_id.state')
|
||||||
|
|
||||||
online_time = fields.Char('开机时长(小时)', reaonly='True')
|
online_time = fields.Char('开机时长(小时)', readonly='True')
|
||||||
|
|
||||||
offline_time = fields.Char('关机时长(小时)', reaonly='True')
|
offline_time = fields.Char('关机时长(小时)', readonly='True')
|
||||||
idle_nums = fields.Integer('待机次数', reaonly='True')
|
idle_nums = fields.Integer('待机次数', readonly='True')
|
||||||
# 待机时长
|
# 待机时长
|
||||||
|
|
||||||
idle_time = fields.Char('待机时长(小时)', reaonly='True')
|
idle_time = fields.Char('待机时长(小时)', readonly='True')
|
||||||
|
|
||||||
# 待机率
|
# 待机率
|
||||||
idle_rate = fields.Char('待机率(%)', reaonly='True')
|
idle_rate = fields.Char('待机率(%)', readonly='True')
|
||||||
|
|
||||||
work_time = fields.Char('加工时长(小时)', reaonly='True')
|
work_time = fields.Char('加工时长(小时)', readonly='True')
|
||||||
work_rate = fields.Char('可用率(%)', reaonly='True')
|
work_rate = fields.Char('可用率(%)', readonly='True')
|
||||||
fault_time = fields.Char('故障时长(小时)', reaonly='True')
|
fault_time = fields.Char('故障时长(小时)', readonly='True')
|
||||||
fault_rate = fields.Char('故障率(%)', reaonly='True')
|
fault_rate = fields.Char('故障率(%)', readonly='True')
|
||||||
fault_nums = fields.Integer('故障次数', reaonly='True')
|
fault_nums = fields.Integer('故障次数', readonly='True')
|
||||||
|
|
||||||
# 设备故障日志
|
# 设备故障日志
|
||||||
sf_maintenance_logs_ids = fields.One2many('sf.maintenance.logs', 'maintenance_equipment_oee_id', '设备故障日志',
|
sf_maintenance_logs_ids = fields.One2many('sf.maintenance.logs', 'maintenance_equipment_oee_id', '设备故障日志',
|
||||||
@@ -90,11 +91,18 @@ class SfMaintenanceEquipmentOEE(models.Model):
|
|||||||
|
|
||||||
def get_running_datas(self):
|
def get_running_datas(self):
|
||||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
url_time = base_url + '/api/RunningTimeDetail'
|
logging.info("base_url=============:%s" % base_url)
|
||||||
|
# 只有当原始 URL 使用 http 时才替换为 https
|
||||||
|
if base_url.startswith("http://"):
|
||||||
|
secure_base_url = base_url.replace("http://", "https://")
|
||||||
|
else:
|
||||||
|
secure_base_url = base_url
|
||||||
|
url_time = secure_base_url + '/api/RunningTimeDetail'
|
||||||
|
logging.info("url_time=============:%s" % url_time)
|
||||||
cnc_list_obj = self.env['maintenance.equipment'].sudo().search(
|
cnc_list_obj = self.env['maintenance.equipment'].sudo().search(
|
||||||
[('function_type', '!=', False), ('active', '=', True)])
|
[('function_type', '!=', False), ('active', '=', True)])
|
||||||
machine_list = list(map(lambda x: x.code, cnc_list_obj))
|
machine_list = list(map(lambda x: x.code, cnc_list_obj))
|
||||||
# print('machine_list: %s' % machine_list)
|
logging.info("machine_list=============:%s" % machine_list)
|
||||||
|
|
||||||
data_time = {
|
data_time = {
|
||||||
"machine_list": str(machine_list)
|
"machine_list": str(machine_list)
|
||||||
@@ -367,25 +375,25 @@ class SfMaintenanceEquipmentOEELog(models.Model):
|
|||||||
[("ZXJGZX", "钻铣加工中心"), ("CXJGZX", "车削加工中心"), ("FHJGZX", "复合加工中心")],
|
[("ZXJGZX", "钻铣加工中心"), ("CXJGZX", "车削加工中心"), ("FHJGZX", "复合加工中心")],
|
||||||
default="", string="功能类型")
|
default="", string="功能类型")
|
||||||
machine_tool_picture = fields.Binary('设备图片')
|
machine_tool_picture = fields.Binary('设备图片')
|
||||||
type_id = fields.Many2one('sf.machine_tool.type', '品牌型号', reaonly='True')
|
type_id = fields.Many2one('sf.machine_tool.type', '品牌型号', readonly='True')
|
||||||
state = fields.Selection([("加工", "加工"), ("关机", "关机"), ("待机", "待机"), ("故障", "故障"),
|
state = fields.Selection([("加工", "加工"), ("关机", "关机"), ("待机", "待机"), ("故障", "故障"),
|
||||||
("检修", "检修"), ("保养", "保养")], default="", string="实时状态")
|
("检修", "检修"), ("保养", "保养")], default="", string="实时状态")
|
||||||
online_time = fields.Char('开机时长', reaonly='True')
|
online_time = fields.Char('开机时长', readonly='True')
|
||||||
|
|
||||||
offline_time = fields.Char('关机时长', reaonly='True')
|
offline_time = fields.Char('关机时长', readonly='True')
|
||||||
offline_nums = fields.Integer('关机次数', reaonly='True')
|
offline_nums = fields.Integer('关机次数', readonly='True')
|
||||||
# 待机时长
|
# 待机时长
|
||||||
|
|
||||||
idle_time = fields.Char('待机时长', reaonly='True')
|
idle_time = fields.Char('待机时长', readonly='True')
|
||||||
|
|
||||||
# 待机率
|
# 待机率
|
||||||
idle_rate = fields.Char('待机率', reaonly='True')
|
idle_rate = fields.Char('待机率', readonly='True')
|
||||||
|
|
||||||
work_time = fields.Char('加工时长', reaonly='True')
|
work_time = fields.Char('加工时长', readonly='True')
|
||||||
work_rate = fields.Char('可用率', reaonly='True')
|
work_rate = fields.Char('可用率', readonly='True')
|
||||||
fault_time = fields.Char('故障时长', reaonly='True')
|
fault_time = fields.Char('故障时长', readonly='True')
|
||||||
fault_rate = fields.Char('故障率', reaonly='True')
|
fault_rate = fields.Char('故障率', readonly='True')
|
||||||
fault_nums = fields.Integer('故障次数', reaonly='True')
|
fault_nums = fields.Integer('故障次数', readonly='True')
|
||||||
|
|
||||||
detail_ids = fields.One2many('maintenance.equipment.oee.log.detail', 'log_id', string='日志详情')
|
detail_ids = fields.One2many('maintenance.equipment.oee.log.detail', 'log_id', string='日志详情')
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@
|
|||||||
<field name="name">维保计划</field>
|
<field name="name">维保计划</field>
|
||||||
<field name="res_model">maintenance.request</field>
|
<field name="res_model">maintenance.request</field>
|
||||||
<field name="view_mode">tree,kanban,form,pivot,graph,calendar</field>
|
<field name="view_mode">tree,kanban,form,pivot,graph,calendar</field>
|
||||||
<field name="view_id" ref="maintenance.hr_equipment_request_view_kanban"/>
|
<field name="view_id" ref="sf_maintenance.maintenance_request_view_tree_sf"/>
|
||||||
<field name="context">{'default_user_id': uid}</field>
|
<field name="context">{'default_user_id': uid}</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_smiling_face">
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
{
|
{
|
||||||
'name': '机企猫智能工厂 制造管理',
|
'name': '机企猫智能工厂 制造管理',
|
||||||
'version': '1.0',
|
'version': '1.1',
|
||||||
'summary': '智能工厂制造模块',
|
'summary': '智能工厂制造模块',
|
||||||
'sequence': 1,
|
'sequence': 1,
|
||||||
'description': """
|
'description': """
|
||||||
@@ -10,8 +10,9 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse','jikimo_attachment_viewer'],
|
'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse','jikimo_attachment_viewer', 'jikimo_sale_multiple_supply_methods'],
|
||||||
'data': [
|
'data': [
|
||||||
|
'data/cron_data.xml',
|
||||||
'data/stock_data.xml',
|
'data/stock_data.xml',
|
||||||
'data/empty_racks_data.xml',
|
'data/empty_racks_data.xml',
|
||||||
'data/panel_data.xml',
|
'data/panel_data.xml',
|
||||||
@@ -21,6 +22,8 @@
|
|||||||
'wizard/workpiece_delivery_views.xml',
|
'wizard/workpiece_delivery_views.xml',
|
||||||
'wizard/rework_wizard_views.xml',
|
'wizard/rework_wizard_views.xml',
|
||||||
'wizard/production_wizard_views.xml',
|
'wizard/production_wizard_views.xml',
|
||||||
|
'wizard/production_technology_wizard_views.xml',
|
||||||
|
'wizard/production_technology_re_adjust_wizard_views.xml',
|
||||||
'views/mrp_views_menus.xml',
|
'views/mrp_views_menus.xml',
|
||||||
'views/agv_scheduling_views.xml',
|
'views/agv_scheduling_views.xml',
|
||||||
'views/stock_lot_views.xml',
|
'views/stock_lot_views.xml',
|
||||||
@@ -29,10 +32,12 @@
|
|||||||
'views/production_line_view.xml',
|
'views/production_line_view.xml',
|
||||||
'views/mrp_workcenter_views.xml',
|
'views/mrp_workcenter_views.xml',
|
||||||
'views/mrp_workorder_view.xml',
|
'views/mrp_workorder_view.xml',
|
||||||
|
'views/stock_picking_view.xml',
|
||||||
'views/model_type_view.xml',
|
'views/model_type_view.xml',
|
||||||
'views/agv_setting_views.xml',
|
'views/agv_setting_views.xml',
|
||||||
'views/sf_maintenance_equipment.xml',
|
'views/sf_maintenance_equipment.xml',
|
||||||
'views/res_config_settings_views.xml',
|
'views/res_config_settings_views.xml',
|
||||||
|
'views/sale_order_views.xml',
|
||||||
],
|
],
|
||||||
'assets': {
|
'assets': {
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
from . import controllers
|
from . import controllers
|
||||||
from . import workpiece
|
from . import workpiece
|
||||||
|
from . import main
|
||||||
|
|||||||
54
sf_manufacturing/controllers/main.py
Normal file
54
sf_manufacturing/controllers/main.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import logging
|
||||||
|
import json
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
from odoo import http
|
||||||
|
from odoo.http import request
|
||||||
|
from odoo.addons.sf_bf_connect.controllers.controllers import Sf_Bf_Connect
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class JikimoSaleRoutePicking(Sf_Bf_Connect):
|
||||||
|
|
||||||
|
@http.route('/api/bfm_process_order/list', type='http', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def get_bfm_process_order_list(self, **kw):
|
||||||
|
"""
|
||||||
|
接收业务平台加工订单分配工厂时传送来的订单数据并生成销售订单和产品及坯料
|
||||||
|
:param kw:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
res = {'status': 1, 'factory_order_no': ''}
|
||||||
|
# _logger.info('get_bfm_process_order_list:%s' % kw['order_number'])
|
||||||
|
try:
|
||||||
|
product_id = request.env.ref('jikimo_sale_multiple_supply_methods.product_template_default').with_context(active_test=False).sudo().product_variant_id
|
||||||
|
_logger.info('product_id:%s' % product_id)
|
||||||
|
company_id = request.env.ref('base.main_company').sudo()
|
||||||
|
bfm_process_order_list = json.loads(kw['bfm_process_order_list'])
|
||||||
|
order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create(
|
||||||
|
company_id, kw['delivery_name'], kw['delivery_telephone'], kw['delivery_address'],
|
||||||
|
kw['delivery_end_date'], kw['payments_way'], kw['pay_way'], state='draft')
|
||||||
|
i = 1
|
||||||
|
# 给sale_order的default_code字段赋值
|
||||||
|
# aa = request.env['sale.order'].sudo().search([('name', '=', order_id.name)])
|
||||||
|
# _logger.info('get_bfm_process_or===================================:%s' % order_id.name)
|
||||||
|
order_id.default_code = kw['order_number']
|
||||||
|
if kw.get('logistics_way'):
|
||||||
|
order_id.logistics_way = kw['logistics_way']
|
||||||
|
for item in bfm_process_order_list:
|
||||||
|
if item.get('embryo_redundancy_id'):
|
||||||
|
item['embryo_redundancy'] = request.env['sf.embryo.redundancy'].sudo().search([('code', '=', item['embryo_redundancy_id'])], limit=1)
|
||||||
|
item['embryo_redundancy_id'] = item['embryo_redundancy'].id
|
||||||
|
product = request.env['product.template'].sudo().product_create(product_id, item, order_id,
|
||||||
|
kw['order_number'], i)
|
||||||
|
product.product_tmpl_id.is_customer_provided = True if item['embryo_redundancy_id'] else False
|
||||||
|
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
||||||
|
i += 1
|
||||||
|
res['factory_order_no'] = order_id.name
|
||||||
|
except Exception as e:
|
||||||
|
traceback_error = traceback.format_exc()
|
||||||
|
logging.error('get_bfm_process_order_list error: %s' % traceback_error)
|
||||||
|
res['status'] = -1
|
||||||
|
res['message'] = '工厂创建销售订单和产品失败,请联系管理员'
|
||||||
|
request.cr.rollback()
|
||||||
|
return json.JSONEncoder().encode(res)
|
||||||
29
sf_manufacturing/data/cron_data.xml
Normal file
29
sf_manufacturing/data/cron_data.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<odoo>
|
||||||
|
<data noupdate="1">
|
||||||
|
<record model="ir.cron" id="ir_cron_update_construction_period_status">
|
||||||
|
<field name="name">工期状态变更</field>
|
||||||
|
<field name="model_id" ref="model_mrp_workorder"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model._corn_update_construction_period_status()</field>
|
||||||
|
<field name="interval_number">12</field>
|
||||||
|
<field name="interval_type">hours</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
<field name="user_id" ref="base.user_root"/>
|
||||||
|
<field name="active" eval="True"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="ir_cron_update_delivery_status">
|
||||||
|
<field name="name">交期状态变更</field>
|
||||||
|
<field name="model_id" ref="model_mrp_production"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model._corn_update_delivery_status()</field>
|
||||||
|
<field name="interval_number">12</field>
|
||||||
|
<field name="interval_type">hours</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
<field name="user_id" ref="base.user_root"/>
|
||||||
|
<field name="active" eval="True"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
12
sf_manufacturing/migrations/1.1/post-migrate.py
Normal file
12
sf_manufacturing/migrations/1.1/post-migrate.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# migrations/1.1.0/post-migrate.py
|
||||||
|
from odoo import api, SUPERUSER_ID
|
||||||
|
|
||||||
|
def migrate(cr, version):
|
||||||
|
# 获取环境
|
||||||
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
|
|
||||||
|
# 示例:添加新字段
|
||||||
|
env.ref('sf_dlm.product_embryo_sf_self_machining').product_tmpl_id.write({'categ_type': '坯料'})
|
||||||
|
env.ref('sf_dlm.product_template_sf').product_tmpl_id.write({'categ_type': '成品'})
|
||||||
|
env.ref('sf_dlm.product_embryo_sf_outsource').product_tmpl_id.write({'categ_type': '坯料'})
|
||||||
|
env.ref('sf_dlm.product_embryo_sf_purchase').product_tmpl_id.write({'categ_type': '坯料'})
|
||||||
@@ -11,3 +11,7 @@ from . import production_line_base
|
|||||||
from . import agv_setting
|
from . import agv_setting
|
||||||
from . import agv_scheduling
|
from . import agv_scheduling
|
||||||
from . import res_config_setting
|
from . import res_config_setting
|
||||||
|
from . import sf_technology_design
|
||||||
|
from . import sf_production_common
|
||||||
|
from . import sale_order
|
||||||
|
from . import quick_easy_order
|
||||||
|
|||||||
@@ -6,42 +6,29 @@ class ModelType(models.Model):
|
|||||||
_description = '模型类型'
|
_description = '模型类型'
|
||||||
|
|
||||||
name = fields.Char('名称')
|
name = fields.Char('名称')
|
||||||
embryo_tolerance = fields.Integer('坯料容余')
|
# embryo_tolerance = fields.Char('坯料容余')
|
||||||
|
embryo_tolerance_id = fields.Many2one('sf.embryo.redundancy', string='坯料冗余')
|
||||||
product_routing_tmpl_ids = fields.One2many('sf.product.model.type.routing.sort', 'product_model_type_id',
|
product_routing_tmpl_ids = fields.One2many('sf.product.model.type.routing.sort', 'product_model_type_id',
|
||||||
'成品工序模板')
|
'成品工序模板(自动化产线加工')
|
||||||
embryo_routing_tmpl_ids = fields.One2many('sf.embryo.model.type.routing.sort', 'embryo_model_type_id',
|
embryo_routing_tmpl_ids = fields.One2many('sf.embryo.model.type.routing.sort', 'embryo_model_type_id',
|
||||||
'坯料工序模板')
|
'坯料工序模板(人工线下加工)')
|
||||||
surface_technics_routing_tmpl_ids = fields.One2many('sf.surface_technics.model.type.routing.sort',
|
surface_technics_routing_tmpl_ids = fields.One2many('sf.surface_technics.model.type.routing.sort',
|
||||||
'surface_technics_model_type_id',
|
'surface_technics_model_type_id',
|
||||||
'表面工艺工序模板')
|
'表面工艺工序模板')
|
||||||
|
manual_product_routing_tmpl_ids = fields.One2many('sf.manual.product.model.type.routing.sort',
|
||||||
|
'manual_product_model_type_id',
|
||||||
|
'成品工序模板(人工线下加工)')
|
||||||
|
|
||||||
|
|
||||||
class ProductModelTypeRoutingSort(models.Model):
|
class ProductModelTypeRoutingSort(models.Model):
|
||||||
_name = 'sf.product.model.type.routing.sort'
|
_name = 'sf.product.model.type.routing.sort'
|
||||||
_description = '成品工序排序'
|
_description = '成品工序排序(自动化产线加工)'
|
||||||
|
|
||||||
sequence = fields.Integer('Sequence')
|
sequence = fields.Integer('Sequence')
|
||||||
route_workcenter_id = fields.Many2one('mrp.routing.workcenter',
|
route_workcenter_id = fields.Many2one('mrp.routing.workcenter',
|
||||||
domain=[('routing_type', 'in', ['装夹预调', 'CNC加工', '解除装夹'])])
|
domain=[('routing_type', 'in', ['装夹预调', 'CNC加工', '解除装夹'])])
|
||||||
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
||||||
|
|
||||||
# routing_type = fields.Selection([
|
|
||||||
# ('获取CNC加工程序', '获取CNC加工程序'),
|
|
||||||
# ('装夹', '装夹'),
|
|
||||||
# ('前置三元定位检测', '前置三元定位检测'),
|
|
||||||
# ('CNC加工', 'CNC加工'),
|
|
||||||
# ('后置三元质量检测', '后置三元质量检测'),
|
|
||||||
# ('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
|
|
||||||
# ], string="工序类型", compute='_compute_route_workcenter_id')
|
|
||||||
#
|
|
||||||
# @api.depends('route_workcenter_id')
|
|
||||||
# def _compute_route_workcenter_id(self):
|
|
||||||
# for record in self:
|
|
||||||
# if record:
|
|
||||||
# record.routing_type = record.route_workcenter_id.routing_type
|
|
||||||
|
|
||||||
routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type')
|
routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type')
|
||||||
|
|
||||||
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
||||||
product_model_type_id = fields.Many2one('sf.model.type')
|
product_model_type_id = fields.Many2one('sf.model.type')
|
||||||
|
|
||||||
@@ -57,24 +44,7 @@ class EmbryoModelTypeRoutingSort(models.Model):
|
|||||||
sequence = fields.Integer('Sequence')
|
sequence = fields.Integer('Sequence')
|
||||||
route_workcenter_id = fields.Many2one('mrp.routing.workcenter', domain=[('routing_type', 'in', ['切割'])])
|
route_workcenter_id = fields.Many2one('mrp.routing.workcenter', domain=[('routing_type', 'in', ['切割'])])
|
||||||
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
||||||
|
|
||||||
# routing_type = fields.Selection([
|
|
||||||
# ('获取CNC加工程序', '获取CNC加工程序'),
|
|
||||||
# ('装夹', '装夹'),
|
|
||||||
# ('前置三元定位检测', '前置三元定位检测'),
|
|
||||||
# ('CNC加工', 'CNC加工'),
|
|
||||||
# ('后置三元质量检测', '后置三元质量检测'),
|
|
||||||
# ('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
|
|
||||||
# ], string="工序类型", compute='_compute_route_workcenter_id')
|
|
||||||
#
|
|
||||||
# @api.depends('route_workcenter_id')
|
|
||||||
# def _compute_route_workcenter_id(self):
|
|
||||||
# for record in self:
|
|
||||||
# if record:
|
|
||||||
# record.routing_type = record.route_workcenter_id.routing_type
|
|
||||||
|
|
||||||
routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type')
|
routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type')
|
||||||
|
|
||||||
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
||||||
embryo_model_type_id = fields.Many2one('sf.model.type')
|
embryo_model_type_id = fields.Many2one('sf.model.type')
|
||||||
|
|
||||||
@@ -90,24 +60,7 @@ class SurfaceTechnicsModelTypeRoutingSort(models.Model):
|
|||||||
sequence = fields.Integer('Sequence')
|
sequence = fields.Integer('Sequence')
|
||||||
route_workcenter_id = fields.Many2one('mrp.routing.workcenter', domain=[('routing_type', 'in', ['表面工艺'])])
|
route_workcenter_id = fields.Many2one('mrp.routing.workcenter', domain=[('routing_type', 'in', ['表面工艺'])])
|
||||||
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
||||||
|
|
||||||
# routing_type = fields.Selection([
|
|
||||||
# ('获取CNC加工程序', '获取CNC加工程序'),
|
|
||||||
# ('装夹', '装夹'),
|
|
||||||
# ('前置三元定位检测', '前置三元定位检测'),
|
|
||||||
# ('CNC加工', 'CNC加工'),
|
|
||||||
# ('后置三元质量检测', '后置三元质量检测'),
|
|
||||||
# ('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
|
|
||||||
# ], string="工序类型", compute='_compute_route_workcenter_id')
|
|
||||||
#
|
|
||||||
# @api.depends('route_workcenter_id')
|
|
||||||
# def _compute_route_workcenter_id(self):
|
|
||||||
# for record in self:
|
|
||||||
# if record:
|
|
||||||
# record.routing_type = record.route_workcenter_id.routing_type
|
|
||||||
|
|
||||||
routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type')
|
routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type')
|
||||||
|
|
||||||
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
||||||
surface_technics_model_type_id = fields.Many2one('sf.model.type')
|
surface_technics_model_type_id = fields.Many2one('sf.model.type')
|
||||||
|
|
||||||
@@ -116,3 +69,18 @@ class SurfaceTechnicsModelTypeRoutingSort(models.Model):
|
|||||||
'route_model_type_uniq', 'unique (route_workcenter_id,surface_technics_model_type_id)',
|
'route_model_type_uniq', 'unique (route_workcenter_id,surface_technics_model_type_id)',
|
||||||
'表面工艺工序不能重复!')
|
'表面工艺工序不能重复!')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class ManualProductModelTypeRoutingSort(models.Model):
|
||||||
|
_name = 'sf.manual.product.model.type.routing.sort'
|
||||||
|
_description = '成品工序排序(人工线下加工)'
|
||||||
|
|
||||||
|
sequence = fields.Integer('Sequence')
|
||||||
|
route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
|
||||||
|
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
||||||
|
routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type')
|
||||||
|
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
||||||
|
manual_product_model_type_id = fields.Many2one('sf.model.type')
|
||||||
|
|
||||||
|
_sql_constraints = [
|
||||||
|
('route_model_type_uniq', 'unique (route_workcenter_id,manual_product_model_type_id)', '成品工序不能重复!')
|
||||||
|
]
|
||||||
@@ -57,6 +57,95 @@ class MrpProduction(models.Model):
|
|||||||
else:
|
else:
|
||||||
production.deadline_of_delivery = False
|
production.deadline_of_delivery = False
|
||||||
|
|
||||||
|
def _compute_default_delivery_status(self):
|
||||||
|
try:
|
||||||
|
if self.state == 'cancel':
|
||||||
|
return False
|
||||||
|
if not self.deadline_of_delivery:
|
||||||
|
return False
|
||||||
|
hours = self.get_hours_diff()
|
||||||
|
if hours >= 48:
|
||||||
|
return '正常'
|
||||||
|
elif hours > 0 and hours < 48 and self.state != 'done':
|
||||||
|
return '预警'
|
||||||
|
elif hours > 0 and hours < 48 and self.state == 'done':
|
||||||
|
return '正常'
|
||||||
|
else:
|
||||||
|
return '已逾期'
|
||||||
|
except Exception as e:
|
||||||
|
logging.error("Error processing production ID {}: {}".format(self.id, e))
|
||||||
|
raise e
|
||||||
|
|
||||||
|
@api.depends('state', 'deadline_of_delivery')
|
||||||
|
def _compute_delivery_status(self):
|
||||||
|
for production in self:
|
||||||
|
delivery_status = production._compute_default_delivery_status()
|
||||||
|
if delivery_status and production.delivery_status != delivery_status:
|
||||||
|
production.delivery_status = delivery_status
|
||||||
|
|
||||||
|
delivery_status = fields.Selection([('正常', '正常'), ('预警', '预警'), ('已逾期', '已逾期')], string='交期状态',
|
||||||
|
store=True,
|
||||||
|
compute='_compute_delivery_status',
|
||||||
|
default=lambda self: self._compute_default_delivery_status())
|
||||||
|
|
||||||
|
def get_page_all_records(self, model_name, func, domain, page_size=100):
|
||||||
|
# 获取模型对象
|
||||||
|
model = self.env[model_name].sudo()
|
||||||
|
|
||||||
|
# 初始化分页参数
|
||||||
|
page_number = 1
|
||||||
|
while True:
|
||||||
|
# 计算偏移量
|
||||||
|
offset = (page_number - 1) * page_size
|
||||||
|
|
||||||
|
# 获取当前页的数据
|
||||||
|
records = model.search(domain, limit=page_size, offset=offset)
|
||||||
|
|
||||||
|
# 如果没有更多记录,退出循环
|
||||||
|
if not records:
|
||||||
|
break
|
||||||
|
|
||||||
|
# 将当前页的数据添加到结果列表
|
||||||
|
func(records)
|
||||||
|
# 增加页码
|
||||||
|
page_number += 1
|
||||||
|
|
||||||
|
def run_compute_delivery_status(self, records):
|
||||||
|
records._compute_delivery_status()
|
||||||
|
|
||||||
|
def _corn_update_delivery_status(self):
|
||||||
|
need_list = [
|
||||||
|
'draft',
|
||||||
|
'technology_to_confirmed',
|
||||||
|
'confirmed',
|
||||||
|
'pending_cam',
|
||||||
|
'progress',
|
||||||
|
'rework',
|
||||||
|
'scrap',
|
||||||
|
'to_close',
|
||||||
|
]
|
||||||
|
# previous_workorder = self.env['mrp.production'].search([('state', 'in', need_list)])
|
||||||
|
self.get_page_all_records('mrp.production', self.run_compute_delivery_status,
|
||||||
|
[('state', 'in', need_list)], 100)
|
||||||
|
|
||||||
|
def get_hours_diff(self):
|
||||||
|
# 获取当前日期和时间
|
||||||
|
current_datetime = fields.Datetime.now()
|
||||||
|
|
||||||
|
# 将 date_field 转换为 datetime 对象
|
||||||
|
if self.deadline_of_delivery:
|
||||||
|
date_obj = fields.Date.from_string(self.deadline_of_delivery)
|
||||||
|
# 将 date 对象转换为 datetime 对象,设置时间为 00:00:00
|
||||||
|
date_obj = datetime.datetime.combine(date_obj, datetime.time.min)
|
||||||
|
|
||||||
|
# 计算两个日期之间的差值
|
||||||
|
delta = date_obj - current_datetime
|
||||||
|
|
||||||
|
# 返回差值的小时数
|
||||||
|
return int(delta.total_seconds() / 3600)
|
||||||
|
else:
|
||||||
|
return 0.0
|
||||||
|
|
||||||
@api.depends('workorder_ids.tool_state_remark')
|
@api.depends('workorder_ids.tool_state_remark')
|
||||||
def _compute_tool_state_remark(self):
|
def _compute_tool_state_remark(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
@@ -98,6 +187,7 @@ class MrpProduction(models.Model):
|
|||||||
# ])
|
# ])
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
('draft', '草稿'),
|
('draft', '草稿'),
|
||||||
|
('technology_to_confirmed', '待工艺确认'),
|
||||||
('confirmed', '待排程'),
|
('confirmed', '待排程'),
|
||||||
('pending_cam', '待加工'),
|
('pending_cam', '待加工'),
|
||||||
('progress', '加工中'),
|
('progress', '加工中'),
|
||||||
@@ -148,6 +238,8 @@ class MrpProduction(models.Model):
|
|||||||
|
|
||||||
quality_standard = fields.Binary('质检标准', related='product_id.quality_standard', readonly=True)
|
quality_standard = fields.Binary('质检标准', related='product_id.quality_standard', readonly=True)
|
||||||
|
|
||||||
|
part_name = fields.Char(string='零件名称', related='product_id.part_name', readonly=True)
|
||||||
|
|
||||||
@api.depends('product_id.manual_quotation')
|
@api.depends('product_id.manual_quotation')
|
||||||
def _compute_manual_quotation(self):
|
def _compute_manual_quotation(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
@@ -158,6 +250,8 @@ class MrpProduction(models.Model):
|
|||||||
is_remanufacture = fields.Boolean('是否重新制造', default=False)
|
is_remanufacture = fields.Boolean('是否重新制造', default=False)
|
||||||
remanufacture_count = fields.Integer("重新制造订单数量", compute='_compute_remanufacture_production_ids')
|
remanufacture_count = fields.Integer("重新制造订单数量", compute='_compute_remanufacture_production_ids')
|
||||||
remanufacture_production_id = fields.Many2one('mrp.production', string='')
|
remanufacture_production_id = fields.Many2one('mrp.production', string='')
|
||||||
|
technology_design_ids = fields.One2many('sf.technology.design', 'production_id', string='工艺设计')
|
||||||
|
is_adjust = fields.Boolean('是否退回调整', default=False)
|
||||||
|
|
||||||
@api.depends('remanufacture_production_id')
|
@api.depends('remanufacture_production_id')
|
||||||
def _compute_remanufacture_production_ids(self):
|
def _compute_remanufacture_production_ids(self):
|
||||||
@@ -184,7 +278,7 @@ class MrpProduction(models.Model):
|
|||||||
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'tool_state',
|
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'tool_state',
|
||||||
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state')
|
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state', 'programming_state', 'is_adjust')
|
||||||
def _compute_state(self):
|
def _compute_state(self):
|
||||||
for production in self:
|
for production in self:
|
||||||
if not production.state or not production.product_uom_id:
|
if not production.state or not production.product_uom_id:
|
||||||
@@ -214,22 +308,33 @@ class MrpProduction(models.Model):
|
|||||||
precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding)
|
precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding)
|
||||||
for move in production.move_raw_ids if move.product_id):
|
for move in production.move_raw_ids if move.product_id):
|
||||||
production.state = 'progress'
|
production.state = 'progress'
|
||||||
|
# 新添加的状态逻辑
|
||||||
# # 新添加的状态逻辑
|
if production.state in ['to_close', 'progress',
|
||||||
if (
|
'technology_to_confirmed'] and production.schedule_state == '未排':
|
||||||
production.state == 'to_close' or production.state == 'progress') and production.schedule_state == '未排':
|
if not production.workorder_ids or production.is_adjust is True:
|
||||||
production.state = 'confirmed'
|
production.state = 'technology_to_confirmed'
|
||||||
|
else:
|
||||||
|
if production.is_adjust is True:
|
||||||
|
production.state = 'technology_to_confirmed'
|
||||||
|
else:
|
||||||
|
production.state = 'confirmed'
|
||||||
elif production.state == 'pending_cam' and production.schedule_state == '未排':
|
elif production.state == 'pending_cam' and production.schedule_state == '未排':
|
||||||
production.state = 'confirmed'
|
production.state = 'confirmed'
|
||||||
elif production.state == 'to_close' and production.schedule_state == '已排':
|
elif production.state == 'to_close' and production.schedule_state == '已排':
|
||||||
production.state = 'pending_cam'
|
production.state = 'pending_cam'
|
||||||
|
elif production.state == 'confirmed' and production.is_adjust is True:
|
||||||
|
production.state = 'technology_to_confirmed'
|
||||||
|
if production.state == 'confirmed' and production.schedule_state == '已排':
|
||||||
|
production.state = 'pending_cam'
|
||||||
if production.state == 'progress':
|
if production.state == 'progress':
|
||||||
if all(wo_state not in ('progress', 'done', 'rework', 'scrap') for wo_state in
|
if all(wo_state not in ('progress', 'done', 'rework', 'scrap') for wo_state in
|
||||||
production.workorder_ids.mapped('state')):
|
production.workorder_ids.mapped('state')):
|
||||||
production.state = 'pending_cam'
|
production.state = 'pending_cam'
|
||||||
if production.is_rework is True:
|
if production.is_rework is True:
|
||||||
production.state = 'rework'
|
production.state = 'rework'
|
||||||
|
if (production.state == 'rework' and production.tool_state == '0'
|
||||||
|
and production.schedule_state == '已排' and production.is_rework is False):
|
||||||
|
production.state = 'pending_cam'
|
||||||
# if production.state == 'pending_cam':
|
# if production.state == 'pending_cam':
|
||||||
# if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')):
|
# if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')):
|
||||||
# production.state = 'done'
|
# production.state = 'done'
|
||||||
@@ -252,6 +357,104 @@ class MrpProduction(models.Model):
|
|||||||
if production.tool_state == '2':
|
if production.tool_state == '2':
|
||||||
production.state = 'rework'
|
production.state = 'rework'
|
||||||
|
|
||||||
|
# 退回调整
|
||||||
|
def technology_back_adjust(self):
|
||||||
|
process_parameters = []
|
||||||
|
domain = [('state', '=', 'confirmed'), ('origin', '=', self.origin)]
|
||||||
|
if self.production_type == '自动化产线加工':
|
||||||
|
cloud_programming = self._cron_get_programming_state()
|
||||||
|
if cloud_programming['send_state'] == 'sending':
|
||||||
|
raise UserError(_("编程文件正在下发中,请稍后重试"))
|
||||||
|
domain += [('programming_no', '=', self.programming_no)]
|
||||||
|
# 带排程的制造订单
|
||||||
|
production_confirmed = self.env['mrp.production'].search(domain)
|
||||||
|
for special in production_confirmed.technology_design_ids:
|
||||||
|
if special.process_parameters_id:
|
||||||
|
product_production_process = self.env['product.template'].search(
|
||||||
|
[('server_product_process_parameters_id', '=', special.process_parameters_id.id)])
|
||||||
|
if not product_production_process:
|
||||||
|
if special.process_parameters_id not in process_parameters:
|
||||||
|
process_parameters.append(special.process_parameters_id.display_name)
|
||||||
|
if process_parameters:
|
||||||
|
raise UserError(_("【工艺设计】-【参数】为%s的在【产品】中不存在,请先创建", ", ".join(process_parameters)))
|
||||||
|
if production_confirmed:
|
||||||
|
return {
|
||||||
|
'name': _('退回调整'),
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_model': 'sf.production.technology.re_adjust.wizard',
|
||||||
|
'target': 'new',
|
||||||
|
'context': {
|
||||||
|
'default_production_id': self.id,
|
||||||
|
'default_origin': self.origin,
|
||||||
|
}}
|
||||||
|
|
||||||
|
# 工艺确认
|
||||||
|
def technology_confirm(self):
|
||||||
|
process_parameters = []
|
||||||
|
account_moves = []
|
||||||
|
parameters_not = []
|
||||||
|
special_design = self.technology_design_ids.filtered(
|
||||||
|
lambda a: a.routing_tag == 'special' and a.is_auto is False)
|
||||||
|
for special in special_design:
|
||||||
|
if special.route_id.routing_type == '表面工艺' and not special.process_parameters_id:
|
||||||
|
parameters_not.append(special.route_id.name)
|
||||||
|
if special.process_parameters_id:
|
||||||
|
product_production_process = self.env['product.template'].search(
|
||||||
|
[('server_product_process_parameters_id', '=', special.process_parameters_id.id)])
|
||||||
|
if not product_production_process:
|
||||||
|
if special.process_parameters_id not in process_parameters:
|
||||||
|
process_parameters.append(special.process_parameters_id.display_name)
|
||||||
|
purchase = self.env['purchase.order'].search([('origin', '=', special.production_id.name)])
|
||||||
|
account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids)])
|
||||||
|
if account.state not in ['cancel', False]:
|
||||||
|
if purchase.name not in account_moves:
|
||||||
|
account_moves.append(purchase.name)
|
||||||
|
if account_moves:
|
||||||
|
raise UserError(_("请联系工厂生产经理对采购订单为%s生成的账单进行取消", ", ".join(account_moves)))
|
||||||
|
if parameters_not:
|
||||||
|
raise UserError(_("【工艺设计】-【工序】为%s未选择参数,请选择", ", ".join(parameters_not)))
|
||||||
|
if process_parameters:
|
||||||
|
raise UserError(_("【工艺设计】-【参数】为%s的在【产品】中不存在,请先创建", ", ".join(process_parameters)))
|
||||||
|
# 判断同一个加工面的标准工序的顺序是否依次排序
|
||||||
|
error_panel = []
|
||||||
|
technology_design = self.technology_design_ids.filtered(lambda a: a.routing_tag == 'standard').sorted(
|
||||||
|
key=lambda m: m.sequence)
|
||||||
|
for index, design in enumerate(technology_design):
|
||||||
|
routing_type = design.route_id.routing_type
|
||||||
|
if index < len(technology_design) - 1:
|
||||||
|
next_index = index + 1
|
||||||
|
next_design = technology_design[next_index]
|
||||||
|
next_design_routing_type = next_design.route_id.routing_type
|
||||||
|
# logging.info('当前工序和加工面: %s-%s' % (design.route_id.name, design.panel))
|
||||||
|
# logging.info('下一个工序和加工面: %s-%s' % (next_design.route_id.name, next_design.panel))
|
||||||
|
if design.panel is not False:
|
||||||
|
if design.panel != next_design.panel:
|
||||||
|
if index == 0:
|
||||||
|
raise UserError('【加工面】为%s的标准工序里含有其他加工面的工序,请调整后重试' % design.panel)
|
||||||
|
if routing_type not in ['解除装夹']:
|
||||||
|
raise UserError('【加工面】为%s的标准工序顺序有误,请调整后重试' % design.panel)
|
||||||
|
if design.panel == next_design.panel:
|
||||||
|
if (routing_type == '装夹预调' and next_design_routing_type == '解除装夹') or (
|
||||||
|
routing_type == 'CNC加工' and next_design_routing_type == '装夹预调'):
|
||||||
|
if design.panel not in error_panel:
|
||||||
|
error_panel.append(design.panel)
|
||||||
|
else:
|
||||||
|
if not error_panel and not process_parameters:
|
||||||
|
return {
|
||||||
|
'name': _('工艺确认'),
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_model': 'sf.production.technology.wizard',
|
||||||
|
'target': 'new',
|
||||||
|
'context': {
|
||||||
|
'default_production_id': self.id,
|
||||||
|
'default_origin': self.origin,
|
||||||
|
}}
|
||||||
|
if error_panel:
|
||||||
|
raise UserError(_("【加工面】为%s的标准工序顺序有误,请调整后重试", ", ".join(error_panel)))
|
||||||
|
return True
|
||||||
|
|
||||||
def action_check(self):
|
def action_check(self):
|
||||||
"""
|
"""
|
||||||
审核启用
|
审核启用
|
||||||
@@ -452,8 +655,8 @@ class MrpProduction(models.Model):
|
|||||||
if self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids:
|
if self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids:
|
||||||
self.move_finished_ids.filtered(
|
self.move_finished_ids.filtered(
|
||||||
lambda m: m.product_id == self.product_id).move_line_ids.lot_id = self.lot_producing_id
|
lambda m: m.product_id == self.product_id).move_line_ids.lot_id = self.lot_producing_id
|
||||||
if self.product_id.tracking == 'serial':
|
# if self.product_id.tracking == 'serial':
|
||||||
self._set_qty_producing()
|
# self._set_qty_producing()
|
||||||
|
|
||||||
# 重载根据工序生成工单的程序:如果产品BOM中没有工序时,
|
# 重载根据工序生成工单的程序:如果产品BOM中没有工序时,
|
||||||
# 根据产品对应的模板类型中工序,去生成工单;
|
# 根据产品对应的模板类型中工序,去生成工单;
|
||||||
@@ -489,122 +692,88 @@ class MrpProduction(models.Model):
|
|||||||
'operation_id': operation.id,
|
'operation_id': operation.id,
|
||||||
'state': 'pending',
|
'state': 'pending',
|
||||||
}]
|
}]
|
||||||
if production.product_id.categ_id.type == '成品':
|
if production.product_id.categ_id.type in ['成品', '坯料']:
|
||||||
# # 根据加工面板的面数及对应的工序模板生成工单
|
# # 根据工序设计生成工单
|
||||||
i = 0
|
for route in production.technology_design_ids:
|
||||||
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
workorder_has = self.env['mrp.workorder'].search(
|
||||||
for k in (production.product_id.model_processing_panel.split(',')):
|
[('technology_design_id', '=', route.id), ('production_id', '=', production.id)])
|
||||||
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
if not workorder_has:
|
||||||
[('product_model_type_id', '=', production.product_id.product_model_type_id.id)],
|
if route.route_id.routing_type not in ['表面工艺']:
|
||||||
order='sequence asc'
|
|
||||||
)
|
|
||||||
i += 1
|
|
||||||
for route in product_routing_workcenter:
|
|
||||||
if route.is_repeat is True:
|
|
||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str(k, production, route, item))
|
self.env['mrp.workorder'].json_workorder_str(production, route))
|
||||||
# if i == processing_panel_len and route.routing_type == '解除装夹':
|
else:
|
||||||
# workorders_values.append(
|
|
||||||
# self.env['mrp.workorder'].json_workorder_str(k, production, route))
|
|
||||||
# 表面工艺工序
|
|
||||||
# 获取表面工艺id
|
|
||||||
# 工序id
|
|
||||||
surface_technics_arr = []
|
|
||||||
route_workcenter_arr = []
|
|
||||||
for item in production.product_id.product_model_type_id.surface_technics_routing_tmpl_ids:
|
|
||||||
if item.route_workcenter_id.surface_technics_id.id:
|
|
||||||
for process_param in production.product_id.model_process_parameters_ids:
|
|
||||||
logging.info('process_param:%s%s' % (process_param.id, process_param.name))
|
|
||||||
if item.route_workcenter_id.surface_technics_id == process_param.process_id:
|
|
||||||
logging.info(
|
|
||||||
'surface_technics_id:%s%s' % (item.route_workcenter_id.surface_technics_id.id,
|
|
||||||
item.route_workcenter_id.surface_technics_id.name))
|
|
||||||
surface_technics_arr.append(item.route_workcenter_id.surface_technics_id.id)
|
|
||||||
route_workcenter_arr.append(item.route_workcenter_id.id)
|
|
||||||
if surface_technics_arr:
|
|
||||||
production_process = self.env['sf.production.process'].search(
|
|
||||||
[('id', 'in', surface_technics_arr)],
|
|
||||||
order='sequence asc'
|
|
||||||
)
|
|
||||||
for p in production_process:
|
|
||||||
logging.info('production_process:%s' % p.name)
|
|
||||||
# if production_process:
|
|
||||||
process_parameter = production.product_id.model_process_parameters_ids.filtered(
|
|
||||||
lambda pm: pm.process_id.id == p.id)
|
|
||||||
if process_parameter:
|
|
||||||
# 产品为表面工艺服务的供应商
|
|
||||||
product_production_process = self.env['product.template'].search(
|
product_production_process = self.env['product.template'].search(
|
||||||
[('server_product_process_parameters_id', '=', process_parameter.id)])
|
[('server_product_process_parameters_id', '=', route.process_parameters_id.id)])
|
||||||
if product_production_process:
|
workorders_values.append(
|
||||||
route_production_process = self.env[
|
self.env[
|
||||||
'mrp.routing.workcenter'].search(
|
'mrp.workorder']._json_workorder_surface_process_str(
|
||||||
[('surface_technics_id', '=', p.id),
|
production, route, product_production_process.seller_ids[0].partner_id.id))
|
||||||
('id', 'in', route_workcenter_arr)])
|
|
||||||
if route_production_process:
|
|
||||||
workorders_values.append(
|
|
||||||
self.env[
|
|
||||||
'mrp.workorder']._json_workorder_surface_process_str(
|
|
||||||
production, route_production_process,
|
|
||||||
process_parameter,
|
|
||||||
product_production_process.seller_ids[0].partner_id.id))
|
|
||||||
elif production.product_id.categ_id.type == '坯料':
|
|
||||||
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
|
|
||||||
[('embryo_model_type_id', '=', production.product_id.embryo_model_type_id.id)],
|
|
||||||
order='sequence asc'
|
|
||||||
)
|
|
||||||
for route in embryo_routing_workcenter:
|
|
||||||
workorders_values.append(
|
|
||||||
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
|
||||||
production.workorder_ids = workorders_values
|
production.workorder_ids = workorders_values
|
||||||
# for production_item in productions:
|
|
||||||
process_parameter_workorder = self.env['mrp.workorder'].search(
|
|
||||||
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
|
|
||||||
('is_subcontract', '=', True)])
|
|
||||||
if process_parameter_workorder:
|
|
||||||
is_pick = False
|
|
||||||
consecutive_workorders = []
|
|
||||||
m = 0
|
|
||||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
|
|
||||||
for i in range(len(sorted_workorders) - 1):
|
|
||||||
if m == 0:
|
|
||||||
is_pick = False
|
|
||||||
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
|
|
||||||
sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
|
|
||||||
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
|
|
||||||
if sorted_workorders[i] not in consecutive_workorders:
|
|
||||||
consecutive_workorders.append(sorted_workorders[i])
|
|
||||||
consecutive_workorders.append(sorted_workorders[i + 1])
|
|
||||||
m += 1
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
|
||||||
production)
|
|
||||||
if sorted_workorders[i] in consecutive_workorders:
|
|
||||||
is_pick = True
|
|
||||||
consecutive_workorders = []
|
|
||||||
m = 0
|
|
||||||
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
|
|
||||||
if is_pick is False:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
|
||||||
production)
|
|
||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
|
||||||
production)
|
|
||||||
if sorted_workorders[i] in consecutive_workorders:
|
|
||||||
is_pick = True
|
|
||||||
consecutive_workorders = []
|
|
||||||
m = 0
|
|
||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
|
||||||
if is_pick is False and m == 0:
|
|
||||||
if len(sorted_workorders) == 1:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production)
|
|
||||||
else:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production)
|
|
||||||
for workorder in production.workorder_ids:
|
for workorder in production.workorder_ids:
|
||||||
workorder.duration_expected = workorder._get_duration_expected()
|
workorder.duration_expected = workorder._get_duration_expected()
|
||||||
|
|
||||||
|
# 外协出入库单处理
|
||||||
|
def get_subcontract_pick_purchase(self):
|
||||||
|
production_all = self.sorted(lambda x: x.id)
|
||||||
|
product_id_to_production_names = {}
|
||||||
|
grouped_product_ids = {k: list(g) for k, g in
|
||||||
|
groupby(production_all, key=lambda x: x.product_id.id)}
|
||||||
|
for product_id, pd in grouped_product_ids.items():
|
||||||
|
product_id_to_production_names[product_id] = [p.name for p in pd]
|
||||||
|
for production in production_all:
|
||||||
|
proc_workorders = []
|
||||||
|
process_parameter_workorder = self.env['mrp.workorder'].search(
|
||||||
|
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
|
||||||
|
('is_subcontract', '=', True), ('state', '!=', 'cancel')], order='sequence asc')
|
||||||
|
if process_parameter_workorder:
|
||||||
|
# 将这些特殊表面工艺工单的采购单与调拨单置为失效
|
||||||
|
for workorder in process_parameter_workorder:
|
||||||
|
workorder._get_surface_technics_purchase_ids().write({'state': 'cancel'})
|
||||||
|
workorder.move_subcontract_workorder_ids.write({'state': 'cancel'})
|
||||||
|
workorder.move_subcontract_workorder_ids.picking_id.write({'state': 'cancel'})
|
||||||
|
consecutive_workorders = []
|
||||||
|
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
||||||
|
for i, workorder in enumerate(sorted_workorders):
|
||||||
|
# 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
|
||||||
|
if i == 0:
|
||||||
|
consecutive_workorders.append(workorder)
|
||||||
|
elif workorder.sequence == sorted_workorders[
|
||||||
|
i - 1].sequence + 1 and workorder.supplier_id.id == sorted_workorders[i - 1].supplier_id.id:
|
||||||
|
consecutive_workorders.append(workorder)
|
||||||
|
else:
|
||||||
|
# 处理连续组,如果它不为空
|
||||||
|
if consecutive_workorders:
|
||||||
|
proc_workorders.append(consecutive_workorders)
|
||||||
|
# 创建外协出入库单和采购订单
|
||||||
|
# self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production, sorted_workorders)
|
||||||
|
# self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
||||||
|
# product_id_to_production_names)
|
||||||
|
if i < len(sorted_workorders) - 1:
|
||||||
|
# 重置连续组,并添加当前工作订单
|
||||||
|
consecutive_workorders = [workorder]
|
||||||
|
else:
|
||||||
|
# 判断最后一笔:
|
||||||
|
if workorder.sequence == sorted_workorders[
|
||||||
|
i - 1].sequence and workorder.supplier_id.id == sorted_workorders[
|
||||||
|
i - 1].supplier_id.id:
|
||||||
|
consecutive_workorders = [workorder]
|
||||||
|
else:
|
||||||
|
proc_workorders.append([workorder])
|
||||||
|
# 立即创建外协出入库单和采购订单
|
||||||
|
# self.env['stock.picking'].create_outcontract_picking(workorder, production)
|
||||||
|
# self.env['purchase.order'].get_purchase_order(workorder, production,
|
||||||
|
# product_id_to_production_names)
|
||||||
|
consecutive_workorders = []
|
||||||
|
|
||||||
|
# 处理最后一个组,即使它可能只有一个工作订单
|
||||||
|
if consecutive_workorders:
|
||||||
|
proc_workorders.append(consecutive_workorders)
|
||||||
|
# self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
||||||
|
# self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
||||||
|
# product_id_to_production_names)
|
||||||
|
for workorders in reversed(proc_workorders):
|
||||||
|
self.env['stock.picking'].create_outcontract_picking(workorders, production, sorted_workorders)
|
||||||
|
self.env['purchase.order'].get_purchase_order(workorders, production, product_id_to_production_names)
|
||||||
# 工单排序
|
# 工单排序
|
||||||
def _reset_work_order_sequence1(self, k):
|
def _reset_work_order_sequence1(self, k):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
@@ -671,7 +840,84 @@ class MrpProduction(models.Model):
|
|||||||
self._reset_work_order_sequence1(k)
|
self._reset_work_order_sequence1(k)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# 需对不连续工单对应的采购单和外协出入库单做处理
|
||||||
|
def _reset_subcontract_pick_purchase(self):
|
||||||
|
production_all = self.sorted(lambda x: x.id)
|
||||||
|
product_id_to_production_names = {}
|
||||||
|
grouped_product_ids = {k: list(g) for k, g in
|
||||||
|
groupby(production_all, key=lambda x: x.product_id.id)}
|
||||||
|
for product_id, pd in grouped_product_ids.items():
|
||||||
|
product_id_to_production_names[product_id] = [p.name for p in pd]
|
||||||
|
for item in production_all:
|
||||||
|
production_process = product_id_to_production_names.get(item.product_id.id)
|
||||||
|
workorder_sf = item.workorder_ids.filtered(lambda sf: sf.routing_type == '表面工艺')
|
||||||
|
for i, workorder in enumerate(workorder_sf):
|
||||||
|
if i == 0:
|
||||||
|
continue
|
||||||
|
elif workorder.sequence != workorder_sf[i - 1].sequence + 1:
|
||||||
|
# workorder.picking_ids.move_ids = False
|
||||||
|
workorder.picking_ids = False
|
||||||
|
purchase_order = self.env['purchase.order'].search(
|
||||||
|
[('state', '=', 'draft'), ('origin', '=', item.name),
|
||||||
|
('purchase_type', '=', 'consignment')])
|
||||||
|
server_template = self.env['product.template'].search(
|
||||||
|
[('server_product_process_parameters_id', '=',
|
||||||
|
workorder.surface_technics_parameters_id.id),
|
||||||
|
('detailed_type', '=', 'service')])
|
||||||
|
for po in purchase_order:
|
||||||
|
for line in po.order_line:
|
||||||
|
if line.product_id == server_template.product_variant_id:
|
||||||
|
continue
|
||||||
|
if server_template.server_product_process_parameters_id != line.product_id.server_product_process_parameters_id:
|
||||||
|
purchase_order_line = self.env['purchase.order.line'].search(
|
||||||
|
[('product_id', '=', server_template.product_variant_id.id), ('id', '=', line.id),
|
||||||
|
('product_qty', '=', 1)], limit=1, order='id desc')
|
||||||
|
if purchase_order_line:
|
||||||
|
line.unlink()
|
||||||
|
|
||||||
def _reset_work_order_sequence(self):
|
def _reset_work_order_sequence(self):
|
||||||
|
"""
|
||||||
|
工单工序排序方法(新)
|
||||||
|
"""
|
||||||
|
for rec in self:
|
||||||
|
workorder_ids = rec.workorder_ids
|
||||||
|
technology_design_ids = rec.technology_design_ids
|
||||||
|
if workorder_ids.filtered(lambda item: item.state in ('返工', 'rework')):
|
||||||
|
# 获取返工后新生成的工单
|
||||||
|
work_ids = workorder_ids.filtered(lambda item: item.sequence == 0)
|
||||||
|
# 对工单进行逐个插入
|
||||||
|
for work_id in work_ids:
|
||||||
|
for order_id in rec.workorder_ids.filtered(lambda item: item.sequence > 0):
|
||||||
|
if work_id.name == order_id.name:
|
||||||
|
work_id.sequence = order_id.sequence + 1
|
||||||
|
break
|
||||||
|
# 对该工单之后的工单工序进行加一
|
||||||
|
work_order_ids = rec.workorder_ids.filtered(
|
||||||
|
lambda item: item.sequence >= work_id.sequence and item.id != work_id.id)
|
||||||
|
for work in work_order_ids:
|
||||||
|
work.sequence = work.sequence + 1
|
||||||
|
|
||||||
|
else:
|
||||||
|
# 将工艺设计生成的工单序号赋值给工单的序号
|
||||||
|
for work in workorder_ids:
|
||||||
|
td_ids = technology_design_ids.filtered(
|
||||||
|
lambda item: (item.route_id.name in work.name and item.process_parameters_id
|
||||||
|
and item.process_parameters_id == work.surface_technics_parameters_id) or
|
||||||
|
(item.route_id.name == work.name and item.panel
|
||||||
|
and item.panel == work.processing_panel))
|
||||||
|
if td_ids:
|
||||||
|
work.sequence = td_ids[0].sequence
|
||||||
|
cancel_work_ids = workorder_ids.filtered(lambda item: item.state in ('已取消', 'cancel'))
|
||||||
|
if cancel_work_ids:
|
||||||
|
sequence = max(workorder_ids.filtered(lambda item: item.state not in ('已取消', 'cancel')),
|
||||||
|
key=lambda w: w.sequence).sequence
|
||||||
|
for cw in cancel_work_ids:
|
||||||
|
cw.sequence = sequence + 1
|
||||||
|
|
||||||
|
def _reset_work_order_sequence_1(self):
|
||||||
|
"""
|
||||||
|
工单工序排序方法(旧)
|
||||||
|
"""
|
||||||
for rec in self:
|
for rec in self:
|
||||||
workorder_ids = rec.workorder_ids.filtered(lambda item: item.state in ('返工', 'rework'))
|
workorder_ids = rec.workorder_ids.filtered(lambda item: item.state in ('返工', 'rework'))
|
||||||
# 产品模型类型
|
# 产品模型类型
|
||||||
@@ -767,52 +1013,32 @@ class MrpProduction(models.Model):
|
|||||||
self._reset_work_order_sequence()
|
self._reset_work_order_sequence()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def production_process(self, pro_plan):
|
||||||
|
type_map = {'装夹预调': False, 'CNC加工': False, '解除装夹': False}
|
||||||
|
# 最后一次加工结束时间
|
||||||
|
last_time = pro_plan.date_planned_start
|
||||||
|
# 预置时间
|
||||||
|
works = self.workorder_ids
|
||||||
|
for index, work in enumerate(works):
|
||||||
|
count = type_map.get(work.routing_type)
|
||||||
|
date_planned_end = None
|
||||||
|
date_planned_start = None
|
||||||
|
if self.production_type == '自动化产线加工':
|
||||||
|
date_planned_start, date_planned_end, last_time = work.auto_production_process(last_time, count,
|
||||||
|
type_map)
|
||||||
|
elif self.production_type == '':
|
||||||
|
date_planned_start, date_planned_end, last_time = work.manual_offline_process(last_time, index)
|
||||||
|
work.update_work_start_end(date_planned_start, date_planned_end)
|
||||||
|
|
||||||
|
# def
|
||||||
def process_range_time(self):
|
def process_range_time(self):
|
||||||
for production in self:
|
for production in self:
|
||||||
works = production.workorder_ids
|
works = production.workorder_ids
|
||||||
pro_plan = self.env['sf.production.plan'].search([('production_id', '=', production.id)], limit=1)
|
pro_plan = self.env['sf.production.plan'].search([('production_id', '=', production.id)], limit=1)
|
||||||
if not pro_plan:
|
if not pro_plan:
|
||||||
continue
|
continue
|
||||||
type_map = {'装夹预调': False, 'CNC加工': False, '解除装夹': False}
|
if production.production_type:
|
||||||
# 最后一次加工结束时间
|
production.production_process(pro_plan)
|
||||||
last_time = pro_plan.date_planned_start
|
|
||||||
# 预置时间
|
|
||||||
for work in works:
|
|
||||||
count = type_map.get(work.routing_type)
|
|
||||||
date_planned_end = None
|
|
||||||
date_planned_start = None
|
|
||||||
duration_expected = datetime.timedelta(minutes=work.duration_expected)
|
|
||||||
reserve_time = datetime.timedelta(minutes=work.reserved_duration)
|
|
||||||
if not count:
|
|
||||||
# 第一轮加工
|
|
||||||
if work.routing_type == '装夹预调':
|
|
||||||
date_planned_end = last_time - reserve_time
|
|
||||||
date_planned_start = date_planned_end - duration_expected
|
|
||||||
elif work.routing_type == 'CNC加工':
|
|
||||||
date_planned_start = last_time
|
|
||||||
date_planned_end = last_time + duration_expected
|
|
||||||
last_time = date_planned_end
|
|
||||||
else:
|
|
||||||
date_planned_start = last_time + reserve_time
|
|
||||||
date_planned_end = date_planned_start + duration_expected
|
|
||||||
last_time = date_planned_end
|
|
||||||
type_map.update({work.routing_type: True})
|
|
||||||
else:
|
|
||||||
date_planned_start = last_time + reserve_time
|
|
||||||
date_planned_end = date_planned_start + duration_expected
|
|
||||||
last_time = date_planned_end
|
|
||||||
work.leave_id.write({
|
|
||||||
'date_from': date_planned_start,
|
|
||||||
'date_to': date_planned_end,
|
|
||||||
})
|
|
||||||
# work.write({'date_planned_start': date_planned_start, 'date_planned_finished': date_planned_end})
|
|
||||||
work.date_planned_start = date_planned_start
|
|
||||||
work.date_planned_finished = date_planned_end
|
|
||||||
routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
[('name', '=', work.routing_type)])
|
|
||||||
|
|
||||||
work.write({'date_planned_start': date_planned_start, 'date_planned_finished': date_planned_end,
|
|
||||||
'duration_expected': routing_workcenter.time_cycle})
|
|
||||||
|
|
||||||
# 修改标记已完成方法
|
# 修改标记已完成方法
|
||||||
def button_mark_done1(self):
|
def button_mark_done1(self):
|
||||||
@@ -836,6 +1062,7 @@ class MrpProduction(models.Model):
|
|||||||
backorders = backorders - productions_to_backorder
|
backorders = backorders - productions_to_backorder
|
||||||
|
|
||||||
productions_not_to_backorder._post_inventory(cancel_backorder=True)
|
productions_not_to_backorder._post_inventory(cancel_backorder=True)
|
||||||
|
# 查出最后一张工单完成入库操作
|
||||||
# if self.workorder_ids.filtered(lambda w: w.routing_type in ['表面工艺']):
|
# if self.workorder_ids.filtered(lambda w: w.routing_type in ['表面工艺']):
|
||||||
# move_finish = self.env['stock.move'].search([('created_production_id', '=', self.id)])
|
# move_finish = self.env['stock.move'].search([('created_production_id', '=', self.id)])
|
||||||
# if move_finish:
|
# if move_finish:
|
||||||
@@ -936,6 +1163,14 @@ class MrpProduction(models.Model):
|
|||||||
cloud_programming = None
|
cloud_programming = None
|
||||||
if self.programming_state in ['已编程']:
|
if self.programming_state in ['已编程']:
|
||||||
cloud_programming = self._cron_get_programming_state()
|
cloud_programming = self._cron_get_programming_state()
|
||||||
|
result_ids = self.detection_result_ids.filtered(lambda dr: dr.handle_result == '待处理')
|
||||||
|
work_id_list = []
|
||||||
|
if result_ids:
|
||||||
|
work_id_list = [self.workorder_ids.filtered(
|
||||||
|
lambda wk: (wk.name == result_id.routing_type and wk.processing_panel == result_id.processing_panel
|
||||||
|
and wk.state == 'done')).id
|
||||||
|
for result_id in result_ids]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'name': _('返工'),
|
'name': _('返工'),
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
@@ -944,6 +1179,8 @@ class MrpProduction(models.Model):
|
|||||||
'target': 'new',
|
'target': 'new',
|
||||||
'context': {
|
'context': {
|
||||||
'default_production_id': self.id,
|
'default_production_id': self.id,
|
||||||
|
'default_workorder_ids': self.workorder_ids.ids,
|
||||||
|
'default_hidden_workorder_ids': ','.join(map(str, work_id_list)) if work_id_list != [] else '',
|
||||||
'default_reprogramming_num': cloud_programming['reprogramming_num'],
|
'default_reprogramming_num': cloud_programming['reprogramming_num'],
|
||||||
'default_programming_state': cloud_programming['programming_state'],
|
'default_programming_state': cloud_programming['programming_state'],
|
||||||
'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False
|
'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False
|
||||||
@@ -1097,13 +1334,15 @@ class MrpProduction(models.Model):
|
|||||||
raise_user_error=not self.env.context.get('from_orderpoint'))
|
raise_user_error=not self.env.context.get('from_orderpoint'))
|
||||||
productions = self.env['mrp.production'].sudo().search(
|
productions = self.env['mrp.production'].sudo().search(
|
||||||
[('origin', '=', self.origin)], order='id desc', limit=1)
|
[('origin', '=', self.origin)], order='id desc', limit=1)
|
||||||
|
productions.write({'programming_no': self.programming_no, 'is_remanufacture': True})
|
||||||
move = self.env['stock.move'].search([('origin', '=', productions.name)], order='id desc')
|
move = self.env['stock.move'].search([('origin', '=', productions.name)], order='id desc')
|
||||||
for mo in move:
|
for mo in move:
|
||||||
if mo.procure_method == 'make_to_order' and mo.name != productions.name:
|
domain = []
|
||||||
if mo.name == '/':
|
if mo.location_id.barcode == 'WH-POSTPRODUCTION' and mo.rule_id.picking_type_id.barcode == 'PC':
|
||||||
domain = [('barcode', '=', 'WH-PC'), ('sequence_code', '=', 'PC')]
|
domain = [('barcode', '=', 'WH-PC'), ('sequence_code', '=', 'PC')]
|
||||||
elif mo.name == '拉':
|
elif mo.location_id.barcode == 'PL' and mo.rule_id.picking_type_id.barcode == 'INT':
|
||||||
domain = [('barcode', '=', 'WH-INTERNAL'), ('sequence_code', '=', 'INT')]
|
domain = [('barcode', '=', 'WH-INTERNAL'), ('sequence_code', '=', 'INT')]
|
||||||
|
if domain:
|
||||||
picking_type = self.env['stock.picking.type'].search(domain)
|
picking_type = self.env['stock.picking.type'].search(domain)
|
||||||
mo.write({'picking_type_id': picking_type.id})
|
mo.write({'picking_type_id': picking_type.id})
|
||||||
mo._assign_picking()
|
mo._assign_picking()
|
||||||
@@ -1121,7 +1360,6 @@ class MrpProduction(models.Model):
|
|||||||
mo_move.write({'reference': sfp_move.reference, 'partner_id': sfp_move.partner_id.id,
|
mo_move.write({'reference': sfp_move.reference, 'partner_id': sfp_move.partner_id.id,
|
||||||
'picking_id': sfp_move.picking_id.id, 'picking_type_id': sfp_move.picking_type_id.id,
|
'picking_id': sfp_move.picking_id.id, 'picking_type_id': sfp_move.picking_type_id.id,
|
||||||
'production_id': False})
|
'production_id': False})
|
||||||
productions.write({'programming_no': self.programming_no, 'is_remanufacture': True})
|
|
||||||
# productions.procurement_group_id.mrp_production_ids.move_dest_ids.write(
|
# productions.procurement_group_id.mrp_production_ids.move_dest_ids.write(
|
||||||
# {'group_id': self.env['procurement.group'].search([('name', '=', sale_order.name)])})
|
# {'group_id': self.env['procurement.group'].search([('name', '=', sale_order.name)])})
|
||||||
stock_picking_remanufacture = self.env['stock.picking'].search([('origin', '=', productions.name)])
|
stock_picking_remanufacture = self.env['stock.picking'].search([('origin', '=', productions.name)])
|
||||||
@@ -1155,7 +1393,6 @@ class MrpProduction(models.Model):
|
|||||||
if purchase_orders.origin.find(productions.name) == -1:
|
if purchase_orders.origin.find(productions.name) == -1:
|
||||||
purchase_orders.origin += ',' + productions.name
|
purchase_orders.origin += ',' + productions.name
|
||||||
if item['is_reprogramming'] is False:
|
if item['is_reprogramming'] is False:
|
||||||
productions._create_workorder(item)
|
|
||||||
productions.programming_state = '已编程'
|
productions.programming_state = '已编程'
|
||||||
else:
|
else:
|
||||||
productions.programming_state = '编程中'
|
productions.programming_state = '编程中'
|
||||||
@@ -1185,6 +1422,103 @@ class MrpProduction(models.Model):
|
|||||||
'user_id': production.user_id.id}
|
'user_id': production.user_id.id}
|
||||||
return production_values_str
|
return production_values_str
|
||||||
|
|
||||||
|
# 增加制造订单类型
|
||||||
|
production_type = fields.Selection(
|
||||||
|
[('自动化产线加工', '自动化产线加工'), ('人工线下加工', '人工线下加工')],
|
||||||
|
string='制造类型',
|
||||||
|
compute='_compute_production_type',
|
||||||
|
store=True
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends('product_id.is_manual_processing')
|
||||||
|
def _compute_production_type(self):
|
||||||
|
for production in self:
|
||||||
|
production.production_type = '自动化产线加工' if not production.product_id.is_manual_processing else '人工线下加工'
|
||||||
|
|
||||||
|
@api.model_create_multi
|
||||||
|
def create(self, vals_list):
|
||||||
|
"""
|
||||||
|
重载创建制造订单的方法,单个制造订单,同一成品只创建一个采购组,用于后续单据的创建
|
||||||
|
"""
|
||||||
|
product_group_id = {}
|
||||||
|
for vals in vals_list:
|
||||||
|
if not vals.get('name', False) or vals['name'] == _('New'):
|
||||||
|
picking_type_id = vals.get('picking_type_id')
|
||||||
|
if not picking_type_id:
|
||||||
|
picking_type_id = self._get_default_picking_type_id(vals.get('company_id', self.env.company.id))
|
||||||
|
vals['picking_type_id'] = picking_type_id
|
||||||
|
vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id()
|
||||||
|
if not vals.get('procurement_group_id'):
|
||||||
|
product_id = self.env['product.product'].browse(vals['product_id'])
|
||||||
|
if product_id.product_tmpl_id.single_manufacturing:
|
||||||
|
if product_id.id not in product_group_id.keys():
|
||||||
|
procurement_group_vals = self._prepare_procurement_group_vals(vals)
|
||||||
|
group_id = self.env["procurement.group"].create(procurement_group_vals).id
|
||||||
|
vals['procurement_group_id'] = group_id
|
||||||
|
product_group_id[product_id.id] = group_id
|
||||||
|
else:
|
||||||
|
vals['procurement_group_id'] = product_group_id[product_id.id]
|
||||||
|
return super(MrpProduction, self).create(vals_list)
|
||||||
|
|
||||||
|
@api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id',
|
||||||
|
'procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id')
|
||||||
|
def _compute_purchase_order_count(self):
|
||||||
|
for production in self:
|
||||||
|
# 找到来源的第一张制造订单的采购组
|
||||||
|
if production.product_id.product_tmpl_id.single_manufacturing == True:
|
||||||
|
first_production = self.env['mrp.production'].search(
|
||||||
|
[('origin', '=', production.origin), ('product_id', '=', production.product_id.id)], limit=1,
|
||||||
|
order='id asc')
|
||||||
|
production.purchase_order_count = len(
|
||||||
|
first_production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
||||||
|
first_production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id)
|
||||||
|
else:
|
||||||
|
production.purchase_order_count = len(
|
||||||
|
production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
||||||
|
production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id)
|
||||||
|
|
||||||
|
@api.depends('procurement_group_id', 'procurement_group_id.stock_move_ids.group_id')
|
||||||
|
def _compute_picking_ids(self):
|
||||||
|
for order in self:
|
||||||
|
if order.product_id.product_tmpl_id.single_manufacturing == True:
|
||||||
|
first_order = self.env['mrp.production'].search(
|
||||||
|
[('origin', '=', order.origin), ('product_id', '=', order.product_id.id)], limit=1, order='id asc')
|
||||||
|
order.picking_ids = self.env['stock.picking'].search([
|
||||||
|
('group_id', '=', first_order.procurement_group_id.id), ('group_id', '!=', False),
|
||||||
|
])
|
||||||
|
order.delivery_count = len(first_order.picking_ids)
|
||||||
|
else:
|
||||||
|
order.picking_ids = self.env['stock.picking'].search([
|
||||||
|
('group_id', '=', order.procurement_group_id.id), ('group_id', '!=', False),
|
||||||
|
])
|
||||||
|
order.delivery_count = len(order.picking_ids)
|
||||||
|
|
||||||
|
def action_view_purchase_orders(self):
|
||||||
|
self.ensure_one()
|
||||||
|
if self.product_id.product_tmpl_id.single_manufacturing == True:
|
||||||
|
production = self.env['mrp.production'].search(
|
||||||
|
[('origin', '=', self.origin), ('product_id', '=', self.product_id.id)], limit=1, order='id asc')
|
||||||
|
else:
|
||||||
|
production = self
|
||||||
|
purchase_order_ids = (
|
||||||
|
production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids
|
||||||
|
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],
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
action.update({
|
||||||
|
'name': _("Purchase Order generated from %s", self.name),
|
||||||
|
'domain': [('id', 'in', purchase_order_ids)],
|
||||||
|
'view_mode': 'tree,form',
|
||||||
|
})
|
||||||
|
return action
|
||||||
|
|
||||||
|
|
||||||
class sf_detection_result(models.Model):
|
class sf_detection_result(models.Model):
|
||||||
_name = 'sf.detection.result'
|
_name = 'sf.detection.result'
|
||||||
@@ -1214,10 +1548,6 @@ class sf_detection_result(models.Model):
|
|||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'res_id': self.id,
|
'res_id': self.id,
|
||||||
'views': [(self.env.ref('sf_manufacturing.sf_test_report_form').id, 'form')],
|
'views': [(self.env.ref('sf_manufacturing.sf_test_report_form').id, 'form')],
|
||||||
# 'view_mode': 'form',
|
|
||||||
# 'context': {
|
|
||||||
# 'default_id': self.id
|
|
||||||
# },
|
|
||||||
'target': 'new'
|
'target': 'new'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,21 +7,25 @@ class ResMrpRoutingWorkcenter(models.Model):
|
|||||||
_inherit = 'mrp.routing.workcenter'
|
_inherit = 'mrp.routing.workcenter'
|
||||||
|
|
||||||
routing_type = fields.Selection([
|
routing_type = fields.Selection([
|
||||||
# ('获取CNC加工程序', '获取CNC加工程序'),
|
|
||||||
('装夹预调', '装夹预调'),
|
('装夹预调', '装夹预调'),
|
||||||
# ('前置三元定位检测', '前置三元定位检测'),
|
|
||||||
('CNC加工', 'CNC加工'),
|
('CNC加工', 'CNC加工'),
|
||||||
# ('后置三元质量检测', '后置三元质量检测'),
|
|
||||||
('解除装夹', '解除装夹'),
|
('解除装夹', '解除装夹'),
|
||||||
('切割', '切割'),
|
('切割', '切割'),
|
||||||
('表面工艺', '表面工艺')
|
('表面工艺', '表面工艺'),
|
||||||
|
('线切割', '线切割'),
|
||||||
|
('人工线下加工', '人工线下加工')
|
||||||
], string="工序类型")
|
], string="工序类型")
|
||||||
|
routing_tag = fields.Selection([
|
||||||
|
('standard', '标准'),
|
||||||
|
('special', '特殊')
|
||||||
|
], string="标签")
|
||||||
is_repeat = fields.Boolean('重复', default=False)
|
is_repeat = fields.Boolean('重复', default=False)
|
||||||
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
|
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
|
||||||
workcenter_ids = fields.Many2many('mrp.workcenter', 'rel_workcenter_route', required=True)
|
workcenter_ids = fields.Many2many('mrp.workcenter', 'rel_workcenter_route', required=True)
|
||||||
bom_id = fields.Many2one('mrp.bom', required=False)
|
bom_id = fields.Many2one('mrp.bom', required=False)
|
||||||
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
|
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
|
||||||
reserved_duration = fields.Float('预留时长', default=30, tracking=True)
|
reserved_duration = fields.Float('预留时长', default=30, tracking=True)
|
||||||
|
|
||||||
def get_no(self):
|
def get_no(self):
|
||||||
international_standards = self.search(
|
international_standards = self.search(
|
||||||
[('code', '!=', ''), ('active', 'in', [True, False])],
|
[('code', '!=', ''), ('active', 'in', [True, False])],
|
||||||
@@ -78,3 +82,16 @@ class ResMrpRoutingWorkcenter(models.Model):
|
|||||||
else:
|
else:
|
||||||
workcenter_id = workcenter_ids[0]
|
workcenter_id = workcenter_ids[0]
|
||||||
return workcenter_id
|
return workcenter_id
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
|
||||||
|
if self._context.get('production_id'):
|
||||||
|
route_ids = []
|
||||||
|
technology_design = self.env['sf.technology.design'].search(
|
||||||
|
[('production_id', '=', self._context.get('production_id'))])
|
||||||
|
for t in technology_design.filtered(lambda a: a.routing_tag == 'special'):
|
||||||
|
if not t.process_parameters_id:
|
||||||
|
route_ids.append(t.route_id.surface_technics_id.id)
|
||||||
|
domain = [('id', 'not in', route_ids), ('routing_tag', '=', 'special')]
|
||||||
|
return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
|
||||||
|
return super()._name_search(name, args, operator, limit, name_get_uid)
|
||||||
|
|||||||
@@ -23,12 +23,15 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
|
|
||||||
product_tmpl_name = fields.Char('坯料产品名称', related='production_bom_id.bom_line_ids.product_id.name')
|
product_tmpl_name = fields.Char('坯料产品名称', related='production_bom_id.bom_line_ids.product_id.name')
|
||||||
|
|
||||||
product_tmpl_id_length = fields.Float(related='production_id.product_tmpl_id.length', readonly=True, store=True,
|
product_tmpl_id_length = fields.Float(string='坯料长度(mm)', related='material_length', readonly=True, store=False)
|
||||||
string="坯料长度(mm)")
|
product_tmpl_id_width = fields.Float(string='坯料宽度(mm)', related='material_width', readonly=True, store=False)
|
||||||
product_tmpl_id_width = fields.Float(related='production_id.product_tmpl_id.width', readonly=True, store=True,
|
product_tmpl_id_height = fields.Float(string='坯料高度(mm)', related='material_height', readonly=True, store=False)
|
||||||
string="坯料宽度(mm)")
|
# product_tmpl_id_length = fields.Float(related='production_id.product_tmpl_id.length', readonly=True, store=True,
|
||||||
product_tmpl_id_height = fields.Float(related='production_id.product_tmpl_id.height', readonly=True, store=True,
|
# string="坯料长度(mm)")
|
||||||
string="坯料高度(mm)")
|
# product_tmpl_id_width = fields.Float(related='production_id.product_tmpl_id.width', readonly=True, store=True,
|
||||||
|
# string="坯料宽度(mm)")
|
||||||
|
# product_tmpl_id_height = fields.Float(related='production_id.product_tmpl_id.height', readonly=True, store=True,
|
||||||
|
# string="坯料高度(mm)")
|
||||||
product_tmpl_id_materials_id = fields.Many2one(related='production_id.product_tmpl_id.materials_id', readonly=True,
|
product_tmpl_id_materials_id = fields.Many2one(related='production_id.product_tmpl_id.materials_id', readonly=True,
|
||||||
store=True, check_company=True, string="材料")
|
store=True, check_company=True, string="材料")
|
||||||
product_tmpl_id_materials_type_id = fields.Many2one(related='production_id.product_tmpl_id.materials_type_id',
|
product_tmpl_id_materials_type_id = fields.Many2one(related='production_id.product_tmpl_id.materials_type_id',
|
||||||
@@ -38,13 +41,10 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
processing_panel = fields.Char('加工面')
|
processing_panel = fields.Char('加工面')
|
||||||
sequence = fields.Integer(string='工序')
|
sequence = fields.Integer(string='工序')
|
||||||
routing_type = fields.Selection([
|
routing_type = fields.Selection([
|
||||||
# ('获取CNC加工程序', '获取CNC加工程序'),
|
|
||||||
('装夹预调', '装夹预调'),
|
('装夹预调', '装夹预调'),
|
||||||
# ('前置三元定位检测', '前置三元定位检测'),
|
|
||||||
('CNC加工', 'CNC加工'),
|
('CNC加工', 'CNC加工'),
|
||||||
# ('后置三元质量检测', '后置三元质量检测'),
|
|
||||||
('解除装夹', '解除装夹'),
|
('解除装夹', '解除装夹'),
|
||||||
('切割', '切割'), ('表面工艺', '表面工艺')
|
('切割', '切割'), ('表面工艺', '表面工艺'), ('线切割', '线切割'), ('人工线下加工', '人工线下加工')
|
||||||
], string="工序类型")
|
], string="工序类型")
|
||||||
results = fields.Char('结果')
|
results = fields.Char('结果')
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
@@ -129,7 +129,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
Y10_axis = fields.Float(default=0)
|
Y10_axis = fields.Float(default=0)
|
||||||
Z10_axis = fields.Float(default=0)
|
Z10_axis = fields.Float(default=0)
|
||||||
X_deviation_angle = fields.Integer(string="X轴偏差度", default=0)
|
X_deviation_angle = fields.Integer(string="X轴偏差度", default=0)
|
||||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
|
test_results = fields.Selection([("合格", "合格")], default='合格',
|
||||||
string="检测结果", tracking=True)
|
string="检测结果", tracking=True)
|
||||||
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工程序")
|
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工程序")
|
||||||
cmm_ids = fields.One2many("sf.cmm.program", 'workorder_id', string="CMM程序")
|
cmm_ids = fields.One2many("sf.cmm.program", 'workorder_id', string="CMM程序")
|
||||||
@@ -137,8 +137,10 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
glb_file = fields.Binary("glb模型文件", related='production_id.model_file')
|
glb_file = fields.Binary("glb模型文件", related='production_id.model_file')
|
||||||
is_subcontract = fields.Boolean(string='是否外协')
|
is_subcontract = fields.Boolean(string='是否外协')
|
||||||
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
||||||
picking_ids = fields.Many2many('stock.picking', string='外协出入库单')
|
|
||||||
# purchase_id = fields.Many2one('purchase.order', string='外协采购单')
|
picking_ids = fields.Many2many('stock.picking', string='外协出入库单', compute='_compute_surface_technics_picking_ids')
|
||||||
|
|
||||||
|
purchase_id = fields.Many2many('purchase.order', string='外协采购单')
|
||||||
surface_technics_picking_count = fields.Integer("外协出入库", compute='_compute_surface_technics_picking_ids')
|
surface_technics_picking_count = fields.Integer("外协出入库", compute='_compute_surface_technics_picking_ids')
|
||||||
surface_technics_purchase_count = fields.Integer("外协采购", compute='_compute_surface_technics_purchase_ids')
|
surface_technics_purchase_count = fields.Integer("外协采购", compute='_compute_surface_technics_purchase_ids')
|
||||||
|
|
||||||
@@ -146,21 +148,107 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
is_trayed = fields.Boolean(string='是否绑定托盘', default=False)
|
is_trayed = fields.Boolean(string='是否绑定托盘', default=False)
|
||||||
|
|
||||||
tag_type = fields.Selection([("重新加工", "重新加工")], string="标签", tracking=True)
|
tag_type = fields.Selection([("重新加工", "重新加工")], string="标签", tracking=True)
|
||||||
|
technology_design_id = fields.Many2one('sf.technology.design')
|
||||||
|
|
||||||
|
def _compute_default_construction_period_status(self):
|
||||||
|
need_list = ['pending', 'waiting', 'ready', 'progress', 'to be detected', 'done']
|
||||||
|
try:
|
||||||
|
if self.state not in need_list:
|
||||||
|
return False
|
||||||
|
if not self.date_planned_finished:
|
||||||
|
return False
|
||||||
|
hours = self.get_hours_diff()
|
||||||
|
if hours >= 12:
|
||||||
|
return '正常'
|
||||||
|
elif hours > 0 and hours < 12 and self.state != 'done':
|
||||||
|
return '预警'
|
||||||
|
elif hours > 0 and hours < 12 and self.state == 'done':
|
||||||
|
return '正常'
|
||||||
|
else:
|
||||||
|
return '已逾期'
|
||||||
|
except Exception as e:
|
||||||
|
logging.error("Error processing production ID {}: {}".format(self.id, e))
|
||||||
|
raise e
|
||||||
|
|
||||||
|
@api.depends('state', 'date_planned_finished')
|
||||||
|
def _compute_construction_period_status(self):
|
||||||
|
for worker in self:
|
||||||
|
construction_period_status = worker._compute_default_construction_period_status()
|
||||||
|
if construction_period_status and worker.construction_period_status != construction_period_status:
|
||||||
|
worker.construction_period_status = construction_period_status
|
||||||
|
|
||||||
|
construction_period_status = fields.Selection([('正常', '正常'), ('预警', '预警'), ('已逾期', '已逾期')],
|
||||||
|
string='工期状态',
|
||||||
|
store=True,
|
||||||
|
compute='_compute_construction_period_status',
|
||||||
|
default=lambda
|
||||||
|
self: self._compute_default_construction_period_status())
|
||||||
|
|
||||||
|
def get_page_all_records(self, model_name, func, domain, page_size=100):
|
||||||
|
# 获取模型对象
|
||||||
|
model = self.env[model_name].sudo()
|
||||||
|
|
||||||
|
# 初始化分页参数
|
||||||
|
page_number = 1
|
||||||
|
while True:
|
||||||
|
# 计算偏移量
|
||||||
|
offset = (page_number - 1) * page_size
|
||||||
|
|
||||||
|
# 获取当前页的数据
|
||||||
|
records = model.search(domain, limit=page_size, offset=offset)
|
||||||
|
|
||||||
|
# 如果没有更多记录,退出循环
|
||||||
|
if not records:
|
||||||
|
break
|
||||||
|
|
||||||
|
# 将当前页的数据添加到结果列表
|
||||||
|
func(records)
|
||||||
|
# 增加页码
|
||||||
|
page_number += 1
|
||||||
|
|
||||||
|
def run_compute_construction_period_status(self, records):
|
||||||
|
records._compute_construction_period_status()
|
||||||
|
|
||||||
|
def _corn_update_construction_period_status(self):
|
||||||
|
need_list = ['pending', 'waiting', 'ready', 'progress', 'to be detected']
|
||||||
|
# need_list = [
|
||||||
|
# 'progress',
|
||||||
|
# 'to be detected']
|
||||||
|
self.get_page_all_records('mrp.workorder', self.run_compute_construction_period_status,
|
||||||
|
[('state', 'in', need_list)], 100)
|
||||||
|
|
||||||
|
def get_hours_diff(self):
|
||||||
|
# 获取当前日期和时间
|
||||||
|
current_datetime = fields.Datetime.now()
|
||||||
|
|
||||||
|
# 将 date_field 转换为 datetime 对象
|
||||||
|
if self.date_planned_finished:
|
||||||
|
date_obj = fields.Datetime.from_string(self.date_planned_finished)
|
||||||
|
# 将 date 对象转换为 datetime 对象,设置时间为 00:00:00
|
||||||
|
# date_obj = datetime.datetime.combine(date_obj, datetime.time.min)
|
||||||
|
|
||||||
|
# 计算两个日期之间的差值
|
||||||
|
delta = date_obj - current_datetime
|
||||||
|
|
||||||
|
# 返回差值的小时数
|
||||||
|
return int(delta.total_seconds() / 3600)
|
||||||
|
else:
|
||||||
|
return 0.0
|
||||||
|
|
||||||
@api.depends('name', 'production_id.name')
|
@api.depends('name', 'production_id.name')
|
||||||
def _compute_surface_technics_picking_ids(self):
|
def _compute_surface_technics_picking_ids(self):
|
||||||
for workorder in self:
|
for workorder in self:
|
||||||
if workorder.routing_type == '表面工艺':
|
if workorder.routing_type == '表面工艺':
|
||||||
domain = [('origin', '=', workorder.production_id.name)]
|
domain = [('origin', '=', workorder.production_id.name), ('state', 'not in', ['cancel']),
|
||||||
|
('partner_id', '=', workorder.supplier_id.id)]
|
||||||
previous_workorder = self.env['mrp.workorder'].search(
|
previous_workorder = self.env['mrp.workorder'].search(
|
||||||
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
||||||
('production_id', '=', workorder.production_id.id)])
|
('production_id', '=', workorder.production_id.id)])
|
||||||
if previous_workorder:
|
# if previous_workorder:
|
||||||
process_product = self.env['product.template']._get_process_parameters_product(
|
# if previous_workorder.supplier_id != workorder.supplier_id:
|
||||||
previous_workorder.surface_technics_parameters_id)
|
# domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
|
||||||
domain += [('partner_id', '=', process_product.partner_id.id)]
|
# else:
|
||||||
else:
|
domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
|
||||||
domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
|
|
||||||
picking_ids = self.env['stock.picking'].search(domain, order='id asc')
|
picking_ids = self.env['stock.picking'].search(domain, order='id asc')
|
||||||
workorder.surface_technics_picking_count = len(picking_ids)
|
workorder.surface_technics_picking_count = len(picking_ids)
|
||||||
workorder.picking_ids = picking_ids.ids
|
workorder.picking_ids = picking_ids.ids
|
||||||
@@ -184,34 +272,72 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
@api.depends('state', 'production_id.name')
|
@api.depends('state', 'production_id.name')
|
||||||
def _compute_surface_technics_purchase_ids(self):
|
def _compute_surface_technics_purchase_ids(self):
|
||||||
for order in self:
|
for order in self:
|
||||||
if order.routing_type == '表面工艺':
|
if order.routing_type == '表面工艺' and order.state not in ['cancel']:
|
||||||
production_programming = self.env['mrp.production'].search(
|
# if order.production_id.production_type == '自动化产线加工':
|
||||||
[('programming_no', '=', order.production_id.programming_no)], order='name asc')
|
# domain = [('programming_no', '=', order.production_id.programming_no)]
|
||||||
production_no_remanufacture = production_programming.filtered(lambda a: a.is_remanufacture is False)
|
# else:buzhdiao
|
||||||
production_list = [production.name for production in production_programming]
|
# domain = [('origin', '=', order.production_id.origin)]
|
||||||
purchase = self.env['purchase.order'].search([('origin', '=', ','.join(production_list))])
|
# production_programming = self.env['mrp.production'].search(domain, order='name asc')
|
||||||
for line in purchase.order_line:
|
# production_list = [production.name for production in production_programming]
|
||||||
if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id and line.product_qty == len(
|
# production_no_remanufacture = production_programming.filtered(lambda a: a.is_remanufacture is False)
|
||||||
production_no_remanufacture):
|
# technology_design = self.env['sf.technology.design'].search(
|
||||||
order.surface_technics_purchase_count = len(purchase)
|
# [('process_parameters_id', '=', order.surface_technics_parameters_id.id),
|
||||||
|
# ('production_id', '=', order.production_id.id)])
|
||||||
|
# if technology_design.is_auto is False:
|
||||||
|
# domain = [('origin', '=', order.production_id.name)]
|
||||||
|
# else:
|
||||||
|
domain = [('purchase_type', '=', 'consignment'), ('origin', '=', order.production_id.name),
|
||||||
|
('state', '!=', 'cancel')]
|
||||||
|
purchase = self.env['purchase.order'].search(domain)
|
||||||
|
purchase_num = 0
|
||||||
|
if not purchase:
|
||||||
|
order.surface_technics_purchase_count = 0
|
||||||
|
for po in purchase:
|
||||||
|
for line in po.order_line:
|
||||||
|
if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id:
|
||||||
|
if line.product_qty == 1:
|
||||||
|
purchase_num += 1
|
||||||
|
order.surface_technics_purchase_count = purchase_num
|
||||||
else:
|
else:
|
||||||
order.surface_technics_purchase_count = 0
|
order.surface_technics_purchase_count = 0
|
||||||
|
|
||||||
def action_view_surface_technics_purchase(self):
|
def action_view_surface_technics_purchase(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
production_programming = self.env['mrp.production'].search(
|
# if self.routing_type == '表面工艺':
|
||||||
[('programming_no', '=', self.production_id.programming_no)], order='name asc')
|
# if self.production_id.production_type == '自动化产线加工':
|
||||||
production_list = [production.name for production in production_programming]
|
# domain = [('programming_no', '=', self.production_id.programming_no)]
|
||||||
purchase_orders = self.env['purchase.order'].search([('origin', '=', ','.join(production_list))])
|
# else:
|
||||||
|
# domain = [('origin', '=', self.production_id.origin)]
|
||||||
|
# production_programming = self.env['mrp.production'].search(domain, order='name asc')
|
||||||
|
# production_list = [production.name for production in production_programming]
|
||||||
|
# production_no_remanufacture = production_programming.filtered(lambda a: a.is_remanufacture is False)
|
||||||
|
# technology_design = self.env['sf.technology.design'].search(
|
||||||
|
# [('process_parameters_id', '=', self.surface_technics_parameters_id.id),
|
||||||
|
# ('production_id', '=', self.production_id.id)])
|
||||||
|
# if technology_design.is_auto is False:
|
||||||
|
# domain = [('origin', '=', self.production_id.name)]
|
||||||
|
# else:
|
||||||
|
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||||
result = {
|
result = {
|
||||||
"type": "ir.actions.act_window",
|
"type": "ir.actions.act_window",
|
||||||
"res_model": "purchase.order",
|
"res_model": "purchase.order",
|
||||||
"res_id": purchase_orders.id,
|
"res_id": purchase_orders_id.id,
|
||||||
# "domain": [['id', 'in', self.purchase_id]],
|
# "domain": [['id', 'in', self.purchase_id]],
|
||||||
"name": _("Purchase Orders"),
|
"name": _("Purchase Orders"),
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def _get_surface_technics_purchase_ids(self):
|
||||||
|
domain = [('origin', '=', self.production_id.name), ('purchase_type', '=', 'consignment')]
|
||||||
|
purchase_orders = self.env['purchase.order'].search(domain)
|
||||||
|
purchase_orders_id = self.env['purchase.order']
|
||||||
|
for po in purchase_orders:
|
||||||
|
for line in po.order_line:
|
||||||
|
if line.product_id.server_product_process_parameters_id == self.surface_technics_parameters_id:
|
||||||
|
if line.product_qty == 1:
|
||||||
|
purchase_orders_id = line.order_id
|
||||||
|
return purchase_orders_id
|
||||||
|
|
||||||
supplier_id = fields.Many2one('res.partner', string='外协供应商')
|
supplier_id = fields.Many2one('res.partner', string='外协供应商')
|
||||||
equipment_id = fields.Many2one('maintenance.equipment', string='加工设备', tracking=True)
|
equipment_id = fields.Many2one('maintenance.equipment', string='加工设备', tracking=True)
|
||||||
@@ -228,6 +354,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
part_number = fields.Char(related='production_id.part_number', string='零件图号')
|
part_number = fields.Char(related='production_id.part_number', string='零件图号')
|
||||||
machining_drawings = fields.Binary('2D加工图纸', related='production_id.part_drawing', readonly=True)
|
machining_drawings = fields.Binary('2D加工图纸', related='production_id.part_drawing', readonly=True)
|
||||||
quality_standard = fields.Binary('质检标准', related='production_id.quality_standard', readonly=True)
|
quality_standard = fields.Binary('质检标准', related='production_id.quality_standard', readonly=True)
|
||||||
|
part_name = fields.Char(related='production_id.part_name', string='零件名称')
|
||||||
|
|
||||||
# 工序状态
|
# 工序状态
|
||||||
process_state = fields.Selection([
|
process_state = fields.Selection([
|
||||||
@@ -279,8 +406,11 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
保存名称
|
保存名称
|
||||||
"""
|
"""
|
||||||
for record in self:
|
for record in self:
|
||||||
tem_name = record.production_id.name.replace('/', '_')
|
if record.processing_panel:
|
||||||
record.save_name = tem_name + '_' + record.processing_panel
|
tem_name = record.production_id.name.replace('/', '_')
|
||||||
|
record.save_name = tem_name + '_' + record.processing_panel
|
||||||
|
else:
|
||||||
|
record.save_name = ''
|
||||||
|
|
||||||
schedule_state = fields.Selection(related='production_id.schedule_state', store=True)
|
schedule_state = fields.Selection(related='production_id.schedule_state', store=True)
|
||||||
# 工件装夹信息
|
# 工件装夹信息
|
||||||
@@ -306,6 +436,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
is_delivery = fields.Boolean('是否配送完成', default=False)
|
is_delivery = fields.Boolean('是否配送完成', default=False)
|
||||||
rfid_code = fields.Char('RFID码')
|
rfid_code = fields.Char('RFID码')
|
||||||
rfid_code_old = fields.Char('RFID码(已解除)')
|
rfid_code_old = fields.Char('RFID码(已解除)')
|
||||||
|
is_test_env = fields.Boolean('测试环境', default=False)
|
||||||
|
|
||||||
production_line_id = fields.Many2one('sf.production.line', related='production_id.production_line_id',
|
production_line_id = fields.Many2one('sf.production.line', related='production_id.production_line_id',
|
||||||
string='生产线', store=True, tracking=True)
|
string='生产线', store=True, tracking=True)
|
||||||
@@ -321,9 +452,13 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
detailed_reason = fields.Text('详细原因')
|
detailed_reason = fields.Text('详细原因')
|
||||||
is_rework = fields.Boolean(string='是否返工', default=False)
|
is_rework = fields.Boolean(string='是否返工', default=False)
|
||||||
|
|
||||||
|
def button_change_env(self):
|
||||||
|
self.is_test_env = not self.is_test_env
|
||||||
|
|
||||||
@api.constrains('blocked_by_workorder_ids')
|
@api.constrains('blocked_by_workorder_ids')
|
||||||
def _check_no_cyclic_dependencies(self):
|
def _check_no_cyclic_dependencies(self):
|
||||||
if self.production_id.state not in ['rework'] and self.state not in ['rework']:
|
if self.production_id.state not in ['rework', 'technology_to_confirmed', 'confirmed'] and self.state not in [
|
||||||
|
'rework']:
|
||||||
if not self._check_m2m_recursion('blocked_by_workorder_ids'):
|
if not self._check_m2m_recursion('blocked_by_workorder_ids'):
|
||||||
raise ValidationError(_("您不能创建周期性的依赖关系."))
|
raise ValidationError(_("您不能创建周期性的依赖关系."))
|
||||||
|
|
||||||
@@ -334,8 +469,9 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
for workorder in self.blocked_by_workorder_ids:
|
for workorder in self.blocked_by_workorder_ids:
|
||||||
if workorder.state in ['done', 'cancel', 'rework']:
|
if workorder.state in ['done', 'cancel', 'rework']:
|
||||||
continue
|
continue
|
||||||
workorder._plan_workorder(replan)
|
if workorder.production_id.state not in ['technology_to_confirmed', 'confirmed']:
|
||||||
start_date = max(start_date, workorder.date_planned_finished)
|
workorder._plan_workorder(replan)
|
||||||
|
start_date = max(start_date, workorder.date_planned_finished)
|
||||||
# Plan only suitable workorders
|
# Plan only suitable workorders
|
||||||
if self.state not in ['pending', 'waiting', 'ready']:
|
if self.state not in ['pending', 'waiting', 'ready']:
|
||||||
return
|
return
|
||||||
@@ -665,35 +801,14 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
# 拼接工单对象属性值
|
# 拼接工单对象属性值
|
||||||
def json_workorder_str(self, k, production, route, item):
|
def json_workorder_str(self, production, route):
|
||||||
# 计算预计时长duration_expected
|
# 计算预计时长duration_expected
|
||||||
routing_types = ['切割', '装夹预调', 'CNC加工', '解除装夹']
|
routing_types = ['切割', '装夹预调', 'CNC加工', '解除装夹']
|
||||||
if route.routing_type in routing_types:
|
if route.route_id.routing_type in routing_types:
|
||||||
routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(
|
routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
[('name', '=', route.routing_type)])
|
[('name', '=', route.routing_type if hasattr(route, 'routing_type') else route.route_id.routing_type)])
|
||||||
duration_expected = routing_workcenter.time_cycle
|
duration_expected = routing_workcenter.time_cycle
|
||||||
reserved_duration = routing_workcenter.reserved_duration
|
reserved_duration = routing_workcenter.reserved_duration
|
||||||
# if route.routing_type == '切割':
|
|
||||||
# duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# [('name', '=', '切割')]).time_cycle
|
|
||||||
# # elif route.routing_type == '获取CNC加工程序':
|
|
||||||
# # duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# # [('name', '=', '获取CNC加工程序')]).time_cycle
|
|
||||||
# elif route.routing_type == '装夹预调':
|
|
||||||
# duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# [('name', '=', '装夹预调')]).time_cycle
|
|
||||||
# # elif route.routing_type == '前置三元定位检测':
|
|
||||||
# # duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# # [('name', '=', '前置三元定位检测')]).time_cycle
|
|
||||||
# elif route.routing_type == 'CNC加工':
|
|
||||||
# duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# [('name', '=', 'CNC加工')]).time_cycle
|
|
||||||
# # elif route.routing_type == '后置三元质量检测':
|
|
||||||
# # duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# # [('name', '=', '后置三元质量检测')]).time_cycle
|
|
||||||
# elif route.routing_type == '解除装夹':
|
|
||||||
# duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# [('name', '=', '解除装夹')]).time_cycle
|
|
||||||
else:
|
else:
|
||||||
duration_expected = 60
|
duration_expected = 60
|
||||||
reserved_duration = 30
|
reserved_duration = 30
|
||||||
@@ -701,26 +816,22 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'product_uom_id': production.product_uom_id.id,
|
'product_uom_id': production.product_uom_id.id,
|
||||||
'qty_producing': 0,
|
'qty_producing': 0,
|
||||||
'operation_id': False,
|
'operation_id': False,
|
||||||
'name': route.route_workcenter_id.name,
|
'name': route.name if hasattr(route, 'routing_type') else route.route_id.name,
|
||||||
'processing_panel': k,
|
'processing_panel': False if hasattr(route, 'routing_type') else route.panel,
|
||||||
'quality_point_ids': route.route_workcenter_id.quality_point_ids,
|
'sequence': route.sequence,
|
||||||
'routing_type': route.routing_type,
|
'quality_point_ids': False if hasattr(route, 'routing_type') else route.route_id.quality_point_ids,
|
||||||
# 'work_state': '待发起',
|
'routing_type': route.routing_type if hasattr(route, 'routing_type') else route.route_id.routing_type,
|
||||||
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
|
'workcenter_id': False if hasattr(route, 'routing_type') else self.env[
|
||||||
route.routing_type,
|
'mrp.routing.workcenter'].get_workcenter(route.route_id.workcenter_ids.ids,
|
||||||
production.product_id),
|
route.route_id.routing_type,
|
||||||
|
production.product_id),
|
||||||
# 设定初始化值,避免出现变成bool问题
|
# 设定初始化值,避免出现变成bool问题
|
||||||
'date_planned_start': datetime.now(),
|
'date_planned_start': datetime.now(),
|
||||||
'date_planned_finished': datetime.now() + timedelta(days=1),
|
'date_planned_finished': datetime.now() + timedelta(days=1),
|
||||||
'duration_expected': duration_expected,
|
'duration_expected': duration_expected,
|
||||||
'duration': 0,
|
'duration': 0,
|
||||||
'tag_type': '重新加工' if item is False else False,
|
'technology_design_id': route.id,
|
||||||
'cnc_ids': False if route.routing_type != 'CNC加工' else self.env['sf.cnc.processing']._json_cnc_processing(
|
# 'tag_type': '重新加工' if item is False else False,
|
||||||
k, item),
|
|
||||||
'cmm_ids': False if route.routing_type != 'CNC加工' else self.env['sf.cmm.program']._json_cmm_program(k,
|
|
||||||
item),
|
|
||||||
# 'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self._json_workpiece_delivery_list(
|
|
||||||
# production)
|
|
||||||
'reserved_duration': reserved_duration,
|
'reserved_duration': reserved_duration,
|
||||||
}]
|
}]
|
||||||
return workorders_values_str
|
return workorders_values_str
|
||||||
@@ -751,22 +862,24 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
]
|
]
|
||||||
|
|
||||||
# 拼接工单对象属性值(表面工艺)
|
# 拼接工单对象属性值(表面工艺)
|
||||||
def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id):
|
def _json_workorder_surface_process_str(self, production, route, supplier_id):
|
||||||
workorders_values_str = [0, '', {
|
workorders_values_str = [0, '', {
|
||||||
'product_uom_id': production.product_uom_id.id,
|
'product_uom_id': production.product_uom_id.id,
|
||||||
'qty_producing': 0,
|
'qty_producing': 0,
|
||||||
'operation_id': False,
|
'operation_id': False,
|
||||||
'name': '%s-%s' % (route.name, process_parameter.name),
|
'name': route.process_parameters_id.display_name,
|
||||||
'processing_panel': '',
|
'processing_panel': '',
|
||||||
|
'sequence': route.sequence,
|
||||||
|
'technology_design_id': route.id,
|
||||||
'routing_type': '表面工艺',
|
'routing_type': '表面工艺',
|
||||||
'surface_technics_parameters_id': process_parameter.id,
|
'surface_technics_parameters_id': route.process_parameters_id.id,
|
||||||
'work_state': '',
|
'work_state': '',
|
||||||
'supplier_id': supplier_id,
|
'supplier_id': supplier_id,
|
||||||
'is_subcontract': True if process_parameter.gain_way == '外协' else False,
|
'is_subcontract': True if route.process_parameters_id.gain_way == '外协' else False,
|
||||||
'workcenter_id': self.env[
|
'workcenter_id': self.env[
|
||||||
'mrp.workcenter'].get_process_outsourcing_workcenter() if process_parameter.gain_way == '外协' else
|
'mrp.workcenter'].get_process_outsourcing_workcenter() if route.process_parameters_id.gain_way == '外协' else
|
||||||
self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
|
self.env['mrp.routing.workcenter'].get_workcenter(route.route_id.workcenter_ids.ids,
|
||||||
route.routing_type,
|
route.route_id.routing_type,
|
||||||
production.product_id),
|
production.product_id),
|
||||||
'date_planned_start': datetime.now(),
|
'date_planned_start': datetime.now(),
|
||||||
'date_planned_finished': datetime.now() + timedelta(days=1),
|
'date_planned_finished': datetime.now() + timedelta(days=1),
|
||||||
@@ -918,208 +1031,223 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
return workorders_values_str
|
return workorders_values_str
|
||||||
|
|
||||||
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
|
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
|
||||||
'production_id.tool_state')
|
'production_id.tool_state', 'production_id.schedule_state', 'sequence',
|
||||||
|
'production_id.programming_state')
|
||||||
def _compute_state(self):
|
def _compute_state(self):
|
||||||
super()._compute_state()
|
# super()._compute_state()
|
||||||
for workorder in self:
|
|
||||||
re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
|
|
||||||
('processing_panel', '=', workorder.processing_panel),
|
|
||||||
('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
|
|
||||||
cnc_workorder = self.env['mrp.workorder'].search(
|
|
||||||
[('production_id', '=', workorder.production_id.id),
|
|
||||||
('processing_panel', '=', workorder.processing_panel),
|
|
||||||
('routing_type', '=', 'CNC加工'), ('state', 'in', ['done', 'rework']),
|
|
||||||
('test_results', '=', '返工')])
|
|
||||||
cnc_workorder_pending = self.env['mrp.workorder'].search(
|
|
||||||
[('production_id', '=', workorder.production_id.id),
|
|
||||||
('processing_panel', '=', workorder.processing_panel),
|
|
||||||
('routing_type', '=', 'CNC加工'), ('state', 'in', ['pending'])])
|
|
||||||
unclamp_workorder = self.env['mrp.workorder'].search(
|
|
||||||
[('production_id', '=', workorder.production_id.id),
|
|
||||||
('sequence', '=', workorder.sequence - 1),
|
|
||||||
('state', 'in', ['done'])])
|
|
||||||
if workorder.state not in ['cancel', 'progress', 'rework']:
|
|
||||||
if workorder.production_id.state == 'rework':
|
|
||||||
if workorder.routing_type == '装夹预调' and workorder.state not in ['done', 'rework',
|
|
||||||
'cancel']:
|
|
||||||
# # 有返工工单
|
|
||||||
# if re_work:
|
|
||||||
# 新工单
|
|
||||||
if workorder.is_rework is False:
|
|
||||||
if workorder.production_id.programming_state == '已编程' and workorder.production_id.is_rework is False:
|
|
||||||
if re_work or cnc_workorder:
|
|
||||||
workorder.state = 'ready'
|
|
||||||
else:
|
|
||||||
if workorder.production_id.is_rework is True:
|
|
||||||
if re_work or cnc_workorder:
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
|
|
||||||
elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'rework', 'cancel']:
|
|
||||||
pre_workorder = self.env['mrp.workorder'].search(
|
|
||||||
[('production_id', '=', workorder.production_id.id),
|
|
||||||
('processing_panel', '=', workorder.processing_panel),
|
|
||||||
('routing_type', '=', '装夹预调'), ('state', '=', 'done')])
|
|
||||||
if pre_workorder:
|
|
||||||
if re_work:
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
elif workorder.routing_type == '解除装夹' and workorder.state not in ['done', 'rework', 'cancel']:
|
|
||||||
if cnc_workorder:
|
|
||||||
if not cnc_workorder_pending or unclamp_workorder.test_results == '报废':
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
# else:
|
|
||||||
# if workorder.production_id.is_rework is True:
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
elif workorder.production_id.state == 'progress':
|
|
||||||
if workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已编程' and \
|
|
||||||
workorder.is_rework is False and workorder.state not in [
|
|
||||||
'done', 'rework',
|
|
||||||
'cancel']:
|
|
||||||
if workorder.production_id.is_rework is False:
|
|
||||||
if re_work or cnc_workorder or unclamp_workorder:
|
|
||||||
workorder.state = 'ready'
|
|
||||||
# if (re_work or cnc_workorder) and workorder.production_id.is_rework is False:
|
|
||||||
# workorder.state = 'ready'
|
|
||||||
if workorder.routing_type == '表面工艺' and workorder.state not in ['done', 'progress']:
|
|
||||||
if unclamp_workorder:
|
|
||||||
if workorder.is_subcontract is False:
|
|
||||||
workorder.state = 'ready'
|
|
||||||
else:
|
|
||||||
production_programming = self.env['mrp.production'].search(
|
|
||||||
[('programming_no', '=', self.production_id.programming_no)], order='name asc')
|
|
||||||
production_no_remanufacture = production_programming.filtered(
|
|
||||||
lambda a: a.is_remanufacture is False)
|
|
||||||
production_list = [production.name for production in production_programming]
|
|
||||||
purchase_orders = self.env['purchase.order'].search(
|
|
||||||
[('origin', 'ilike', ','.join(production_list))])
|
|
||||||
for line in purchase_orders.order_line:
|
|
||||||
if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id and line.product_qty == len(
|
|
||||||
production_no_remanufacture):
|
|
||||||
if purchase_orders.state == 'purchase':
|
|
||||||
workorder.state = 'ready'
|
|
||||||
else:
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
elif workorder.production_id.state == 'scrap':
|
|
||||||
if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']:
|
|
||||||
workorder_ids = workorder.production_id.workorder_ids
|
|
||||||
work_bo = True
|
|
||||||
for wo in workorder_ids.filtered(lambda a: a.routing_type == '装夹预调' and a.state == 'rework'):
|
|
||||||
if not workorder_ids.filtered(
|
|
||||||
lambda a: (a.routing_type == '装夹预调' and a.state not in ['rework', 'cancel']
|
|
||||||
and a.processing_panel == wo.processing_panel)):
|
|
||||||
work_bo = False
|
|
||||||
break
|
|
||||||
if (workorder.production_id.programming_state == '已编程' and work_bo
|
|
||||||
and not workorder_ids.filtered(lambda a: a.sequence == 0)):
|
|
||||||
# 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
|
|
||||||
if workorder.production_id.tool_state in ['1', '2']:
|
|
||||||
if workorder.state in ['ready']:
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
continue
|
|
||||||
elif workorder.state in ['waiting']:
|
|
||||||
continue
|
|
||||||
elif workorder.state == 'pending' and workorder == self.search(
|
|
||||||
[('production_id', '=', workorder.production_id.id),
|
|
||||||
('routing_type', '=', '装夹预调'),
|
|
||||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
|
||||||
limit=1,
|
|
||||||
order="sequence"):
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
continue
|
|
||||||
elif workorder.production_id.tool_state in ['0']:
|
|
||||||
if workorder_ids.filtered(lambda a: a.state == 'rework'):
|
|
||||||
if not workorder_ids.filtered(
|
|
||||||
lambda a: (a.routing_type not in ['装夹预调'] and
|
|
||||||
a.state not in ['pending', 'done', 'rework', 'cancel'])):
|
|
||||||
# 查询工序最小的非完工、非返工的装夹预调工单
|
|
||||||
work_id = self.search(
|
|
||||||
[('production_id', '=', workorder.production_id.id),
|
|
||||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
|
||||||
limit=1,
|
|
||||||
order="sequence")
|
|
||||||
if work_id.routing_type == '装夹预调':
|
|
||||||
if workorder == work_id:
|
|
||||||
if workorder.production_id.reservation_state == 'assigned':
|
|
||||||
workorder.state = 'ready'
|
|
||||||
elif workorder.production_id.reservation_state != 'assigned':
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
continue
|
|
||||||
elif (workorder.name == '装夹预调' and
|
|
||||||
workorder.state not in ['rework', 'done', 'cancel']):
|
|
||||||
if workorder.state != 'pending':
|
|
||||||
workorder.state = 'pending'
|
|
||||||
if workorder.production_id.tool_state in ['1', '2'] and workorder.state == 'ready':
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
continue
|
|
||||||
if (workorder.production_id.tool_state in ['1', '2']
|
|
||||||
and not workorder.production_id.workorder_ids.filtered(lambda a: a.sequence == 0)
|
|
||||||
and workorder.production_id.programming_state == '编程中' and workorder.name == '装夹预调'):
|
|
||||||
if workorder.state == 'pending' and workorder == self.search(
|
|
||||||
[('production_id', '=', workorder.production_id.id),
|
|
||||||
('routing_type', '=', '装夹预调'),
|
|
||||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
|
||||||
limit=1,
|
|
||||||
order="sequence"):
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
continue
|
|
||||||
|
|
||||||
# elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'cancel', 'progress',
|
|
||||||
# 'rework']:
|
|
||||||
# per_work = self.env['mrp.workorder'].search(
|
|
||||||
# [('routing_type', '=', '装夹预调'), ('production_id', '=', workorder.production_id.id),
|
|
||||||
# ('processing_panel', '=', workorder.processing_panel), ('is_rework', '=', True)])
|
|
||||||
# if per_work:
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
# if workorder.routing_type == 'CNC加工' and workorder.state == 'progress':
|
|
||||||
# workorder.state = 'to be detected'
|
|
||||||
|
|
||||||
# for workorder in self:
|
# for workorder in self:
|
||||||
# if workorder.is_rework is True and workorder.state == 'done':
|
# if workorder.sequence != 1:
|
||||||
# cnc_work = self.env['mrp.workorder'].search([('routing_type','=','CNC加工'),('production_id','=',workorder.production_id.id)])
|
# previous_workorder = self.env['mrp.workorder'].search(
|
||||||
# if cnc_work:
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
# cnc_work.state = 'waiting'
|
# ('sequence', '=', workorder.sequence - 1)])
|
||||||
# if workorder.state == 'pending':
|
# if workorder.state == 'pending':
|
||||||
# if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
# if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
||||||
# workorder.state = 'ready' if workorder.production_id.reservation_state == 'assigned' else 'waiting'
|
# if workorder.production_id.reservation_state == 'assigned' and workorder.production_id.schedule_state == '已排':
|
||||||
# continue
|
# if ((workorder.sequence == 1 and not workorder.blocked_by_workorder_ids)
|
||||||
|
# or (workorder.blocked_by_workorder_ids.state in ('done', 'cancel')
|
||||||
|
# and workorder.blocked_by_workorder_ids.test_results not in ['报废', '返工'])
|
||||||
|
# or (previous_workorder.state in ('done', 'cancel')
|
||||||
|
# and not workorder.blocked_by_workorder_ids
|
||||||
|
# and previous_workorder.test_results not in ['报废', '返工'])
|
||||||
|
# ):
|
||||||
|
# workorder.state = 'ready'
|
||||||
|
# continue
|
||||||
|
# if workorder.production_id.schedule_state == '未排' and workorder.state in ('waiting', 'ready'):
|
||||||
|
# if workorder.sequence != 1:
|
||||||
|
# workorder.state = 'pending'
|
||||||
|
# continue
|
||||||
# if workorder.state not in ('waiting', 'ready'):
|
# if workorder.state not in ('waiting', 'ready'):
|
||||||
# continue
|
# continue
|
||||||
|
# if workorder.state in (
|
||||||
|
# 'waiting') and workorder.sequence == 1 and workorder.production_id.schedule_state == '已排':
|
||||||
|
# workorder.state = 'ready'
|
||||||
|
# continue
|
||||||
# if not all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
# if not all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
||||||
# workorder.state = 'pending'
|
# workorder.state = 'pending'
|
||||||
|
# if workorder.state in ['waiting']:
|
||||||
|
# if previous_workorder.state == 'waiting':
|
||||||
|
# workorder.state = 'pending'
|
||||||
|
# if workorder.sequence == 1 and workorder.state == 'pending':
|
||||||
|
# workorder.state = 'waiting'
|
||||||
# continue
|
# continue
|
||||||
# if workorder.production_id.reservation_state not in ('waiting', 'confirmed', 'assigned'):
|
# if workorder.production_id.reservation_state not in ('waiting', 'confirmed', 'assigned'):
|
||||||
# continue
|
# continue
|
||||||
# if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting':
|
# if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting' and workorder.production_id.schedule_state == '已排':
|
||||||
# workorder.state = 'ready'
|
# workorder.state = 'ready'
|
||||||
# elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
|
# elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
|
||||||
# workorder.state = 'waiting'
|
# workorder.state = 'waiting'
|
||||||
|
|
||||||
|
for workorder in self:
|
||||||
|
# 如果工单的工序没有进行排序则跳出循环
|
||||||
|
if workorder.production_id.workorder_ids.filtered(lambda wk: wk.sequence == 0):
|
||||||
|
continue
|
||||||
|
# ===== 对所有按序号排序的非[进行中、完成、返工、取消]状态的工单,除了第一条之外的工单状态都设置为[等待其他工单] =====
|
||||||
|
# logging.info(workorder.state)
|
||||||
|
work_ids = workorder.production_id.workorder_ids.filtered(
|
||||||
|
lambda wk: wk.state not in ['done', 'rework', 'cancel'])
|
||||||
|
if not work_ids:
|
||||||
|
continue
|
||||||
|
min_sequence_wk = min(work_ids, key=lambda wk: wk.sequence)
|
||||||
|
if workorder.state in ['done', 'rework', 'cancel', 'progress', 'to be detected']:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if workorder != min_sequence_wk:
|
||||||
|
if workorder.state != 'pending':
|
||||||
|
workorder.state = 'pending'
|
||||||
|
continue
|
||||||
|
# ================= 如果制造订单制造类型为【人工线下加工】==========================
|
||||||
|
if (workorder.production_id.production_type == '人工线下加工'
|
||||||
|
and workorder.production_id.schedule_state == '已排'
|
||||||
|
and len(workorder.production_id.picking_ids.filtered(
|
||||||
|
lambda w: w.state not in ['done', 'cancel'])) == 0):
|
||||||
|
if workorder.is_subcontract is True:
|
||||||
|
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||||
|
if purchase_orders_id.state == 'purchase':
|
||||||
|
workorder.state = 'ready'
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
workorder.state = 'waiting'
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
workorder.state = 'ready'
|
||||||
|
continue
|
||||||
|
# ================= 如果制造订单刀具状态为[无效刀、缺刀] 或者 制造订单状态为[返工]==========================
|
||||||
|
if (workorder.production_id.tool_state in ['1', '2'] or workorder.production_id.state == 'rework'
|
||||||
|
or workorder.production_id.schedule_state != '已排'
|
||||||
|
or workorder.production_id.reservation_state not in ['assigned']
|
||||||
|
or workorder.production_id.workorder_ids.filtered(
|
||||||
|
lambda wk: wk.sequence == workorder.sequence - 1).test_results in ['报废', '返工']):
|
||||||
|
if workorder.state != 'waiting':
|
||||||
|
workorder.state = 'waiting'
|
||||||
|
continue
|
||||||
|
if workorder.production_id.programming_state == '已编程':
|
||||||
|
workorder.state = 'ready'
|
||||||
|
elif workorder.state != 'waiting':
|
||||||
|
workorder.state = 'waiting'
|
||||||
|
# =========== 特殊工艺工单处理 ===================
|
||||||
|
# if workorder.routing_type == '表面工艺' and workorder.is_subcontrac:
|
||||||
|
# purchase_order = self.env['purchase.order'].search(
|
||||||
|
# [('origin', 'ilike', workorder.production_id.name)])
|
||||||
|
# if purchase_order.picking_ids.filtered(lambda p: p.state in ['waiting', 'confirmed', 'assigned']):
|
||||||
|
# workorder.state = 'waiting'
|
||||||
|
# continue
|
||||||
|
if workorder.technology_design_id.routing_tag == 'special':
|
||||||
|
if workorder.is_subcontract is False:
|
||||||
|
workorder.state = 'ready'
|
||||||
|
else:
|
||||||
|
# production_programming = self.env['mrp.production'].search(
|
||||||
|
# [('origin', '=', self.production_id.origin)], order='name asc')
|
||||||
|
# production_no_remanufacture = production_programming.filtered(
|
||||||
|
# lambda a: a.is_remanufacture is False)
|
||||||
|
# production_list = [production.name for production in production_programming]
|
||||||
|
# purchase_orders = self.env['purchase.order'].search(
|
||||||
|
# [('origin', 'ilike', ','.join(production_list))])
|
||||||
|
# for line in purchase_orders.order_line:
|
||||||
|
# if (
|
||||||
|
# line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id
|
||||||
|
# and line.product_qty == len(production_no_remanufacture)):
|
||||||
|
# if all(pur_order.state == 'purchase' for pur_order in purchase_orders):
|
||||||
|
# workorder.state = 'ready'
|
||||||
|
# else:
|
||||||
|
# workorder.state = 'waiting'
|
||||||
|
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||||
|
if purchase_orders_id:
|
||||||
|
workorder.state = 'ready' if purchase_orders_id.state == 'purchase' else 'waiting'
|
||||||
|
else:
|
||||||
|
workorder.state = 'waiting'
|
||||||
|
|
||||||
|
# re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
|
||||||
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
|
# ('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
|
||||||
|
# cnc_workorder = self.env['mrp.workorder'].search(
|
||||||
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
|
# ('routing_type', '=', 'CNC加工'), ('state', 'in', ['done', 'rework']),
|
||||||
|
# ('test_results', '=', '返工')])
|
||||||
|
# cnc_workorder_pending = self.env['mrp.workorder'].search(
|
||||||
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
|
# ('routing_type', '=', 'CNC加工'), ('state', 'in', ['pending'])])
|
||||||
|
# unclamp_workorder = self.env['mrp.workorder'].search(
|
||||||
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
|
# ('sequence', '=', workorder.sequence - 1),
|
||||||
|
# ('state', 'in', ['done'])])
|
||||||
|
# if workorder.state not in ['cancel', 'progress', 'rework']:
|
||||||
|
# if workorder.production_id.state == 'rework':
|
||||||
|
# if workorder.routing_type == '装夹预调':
|
||||||
|
# # # 有返工工单
|
||||||
|
# # if re_work:
|
||||||
|
# # 新工单
|
||||||
|
# if workorder.is_rework is False:
|
||||||
|
# if (workorder.production_id.programming_state == '已编程'
|
||||||
|
# and workorder.production_id.is_rework is False):
|
||||||
|
# if re_work or cnc_workorder:
|
||||||
|
# workorder.state = 'ready'
|
||||||
|
# else:
|
||||||
|
# if workorder.production_id.is_rework is True:
|
||||||
|
# if re_work or cnc_workorder:
|
||||||
|
# workorder.state = 'waiting'
|
||||||
|
#
|
||||||
|
# elif workorder.routing_type == 'CNC加工':
|
||||||
|
# pre_workorder = self.env['mrp.workorder'].search(
|
||||||
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
|
# ('routing_type', '=', '装夹预调'), ('state', '=', 'done')])
|
||||||
|
# if pre_workorder:
|
||||||
|
# if re_work:
|
||||||
|
# workorder.state = 'waiting'
|
||||||
|
# elif workorder.routing_type == '解除装夹':
|
||||||
|
# if cnc_workorder:
|
||||||
|
# if not cnc_workorder_pending or unclamp_workorder.test_results == '报废':
|
||||||
|
# workorder.state = 'waiting'
|
||||||
|
# # else:
|
||||||
|
# # if workorder.production_id.is_rework is True:
|
||||||
|
# # workorder.state = 'waiting'
|
||||||
|
# elif workorder.production_id.state == 'progress':
|
||||||
|
# if (workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已编程'
|
||||||
|
# and workorder.is_rework is False and workorder.state not in ['done', 'rework', 'cancel']):
|
||||||
|
# if workorder.production_id.is_rework is False:
|
||||||
|
# if re_work or cnc_workorder or unclamp_workorder:
|
||||||
|
# workorder.state = 'ready'
|
||||||
|
# # if (re_work or cnc_workorder) and workorder.production_id.is_rework is False:
|
||||||
|
# # workorder.state = 'ready'
|
||||||
|
# elif workorder.production_id.state == 'scrap':
|
||||||
|
# if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
|
||||||
|
# workorder.state = 'waiting'
|
||||||
|
|
||||||
# 重写工单开始按钮方法
|
# 重写工单开始按钮方法
|
||||||
def button_start(self):
|
def button_start(self):
|
||||||
|
# 判断工单状态是否为等待组件
|
||||||
|
if self.state in ['waiting', 'pending']:
|
||||||
|
raise UserError('制造订单【%s】缺少组件信息!' % self.production_id.name)
|
||||||
|
|
||||||
if self.routing_type == 'CNC加工':
|
if self.routing_type == 'CNC加工':
|
||||||
self.env['sf.production.plan'].sudo().search([('name', '=', self.production_id.name)]).write({
|
self.env['sf.production.plan'].sudo().search([('name', '=', self.production_id.name)]).write({
|
||||||
'state': 'processing',
|
'state': 'processing',
|
||||||
'actual_start_time': datetime.now()
|
'actual_start_time': datetime.now()
|
||||||
})
|
})
|
||||||
|
|
||||||
if self.routing_type == '装夹预调':
|
if self.sequence == 1:
|
||||||
# 判断是否有坯料的序列号信息
|
# 判断是否有坯料的序列号信息
|
||||||
boolean = False
|
boolean = False
|
||||||
if self.production_id.move_raw_ids:
|
if self.production_id.move_raw_ids:
|
||||||
if self.production_id.move_raw_ids[0].move_line_ids:
|
if self.production_id.move_raw_ids[0].product_id.categ_type == '坯料':
|
||||||
if self.production_id.move_raw_ids[0].move_line_ids:
|
if self.production_id.move_raw_ids[0].move_line_ids:
|
||||||
if self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name:
|
if self.production_id.move_raw_ids[0].move_line_ids:
|
||||||
boolean = True
|
if self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name:
|
||||||
|
boolean = True
|
||||||
|
else:
|
||||||
|
boolean = True
|
||||||
if not boolean:
|
if not boolean:
|
||||||
raise UserError('制造订单【%s】缺少组件的序列号信息!' % self.production_id.name)
|
raise UserError('制造订单【%s】缺少组件的序列号信息!' % self.production_id.name)
|
||||||
self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name
|
self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name
|
||||||
# cnc校验
|
# cnc校验
|
||||||
cnc_workorder = self.search(
|
if self.production_id.production_type == '自动化产线加工':
|
||||||
[('production_id', '=', self.production_id.id), ('routing_type', '=', 'CNC加工')],
|
cnc_workorder = self.search(
|
||||||
limit=1, order='id asc')
|
[('production_id', '=', self.production_id.id), ('routing_type', '=', 'CNC加工')],
|
||||||
if not cnc_workorder.cnc_ids:
|
limit=1, order='id asc')
|
||||||
raise UserError(_('该制造订单还未下发CNC程序,请稍后再试'))
|
# if not cnc_workorder.cnc_ids:
|
||||||
|
# raise UserError(_('该制造订单还未下发CNC程序,请稍后再试'))
|
||||||
else:
|
else:
|
||||||
if self.production_id.tool_state in ['1', '2']:
|
if self.production_id.tool_state in ['1', '2']:
|
||||||
if self.production_id.tool_state == '1':
|
if self.production_id.tool_state == '1':
|
||||||
@@ -1136,15 +1264,33 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# 表面工艺外协出库单
|
# 表面工艺外协出库单
|
||||||
if self.routing_type == '表面工艺':
|
if self.routing_type == '表面工艺':
|
||||||
if self.is_subcontract is True:
|
if self.is_subcontract is True:
|
||||||
move_out = self.env['stock.move'].search(
|
move_out = self.move_subcontract_workorder_ids[1]
|
||||||
[('location_id', '=', self.env['stock.location'].search(
|
# move_out = self.env['stock.move'].search(
|
||||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
# [('location_id', '=', self.env['stock.location'].search(
|
||||||
('location_dest_id', '=', self.env['stock.location'].search(
|
# [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
||||||
[('barcode', 'ilike', 'VL-SPOC')]).id),
|
# ('location_dest_id', '=', self.env['stock.location'].search(
|
||||||
('origin', '=', self.production_id.name)])
|
# [('barcode', 'ilike', 'VL-SPOC')]).id),
|
||||||
if move_out.state != 'done':
|
# ('origin', '=', self.production_id.name), ('state', 'not in', ['cancel', 'done'])])
|
||||||
move_out.write({'state': 'assigned', 'production_id': False})
|
for mo in move_out:
|
||||||
self.env['stock.move.line'].create(move_out.get_move_line(self.production_id, self))
|
if mo.state != 'done':
|
||||||
|
mo.write({'state': 'assigned', 'production_id': False})
|
||||||
|
if not mo.move_line_ids:
|
||||||
|
self.env['stock.move.line'].create(mo.get_move_line(self.production_id, self))
|
||||||
|
# product_qty = mo.product_uom._compute_quantity(
|
||||||
|
# mo.product_uom_qty, mo.product_id.uom_id, rounding_method='HALF-UP')
|
||||||
|
# available_quantity = self.env['stock.quant']._get_available_quantity(
|
||||||
|
# mo.product_id,
|
||||||
|
# mo.location_id,
|
||||||
|
# lot_id=mo.move_line_ids.lot_id,
|
||||||
|
# strict=False,
|
||||||
|
# )
|
||||||
|
# mo._update_reserved_quantity(
|
||||||
|
# product_qty,
|
||||||
|
# available_quantity,
|
||||||
|
# mo.location_id,
|
||||||
|
# lot_id=mo.move_line_ids.lot_id,
|
||||||
|
# strict=False,
|
||||||
|
# )
|
||||||
|
|
||||||
# move_out._action_assign()
|
# move_out._action_assign()
|
||||||
if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress':
|
if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress':
|
||||||
@@ -1214,8 +1360,8 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
if record.is_rework is False:
|
if record.is_rework is False:
|
||||||
if not record.material_center_point:
|
if not record.material_center_point:
|
||||||
raise UserError("坯料中心点为空,请检查")
|
raise UserError("坯料中心点为空,请检查")
|
||||||
# if record.X_deviation_angle <= 0:
|
# if record.X_deviation_angle <= 0:
|
||||||
# raise UserError("X偏差角度小于等于0,请检查!本次计算的X偏差角度为:%s" % record.X_deviation_angle)
|
# raise UserError("X偏差角度小于等于0,请检查!本次计算的X偏差角度为:%s" % record.X_deviation_angle)
|
||||||
record.process_state = '待加工'
|
record.process_state = '待加工'
|
||||||
# record.write({'process_state': '待加工'})
|
# record.write({'process_state': '待加工'})
|
||||||
record.production_id.process_state = '待加工'
|
record.production_id.process_state = '待加工'
|
||||||
@@ -1245,23 +1391,17 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'''
|
'''
|
||||||
record.date_finished = datetime.now()
|
record.date_finished = datetime.now()
|
||||||
if record.routing_type == '表面工艺':
|
if record.routing_type == '表面工艺':
|
||||||
logging.info('record.picking_ids:%s' % record.picking_ids)
|
|
||||||
logging.info('record.picking_out:%s' % record.picking_ids[0])
|
|
||||||
if record.picking_ids:
|
if record.picking_ids:
|
||||||
for pick_item in record.picking_ids:
|
picks = record.picking_ids.filtered(lambda p: p.state not in ('done'))
|
||||||
if pick_item.state not in ['done']:
|
if picks:
|
||||||
raise UserError(
|
raise UserError('请先完成该工单的工艺外协再进行操作')
|
||||||
'请先完成该工单的工艺外协再进行操作')
|
# 表面工艺外协,最后一张工单
|
||||||
picking_out = record.env['stock.move.line'].search(
|
workorders = self.production_id.workorder_ids
|
||||||
[('picking_id', '=', record.picking_ids[0].id)])
|
subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True).sorted('sequence')
|
||||||
logging.info('picking_out:%s' % picking_out.picking_id.name)
|
if self == subcontract_workorders[-1]:
|
||||||
# if picking_out:
|
# 给下一个库存移动就绪
|
||||||
# order_line_ids = []
|
self.move_subcontract_workorder_ids[0].move_dest_ids._action_done()
|
||||||
# logging.info('surface_technics_parameters_id:%s' % record.surface_technics_parameters_id.name)
|
# self.production_id.button_mark_done()
|
||||||
#
|
|
||||||
# else:
|
|
||||||
# raise UserError(
|
|
||||||
# '请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
|
|
||||||
tem_date_planned_finished = record.date_planned_finished
|
tem_date_planned_finished = record.date_planned_finished
|
||||||
tem_date_finished = record.date_finished
|
tem_date_finished = record.date_finished
|
||||||
logging.info('routing_type:%s' % record.routing_type)
|
logging.info('routing_type:%s' % record.routing_type)
|
||||||
@@ -1280,7 +1420,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# record.recreateManufacturingOrWorkerOrder()
|
# record.recreateManufacturingOrWorkerOrder()
|
||||||
is_production_id = False
|
is_production_id = False
|
||||||
rework_workorder = record.production_id.workorder_ids.filtered(lambda p: p.state == 'rework')
|
rework_workorder = record.production_id.workorder_ids.filtered(lambda p: p.state == 'rework')
|
||||||
done_workorder = record.production_id.workorder_ids.filtered(lambda p1: p1.state == 'done')
|
done_workorder = record.production_id.workorder_ids.filtered(lambda p1: p1.state in ['done'])
|
||||||
if (len(rework_workorder) + len(done_workorder) == len(record.production_id.workorder_ids)) or (
|
if (len(rework_workorder) + len(done_workorder) == len(record.production_id.workorder_ids)) or (
|
||||||
len(done_workorder) == len(record.production_id.workorder_ids)):
|
len(done_workorder) == len(record.production_id.workorder_ids)):
|
||||||
is_production_id = True
|
is_production_id = True
|
||||||
@@ -1297,19 +1437,20 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# workorder.rfid_code_old = rfid_code
|
# workorder.rfid_code_old = rfid_code
|
||||||
# workorder.rfid_code = False
|
# workorder.rfid_code = False
|
||||||
logging.info('workorder.rfid_code:%s' % workorder.rfid_code)
|
logging.info('workorder.rfid_code:%s' % workorder.rfid_code)
|
||||||
if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺']:
|
# if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺', '切割']:
|
||||||
|
if is_production_id is True:
|
||||||
logging.info('product_qty:%s' % record.production_id.product_qty)
|
logging.info('product_qty:%s' % record.production_id.product_qty)
|
||||||
for move_raw_id in record.production_id.move_raw_ids:
|
for move_raw_id in record.production_id.move_raw_ids:
|
||||||
move_raw_id.quantity_done = move_raw_id.product_uom_qty
|
move_raw_id.quantity_done = move_raw_id.product_uom_qty
|
||||||
record.process_state = '已完工'
|
record.process_state = '已完工'
|
||||||
record.production_id.process_state = '已完工'
|
record.production_id.process_state = '已完工'
|
||||||
if record.routing_type in ['表面工艺']:
|
# if record.routing_type in ['表面工艺']:
|
||||||
raw_move = self.env['stock.move'].sudo().search(
|
# raw_move = self.env['stock.move'].sudo().search(
|
||||||
[('origin', '=', record.production_id.name),
|
# [('origin', '=', record.production_id.name),
|
||||||
('procure_method', 'in', ['make_to_order', 'make_to_stock']),
|
# ('procure_method', 'in', ['make_to_order', 'make_to_stock']),
|
||||||
('state', '!=', 'done')])
|
# ('state', '!=', 'done')])
|
||||||
if raw_move:
|
# if raw_move:
|
||||||
raw_move.write({'state': 'done'})
|
# raw_move.write({'state': 'done'})
|
||||||
record.production_id.button_mark_done1()
|
record.production_id.button_mark_done1()
|
||||||
# record.production_id.state = 'done'
|
# record.production_id.state = 'done'
|
||||||
|
|
||||||
@@ -1429,6 +1570,8 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'default_confirm_button': '确认解除',
|
'default_confirm_button': '确认解除',
|
||||||
# 'default_feeder_station_start_id': feeder_station_start_id,
|
# 'default_feeder_station_start_id': feeder_station_start_id,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
move_subcontract_workorder_ids = fields.One2many('stock.move', 'subcontract_workorder_id', string='组件')
|
||||||
|
|
||||||
|
|
||||||
class CNCprocessing(models.Model):
|
class CNCprocessing(models.Model):
|
||||||
@@ -1952,3 +2095,56 @@ class CMMprogram(models.Model):
|
|||||||
'program_create_date': datetime.strptime(item['program_create_date'], '%Y-%m-%d %H:%M:%S'),
|
'program_create_date': datetime.strptime(item['program_create_date'], '%Y-%m-%d %H:%M:%S'),
|
||||||
}))
|
}))
|
||||||
return cmm_program
|
return cmm_program
|
||||||
|
|
||||||
|
def update_work_start_end(self, date_planned_start, date_planned_end):
|
||||||
|
self.leave_id.write({
|
||||||
|
'date_from': date_planned_start,
|
||||||
|
'date_to': date_planned_end,
|
||||||
|
})
|
||||||
|
self.date_planned_finished = datetime.datetime.today() + datetime.timedelta(days=100)
|
||||||
|
self.date_planned_start = date_planned_start
|
||||||
|
self.date_planned_finished = date_planned_end
|
||||||
|
routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
|
[('name', '=', self.routing_type)])
|
||||||
|
|
||||||
|
self.write({'date_planned_start': date_planned_start, 'date_planned_finished': date_planned_end,
|
||||||
|
'duration_expected': routing_workcenter.time_cycle})
|
||||||
|
|
||||||
|
def auto_production_process(self, last_time, is_first, type_map):
|
||||||
|
date_planned_end = None
|
||||||
|
date_planned_start = None
|
||||||
|
duration_expected = datetime.timedelta(minutes=self.duration_expected)
|
||||||
|
reserve_time = datetime.timedelta(minutes=self.reserved_duration)
|
||||||
|
if is_first:
|
||||||
|
# 第一轮加工
|
||||||
|
if self.routing_type == '装夹预调':
|
||||||
|
date_planned_end = last_time - reserve_time
|
||||||
|
date_planned_start = date_planned_end - duration_expected
|
||||||
|
elif self.routing_type == 'CNC加工':
|
||||||
|
date_planned_start = last_time
|
||||||
|
date_planned_end = last_time + duration_expected
|
||||||
|
last_time = date_planned_end
|
||||||
|
else:
|
||||||
|
date_planned_start = last_time + reserve_time
|
||||||
|
date_planned_end = date_planned_start + duration_expected
|
||||||
|
last_time = date_planned_end
|
||||||
|
type_map.update({self.routing_type: True})
|
||||||
|
else:
|
||||||
|
date_planned_start = last_time + reserve_time
|
||||||
|
date_planned_end = date_planned_start + duration_expected
|
||||||
|
last_time = date_planned_end
|
||||||
|
return date_planned_start, date_planned_end, last_time
|
||||||
|
|
||||||
|
def manual_offline_process(self, last_time, is_first):
|
||||||
|
date_planned_end = None
|
||||||
|
date_planned_start = None
|
||||||
|
duration_expected = datetime.timedelta(minutes=self.duration_expected)
|
||||||
|
reserve_time = datetime.timedelta(minutes=self.reserved_duration)
|
||||||
|
if is_first:
|
||||||
|
date_planned_start = last_time
|
||||||
|
date_planned_end = last_time + duration_expected
|
||||||
|
|
||||||
|
else:
|
||||||
|
date_planned_start = last_time + reserve_time
|
||||||
|
date_planned_end = date_planned_start + duration_expected
|
||||||
|
return date_planned_start, date_planned_end, last_time
|
||||||
|
|||||||
@@ -141,11 +141,11 @@ class ResProductMo(models.Model):
|
|||||||
cutting_tool_coarse_medium_fine = fields.Selection(related='cutting_tool_model_id.integral_coarse_medium_fine', string='粗/中/精')
|
cutting_tool_coarse_medium_fine = fields.Selection(related='cutting_tool_model_id.integral_coarse_medium_fine', string='粗/中/精')
|
||||||
# cutting_tool_model_id.integral_coarse_medium_fine
|
# cutting_tool_model_id.integral_coarse_medium_fine
|
||||||
# cutting_tool_run_out_accuracy_max = fields.Float('端跳精度max', digits=(6, 1))
|
# cutting_tool_run_out_accuracy_max = fields.Float('端跳精度max', digits=(6, 1))
|
||||||
cutting_tool_run_out_accuracy_max = fields.Char(related='cutting_tool_model_id.integral_run_out_accuracy_max', string='端跳精度max', digits=(6, 1))
|
cutting_tool_run_out_accuracy_max = fields.Char(related='cutting_tool_model_id.integral_run_out_accuracy_max', string='端跳精度max')
|
||||||
# cutting_tool_model_id.integral_run_out_accuracy_max
|
# cutting_tool_model_id.integral_run_out_accuracy_max
|
||||||
# cutting_tool_run_out_accuracy_min = fields.Float('端跳精度min', digits=(6, 1))
|
# cutting_tool_run_out_accuracy_min = fields.Float('端跳精度min', digits=(6, 1))
|
||||||
cutting_tool_run_out_accuracy_min = fields.Char(related='cutting_tool_model_id.integral_run_out_accuracy_min',
|
cutting_tool_run_out_accuracy_min = fields.Char(related='cutting_tool_model_id.integral_run_out_accuracy_min',
|
||||||
string='端跳精度min', digits=(6, 1))
|
string='端跳精度min')
|
||||||
# cutting_tool_model_id.integral_run_out_accuracy_min
|
# cutting_tool_model_id.integral_run_out_accuracy_min
|
||||||
# cutting_tool_blade_tip_working_size = fields.Char('刀尖倒角度(°)', size=20)
|
# cutting_tool_blade_tip_working_size = fields.Char('刀尖倒角度(°)', size=20)
|
||||||
cutting_tool_blade_tip_working_size = fields.Char(related='specification_id.blade_tip_working_size',
|
cutting_tool_blade_tip_working_size = fields.Char(related='specification_id.blade_tip_working_size',
|
||||||
@@ -777,6 +777,7 @@ class ResProductMo(models.Model):
|
|||||||
part_number = fields.Char(string='零件图号', readonly=True)
|
part_number = fields.Char(string='零件图号', readonly=True)
|
||||||
machining_drawings = fields.Binary('2D加工图纸', readonly=True)
|
machining_drawings = fields.Binary('2D加工图纸', readonly=True)
|
||||||
quality_standard = fields.Binary('质检标准', readonly=True)
|
quality_standard = fields.Binary('质检标准', readonly=True)
|
||||||
|
part_name = fields.Char(string='零件名称', readonly=True)
|
||||||
|
|
||||||
@api.constrains('tool_length')
|
@api.constrains('tool_length')
|
||||||
def _check_tool_length_size(self):
|
def _check_tool_length_size(self):
|
||||||
@@ -849,16 +850,23 @@ class ResProductMo(models.Model):
|
|||||||
copy_product_id.product_tmpl_id.active = True
|
copy_product_id.product_tmpl_id.active = True
|
||||||
model_type = self.env['sf.model.type'].search([], limit=1)
|
model_type = self.env['sf.model.type'].search([], limit=1)
|
||||||
attachment = self.attachment_create(item['model_name'], item['model_data'])
|
attachment = self.attachment_create(item['model_name'], item['model_data'])
|
||||||
|
# 获取坯料冗余配置
|
||||||
|
if not item.get('embryo_redundancy'):
|
||||||
|
embryo_redundancy_id = model_type.embryo_tolerance_id
|
||||||
|
else:
|
||||||
|
embryo_redundancy_id = item.get('embryo_redundancy')
|
||||||
|
if not embryo_redundancy_id:
|
||||||
|
raise UserError('请先配置模型类型内的坯料冗余')
|
||||||
vals = {
|
vals = {
|
||||||
'name': '%s-%s-%s' % ('P', order_id.name, i),
|
'name': '%s-%s-%s' % ('P', order_id.name, i),
|
||||||
'model_long': item['model_long'] + model_type.embryo_tolerance,
|
'model_long': self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
||||||
'model_width': item['model_width'] + model_type.embryo_tolerance,
|
'model_width': self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
||||||
'model_height': item['model_height'] + model_type.embryo_tolerance,
|
'model_height': self.format_float(item['model_height'] + embryo_redundancy_id.height),
|
||||||
'model_volume': (item['model_long'] + model_type.embryo_tolerance) * (
|
'model_volume': self.format_float((item['model_long'] + embryo_redundancy_id.long) * (
|
||||||
item['model_width'] + model_type.embryo_tolerance) * (
|
item['model_width'] + embryo_redundancy_id.width) * (
|
||||||
item['model_height'] + model_type.embryo_tolerance),
|
item['model_height'] + embryo_redundancy_id.height)),
|
||||||
'product_model_type_id': model_type.id,
|
'product_model_type_id': model_type.id,
|
||||||
# 'model_processing_panel': 'R',
|
'model_processing_panel': item['processing_panel_detail'],
|
||||||
'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'],
|
||||||
@@ -866,8 +874,8 @@ class ResProductMo(models.Model):
|
|||||||
'height': item['model_height'],
|
'height': item['model_height'],
|
||||||
'volume': item['model_long'] * item['model_width'] * item['model_height'],
|
'volume': item['model_long'] * item['model_width'] * item['model_height'],
|
||||||
'model_file': '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
'model_file': '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||||
'model_name': attachment.name,
|
'model_name': attachment.name if attachment else None,
|
||||||
'upload_model_file': [(6, 0, [attachment.id])],
|
'upload_model_file': [(6, 0, [attachment.id])] if attachment else None,
|
||||||
'list_price': item['price'],
|
'list_price': item['price'],
|
||||||
'materials_id': self.env['sf.production.materials'].search(
|
'materials_id': self.env['sf.production.materials'].search(
|
||||||
[('materials_no', '=', item['texture_code'])]).id,
|
[('materials_no', '=', item['texture_code'])]).id,
|
||||||
@@ -884,6 +892,7 @@ class ResProductMo(models.Model):
|
|||||||
'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode(
|
'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode(
|
||||||
item['machining_drawings']),
|
item['machining_drawings']),
|
||||||
'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']),
|
'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']),
|
||||||
|
'part_name': item['part_name'],
|
||||||
}
|
}
|
||||||
tax_id = self.env['account.tax'].sudo().search(
|
tax_id = self.env['account.tax'].sudo().search(
|
||||||
[('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')])
|
[('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')])
|
||||||
@@ -898,6 +907,20 @@ class ResProductMo(models.Model):
|
|||||||
self.attachment_update(item['quality_standard_name'], copy_product_id.product_tmpl_id.id,
|
self.attachment_update(item['quality_standard_name'], copy_product_id.product_tmpl_id.id,
|
||||||
'quality_standard', item['quality_standard_mimetype'])
|
'quality_standard', item['quality_standard_mimetype'])
|
||||||
return copy_product_id
|
return copy_product_id
|
||||||
|
|
||||||
|
def format_float(self, value):
|
||||||
|
# 将浮点数转换为字符串
|
||||||
|
value_str = str(value)
|
||||||
|
# 检查小数点的位置
|
||||||
|
if '.' in value_str:
|
||||||
|
# 获取小数部分
|
||||||
|
decimal_part = value_str.split('.')[1]
|
||||||
|
# 判断小数位数是否超过2位
|
||||||
|
if len(decimal_part) > 2:
|
||||||
|
# 超过2位则保留2位小数
|
||||||
|
return "{:.2f}".format(value)
|
||||||
|
# 否则保持原来的位数
|
||||||
|
return float(value_str)
|
||||||
|
|
||||||
def _get_ids(self, param):
|
def _get_ids(self, param):
|
||||||
type_ids = []
|
type_ids = []
|
||||||
@@ -915,6 +938,8 @@ class ResProductMo(models.Model):
|
|||||||
return [(6, 0, process_parameters_ids)]
|
return [(6, 0, process_parameters_ids)]
|
||||||
|
|
||||||
def attachment_create(self, name, data):
|
def attachment_create(self, name, data):
|
||||||
|
if not data:
|
||||||
|
return None
|
||||||
attachment = self.env['ir.attachment'].create({
|
attachment = self.env['ir.attachment'].create({
|
||||||
'datas': base64.b64decode(data),
|
'datas': base64.b64decode(data),
|
||||||
'type': 'binary',
|
'type': 'binary',
|
||||||
@@ -932,31 +957,40 @@ class ResProductMo(models.Model):
|
|||||||
# if surface_technology:
|
# if surface_technology:
|
||||||
# no_bom_copy_product_id.route_ids |= surface_technology
|
# no_bom_copy_product_id.route_ids |= surface_technology
|
||||||
no_bom_copy_product_id.product_tmpl_id.active = True
|
no_bom_copy_product_id.product_tmpl_id.active = True
|
||||||
|
logging.info('no_bom_copy_product_id[is_manual_processing]:%s' % no_bom_copy_product_id.is_manual_processing)
|
||||||
materials_id = self.env['sf.production.materials'].search(
|
materials_id = self.env['sf.production.materials'].search(
|
||||||
[('materials_no', '=', item['texture_code'])])
|
[('materials_no', '=', item['texture_code'])])
|
||||||
materials_type_id = self.env['sf.materials.model'].search(
|
materials_type_id = self.env['sf.materials.model'].search(
|
||||||
[('materials_no', '=', item['texture_type_code'])])
|
[('materials_no', '=', item['texture_type_code'])])
|
||||||
model_type = self.env['sf.model.type'].search([], limit=1)
|
model_type = self.env['sf.model.type'].search([], limit=1)
|
||||||
supplier = self.env['mrp.bom'].get_supplier(materials_type_id)
|
supplier = self.env['mrp.bom'].get_supplier(materials_type_id)
|
||||||
|
# 获取坯料冗余配置
|
||||||
|
if not item.get('embryo_redundancy_id'):
|
||||||
|
embryo_redundancy_id = model_type.embryo_tolerance_id
|
||||||
|
else:
|
||||||
|
embryo_redundancy_id = item.get('embryo_redundancy_id')
|
||||||
|
if not embryo_redundancy_id:
|
||||||
|
raise UserError('请先配置模型类型内的坯料冗余')
|
||||||
logging.info('no_bom_copy_product_supplier-vals:%s' % supplier)
|
logging.info('no_bom_copy_product_supplier-vals:%s' % supplier)
|
||||||
vals = {
|
vals = {
|
||||||
'name': '%s-%s-%s [%s %s-%s * %s * %s]' % ('R',
|
'name': '%s-%s-%s [%s %s-%s * %s * %s]' % ('R',
|
||||||
order_id.name, i, materials_id.name, materials_type_id.name,
|
order_id.name, i, materials_id.name, materials_type_id.name,
|
||||||
item['model_long'] + model_type.embryo_tolerance,
|
item['model_long'] + embryo_redundancy_id.long,
|
||||||
item['model_width'] + model_type.embryo_tolerance,
|
item['model_width'] + embryo_redundancy_id.width,
|
||||||
item['model_height'] + model_type.embryo_tolerance),
|
item['model_height'] + embryo_redundancy_id.height),
|
||||||
'length': item['model_long'] + model_type.embryo_tolerance,
|
'length': item['model_long'] + embryo_redundancy_id.long,
|
||||||
'width': item['model_width'] + model_type.embryo_tolerance,
|
'width': item['model_width'] + embryo_redundancy_id.width,
|
||||||
'height': item['model_height'] + model_type.embryo_tolerance,
|
'height': item['model_height'] + embryo_redundancy_id.height,
|
||||||
'volume': (item['model_long'] + model_type.embryo_tolerance) * (
|
'volume': (item['model_long'] + embryo_redundancy_id.long) * (
|
||||||
item['model_width'] + model_type.embryo_tolerance) * (
|
item['model_width'] + embryo_redundancy_id.width) * (
|
||||||
item['model_height'] + model_type.embryo_tolerance),
|
item['model_height'] + embryo_redundancy_id.height),
|
||||||
'embryo_model_type_id': model_type.id,
|
'embryo_model_type_id': model_type.id,
|
||||||
'list_price': item['price'],
|
'list_price': item['price'],
|
||||||
'materials_id': materials_id.id,
|
'materials_id': materials_id.id,
|
||||||
'materials_type_id': materials_type_id.id,
|
'materials_type_id': materials_type_id.id,
|
||||||
|
'single_manufacturing': product_id.single_manufacturing,
|
||||||
'is_bfm': True,
|
'is_bfm': True,
|
||||||
'active': True
|
'active': True,
|
||||||
}
|
}
|
||||||
# 外协和采购生成的坯料需要根据材料型号绑定供应商
|
# 外协和采购生成的坯料需要根据材料型号绑定供应商
|
||||||
if route_type == 'subcontract' or route_type == 'purchase':
|
if route_type == 'subcontract' or route_type == 'purchase':
|
||||||
|
|||||||
71
sf_manufacturing/models/quick_easy_order.py
Normal file
71
sf_manufacturing/models/quick_easy_order.py
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from odoo import models
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import base64
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class QuickEasyOrder(models.Model):
|
||||||
|
_inherit = 'quick.easy.order'
|
||||||
|
|
||||||
|
def distribute_to_factory(self, obj):
|
||||||
|
"""
|
||||||
|
多供货方式,重写派单到工厂
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
_logger.info('---------派单到工厂-------')
|
||||||
|
res = {'bfm_process_order_list': []}
|
||||||
|
for item in obj:
|
||||||
|
attachment = item.upload_model_file[0]
|
||||||
|
base64_data = base64.b64encode(attachment.datas)
|
||||||
|
base64_datas = base64_data.decode('utf-8')
|
||||||
|
barcode = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||||
|
# logging.info('model_file-size: %s' % len(item.model_file))
|
||||||
|
res['bfm_process_order_list'].append({
|
||||||
|
'model_long': item.model_length,
|
||||||
|
'model_width': item.model_width,
|
||||||
|
'model_height': item.model_height,
|
||||||
|
'model_volume': item.model_volume,
|
||||||
|
'model_machining_precision': item.machining_precision,
|
||||||
|
'model_name': attachment.name,
|
||||||
|
'model_data': base64_datas,
|
||||||
|
'model_file': base64.b64encode(item.model_file).decode('utf-8'),
|
||||||
|
'texture_code': item.material_id.materials_no,
|
||||||
|
'texture_type_code': item.material_model_id.materials_no,
|
||||||
|
# 'surface_process_code': self.env['jikimo.surface.process']._json_surface_process_code(item),
|
||||||
|
'process_parameters_code': self.env[
|
||||||
|
'sf.production.process.parameter']._json_production_process_item_code(
|
||||||
|
item),
|
||||||
|
'price': item.price,
|
||||||
|
'number': item.quantity,
|
||||||
|
'total_amount': item.price,
|
||||||
|
'remark': '',
|
||||||
|
'manual_quotation': True,
|
||||||
|
'barcode': barcode,
|
||||||
|
'part_number': item.part_drawing_number,
|
||||||
|
'machining_drawings_name': '',
|
||||||
|
'quality_standard_name': '',
|
||||||
|
'machining_drawings_mimetype': '',
|
||||||
|
'quality_standard_mimetype': '',
|
||||||
|
'machining_drawings': item.machining_drawings,
|
||||||
|
'quality_standard': '',
|
||||||
|
'part_name': '',
|
||||||
|
})
|
||||||
|
company_id = self.env.ref('base.main_company').sudo()
|
||||||
|
product_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_default').sudo().with_context(active_test=False).product_variant_id
|
||||||
|
# user_id = request.env.ref('base.user_admin').sudo()
|
||||||
|
order_id = self.env['sale.order'].sale_order_create(company_id, 'XXXXX', 'XXXXX', 'XXXXX',
|
||||||
|
str(datetime.now()), '现结', '支付宝', state='draft')
|
||||||
|
order_id.default_code = obj.name
|
||||||
|
i = 1
|
||||||
|
for item in res['bfm_process_order_list']:
|
||||||
|
product = self.env['product.template'].sudo().product_create(product_id, item, order_id,
|
||||||
|
obj.name, i)
|
||||||
|
order_id.with_user(self.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
||||||
|
return order_id
|
||||||
|
except Exception as e:
|
||||||
|
return UserError('工厂创建销售订单和产品失败,请联系管理员')
|
||||||
166
sf_manufacturing/models/sale_order.py
Normal file
166
sf_manufacturing/models/sale_order.py
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
import logging
|
||||||
|
import json
|
||||||
|
from odoo import models, fields, api
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class SaleOrder(models.Model):
|
||||||
|
_inherit = 'sale.order'
|
||||||
|
|
||||||
|
state = fields.Selection([
|
||||||
|
('draft', "报价"),
|
||||||
|
('sent', "报价已发送"),
|
||||||
|
('supply method', "供货方式待确认"),
|
||||||
|
('sale', "销售订单"),
|
||||||
|
('done', "已锁定"),
|
||||||
|
('cancel', "已取消"),
|
||||||
|
])
|
||||||
|
|
||||||
|
def confirm_to_supply_method(self):
|
||||||
|
self.state = 'supply method'
|
||||||
|
|
||||||
|
def action_confirm(self):
|
||||||
|
# 判断是否所有产品都选择了供货方式
|
||||||
|
filter_line = self.order_line.filtered(lambda line: not line.supply_method)
|
||||||
|
if filter_line:
|
||||||
|
raise UserError('当前订单内(%s)产品未选择路线,请选择后重试' % ','.join(filter_line.mapped('product_id.name')))
|
||||||
|
|
||||||
|
for line in self.order_line:
|
||||||
|
bom_type = ''
|
||||||
|
# 根据供货方式修改成品模板
|
||||||
|
if line.supply_method == 'automation':
|
||||||
|
bom_type = 'normal'
|
||||||
|
product_template_id = self.env.ref('sf_dlm.product_template_sf').sudo().product_tmpl_id
|
||||||
|
elif line.supply_method == 'outsourcing':
|
||||||
|
bom_type = 'subcontract'
|
||||||
|
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_outsourcing').sudo()
|
||||||
|
elif line.supply_method == 'purchase':
|
||||||
|
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_purchase').sudo()
|
||||||
|
elif line.supply_method == 'manual':
|
||||||
|
bom_type = 'normal'
|
||||||
|
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_manual_processing').sudo()
|
||||||
|
|
||||||
|
# 复制成品模板上的属性
|
||||||
|
line.product_id.product_tmpl_id.copy_template(product_template_id)
|
||||||
|
# 将模板上的single_manufacturing属性复制到成品上
|
||||||
|
line.product_id.single_manufacturing = product_template_id.single_manufacturing
|
||||||
|
|
||||||
|
order_id = self
|
||||||
|
product = line.product_id
|
||||||
|
# 拼接方法需要的item结构
|
||||||
|
item = {
|
||||||
|
'texture_code': product.materials_id.materials_no,
|
||||||
|
'texture_type_code': product.materials_type_id.materials_no,
|
||||||
|
'model_long': product.length,
|
||||||
|
'model_width': product.width,
|
||||||
|
'model_height': product.height,
|
||||||
|
'price': product.list_price,
|
||||||
|
'embryo_redundancy_id': line.embryo_redundancy_id,
|
||||||
|
}
|
||||||
|
# 获取成品名结尾-n的n
|
||||||
|
product_seria = int(product.name.split('-')[-1])
|
||||||
|
# 成品供货方式为采购则不生成bom
|
||||||
|
if line.supply_method != 'purchase':
|
||||||
|
bom_data = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).get_bom(product)
|
||||||
|
_logger.info('bom_data:%s' % bom_data)
|
||||||
|
if bom_data:
|
||||||
|
bom = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).bom_create(product, 'normal', False)
|
||||||
|
bom.with_user(self.env.ref("base.user_admin")).bom_create_line_has(bom_data)
|
||||||
|
else:
|
||||||
|
# 当成品上带有客供料选项时,生成坯料时选择“客供料”路线
|
||||||
|
if line.embryo_redundancy_id:
|
||||||
|
# 将成品模板的内容复制到成品上
|
||||||
|
customer_provided_embryo = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_embryo_customer_provided').sudo()
|
||||||
|
# 创建坯料,客供料的批量不需要创建bom
|
||||||
|
material_customer_provided_embryo = self.env['product.template'].sudo().no_bom_product_create(
|
||||||
|
customer_provided_embryo.with_context(active_test=False).product_variant_id,
|
||||||
|
item,
|
||||||
|
order_id, 'material_customer_provided', product_seria, product)
|
||||||
|
# 成品配置bom
|
||||||
|
product_bom_material_customer_provided = self.env['mrp.bom'].with_user(
|
||||||
|
self.env.ref("base.user_admin")).bom_create(
|
||||||
|
product, bom_type, 'product')
|
||||||
|
product_bom_material_customer_provided.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
|
||||||
|
material_customer_provided_embryo)
|
||||||
|
elif line.product_id.materials_type_id.gain_way == '自加工':
|
||||||
|
self_machining_id = self.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo()
|
||||||
|
# 创建坯料
|
||||||
|
self_machining_embryo = self.env['product.template'].sudo().no_bom_product_create(
|
||||||
|
self_machining_id,
|
||||||
|
item,
|
||||||
|
order_id, 'self_machining', product_seria, product)
|
||||||
|
# 创建坯料的bom
|
||||||
|
self_machining_bom = self.env['mrp.bom'].with_user(
|
||||||
|
self.env.ref("base.user_admin")).bom_create(
|
||||||
|
self_machining_embryo, 'normal', False)
|
||||||
|
# 创建坯料里bom的组件
|
||||||
|
self_machining_bom_line = self_machining_bom.with_user(
|
||||||
|
self.env.ref("base.user_admin")).bom_create_line(
|
||||||
|
self_machining_embryo)
|
||||||
|
if not self_machining_bom_line:
|
||||||
|
raise UserError('该订单模型的材料型号暂未有原材料,请先配置再进行分配')
|
||||||
|
# 产品配置bom
|
||||||
|
product_bom_self_machining = self.env['mrp.bom'].with_user(
|
||||||
|
self.env.ref("base.user_admin")).bom_create(
|
||||||
|
product, bom_type, 'product')
|
||||||
|
product_bom_self_machining.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
|
||||||
|
self_machining_embryo)
|
||||||
|
elif line.product_id.materials_type_id.gain_way == '外协':
|
||||||
|
outsource_id = self.env.ref('sf_dlm.product_embryo_sf_outsource').sudo()
|
||||||
|
# 创建坯料
|
||||||
|
outsource_embryo = self.env['product.template'].sudo().no_bom_product_create(outsource_id,
|
||||||
|
item,
|
||||||
|
order_id,
|
||||||
|
'subcontract',
|
||||||
|
product_seria, product)
|
||||||
|
if outsource_embryo == -3:
|
||||||
|
raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配')
|
||||||
|
# 创建坯料的bom
|
||||||
|
outsource_bom = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).bom_create(
|
||||||
|
outsource_embryo,
|
||||||
|
'subcontract', True)
|
||||||
|
# 创建坯料的bom的组件
|
||||||
|
outsource_bom_line = outsource_bom.with_user(
|
||||||
|
self.env.ref("base.user_admin")).bom_create_line(outsource_embryo)
|
||||||
|
if not outsource_bom_line:
|
||||||
|
raise UserError('该订单模型的材料型号暂未有原材料,请先配置再进行分配')
|
||||||
|
# 产品配置bom
|
||||||
|
product_bom_outsource = self.env['mrp.bom'].with_user(
|
||||||
|
self.env.ref("base.user_admin")).bom_create(product, bom_type, 'product')
|
||||||
|
product_bom_outsource.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
|
||||||
|
outsource_embryo)
|
||||||
|
elif line.product_id.materials_type_id.gain_way == '采购':
|
||||||
|
purchase_id = self.env.ref('sf_dlm.product_embryo_sf_purchase').sudo()
|
||||||
|
purchase_embryo = self.env['product.template'].sudo().no_bom_product_create(purchase_id,
|
||||||
|
item,
|
||||||
|
order_id,
|
||||||
|
'purchase', product_seria,
|
||||||
|
product)
|
||||||
|
if purchase_embryo == -3:
|
||||||
|
raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配')
|
||||||
|
else:
|
||||||
|
# 产品配置bom
|
||||||
|
product_bom_purchase = self.env['mrp.bom'].with_user(
|
||||||
|
self.env.ref("base.user_admin")).bom_create(product, bom_type, 'product')
|
||||||
|
product_bom_purchase.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
|
||||||
|
purchase_embryo)
|
||||||
|
return super(SaleOrder, self).action_confirm()
|
||||||
|
|
||||||
|
class SaleOrderLine(models.Model):
|
||||||
|
_inherit = 'sale.order.line'
|
||||||
|
|
||||||
|
# 供货方式
|
||||||
|
supply_method = fields.Selection([
|
||||||
|
('automation', "自动化产线加工"),
|
||||||
|
('manual', "人工线下加工"),
|
||||||
|
('purchase', "外购"),
|
||||||
|
('outsourcing', "委外加工"),
|
||||||
|
], string='供货方式')
|
||||||
|
|
||||||
|
def write(self, vals):
|
||||||
|
if 'supply_method' in vals:
|
||||||
|
for line in self:
|
||||||
|
if vals['supply_method'] == 'automation' and line.manual_quotation:
|
||||||
|
raise UserError('当前(%s)产品为人工编程产品,不能选择自动化产线加工' % ','.join(line.mapped('product_id.name')))
|
||||||
|
return super(SaleOrderLine, self).write(vals)
|
||||||
23
sf_manufacturing/models/sf_production_common.py
Normal file
23
sf_manufacturing/models/sf_production_common.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import logging
|
||||||
|
from odoo import fields, models, api
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
|
class SfProductionProcessParameter(models.Model):
|
||||||
|
_inherit = 'sf.production.process.parameter'
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
|
||||||
|
if self._context.get('route_id'):
|
||||||
|
parameter = []
|
||||||
|
routing = self.env['mrp.routing.workcenter'].search([('id', '=', self._context.get('route_id'))])
|
||||||
|
technology_design = self.env['sf.technology.design'].search(
|
||||||
|
[('production_id', '=', self._context.get('production_id')), ('routing_tag', '=', 'special'),
|
||||||
|
('route_id', '=', self._context.get('route_id'))])
|
||||||
|
for t in technology_design:
|
||||||
|
if t.process_parameters_id:
|
||||||
|
parameter.append(t.process_parameters_id.id)
|
||||||
|
domain = [('process_id', '=', routing.surface_technics_id.id), ('id', 'not in', parameter)]
|
||||||
|
return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
|
||||||
|
return super()._name_search(name, args, operator, limit, name_get_uid)
|
||||||
40
sf_manufacturing/models/sf_technology_design.py
Normal file
40
sf_manufacturing/models/sf_technology_design.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from odoo import fields, models, api, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class sf_technology_design(models.Model):
|
||||||
|
_name = 'sf.technology.design'
|
||||||
|
_description = "工艺设计"
|
||||||
|
|
||||||
|
sequence = fields.Integer('序号')
|
||||||
|
route_id = fields.Many2one('mrp.routing.workcenter', '工序')
|
||||||
|
process_parameters_id = fields.Many2one('sf.production.process.parameter', string='表面工艺参数')
|
||||||
|
panel = fields.Char('加工面')
|
||||||
|
routing_tag = fields.Selection(related='route_id.routing_tag', string='标签', store=True)
|
||||||
|
time_cycle_manual = fields.Float(related='route_id.time_cycle_manual', string='预计时长')
|
||||||
|
production_id = fields.Many2one('mrp.production')
|
||||||
|
is_auto = fields.Boolean('是否自动生成', default=False)
|
||||||
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
def json_technology_design_str(self, k, route, i, process_parameter):
|
||||||
|
workorders_values_str = [0, '', {
|
||||||
|
'route_id': route.id if route.routing_type in ['表面工艺'] else route.route_workcenter_id.id,
|
||||||
|
'panel': k,
|
||||||
|
'process_parameters_id': False if route.routing_type != '表面工艺' else self.env[
|
||||||
|
'sf.production.process.parameter'].search(
|
||||||
|
[('id', '=', process_parameter.id)]).id,
|
||||||
|
'sequence': i,
|
||||||
|
'is_auto': True}]
|
||||||
|
return workorders_values_str
|
||||||
|
|
||||||
|
def unlink_technology_design(self):
|
||||||
|
self.active = False
|
||||||
|
|
||||||
|
|
||||||
|
@api.model_create_multi
|
||||||
|
def create(self, vals_list):
|
||||||
|
for vals in vals_list:
|
||||||
|
if not vals.get('route_id'):
|
||||||
|
raise ValidationError(_("工序不能为空"))
|
||||||
|
return super(sf_technology_design, self).create(vals_list)
|
||||||
@@ -208,6 +208,15 @@ 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_raw_values())
|
||||||
# self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
# self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||||
@@ -272,18 +281,26 @@ class StockRule(models.Model):
|
|||||||
workorder_duration += workorder.duration_expected
|
workorder_duration += workorder.duration_expected
|
||||||
|
|
||||||
sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)])
|
sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)])
|
||||||
if sale_order:
|
# 如果订单为空,则获取来源制造订单的销售单
|
||||||
# sale_order.write({'schedule_status': 'to schedule'})
|
if not sale_order:
|
||||||
self.env['sf.production.plan'].sudo().with_company(company_id).create({
|
mrp_production = self.env['mrp.production'].sudo().search([('name', '=', production.origin)],
|
||||||
'name': production.name,
|
limit=1)
|
||||||
'order_deadline': sale_order.deadline_of_delivery,
|
if mrp_production:
|
||||||
'production_id': production.id,
|
sale_order = self.env['sale.order'].sudo().search([('name', '=', mrp_production.origin)])
|
||||||
'date_planned_start': production.date_planned_start,
|
else:
|
||||||
'origin': production.origin,
|
mrp_production = production
|
||||||
'product_qty': production.product_qty,
|
# if sale_order:
|
||||||
'product_id': production.product_id.id,
|
# sale_order.write({'schedule_status': 'to schedule'})
|
||||||
'state': 'draft',
|
self.env['sf.production.plan'].sudo().with_company(company_id).create({
|
||||||
})
|
'name': production.name,
|
||||||
|
'order_deadline': sale_order.deadline_of_delivery,
|
||||||
|
'production_id': production.id,
|
||||||
|
'date_planned_start': production.date_planned_start,
|
||||||
|
'origin': mrp_production.origin,
|
||||||
|
'product_qty': production.product_qty,
|
||||||
|
'product_id': production.product_id.id,
|
||||||
|
'state': 'draft',
|
||||||
|
})
|
||||||
all_production = productions
|
all_production = productions
|
||||||
grouped_product_ids = {k: list(g) for k, g in groupby(all_production, key=lambda x: x.product_id.id)}
|
grouped_product_ids = {k: list(g) for k, g in groupby(all_production, key=lambda x: x.product_id.id)}
|
||||||
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
|
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
|
||||||
@@ -293,78 +310,86 @@ class StockRule(models.Model):
|
|||||||
# 为同一个product_id创建一个生产订单名称列表
|
# 为同一个product_id创建一个生产订单名称列表
|
||||||
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
||||||
for production_item in productions:
|
for production_item in productions:
|
||||||
|
technology_design_values = []
|
||||||
production_programming = self.env['mrp.production'].search(
|
production_programming = self.env['mrp.production'].search(
|
||||||
[('product_id.id', '=', production_item.product_id.id),
|
[('product_id.id', '=', production_item.product_id.id),
|
||||||
('origin', '=', production_item.origin)],
|
('origin', '=', production_item.origin)],
|
||||||
limit=1, order='id asc')
|
limit=1, order='id asc')
|
||||||
if production_item.product_id.id in product_id_to_production_names:
|
if production_item.product_id.id in product_id_to_production_names:
|
||||||
if not production_programming.programming_no:
|
# 同一个产品多个制造订单对应一个编程单和模型库
|
||||||
if production_item.product_id.model_process_parameters_ids:
|
# 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
||||||
is_purchase = False
|
if not production_item.programming_no and production_item.production_type == '自动化产线加工':
|
||||||
sorted_process_parameters = sorted(production_item.product_id.model_process_parameters_ids,
|
|
||||||
key=lambda w: w.id)
|
|
||||||
|
|
||||||
consecutive_process_parameters = []
|
|
||||||
m = 0
|
|
||||||
for i in range(len(sorted_process_parameters) - 1):
|
|
||||||
if m == 0:
|
|
||||||
is_purchase = False
|
|
||||||
if self.env['product.template']._get_process_parameters_product(
|
|
||||||
sorted_process_parameters[i]).partner_id == self.env[
|
|
||||||
'product.template']._get_process_parameters_product(sorted_process_parameters[
|
|
||||||
i + 1]).partner_id and \
|
|
||||||
sorted_process_parameters[i].gain_way == '外协':
|
|
||||||
if sorted_process_parameters[i] not in consecutive_process_parameters:
|
|
||||||
consecutive_process_parameters.append(sorted_process_parameters[i])
|
|
||||||
consecutive_process_parameters.append(sorted_process_parameters[i + 1])
|
|
||||||
m += 1
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
|
||||||
production_item,
|
|
||||||
product_id_to_production_names)
|
|
||||||
if sorted_process_parameters[i] in consecutive_process_parameters:
|
|
||||||
is_purchase = True
|
|
||||||
consecutive_process_parameters = []
|
|
||||||
m = 0
|
|
||||||
# 当前面的连续外协采购单生成再生成当前外协采购单
|
|
||||||
if is_purchase is False:
|
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
|
||||||
production_item,
|
|
||||||
product_id_to_production_names)
|
|
||||||
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
|
||||||
production_item,
|
|
||||||
product_id_to_production_names)
|
|
||||||
if sorted_process_parameters[i] in consecutive_process_parameters:
|
|
||||||
is_purchase = True
|
|
||||||
consecutive_process_parameters = []
|
|
||||||
m = 0
|
|
||||||
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
|
||||||
production_item,
|
|
||||||
product_id_to_production_names)
|
|
||||||
if is_purchase is False and m == 0:
|
|
||||||
if len(sorted_process_parameters) == 1:
|
|
||||||
self.env['purchase.order'].get_purchase_order(sorted_process_parameters,
|
|
||||||
production_item,
|
|
||||||
product_id_to_production_names)
|
|
||||||
else:
|
|
||||||
self.env['purchase.order'].get_purchase_order(sorted_process_parameters[i],
|
|
||||||
production_item,
|
|
||||||
product_id_to_production_names)
|
|
||||||
# # 同一个产品多个制造订单对应一个编程单和模型库
|
|
||||||
# # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
|
||||||
if not production_item.programming_no:
|
|
||||||
if not production_programming.programming_no:
|
if not production_programming.programming_no:
|
||||||
production_item.fetchCNC(
|
production_item.fetchCNC(
|
||||||
', '.join(product_id_to_production_names[production_item.product_id.id]))
|
', '.join(product_id_to_production_names[production_item.product_id.id]))
|
||||||
else:
|
else:
|
||||||
production_item.write({'programming_no': production_programming.programming_no,
|
production_item.write({'programming_no': production_programming.programming_no,
|
||||||
'programming_state': '编程中'})
|
'programming_state': '编程中'})
|
||||||
return True
|
i = 0
|
||||||
|
if production_item.product_id.categ_id.type == '成品':
|
||||||
|
# 根据加工面板的面数及成品工序模板生成工序设计
|
||||||
|
if production_item.production_type == '自动化产线加工':
|
||||||
|
model = 'sf.product.model.type.routing.sort'
|
||||||
|
domain = [
|
||||||
|
('product_model_type_id', '=', production_item.product_id.product_model_type_id.id)]
|
||||||
|
else:
|
||||||
|
model = 'sf.manual.product.model.type.routing.sort'
|
||||||
|
domain = [('manual_product_model_type_id', '=',
|
||||||
|
production_item.product_id.product_model_type_id.id)]
|
||||||
|
product_routing_workcenter = self.env[model].search(domain, order='sequence asc')
|
||||||
|
if production_item.production_type == '自动化产线加工':
|
||||||
|
for k in (production_item.product_id.model_processing_panel.split(',')):
|
||||||
|
for route in product_routing_workcenter:
|
||||||
|
i += 1
|
||||||
|
technology_design_values.append(
|
||||||
|
self.env['sf.technology.design'].json_technology_design_str(k, route, i, False))
|
||||||
|
else:
|
||||||
|
for route in product_routing_workcenter:
|
||||||
|
i += 1
|
||||||
|
technology_design_values.append(
|
||||||
|
self.env['sf.technology.design'].json_technology_design_str(False, route, i, False))
|
||||||
|
elif production_item.product_id.categ_id.type == '坯料':
|
||||||
|
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
|
||||||
|
[('embryo_model_type_id', '=', production_item.product_id.embryo_model_type_id.id)],
|
||||||
|
order='sequence asc'
|
||||||
|
)
|
||||||
|
for route_embryo in embryo_routing_workcenter:
|
||||||
|
i += 1
|
||||||
|
technology_design_values.append(
|
||||||
|
self.env['sf.technology.design'].json_technology_design_str(False, route_embryo, i,
|
||||||
|
False))
|
||||||
|
surface_technics_arr = []
|
||||||
|
route_workcenter_arr = []
|
||||||
|
for item in production_item.product_id.product_model_type_id.surface_technics_routing_tmpl_ids:
|
||||||
|
if item.route_workcenter_id.surface_technics_id.id:
|
||||||
|
for process_param in production_item.product_id.model_process_parameters_ids:
|
||||||
|
if item.route_workcenter_id.surface_technics_id == process_param.process_id:
|
||||||
|
surface_technics_arr.append(
|
||||||
|
item.route_workcenter_id.surface_technics_id.id)
|
||||||
|
route_workcenter_arr.append(item.route_workcenter_id.id)
|
||||||
|
if surface_technics_arr:
|
||||||
|
production_process = self.env['sf.production.process'].search(
|
||||||
|
[('id', 'in', surface_technics_arr)],
|
||||||
|
order='sequence asc'
|
||||||
|
)
|
||||||
|
for p in production_process:
|
||||||
|
logging.info('production_process:%s' % p.name)
|
||||||
|
process_parameter = production_item.product_id.model_process_parameters_ids.filtered(
|
||||||
|
lambda pm: pm.process_id.id == p.id)
|
||||||
|
if process_parameter:
|
||||||
|
i += 1
|
||||||
|
route_production_process = self.env[
|
||||||
|
'mrp.routing.workcenter'].search(
|
||||||
|
[('surface_technics_id', '=', p.id),
|
||||||
|
('id', 'in', route_workcenter_arr)])
|
||||||
|
technology_design_values.append(
|
||||||
|
self.env['sf.technology.design'].json_technology_design_str(False,
|
||||||
|
route_production_process,
|
||||||
|
i,
|
||||||
|
process_parameter))
|
||||||
|
production_item.technology_design_ids = technology_design_values
|
||||||
|
productions.write({'state': 'technology_to_confirmed'})
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class ProductionLot(models.Model):
|
class ProductionLot(models.Model):
|
||||||
@@ -398,6 +423,8 @@ class ProductionLot(models.Model):
|
|||||||
"""Generate `lot_names` from a string."""
|
"""Generate `lot_names` from a string."""
|
||||||
if first_lot.__contains__(display_name):
|
if first_lot.__contains__(display_name):
|
||||||
first_lot = first_lot[(len(display_name) + 1):]
|
first_lot = first_lot[(len(display_name) + 1):]
|
||||||
|
else:
|
||||||
|
first_lot = first_lot[-3:]
|
||||||
|
|
||||||
# We look if the first lot contains at least one digit.
|
# We look if the first lot contains at least one digit.
|
||||||
caught_initial_number = regex_findall(r"\d+", first_lot)
|
caught_initial_number = regex_findall(r"\d+", first_lot)
|
||||||
@@ -452,6 +479,14 @@ class ProductionLot(models.Model):
|
|||||||
if product.categ_id.name == '刀具':
|
if product.categ_id.name == '刀具':
|
||||||
return self.env['stock.lot'].get_tool_generate_lot_names1(company, product)
|
return self.env['stock.lot'].get_tool_generate_lot_names1(company, product)
|
||||||
else:
|
else:
|
||||||
|
# 对last_serial的name进行检测,如果不是以产品名称+数字的形式的就重新搜索
|
||||||
|
if product.name.split('[')[0] not in last_serial.name:
|
||||||
|
last_serial = self.env['stock.lot'].search(
|
||||||
|
[('company_id', '=', company.id), ('product_id', '=', product.id),
|
||||||
|
('name', 'ilike', product.name.split('[')[0])],
|
||||||
|
limit=1, order='name desc')
|
||||||
|
if not last_serial:
|
||||||
|
return "%s-%03d" % (product.name, 1)
|
||||||
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name, 2)[1]
|
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name, 2)[1]
|
||||||
now = datetime.now().strftime("%Y%m%d")
|
now = datetime.now().strftime("%Y%m%d")
|
||||||
if product.cutting_tool_model_id:
|
if product.cutting_tool_model_id:
|
||||||
@@ -548,6 +583,45 @@ class StockPicking(models.Model):
|
|||||||
_inherit = 'stock.picking'
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
||||||
|
person_of_delivery = fields.Char('收货人', compute='_compute_move_ids', store=True)
|
||||||
|
telephone_of_delivery = fields.Char('电话号码', compute='_compute_move_ids', store=True)
|
||||||
|
address_of_delivery = fields.Char('联系地址', compute='_compute_move_ids', store=True)
|
||||||
|
|
||||||
|
retrospect_ref = fields.Char('追溯参考', compute='_compute_move_ids', store=True)
|
||||||
|
|
||||||
|
picking_type_sequence_code = fields.Char(related='picking_type_id.sequence_code')
|
||||||
|
|
||||||
|
@api.depends('move_ids', 'move_ids.product_id')
|
||||||
|
def _compute_move_ids(self):
|
||||||
|
for item in self:
|
||||||
|
if item.move_ids:
|
||||||
|
if item.picking_type_id.sequence_code == 'DL':
|
||||||
|
sale_name = item.move_ids[0].product_id.name.split('-')[1]
|
||||||
|
if 'S' in sale_name:
|
||||||
|
sale_id = self.env['sale.order'].sudo().search([('name', '=', sale_name)])
|
||||||
|
item.person_of_delivery = sale_id.person_of_delivery
|
||||||
|
item.telephone_of_delivery = sale_id.telephone_of_delivery
|
||||||
|
item.address_of_delivery = sale_id.address_of_delivery
|
||||||
|
else:
|
||||||
|
raise ValidationError('坯料名称格式错误,正确格式为[R-S???-?]!!!')
|
||||||
|
move_ids = []
|
||||||
|
for move_id in item.move_ids:
|
||||||
|
move_ids.append(move_id.product_id.id)
|
||||||
|
boms = self.env['mrp.bom'].sudo().search([('bom_line_ids.product_id', 'in', move_ids)])
|
||||||
|
if boms:
|
||||||
|
codes_list = []
|
||||||
|
for bom in boms:
|
||||||
|
if bom.product_tmpl_id.default_code:
|
||||||
|
code_list = bom.product_tmpl_id.default_code.split('-')
|
||||||
|
if len(code_list) >= 4:
|
||||||
|
code = '-'.join(code_list[:4])
|
||||||
|
if code not in codes_list:
|
||||||
|
codes_list.append(code)
|
||||||
|
else:
|
||||||
|
raise ValidationError('坯料成品的内部参考值格式错误')
|
||||||
|
item.retrospect_ref = ','.join(codes_list)
|
||||||
|
elif item.picking_type_id.sequence_code in ['INT', 'PC']:
|
||||||
|
pass
|
||||||
|
|
||||||
# 设置外协出入单的名称
|
# 设置外协出入单的名称
|
||||||
def _get_name_Res(self, rescode):
|
def _get_name_Res(self, rescode):
|
||||||
@@ -561,84 +635,79 @@ class StockPicking(models.Model):
|
|||||||
return '%s%s' % (rescode, num)
|
return '%s%s' % (rescode, num)
|
||||||
|
|
||||||
def button_validate(self):
|
def button_validate(self):
|
||||||
move_out = self.env['stock.move'].search(
|
|
||||||
[('location_id', '=', self.env['stock.location'].search(
|
|
||||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
|
||||||
('location_dest_id', '=', self.env['stock.location'].search(
|
|
||||||
[('barcode', 'ilike', 'VL-SPOC')]).id),
|
|
||||||
('origin', '=', self.origin)])
|
|
||||||
# if self.id == move_out.picking_id.id:
|
|
||||||
# if move_out.move_line_ids.workorder_id.state not in ['progress']:
|
|
||||||
# raise UserError(
|
|
||||||
# _('该出库单里源单据内的单号为%s的工单还未开始,不能进行验证操作!' % move_out.move_line_ids.workorder_id.name))
|
|
||||||
# 入库单验证
|
|
||||||
move_in = self.env['stock.move'].search(
|
|
||||||
[('location_dest_id', '=', self.env['stock.location'].search(
|
|
||||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
|
||||||
('location_id', '=', self.env['stock.location'].search(
|
|
||||||
[('barcode', 'ilike', 'VL-SPOC')]).id),
|
|
||||||
('origin', '=', self.origin), ('picking_id', '=', self.id)])
|
|
||||||
if self.location_id == move_in.location_id and self.location_dest_id == move_in.location_dest_id:
|
|
||||||
if move_out.origin == move_in.origin:
|
|
||||||
move_in.write({'production_id': False})
|
|
||||||
if move_out.picking_id.state != 'done':
|
|
||||||
raise UserError(
|
|
||||||
_('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % move_out.picking_id.name))
|
|
||||||
res = super().button_validate()
|
res = super().button_validate()
|
||||||
if res is True:
|
picking_type_in = self.env.ref('sf_manufacturing.outcontract_picking_in').id
|
||||||
if self.id == move_out.picking_id.id:
|
if res is True and self.picking_type_id.id == picking_type_in:
|
||||||
# if move_out.move_line_ids.workorder_id.state == 'progress':
|
# 如果是最后一张外协入库单,则设置库存位置的预留数量
|
||||||
move_in = self.env['stock.move'].search(
|
move_in = self.move_ids
|
||||||
[('location_dest_id', '=', self.env['stock.location'].search(
|
if move_in:
|
||||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
workorder = move_in.subcontract_workorder_id
|
||||||
('location_id', '=', self.env['stock.location'].search(
|
workorders = workorder.production_id.workorder_ids
|
||||||
[('barcode', 'ilike', 'VL-SPOC')]).id),
|
subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True).sorted('sequence')
|
||||||
('origin', '=', self.origin)])
|
if workorder == subcontract_workorders[-1]:
|
||||||
production = self.env['mrp.production'].search([('name', '=', self.origin)])
|
self.env['stock.quant']._update_reserved_quantity(
|
||||||
if move_in.state != 'done':
|
move_in.product_id, move_in.location_dest_id, move_in.product_uom_qty, lot_id=move_in.move_line_ids.lot_id,
|
||||||
move_in.write({'state': 'assigned'})
|
package_id=False, owner_id=False, strict=False
|
||||||
self.env['stock.move.line'].create(move_in.get_move_line(production, None))
|
)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# 创建 外协出库入单
|
# 创建 外协出库入单
|
||||||
def create_outcontract_picking(self, sorted_workorders_arr, item):
|
def create_outcontract_picking(self, workorders, item, sorted_workorders):
|
||||||
m = 0
|
for workorder in workorders:
|
||||||
for sorted_workorders in sorted_workorders_arr:
|
if workorder.move_subcontract_workorder_ids:
|
||||||
# pick_ids = []
|
workorder.move_subcontract_workorder_ids.write({'state': 'draft'})
|
||||||
if m == 0:
|
workorder.move_subcontract_workorder_ids.picking_id.write({'state': 'draft'})
|
||||||
outcontract_stock_move = self.env['stock.move'].search(
|
else:
|
||||||
[('workorder_id', '=', sorted_workorders.id), ('production_id', '=', item.id)])
|
# 创建一个新的补货组
|
||||||
if not outcontract_stock_move:
|
procurement_group_id = self.env['procurement.group'].create({
|
||||||
new_picking = True
|
'name': workorder.name,
|
||||||
location_id = self.env['stock.location'].search(
|
'partner_id': self.partner_id.id,
|
||||||
[('barcode', 'ilike', 'VL-SPOC')]).id,
|
})
|
||||||
location_dest_id = self.env['stock.location'].search(
|
move_dest_id = False
|
||||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id,
|
# 如果当前工单是是制造订单的最后一个工单
|
||||||
outcontract_picking_type_in = self.env.ref(
|
if workorder == item.workorder_ids[-1]:
|
||||||
'sf_manufacturing.outcontract_picking_in').id,
|
move_dest_id = item.move_raw_ids[0].id
|
||||||
outcontract_picking_type_out = self.env.ref(
|
else:
|
||||||
'sf_manufacturing.outcontract_picking_out').id,
|
# 从sorted_workorders中找到上一工单的move
|
||||||
moves_out = self.env['stock.move'].sudo().create(
|
if sorted_workorders.index(workorder) > 0:
|
||||||
self.env['stock.move']._get_stock_move_values_Res(item, location_dest_id, location_id,
|
move_dest_id = sorted_workorders[sorted_workorders.index(workorder) - 1].move_subcontract_workorder_ids[1].id
|
||||||
outcontract_picking_type_out))
|
new_picking = True
|
||||||
picking_out = self.create(
|
outcontract_picking_type_in = self.env.ref(
|
||||||
moves_out._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCOUT/'))
|
'sf_manufacturing.outcontract_picking_in').id,
|
||||||
# pick_ids.append(picking_out.id)
|
outcontract_picking_type_out = self.env.ref(
|
||||||
moves_out.write(
|
'sf_manufacturing.outcontract_picking_out').id,
|
||||||
{'picking_id': picking_out.id, 'state': 'waiting', 'workorder_id': sorted_workorders.id})
|
moves_in = self.env['stock.move'].sudo().create(
|
||||||
moves_out._assign_picking_post_process(new=new_picking)
|
self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_in, procurement_group_id.id, move_dest_id))
|
||||||
moves_in = self.env['stock.move'].sudo().create(
|
picking_in = self.create(
|
||||||
self.env['stock.move']._get_stock_move_values_Res(item, location_id, location_dest_id,
|
moves_in._get_new_picking_values_Res(item, workorder, 'WH/OCIN/'))
|
||||||
outcontract_picking_type_in))
|
# pick_ids.append(picking_in.id)
|
||||||
picking_in = self.create(
|
moves_in.write(
|
||||||
moves_in._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCIN/'))
|
{'picking_id': picking_in.id, 'state': 'waiting'})
|
||||||
# pick_ids.append(picking_in.id)
|
moves_in._assign_picking_post_process(new=new_picking)
|
||||||
moves_in.write(
|
moves_out = self.env['stock.move'].sudo().create(
|
||||||
{'picking_id': picking_in.id, 'state': 'waiting', 'workorder_id': sorted_workorders.id})
|
self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_out, procurement_group_id.id, moves_in.id))
|
||||||
moves_in._assign_picking_post_process(new=new_picking)
|
workorder.write({'move_subcontract_workorder_ids': [(6, 0, [moves_in.id, moves_out.id])]})
|
||||||
m += 1
|
picking_out = self.create(
|
||||||
# sorted_workorders.write({'picking_ids': [(6, 0, pick_ids)]})
|
moves_out._get_new_picking_values_Res(item, workorder, 'WH/OCOUT/'))
|
||||||
|
# pick_ids.append(picking_out.id)
|
||||||
|
moves_out.write(
|
||||||
|
{'picking_id': picking_out.id, 'state': 'waiting'})
|
||||||
|
moves_out._assign_picking_post_process(new=new_picking)
|
||||||
|
|
||||||
|
|
||||||
|
@api.depends('move_type', 'immediate_transfer', 'move_ids.state', 'move_ids.picking_id')
|
||||||
|
def _compute_state(self):
|
||||||
|
super(StockPicking, self)._compute_state()
|
||||||
|
for picking in self:
|
||||||
|
# 外协出库单根据工单状态,采购单状态来确定
|
||||||
|
picking_type_id = self.env.ref('sf_manufacturing.outcontract_picking_out').id
|
||||||
|
if picking.picking_type_id.id == picking_type_id:
|
||||||
|
if picking.move_ids:
|
||||||
|
workorder = picking.move_ids[0].subcontract_workorder_id
|
||||||
|
if picking.state == 'assigned':
|
||||||
|
if workorder.state in ['pending', 'waiting'] or workorder._get_surface_technics_purchase_ids().state in ['draft', 'sent']:
|
||||||
|
picking.state = 'waiting'
|
||||||
|
|
||||||
|
|
||||||
class ReStockMove(models.Model):
|
class ReStockMove(models.Model):
|
||||||
@@ -648,17 +717,20 @@ class ReStockMove(models.Model):
|
|||||||
materiel_width = fields.Float(string='物料宽度', digits=(16, 4))
|
materiel_width = fields.Float(string='物料宽度', digits=(16, 4))
|
||||||
materiel_height = fields.Float(string='物料高度', digits=(16, 4))
|
materiel_height = fields.Float(string='物料高度', digits=(16, 4))
|
||||||
|
|
||||||
def _get_stock_move_values_Res(self, item, location_src_id, location_dest_id, picking_type_id):
|
def _get_stock_move_values_Res(self, item, picking_type_id, group_id, move_dest_ids=False):
|
||||||
route = self.env['stock.route'].sudo().search([('name', '=', '表面工艺外协')])
|
route_id = self.env.ref('sf_manufacturing.route_surface_technology_outsourcing').id
|
||||||
|
stock_rule = self.env['stock.rule'].sudo().search([('route_id', '=', route_id), ('picking_type_id', '=', picking_type_id)])
|
||||||
move_values = {
|
move_values = {
|
||||||
'name': '推',
|
'name': '推',
|
||||||
'company_id': item.company_id.id,
|
'company_id': item.company_id.id,
|
||||||
'product_id': item.bom_id.bom_line_ids.product_id.id,
|
'product_id': item.bom_id.bom_line_ids.product_id.id,
|
||||||
'product_uom': item.bom_id.bom_line_ids.product_uom_id.id,
|
'product_uom': item.bom_id.bom_line_ids.product_uom_id.id,
|
||||||
'product_uom_qty': 1.0,
|
'product_uom_qty': 1.0,
|
||||||
'location_id': location_src_id,
|
'location_id': stock_rule.location_src_id.id,
|
||||||
'location_dest_id': location_dest_id,
|
'location_dest_id': stock_rule.location_dest_id.id,
|
||||||
'origin': item.name,
|
'origin': item.name,
|
||||||
|
'group_id': group_id,
|
||||||
|
'move_dest_ids': [(6, 0, [move_dest_ids])] if move_dest_ids else False,
|
||||||
# 'route_ids': False if not route else [(4, route.id)],
|
# 'route_ids': False if not route else [(4, route.id)],
|
||||||
'date_deadline': datetime.now(),
|
'date_deadline': datetime.now(),
|
||||||
'picking_type_id': picking_type_id,
|
'picking_type_id': picking_type_id,
|
||||||
@@ -682,7 +754,7 @@ class ReStockMove(models.Model):
|
|||||||
'picking_type_id': picking_type_id,
|
'picking_type_id': picking_type_id,
|
||||||
'location_id': self.mapped('location_id').id,
|
'location_id': self.mapped('location_id').id,
|
||||||
'location_dest_id': self.mapped('location_dest_id').id,
|
'location_dest_id': self.mapped('location_dest_id').id,
|
||||||
'state': 'confirmed',
|
'state': 'waiting',
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_move_line(self, production_id, sorted_workorders):
|
def get_move_line(self, production_id, sorted_workorders):
|
||||||
@@ -695,7 +767,7 @@ class ReStockMove(models.Model):
|
|||||||
'picking_id': self.picking_id.id,
|
'picking_id': self.picking_id.id,
|
||||||
'reserved_uom_qty': 1.0,
|
'reserved_uom_qty': 1.0,
|
||||||
'lot_id': production_id.move_line_raw_ids.lot_id.id,
|
'lot_id': production_id.move_line_raw_ids.lot_id.id,
|
||||||
'company_id': self.company_id.id,
|
'company_id': self.env.company.id,
|
||||||
# 'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
|
# 'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
|
||||||
# 'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,
|
# 'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,
|
||||||
'state': 'assigned',
|
'state': 'assigned',
|
||||||
@@ -739,6 +811,8 @@ class ReStockMove(models.Model):
|
|||||||
self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
|
self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
|
||||||
else:
|
else:
|
||||||
self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
|
self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
|
||||||
|
if self.picking_type_id.sequence_code == 'DL' and not self.move_line_nosuggest_ids:
|
||||||
|
self.action_assign_serial_show_details()
|
||||||
elif self.product_id.tracking == "lot":
|
elif self.product_id.tracking == "lot":
|
||||||
self._put_tool_lot(self.company_id, self.product_id, self.origin)
|
self._put_tool_lot(self.company_id, self.product_id, self.origin)
|
||||||
|
|
||||||
@@ -891,6 +965,40 @@ class ReStockMove(models.Model):
|
|||||||
qty_by_location[loc.id] += 1
|
qty_by_location[loc.id] += 1
|
||||||
return move_lines_commands
|
return move_lines_commands
|
||||||
|
|
||||||
|
def _merge_moves_fields(self):
|
||||||
|
"""
|
||||||
|
合并制造订单的完成move单据
|
||||||
|
"""
|
||||||
|
res = super(ReStockMove, self)._merge_moves_fields()
|
||||||
|
if self[0].origin and self.picking_type_id.name in ['生产发料', '内部调拨', '生产入库', '客供料入库']:
|
||||||
|
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
||||||
|
productions = self.env['mrp.production'].search(
|
||||||
|
[('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
||||||
|
res['origin'] = ','.join(productions.mapped('name'))
|
||||||
|
return res
|
||||||
|
|
||||||
|
def _get_new_picking_values(self):
|
||||||
|
"""
|
||||||
|
创建调拨单时,在此新增或修改调拨单的数据
|
||||||
|
"""
|
||||||
|
res = super(ReStockMove, self)._get_new_picking_values()
|
||||||
|
## 制造订单报废生成的新制造订单不走合并
|
||||||
|
production_remanufacture = None
|
||||||
|
if 'origin' in res:
|
||||||
|
if self.picking_type_id.name in ['生产发料', '内部调拨']:
|
||||||
|
production_remanufacture = self.env['mrp.production'].search(
|
||||||
|
[('name', '=', res['origin']), ('is_remanufacture', '=', True)])
|
||||||
|
if not production_remanufacture:
|
||||||
|
if self[0].origin and self.picking_type_id.name in ['生产发料', '内部调拨']:
|
||||||
|
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
||||||
|
productions = self.env['mrp.production'].search(
|
||||||
|
[('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
||||||
|
res['origin'] = ','.join(productions.mapped('name'))
|
||||||
|
res['retrospect_ref'] = production.product_id.name
|
||||||
|
return res
|
||||||
|
|
||||||
|
subcontract_workorder_id = fields.Many2one('mrp.workorder', '外协工单组件', check_company=True, index='btree_not_null')
|
||||||
|
|
||||||
|
|
||||||
class ReStockQuant(models.Model):
|
class ReStockQuant(models.Model):
|
||||||
_inherit = 'stock.quant'
|
_inherit = 'stock.quant'
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data noupdate="1">
|
||||||
|
<record id="group_show_button" model="res.groups">
|
||||||
|
<field name="name">演示模式</field>
|
||||||
|
<field name="category_id" ref="base.module_category_hidden"/>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ access_sf_model_type_group_sale_director,sf_model_type_group_sale_director,model
|
|||||||
access_sf_model_type_group_purchase_director,sf_model_type_group_purchase_director,model_sf_model_type,sf_base.group_purchase_director,1,0,0,0
|
access_sf_model_type_group_purchase_director,sf_model_type_group_purchase_director,model_sf_model_type,sf_base.group_purchase_director,1,0,0,0
|
||||||
access_sf_model_type_group_plan_director,sf_model_type_group_plan_director,model_sf_model_type,sf_base.group_plan_director,1,0,0,0
|
access_sf_model_type_group_plan_director,sf_model_type_group_plan_director,model_sf_model_type,sf_base.group_plan_director,1,0,0,0
|
||||||
access_sf_product_model_type_routing_sort_group_sf_mrp_user,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0
|
access_sf_product_model_type_routing_sort_group_sf_mrp_user,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0
|
||||||
access_sf_product_model_type_routing_sort_manager,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,0
|
access_sf_product_model_type_routing_sort_manager,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,1
|
||||||
access_sf_embryo_model_type_routing_sort_group_sf_mrp_user,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0
|
access_sf_embryo_model_type_routing_sort_group_sf_mrp_user,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0
|
||||||
access_sf_embryo_model_type_routing_sort_manager,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,0
|
access_sf_embryo_model_type_routing_sort_manager,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,1
|
||||||
access_sf_surface_technics_model_type_routing_sort,sf_surface_technics_model_type_routing_sort,model_sf_surface_technics_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0
|
access_sf_surface_technics_model_type_routing_sort,sf_surface_technics_model_type_routing_sort,model_sf_surface_technics_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0
|
||||||
access_sf_surface_technics_model_type_routing_sort_manager,sf_surface_technics_model_type_routing_sort,model_sf_surface_technics_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,0
|
access_sf_surface_technics_model_type_routing_sort_manager,sf_surface_technics_model_type_routing_sort,model_sf_surface_technics_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,1
|
||||||
access_sf_production_line_group_sf_mrp_user,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_user,1,1,1,0
|
access_sf_production_line_group_sf_mrp_user,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_user,1,1,1,0
|
||||||
access_sf_production_line_manager,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_manager,1,1,1,0
|
access_sf_production_line_manager,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_manager,1,1,1,0
|
||||||
access_maintenance_equipment_tool_group_sf_mrp_user,maintenance_equipment_tool,model_maintenance_equipment_tool,sf_base.group_sf_mrp_user,1,0,0,0
|
access_maintenance_equipment_tool_group_sf_mrp_user,maintenance_equipment_tool,model_maintenance_equipment_tool,sf_base.group_sf_mrp_user,1,0,0,0
|
||||||
@@ -52,6 +52,7 @@ access_mrp_routing_workcenter_manager_group_sf_mrp_user,mrp.routing.workcenter.m
|
|||||||
access_mrp_bom_manager_group_sf_mrp_user,mrp.bom.manager,mrp.model_mrp_bom,sf_base.group_sf_mrp_user,1,1,1,0
|
access_mrp_bom_manager_group_sf_mrp_user,mrp.bom.manager,mrp.model_mrp_bom,sf_base.group_sf_mrp_user,1,1,1,0
|
||||||
access_mrp_bom_line_manager_group_sf_mrp_user,mrp.bom.line.manager,mrp.model_mrp_bom_line,sf_base.group_sf_mrp_user,1,1,1,0
|
access_mrp_bom_line_manager_group_sf_mrp_user,mrp.bom.line.manager,mrp.model_mrp_bom_line,sf_base.group_sf_mrp_user,1,1,1,0
|
||||||
access_mrp_bom_line_group_plan_director,mrp_bom_line_group_plan_director,mrp.model_mrp_bom_line,sf_base.group_plan_director,1,1,1,0
|
access_mrp_bom_line_group_plan_director,mrp_bom_line_group_plan_director,mrp.model_mrp_bom_line,sf_base.group_plan_director,1,1,1,0
|
||||||
|
access_mrp_bom_line_group_sf_stock_user,mrp_bom_line_group_sf_stock_user,mrp.model_mrp_bom_line,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_mrp_bom_line_group_sale_director,mrp_bom_line_group_sale_director,mrp.model_mrp_bom_line,sf_base.group_sale_director,1,1,1,0
|
access_mrp_bom_line_group_sale_director,mrp_bom_line_group_sale_director,mrp.model_mrp_bom_line,sf_base.group_sale_director,1,1,1,0
|
||||||
access_mrp_bom_line_group_sale_salemanager,mrp_bom_line_group_sale_salemanager,mrp.model_mrp_bom_line,sf_base.group_sale_salemanager,1,0,1,0
|
access_mrp_bom_line_group_sale_salemanager,mrp_bom_line_group_sale_salemanager,mrp.model_mrp_bom_line,sf_base.group_sale_salemanager,1,0,1,0
|
||||||
access_mrp_bom_line_group_purchase_director,mrp_bom_line_group_purchase_director,mrp.model_mrp_bom_line,sf_base.group_purchase_director,1,1,1,0
|
access_mrp_bom_line_group_purchase_director,mrp_bom_line_group_purchase_director,mrp.model_mrp_bom_line,sf_base.group_purchase_director,1,1,1,0
|
||||||
@@ -116,7 +117,7 @@ access_mrp_production_group_quality,mrp_production,model_mrp_production,sf_base.
|
|||||||
access_mrp_production_group_quality_director,mrp_production,model_mrp_production,sf_base.group_quality_director,1,1,0,0
|
access_mrp_production_group_quality_director,mrp_production,model_mrp_production,sf_base.group_quality_director,1,1,0,0
|
||||||
access_mrp_workorder_group_quality,mrp_workorder,model_mrp_workorder,sf_base.group_quality,1,1,0,0
|
access_mrp_workorder_group_quality,mrp_workorder,model_mrp_workorder,sf_base.group_quality,1,1,0,0
|
||||||
access_mrp_workorder_group_quality_director,mrp_workorder,model_mrp_workorder,sf_base.group_quality_director,1,1,0,0
|
access_mrp_workorder_group_quality_director,mrp_workorder,model_mrp_workorder,sf_base.group_quality_director,1,1,0,0
|
||||||
access_mrp_workorder,mrp_workorder,model_mrp_workorder,sf_base.group_plan_dispatch,1,1,0,0
|
access_mrp_workorder,mrp_workorder,model_mrp_workorder,sf_base.group_plan_dispatch,1,1,1,0
|
||||||
access_sf_production_line_group_plan_dispatch,sf.production.line,model_sf_production_line,sf_base.group_plan_dispatch,1,0,0,0
|
access_sf_production_line_group_plan_dispatch,sf.production.line,model_sf_production_line,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
access_sf_production_line_group_plan_director,sf.production.line,model_sf_production_line,sf_base.group_plan_director,1,1,1,0
|
access_sf_production_line_group_plan_director,sf.production.line,model_sf_production_line,sf_base.group_plan_director,1,1,1,0
|
||||||
access_sf_production_line,sf.production.line,model_sf_production_line,sf_maintenance.sf_group_equipment_user,1,1,1,0
|
access_sf_production_line,sf.production.line,model_sf_production_line,sf_maintenance.sf_group_equipment_user,1,1,1,0
|
||||||
@@ -165,7 +166,19 @@ access_sf_agv_scheduling_group_sf_order_user,sf_agv_scheduling_group_sf_order_us
|
|||||||
access_sf_agv_scheduling_group_sf_mrp_manager,sf_agv_scheduling_group_sf_mrp_manager,model_sf_agv_scheduling,sf_base.group_sf_mrp_manager,1,1,1,0
|
access_sf_agv_scheduling_group_sf_mrp_manager,sf_agv_scheduling_group_sf_mrp_manager,model_sf_agv_scheduling,sf_base.group_sf_mrp_manager,1,1,1,0
|
||||||
access_sf_agv_scheduling_group_sf_equipment_user,sf_agv_scheduling_group_sf_equipment_user,model_sf_agv_scheduling,sf_base.group_sf_equipment_user,1,1,1,0
|
access_sf_agv_scheduling_group_sf_equipment_user,sf_agv_scheduling_group_sf_equipment_user,model_sf_agv_scheduling,sf_base.group_sf_equipment_user,1,1,1,0
|
||||||
|
|
||||||
|
access_sf_technology_design_group_plan_dispatch,sf_technology_design_group_plan_dispatch,model_sf_technology_design,sf_base.group_plan_dispatch,1,1,1,0
|
||||||
|
access_sf_technology_design_group_sf_mrp_manager,sf_technology_design_group_sf_mrp_manager,model_sf_technology_design,sf_base.group_sf_mrp_manager,1,0,0,0
|
||||||
|
access_sf_technology_design_group_production_engineer,sf_technology_design_group_production_engineer,model_sf_technology_design,sf_base.group_production_engineer,1,1,1,0
|
||||||
|
access_sf_technology_design_group_sf_equipment_user,sf_technology_design_group_sf_equipment_user,model_sf_technology_design,sf_base.group_sf_equipment_user,1,0,0,0
|
||||||
|
access_sf_technology_design_group_sf_order_user,sf_technology_design_group_sf_order_user,model_sf_technology_design,sf_base.group_sf_order_user,1,0,0,0
|
||||||
|
access_sf_production_technology_wizard_group_plan_dispatch,sf_production_technology_wizard_group_plan_dispatch,model_sf_production_technology_wizard,sf_base.group_plan_dispatch,1,1,1,0
|
||||||
|
access_sf_production_technology_wizard_group_sf_mrp_manager,sf_production_technology_wizard_group_sf_mrp_manager,model_sf_production_technology_wizard,sf_base.group_sf_mrp_manager,1,0,0,0
|
||||||
|
access_sf_production_technology_wizard_group_production_engineer,sf_production_technology_wizard_group_production_engineer,model_sf_production_technology_wizard,sf_base.group_production_engineer,1,1,1,0
|
||||||
|
access_sf_production_technology_re_adjust_wizard_group_plan_dispatch,sf_production_technology_re_adjust_wizard_group_plan_dispatch,model_sf_production_technology_re_adjust_wizard,sf_base.group_plan_dispatch,1,1,1,0
|
||||||
|
access_sf_production_technology_re_adjust_wizard_group_sf_mrp_manager,sf_production_technology_re_adjust_wizard_group_sf_mrp_manager,model_sf_production_technology_re_adjust_wizard,sf_base.group_sf_mrp_manager,1,1,1,0
|
||||||
|
access_sf_production_technology_re_adjust_wizard_group_production_engineer,sf_production_technology_re_adjust_wizard_group_production_engineer,model_sf_production_technology_re_adjust_wizard,sf_base.group_production_engineer,1,1,1,0
|
||||||
|
|
||||||
|
access_sf_manual_product_model_type_routing_sort_group_sf_mrp_user,sf_manual_product_model_type_routing_sort,model_sf_manual_product_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0
|
||||||
|
access_sf_manual_product_model_type_routing_sort_manager,sf_manual_product_model_type_routing_sort,model_sf_manual_product_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,1
|
||||||
|
access_sf_manual_product_model_type_routing_sort_group_plan_dispatch,sf_manual_product_model_type_routing_sort_group_plan_dispatch,model_sf_manual_product_model_type_routing_sort,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
|
access_sf_detection_result_manager,sf_detection_result_manager,model_sf_detection_result,,1,1,1,1
|
||||||
|
|||||||
|
@@ -31,7 +31,7 @@
|
|||||||
<form string="模型类型">
|
<form string="模型类型">
|
||||||
<group>
|
<group>
|
||||||
<field name="name" required="1"/>
|
<field name="name" required="1"/>
|
||||||
<field name="embryo_tolerance" required="1" string="坯料容余(mm)"/>
|
<field name="embryo_tolerance_id" required="1"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name='product_routing_tmpl_ids'>
|
<field name='product_routing_tmpl_ids'>
|
||||||
@@ -44,6 +44,17 @@
|
|||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name='manual_product_routing_tmpl_ids'>
|
||||||
|
<tree editable='bottom'>
|
||||||
|
<field name="sequence" widget="handle" string="序号"/>
|
||||||
|
<field name="route_workcenter_id" string="工序" options="{'no_create': True}"/>
|
||||||
|
<field name="routing_type" string="类型"/>
|
||||||
|
<field name="is_repeat" string="重复"/>
|
||||||
|
<field name="workcenter_ids" string="工作中心" widget="many2many_tags"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name='embryo_routing_tmpl_ids'>
|
<field name='embryo_routing_tmpl_ids'>
|
||||||
<tree editable='bottom'>
|
<tree editable='bottom'>
|
||||||
|
|||||||
@@ -35,9 +35,10 @@
|
|||||||
<field name="reservation_state" optional="hide" decoration-danger="reservation_state == 'confirmed'"
|
<field name="reservation_state" optional="hide" decoration-danger="reservation_state == 'confirmed'"
|
||||||
decoration-success="reservation_state == 'assigned'"/>
|
decoration-success="reservation_state == 'assigned'"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<!-- <xpath expr="//field[@name='state']" position="before"> -->
|
<xpath expr="//field[@name='state']" position="before">
|
||||||
<!-- <field name="schedule_state" optional="show"/> -->
|
<field name="production_type" widget="badge" decoration-warning="production_type == '人工线下加工'"
|
||||||
<!-- </xpath> -->
|
decoration-success="production_type == '自动化产线加工'" optional="show"/>
|
||||||
|
</xpath>
|
||||||
<xpath expr="//field[@name='activity_ids']" position="replace">
|
<xpath expr="//field[@name='activity_ids']" position="replace">
|
||||||
<field name="activity_ids" string="下一个活动" widget="list_activity" optional="hide"/>
|
<field name="activity_ids" string="下一个活动" widget="list_activity" optional="hide"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
@@ -56,6 +57,16 @@
|
|||||||
<!-- <button name="action_view_production_schedule" string="生产排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','已排程','progress','done','to_close'])]}"/> -->
|
<!-- <button name="action_view_production_schedule" string="生产排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','已排程','progress','done','to_close'])]}"/> -->
|
||||||
<!-- <button name="cancel_plan" string="取消排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','progress','done','to_close','confirmed'])]}"/> -->
|
<!-- <button name="cancel_plan" string="取消排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','progress','done','to_close','confirmed'])]}"/> -->
|
||||||
<!-- </xpath> -->
|
<!-- </xpath> -->
|
||||||
|
<xpath expr="//field[@name='production_real_duration']" position="before">
|
||||||
|
<field name="delivery_status" optional="show" widget="badge"
|
||||||
|
decoration-success="delivery_status == '正常'"
|
||||||
|
decoration-warning="delivery_status == '预警'"
|
||||||
|
decoration-danger="delivery_status == '已逾期'"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='production_real_duration']" position="attributes">
|
||||||
|
<attribute name="invisible">1</attribute>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -70,9 +81,15 @@
|
|||||||
<!-- <attribute name="statusbar_visible">draft,confirmed,progress,pending_processing,completed,done -->
|
<!-- <attribute name="statusbar_visible">draft,confirmed,progress,pending_processing,completed,done -->
|
||||||
<!-- </attribute> -->
|
<!-- </attribute> -->
|
||||||
<attribute name="statusbar_visible">
|
<attribute name="statusbar_visible">
|
||||||
confirmed,pending_cam,progress,rework,scrap,done
|
technology_to_confirmed,confirmed,pending_cam,progress,rework,scrap,done
|
||||||
</attribute>
|
</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//div[@class='d-flex flex-row align-items-start']//span[1]" position="attributes">
|
||||||
|
<attribute name="invisible">1</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//button[@name='action_product_forecast_report']" position="attributes">
|
||||||
|
<attribute name="invisible">1</attribute>
|
||||||
|
</xpath>
|
||||||
<xpath expr="//sheet//group//group[2]//label" position="before">
|
<xpath expr="//sheet//group//group[2]//label" position="before">
|
||||||
<!-- <field name="process_state"/> -->
|
<!-- <field name="process_state"/> -->
|
||||||
<field name="state" readonly="1"/>
|
<field name="state" readonly="1"/>
|
||||||
@@ -80,9 +97,13 @@
|
|||||||
|
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//sheet//group//group//div[3]" position="after">
|
<xpath expr="//sheet//group//group//div[3]" position="after">
|
||||||
<field name="manual_quotation" readonly="1"/>
|
<field name="production_type" readonly="1"/>
|
||||||
<field name="programming_no" readonly="1"/>
|
<field name="manual_quotation" readonly="1"
|
||||||
|
attrs="{'invisible': [('production_type', 'not in', ['自动化产线加工'])]}"/>
|
||||||
|
<field name="programming_no" readonly="1"
|
||||||
|
attrs="{'invisible': [('production_type', 'not in', ['自动化产线加工'])]}"/>
|
||||||
<field name="programming_state" readonly="1"
|
<field name="programming_state" readonly="1"
|
||||||
|
attrs="{'invisible': [('production_type', 'not in', ['自动化产线加工'])]}"
|
||||||
decoration-success="programming_state == '已编程'"
|
decoration-success="programming_state == '已编程'"
|
||||||
decoration-warning="programming_state =='编程中'"
|
decoration-warning="programming_state =='编程中'"
|
||||||
decoration-danger="programming_state =='已编程未下发'"/>
|
decoration-danger="programming_state =='已编程未下发'"/>
|
||||||
@@ -97,8 +118,10 @@
|
|||||||
<xpath expr="//field[@name='user_id']" position="after">
|
<xpath expr="//field[@name='user_id']" position="after">
|
||||||
<field name="production_line_id" readonly="1"/>
|
<field name="production_line_id" readonly="1"/>
|
||||||
<!-- <field name="production_line_state" readonly="1"/>-->
|
<!-- <field name="production_line_state" readonly="1"/>-->
|
||||||
<field name="part_number" string="成品的零件图号"/>
|
<field name="part_name"/>
|
||||||
<field name="tool_state"/>
|
<field name="part_number" string="零件图号"/>
|
||||||
|
<field name="tool_state"
|
||||||
|
attrs="{'invisible': [('production_type', 'not in', ['自动化产线加工'])]}"/>
|
||||||
<field name="tool_state_remark" string="备注" attrs="{'invisible': [('tool_state', '!=', '1')]}"/>
|
<field name="tool_state_remark" string="备注" attrs="{'invisible': [('tool_state', '!=', '1')]}"/>
|
||||||
<field name="deadline_of_delivery" readonly="1"/>
|
<field name="deadline_of_delivery" readonly="1"/>
|
||||||
<field name="tool_state_remark2" invisible="1"/>
|
<field name="tool_state_remark2" invisible="1"/>
|
||||||
@@ -122,6 +145,10 @@
|
|||||||
groups="sf_base.group_sf_mrp_user"/>
|
groups="sf_base.group_sf_mrp_user"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="(//header//button[@name='button_scrap'])" position="replace">
|
<xpath expr="(//header//button[@name='button_scrap'])" position="replace">
|
||||||
|
<button name="technology_confirm" string="工艺确认" type="object" class="oe_highlight"
|
||||||
|
attrs="{'invisible': [('state', '!=', 'technology_to_confirmed')]}"></button>
|
||||||
|
<button name="technology_back_adjust" string="退回调整" type="object" class="oe_highlight"
|
||||||
|
attrs="{'invisible': [('state', '!=', 'confirmed')]}"></button>
|
||||||
<button name="button_scrap" invisible="1"/>
|
<button name="button_scrap" invisible="1"/>
|
||||||
<button name="do_update_program" string="更新程序" type="object" groups="sf_base.group_sf_mrp_user"
|
<button name="do_update_program" string="更新程序" type="object" groups="sf_base.group_sf_mrp_user"
|
||||||
confirm="是否确认更新程序"
|
confirm="是否确认更新程序"
|
||||||
@@ -291,8 +318,7 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
<xpath expr="//sheet//notebook//page[@name='operations']" position="attributes">
|
<xpath expr="//sheet//notebook//page[@name='operations']" position="attributes">
|
||||||
<attribute name="attrs">{'invisible': ['|',('schedule_state', '=', '未排'),('workorder_ids', '=',
|
<attribute name="attrs">{'invisible': [('workorder_ids', '=', [])]}
|
||||||
[])]}
|
|
||||||
</attribute>
|
</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
@@ -333,10 +359,48 @@
|
|||||||
<field name="part_drawing" widget="adaptive_viewer"/>
|
<field name="part_drawing" widget="adaptive_viewer"/>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//sheet//notebook//page[@name='components']" position="before">
|
||||||
|
<page string="工艺设计" attrs="{'invisible': [('state', '!=', 'technology_to_confirmed')]}">
|
||||||
|
<field name="technology_design_ids" widget="one2many">
|
||||||
|
<tree editable="bottom">
|
||||||
|
<field name="sequence" widget="handle"/>
|
||||||
|
<field name="route_id" context="{'production_id': production_id}"
|
||||||
|
attrs="{'readonly': [('id', '!=', False)]}" options="{'no_create': True}"/>
|
||||||
|
<field name="process_parameters_id"
|
||||||
|
attrs="{'readonly': [('id', '!=', False),('routing_tag', '=', 'standard')]}"
|
||||||
|
string="参数" context="{'route_id':route_id,'production_id': production_id}"
|
||||||
|
options="{'no_create': True}"/>
|
||||||
|
<field name="panel" readonly="1"/>
|
||||||
|
<field name="routing_tag" readonly="1" widget="badge"
|
||||||
|
decoration-success="routing_tag == 'standard'"
|
||||||
|
decoration-warning="routing_tag == 'special'"/>
|
||||||
|
<field name="time_cycle_manual" attrs="{'readonly': [('id', '!=', False)]}"/>
|
||||||
|
<field name="is_auto" invisible="1"/>
|
||||||
|
<field name="production_id" invisible="1"/>
|
||||||
|
<button name="unlink_technology_design" confirm="是否确认删除?" class="oe_highlight"
|
||||||
|
attrs="{'invisible': [('is_auto', '=', True)]}" type="object"
|
||||||
|
string="删除"></button>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
<xpath expr="//sheet//notebook" position="inside">
|
<xpath expr="//sheet//notebook" position="inside">
|
||||||
<page string="质检标准">
|
<page string="质检标准">
|
||||||
<field name="quality_standard" widget="adaptive_viewer"/>
|
<field name="quality_standard" widget="adaptive_viewer"/>
|
||||||
</page>
|
</page>
|
||||||
|
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//sheet/group/group/div[@class='d-flex flex-row align-items-start']/span[last()]"
|
||||||
|
position="attributes">
|
||||||
|
<attribute name="invisible">True</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//sheet/group/group/div[@class='d-flex flex-row align-items-start']/button[@name='action_product_forecast_report']"
|
||||||
|
position="attributes">
|
||||||
|
<attribute name="invisible">True</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//sheet/div[@class='oe_button_box']/button[@name='action_view_mrp_production_childs']/div/span[last()]"
|
||||||
|
position="replace">
|
||||||
|
<span class="o_stat_text">子MO</span>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -517,8 +581,9 @@
|
|||||||
<separator/>
|
<separator/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//search" position="inside">
|
<xpath expr="//search" position="inside">
|
||||||
<searchpanel class="account_root">
|
<searchpanel>
|
||||||
<field name="state" icon="fa-filter" enable_counters="1"/>
|
<field name="state" icon="fa-filter" enable_counters="1"/>
|
||||||
|
<field name="delivery_status" icon="fa-filter" enable_counters="1"/>
|
||||||
</searchpanel>
|
</searchpanel>
|
||||||
</xpath>
|
</xpath>
|
||||||
<filter name='todo' position="replace"/>
|
<filter name='todo' position="replace"/>
|
||||||
@@ -673,5 +738,19 @@
|
|||||||
<!-- parent="mrp.menu_mrp_manufacturing"-->
|
<!-- parent="mrp.menu_mrp_manufacturing"-->
|
||||||
<!-- sequence="1"/>-->
|
<!-- sequence="1"/>-->
|
||||||
|
|
||||||
|
<menuitem id="mrp.menu_mrp_production_action"
|
||||||
|
name="制造订单"
|
||||||
|
parent="mrp.menu_mrp_manufacturing"
|
||||||
|
action="mrp.mrp_production_action"
|
||||||
|
groups="sf_base.group_plan_dispatch,sf_base.group_sf_mrp_manager"
|
||||||
|
sequence="1"/>
|
||||||
|
|
||||||
|
<menuitem id="stock_picking_type_menu"
|
||||||
|
name="驾驶舱"
|
||||||
|
parent="stock.menu_stock_root"
|
||||||
|
action="stock.stock_picking_type_action"
|
||||||
|
groups="sf_base.group_sf_stock_user"
|
||||||
|
sequence="0"/>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
</field>
|
</field>
|
||||||
<field name="bom_product_template_attribute_value_ids" position="after">
|
<field name="bom_product_template_attribute_value_ids" position="after">
|
||||||
<field name="routing_type" required="1"/>
|
<field name="routing_type" required="1"/>
|
||||||
|
<field name="routing_tag" required="1" string="工序标签"/>
|
||||||
<field name="is_repeat"/>
|
<field name="is_repeat"/>
|
||||||
<field name="reserved_duration"/>
|
<field name="reserved_duration"/>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -32,8 +32,11 @@
|
|||||||
</field>
|
</field>
|
||||||
<xpath expr="//field[@name='qty_remaining']" position="after">
|
<xpath expr="//field[@name='qty_remaining']" position="after">
|
||||||
<field name="manual_quotation" optional="show"/>
|
<field name="manual_quotation" optional="show"/>
|
||||||
<field name='tag_type' widget="badge"
|
<field name="tag_type" optional="show"/>
|
||||||
decoration-danger="tag_type == '重新加工'"/>
|
<field name="construction_period_status" optional="show" widget="badge"
|
||||||
|
decoration-success="construction_period_status == '正常'"
|
||||||
|
decoration-warning="construction_period_status == '预警'"
|
||||||
|
decoration-danger="construction_period_status == '已逾期'"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='date_planned_start']" position="replace">
|
<xpath expr="//field[@name='date_planned_start']" position="replace">
|
||||||
<field name="date_planned_start" string="计划开始日期" optional="show"/>
|
<field name="date_planned_start" string="计划开始日期" optional="show"/>
|
||||||
@@ -102,7 +105,7 @@
|
|||||||
<field name="target">current</field>
|
<field name="target">current</field>
|
||||||
<field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field>
|
<field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field>
|
||||||
<field name="context">{'search_default_product': 1, 'search_default_workcenter_id':
|
<field name="context">{'search_default_product': 1, 'search_default_workcenter_id':
|
||||||
active_id,'search_default_filter_order_warning':1,'search_default_filter_order_overdue':1}
|
active_id,'search_default_filter_order_warning':1,'search_default_filter_order_overdue':1,'search_default_filter_order_normal':1}
|
||||||
</field>
|
</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_workorder">
|
<p class="o_view_nocontent_workorder">
|
||||||
@@ -125,9 +128,9 @@
|
|||||||
<field name="model">mrp.workorder</field>
|
<field name="model">mrp.workorder</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<!-- <xpath expr="//form" position="inside"> -->
|
<!-- <xpath expr="//form" position="inside"> -->
|
||||||
<!-- <script src="sf_manufacturing/static/src/js/customRFID.js"/> -->
|
<!-- <script src="sf_manufacturing/static/src/js/customRFID.js"/> -->
|
||||||
<!-- </xpath> -->
|
<!-- </xpath> -->
|
||||||
<xpath expr="//header/field[@name='state']" position="replace">
|
<xpath expr="//header/field[@name='state']" position="replace">
|
||||||
<field name="state" widget="statusbar"
|
<field name="state" widget="statusbar"
|
||||||
statusbar_visible="pending,waiting,ready,progress,to be detected,done,rework"/>
|
statusbar_visible="pending,waiting,ready,progress,to be detected,done,rework"/>
|
||||||
@@ -136,7 +139,7 @@
|
|||||||
<button type="object" name="action_view_surface_technics_purchase" class="oe_stat_button"
|
<button type="object" name="action_view_surface_technics_purchase" class="oe_stat_button"
|
||||||
icon="fa-credit-card"
|
icon="fa-credit-card"
|
||||||
groups="base.group_user,sf_base.group_sf_order_user"
|
groups="base.group_user,sf_base.group_sf_order_user"
|
||||||
attrs="{'invisible': [('surface_technics_purchase_count', '=', 0),('routing_type', '!=', '表面工艺')]}">
|
attrs="{'invisible': [('surface_technics_purchase_count', '=', 0)]}">
|
||||||
<div class="o_field_widget o_stat_info">
|
<div class="o_field_widget o_stat_info">
|
||||||
<span class="o_stat_value">
|
<span class="o_stat_value">
|
||||||
<field name="surface_technics_purchase_count"/>
|
<field name="surface_technics_purchase_count"/>
|
||||||
@@ -197,7 +200,7 @@
|
|||||||
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('state','=','done')]}"/> -->
|
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('state','=','done')]}"/> -->
|
||||||
<!-- <button name="button_workpiece_delivery" type="object" string="工件配送" class="btn-primary"-->
|
<!-- <button name="button_workpiece_delivery" type="object" string="工件配送" class="btn-primary"-->
|
||||||
<!-- attrs="{'invisible': ['|','|','|','|',('routing_type','!=','装夹预调'),('is_delivery','=',True),('state','!=','done'),('is_rework','=',True),'&',('rfid_code','in',['',False]),('state','=','done')]}"/>-->
|
<!-- attrs="{'invisible': ['|','|','|','|',('routing_type','!=','装夹预调'),('is_delivery','=',True),('state','!=','done'),('is_rework','=',True),'&',('rfid_code','in',['',False]),('state','=','done')]}"/>-->
|
||||||
<button name="button_rework_pre" type="object" string="返工"
|
<button name="button_rework_pre" type="object" string="异常反馈" invisible="1"
|
||||||
class="btn-primary"
|
class="btn-primary"
|
||||||
attrs="{'invisible': ['|','|',('routing_type','!=','装夹预调'),('state','!=','progress'),('is_rework','=',True)]}"/>
|
attrs="{'invisible': ['|','|',('routing_type','!=','装夹预调'),('state','!=','progress'),('is_rework','=',True)]}"/>
|
||||||
<button name="unbind_tray" type="object" string="解绑托盘"
|
<button name="unbind_tray" type="object" string="解绑托盘"
|
||||||
@@ -207,7 +210,7 @@
|
|||||||
attrs="{'invisible': ['|',('routing_type','!=','解除装夹'),('state','!=','done')]}"/>
|
attrs="{'invisible': ['|',('routing_type','!=','解除装夹'),('state','!=','done')]}"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//page[1]" position="before">
|
<xpath expr="//page[1]" position="before">
|
||||||
<page string="开料要求" attrs='{"invisible": [("routing_type","!=","切割")]}'>
|
<page string="开料要求" attrs='{"invisible": [("routing_type","not in",("切割", "线切割", "人工线下加工"))]}'>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="product_tmpl_id_materials_id" widget="many2one"/>
|
<field name="product_tmpl_id_materials_id" widget="many2one"/>
|
||||||
@@ -247,11 +250,25 @@
|
|||||||
<field name='process_state' invisible="1"/>
|
<field name='process_state' invisible="1"/>
|
||||||
<field name='tag_type' readonly="1" attrs='{"invisible": [("tag_type","=",False)]}'
|
<field name='tag_type' readonly="1" attrs='{"invisible": [("tag_type","=",False)]}'
|
||||||
decoration-danger="tag_type == '重新加工'"/>
|
decoration-danger="tag_type == '重新加工'"/>
|
||||||
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
<field name="is_test_env" invisible="1"/>
|
||||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}" widget='qrcode_widget'/>
|
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
||||||
|
attrs="{'invisible': [('rfid_code_old', '!=', False)]}" widget="qrcode_widget"/>
|
||||||
|
<field name="rfid_code" string="RFID码(手动输入框)" force_save="1" readonly="0" cache="True"
|
||||||
|
attrs="{'invisible': ['|',('rfid_code_old', '!=', False), ('is_test_env', '=', False)]}"/>
|
||||||
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
||||||
|
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
|
<xpath expr="//header" position="inside">
|
||||||
|
<div class="o_statusbar_buttons">
|
||||||
|
<button name="button_change_env"
|
||||||
|
type="object"
|
||||||
|
string="演示模式"
|
||||||
|
class="btn-primary"
|
||||||
|
groups="sf_manufacturing.group_show_button"/>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
<xpath expr="//form//sheet//group//group//div[2]" position="replace">
|
<xpath expr="//form//sheet//group//group//div[2]" position="replace">
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//form//sheet//group//group//div[1]" position="after">
|
<xpath expr="//form//sheet//group//group//div[1]" position="after">
|
||||||
@@ -268,7 +285,8 @@
|
|||||||
<label for="material_height" string="高"/>
|
<label for="material_height" string="高"/>
|
||||||
<field name="material_height" class="o_address_zip"/>
|
<field name="material_height" class="o_address_zip"/>
|
||||||
</div>
|
</div>
|
||||||
<field name="part_number" string="成品的零件图号"/>
|
<field name="part_name"/>
|
||||||
|
<field name="part_number" string="零件图号"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//label[1]" position="attributes">
|
<xpath expr="//label[1]" position="attributes">
|
||||||
<attribute name="string">计划加工时间</attribute>
|
<attribute name="string">计划加工时间</attribute>
|
||||||
@@ -468,11 +486,11 @@
|
|||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
|
|
||||||
<page string="2D加工图纸" attrs="{'invisible': [('routing_type','!=','装夹预调')]}">
|
<page string="2D加工图纸" attrs="{'invisible': [('routing_type','!=','装夹预调')]}">
|
||||||
<field name="machining_drawings" widget="adaptive_viewer"/>
|
<field name="machining_drawings" widget="adaptive_viewer"/>
|
||||||
</page>
|
</page>
|
||||||
|
|
||||||
<page string="质检标准" attrs="{'invisible': [('routing_type','!=','装夹预调')]}">
|
<page string="质检标准" attrs="{'invisible': [('routing_type','!=','装夹预调')]}">
|
||||||
<field name="quality_standard" widget="adaptive_viewer"/>
|
<field name="quality_standard" widget="adaptive_viewer"/>
|
||||||
</page>
|
</page>
|
||||||
|
|
||||||
@@ -529,11 +547,11 @@
|
|||||||
<!-- attrs='{"invisible": ["|","|",("state","!=","progress"),("user_permissions","=",False),("results","=","合格")]}'/>-->
|
<!-- attrs='{"invisible": ["|","|",("state","!=","progress"),("user_permissions","=",False),("results","=","合格")]}'/>-->
|
||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
</page>
|
</page>
|
||||||
<page string="2D加工图纸" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
<page string="2D加工图纸" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||||
<field name="machining_drawings" widget="adaptive_viewer"/>
|
<field name="machining_drawings" widget="adaptive_viewer"/>
|
||||||
</page>
|
</page>
|
||||||
|
|
||||||
<page string="质检标准" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
<page string="质检标准" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||||
<field name="quality_standard" widget="adaptive_viewer"/>
|
<field name="quality_standard" widget="adaptive_viewer"/>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
@@ -646,6 +664,7 @@
|
|||||||
<separator/>
|
<separator/>
|
||||||
<filter string="预警" name="filter_order_warning" domain="[('delivery_warning', '=', 'warning')]"/>
|
<filter string="预警" name="filter_order_warning" domain="[('delivery_warning', '=', 'warning')]"/>
|
||||||
<filter string="逾期" name="filter_order_overdue" domain="[('delivery_warning', '=', 'overdue')]"/>
|
<filter string="逾期" name="filter_order_overdue" domain="[('delivery_warning', '=', 'overdue')]"/>
|
||||||
|
<filter string="正常" name="filter_order_normal" domain="[('delivery_warning', '=', 'normal')]"/>
|
||||||
<separator/>
|
<separator/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
94
sf_manufacturing/views/sale_order_views.xml
Normal file
94
sf_manufacturing/views/sale_order_views.xml
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="view_order_form_inherit_supply_method" model="ir.ui.view">
|
||||||
|
<field name="name">view.sale.order.form.inherit.supply.method</field>
|
||||||
|
<field name="inherit_id" ref="sf_sale.view_sale_order_form_inherit_sf"/>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//header/button[@name='action_confirm'][last()]" position="attributes">
|
||||||
|
<attribute name="attrs">{'invisible': [('state', '!=', 'draft')]}</attribute>
|
||||||
|
<attribute name="name">confirm_to_supply_method</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//header/button[@name='confirm_to_supply_method']" position="before">
|
||||||
|
<button name="action_confirm" string="供货方式确认" type="object" attrs="{'invisible': [('state', '!=', 'supply method')]}" confirm="确认供货方式"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//header/field[@name='state']" position="attributes">
|
||||||
|
<attribute name="statusbar_visible">draft,sent,supply method,sale</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//page/field[@name='order_line']/tree/field[@name='remark']" position="before">
|
||||||
|
<field name="supply_method" attrs="{'invisible': [('state', '=', 'draft')], 'required': [('state', '=', 'supply method')]}" />
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//header/button[@name='action_cancel']" position="attributes">
|
||||||
|
<attribute name="attrs">{'invisible': [('state', '!=', 'draft')]}</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//header/button[@name='action_cancel']" position="attributes">
|
||||||
|
<attribute name="attrs">{'invisible': [('state', '!=', 'draft')]}</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//header/button[@name='action_quotation_send'][5]" position="attributes">
|
||||||
|
<attribute name="attrs">{'invisible': ['|','&',('check_status', '!=', 'approved'),('state', 'in', ['draft','cancel','supply method']),'&',('check_status', '=', 'approved'),('state', 'in', ['sale','cancel','supply method'])]}</attribute>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="jikimo_sale_order_view_search_inherit_quotation_supply_method" model="ir.ui.view">
|
||||||
|
<field name="name">jikimo.sale.order.search.inherit.quotation.supply.method</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="mode">primary</field>
|
||||||
|
<field name="inherit_id" ref="sale.sale_order_view_search_inherit_quotation"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//filter[@name='my_quotation']" position="attributes">
|
||||||
|
<attribute name="domain">[('state', 'in', ('draft', 'sent')), ('user_id', '=', uid)]</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//filter[@name='draft']" position="after">
|
||||||
|
<filter string="供货方式待确认" name="supply_method" domain="[('state', '=', 'supply method')]"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="sale.action_quotations_with_onboarding" model="ir.actions.act_window">
|
||||||
|
<field name="search_view_id" ref="jikimo_sale_order_view_search_inherit_quotation_supply_method"/>
|
||||||
|
<field name="context">{'search_default_draft': 1}</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_quotations_supply_method" model="ir.actions.act_window">
|
||||||
|
<field name="name">报价单</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">sale.order</field>
|
||||||
|
<field name="view_mode">tree,kanban,form,calendar,pivot,graph,activity</field>
|
||||||
|
<field name="view_id" ref="sale.view_quotation_tree_with_onboarding"/>
|
||||||
|
<field name="search_view_id" ref="jikimo_sale_order_view_search_inherit_quotation_supply_method"/>
|
||||||
|
<field name="context">{'search_default_supply_method': 1}</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
Create a new quotation, the first step of a new sale!
|
||||||
|
</p><p>
|
||||||
|
Once the quotation is confirmed by the customer, it becomes a sales order.<br/> You will be able to create an invoice and collect the payment.
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<menuitem
|
||||||
|
id="sale.sale_menu_root"
|
||||||
|
groups="sf_base.group_production_engineer,sf_base.group_sale_director,sf_base.group_sale_salemanager"
|
||||||
|
/>
|
||||||
|
<!--供货路线专员菜单-->
|
||||||
|
<menuitem
|
||||||
|
id="sale_order_menu_quotations_supply_method"
|
||||||
|
name="报价"
|
||||||
|
action="action_quotations_supply_method"
|
||||||
|
parent="sale.sale_order_menu"
|
||||||
|
groups="sf_base.group_production_engineer"
|
||||||
|
sequence="2"/>
|
||||||
|
|
||||||
|
<record id="sale.menu_sale_order" model="ir.ui.menu">
|
||||||
|
<field name="groups_id" eval="[(4, ref('sf_base.group_production_engineer'))]"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="sale.report_sales_team" model="ir.ui.menu">
|
||||||
|
<field name="groups_id" eval="[(4, ref('sf_base.group_production_engineer'))]"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="sale.res_partner_menu" model="ir.ui.menu">
|
||||||
|
<field name="groups_id" eval="[(4, ref('sf_base.group_production_engineer'))]"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
@@ -1,23 +1,60 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
<record id="view_stock_move_operations_inherit_sf" model="ir.ui.view">
|
<!-- <record id="view_stock_move_operations_inherit_sf" model="ir.ui.view">-->
|
||||||
<field name="name">stock.move.operations.form.inherit.sf</field>
|
<!-- <field name="name">stock.move.operations.form.inherit.sf</field>-->
|
||||||
<field name="model">stock.move</field>
|
<!-- <field name="model">stock.move</field>-->
|
||||||
<field name="inherit_id" ref="stock.view_stock_move_operations"/>
|
<!-- <field name="inherit_id" ref="stock.view_stock_move_operations"/>-->
|
||||||
<field name="arch" type="xml">
|
<!-- <field name="arch" type="xml">-->
|
||||||
<xpath expr="//button[@name='action_assign_serial_show_details']" position="after">
|
<!-- <xpath expr="//button[@name='action_assign_serial_show_details']" position="after">-->
|
||||||
<button name="print_serial_numbers" string="序列号打印" type="object"/>
|
<!-- <button name="print_serial_numbers" string="序列号打印" type="object"/>-->
|
||||||
</xpath>
|
<!-- </xpath>-->
|
||||||
</field>
|
<!-- </field>-->
|
||||||
</record>
|
<!-- </record>-->
|
||||||
|
|
||||||
<record model="ir.ui.view" id="view_picking_form_inherit_sf">
|
<record model="ir.ui.view" id="view_picking_form_inherit_sf_1">
|
||||||
<field name="name">stock.picking.form.inherit.sf</field>
|
<field name="name">stock.picking.form.inherit.sf</field>
|
||||||
<field name="model">stock.picking</field>
|
<field name="model">stock.picking</field>
|
||||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='user_id']" position="after">
|
||||||
|
<field name="picking_type_sequence_code" invisible="1"/>
|
||||||
|
<field name="retrospect_ref"
|
||||||
|
attrs="{'invisible':[('picking_type_sequence_code','not in',['DL', 'INT', 'PC'])]}"/>
|
||||||
|
<field name="person_of_delivery" attrs="{'invisible':[('picking_type_sequence_code','!=','DL')]}"/>
|
||||||
|
<field name="telephone_of_delivery"
|
||||||
|
attrs="{'invisible':[('picking_type_sequence_code','!=','DL')]}"/>
|
||||||
|
<field name="address_of_delivery" attrs="{'invisible':[('picking_type_sequence_code','!=','DL')]}"/>
|
||||||
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="sf_vpicktree_1" model="ir.ui.view">
|
||||||
|
<field name="name">sf.vpicktree.1</field>
|
||||||
|
<field name="model">stock.picking</field>
|
||||||
|
<field name="inherit_id" ref="stock.vpicktree"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='origin']" position="after">
|
||||||
|
<field name="retrospect_ref"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_picking_internal_search_sf" model="ir.ui.view">
|
||||||
|
<field name="name">stock.picking.search</field>
|
||||||
|
<field name="model">stock.picking</field>
|
||||||
|
<field name="inherit_id" ref="stock.view_picking_internal_search"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//filter[@name='picking_type']" position="after">
|
||||||
|
<filter string="追溯参考" name="retrospect_ref" domain="[]"
|
||||||
|
context="{'group_by': 'retrospect_ref'}"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="stock.action_picking_tree_all" model="ir.actions.act_window">
|
||||||
|
<field name="view_ids" eval="[(5, 0, 0),
|
||||||
|
(0, 0, {'view_mode': 'tree', 'view_id': ref('stock.vpicktree')})]"/>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
from . import workpiece_delivery_wizard
|
from . import workpiece_delivery_wizard
|
||||||
from . import rework_wizard
|
from . import rework_wizard
|
||||||
from . import production_wizard
|
from . import production_wizard
|
||||||
|
from . import production_technology_wizard
|
||||||
|
from . import production_technology_re_adjust_wizard
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import logging
|
||||||
|
from itertools import groupby
|
||||||
|
from odoo import models, api, fields, _
|
||||||
|
|
||||||
|
|
||||||
|
class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
||||||
|
_name = 'sf.production.technology.re_adjust.wizard'
|
||||||
|
_description = '制造订单工艺调整'
|
||||||
|
|
||||||
|
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||||
|
origin = fields.Char(string='源单据')
|
||||||
|
is_technology_re_adjust = fields.Boolean(default=False)
|
||||||
|
|
||||||
|
def confirm(self):
|
||||||
|
if self.is_technology_re_adjust is True:
|
||||||
|
domain = [('origin', '=', self.origin), ('state', '=', 'confirmed'),
|
||||||
|
('product_id', '=', self.production_id.product_id.id)]
|
||||||
|
else:
|
||||||
|
domain = [('id', '=', self.production_id.id)]
|
||||||
|
technology_designs = self.env['sf.technology.design'].sudo().search(
|
||||||
|
[('production_id', '=', self.production_id.id), ('active', 'in', [True, False])])
|
||||||
|
productions = self.env['mrp.production'].search(domain)
|
||||||
|
for production_item in productions:
|
||||||
|
# 该制造订单的其他同一销售订单的制造订单的工艺设计处理
|
||||||
|
if production_item != self.production_id:
|
||||||
|
for td_other in production_item.technology_design_ids:
|
||||||
|
if td_other.is_auto is False:
|
||||||
|
td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
||||||
|
if not td_del or td_del.active is False:
|
||||||
|
td_other.write({'active': False})
|
||||||
|
for td_main in technology_designs:
|
||||||
|
route_other = production_item.technology_design_ids.filtered(
|
||||||
|
lambda td: td.route_id.id == td_main.route_id.id)
|
||||||
|
if not route_other and td_main.active is True:
|
||||||
|
production_item.write({'technology_design_ids': [(0, 0, {
|
||||||
|
'route_id': td_main.route_id.id,
|
||||||
|
'process_parameters_id': False if td_main.process_parameters_id is False else
|
||||||
|
self.env[
|
||||||
|
'sf.production.process.parameter'].search(
|
||||||
|
[('id', '=', td_main.process_parameters_id.id)]).id,
|
||||||
|
'sequence': td_main.sequence,
|
||||||
|
'is_auto': td_main.is_auto})]})
|
||||||
|
else:
|
||||||
|
for ro in route_other:
|
||||||
|
domain = [('production_id', '=', self.production_id.id),
|
||||||
|
('active', 'in', [True, False]),
|
||||||
|
('route_id', '=', ro.route_id.id)]
|
||||||
|
if ro.route_id.routing_type == '表面工艺':
|
||||||
|
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||||
|
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
||||||
|
# display_name = ro.route_id.display_name
|
||||||
|
domain += [('id', '=', ro.id)]
|
||||||
|
elif ro.panel is not False:
|
||||||
|
domain += [('panel', '=', ro.panel)]
|
||||||
|
td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
||||||
|
if td_upd:
|
||||||
|
ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
||||||
|
special_design = self.env['sf.technology.design'].sudo().search(
|
||||||
|
[('routing_tag', '=', 'special'), ('production_id', '=', production_item.id),
|
||||||
|
('is_auto', '=', False), ('active', 'in', [True, False])])
|
||||||
|
for special in special_design:
|
||||||
|
workorders_values = []
|
||||||
|
if special.active is False:
|
||||||
|
is_cancel = False
|
||||||
|
# 工单采购单外协出入库单皆需取消
|
||||||
|
domain = [('production_id', '=', special.production_id.id)]
|
||||||
|
if special.process_parameters_id:
|
||||||
|
domain += [('surface_technics_parameters_id', '=', special.process_parameters_id.id), ('state', '!=', 'cancel')]
|
||||||
|
else:
|
||||||
|
domain += [('technology_design_id', '=', special.id), ('state', '!=', 'cancel')]
|
||||||
|
workorder = self.env['mrp.workorder'].search(domain)
|
||||||
|
# previous_workorder = self.env['mrp.workorder'].search(
|
||||||
|
# [('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
||||||
|
# ('production_id', '=', workorder.production_id.id)])
|
||||||
|
# if previous_workorder:
|
||||||
|
# if previous_workorder.supplier_id != workorder.supplier_id:
|
||||||
|
# is_cancel = True
|
||||||
|
# else:
|
||||||
|
# is_cancel = True
|
||||||
|
# if workorder.state != 'cancel' and is_cancel is True:
|
||||||
|
# workorder.write({'state': 'cancel'})
|
||||||
|
# workorder.picking_ids.write({'state': 'cancel'})
|
||||||
|
# workorder.picking_ids.move_ids.write({'state': 'cancel'})
|
||||||
|
# purchase_order = self.env['purchase.order'].search(
|
||||||
|
# [('origin', '=', workorder.production_id.name)])
|
||||||
|
# for line in purchase_order.order_line:
|
||||||
|
# if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id:
|
||||||
|
# purchase_order.write({'state': 'cancel'})
|
||||||
|
else:
|
||||||
|
workorder = self.env['mrp.workorder'].search(
|
||||||
|
[('technology_design_id', '=', special.id), ('production_id', '=', special.production_id.id), ('state', '!=', 'cancel')])
|
||||||
|
if not workorder:
|
||||||
|
if special.route_id.routing_type == '表面工艺':
|
||||||
|
product_production_process = self.env['product.template'].search(
|
||||||
|
[('server_product_process_parameters_id', '=', special.process_parameters_id.id)])
|
||||||
|
workorders_values.append(
|
||||||
|
self.env[
|
||||||
|
'mrp.workorder']._json_workorder_surface_process_str(special.production_id, special,
|
||||||
|
product_production_process.seller_ids[
|
||||||
|
0].partner_id.id))
|
||||||
|
else:
|
||||||
|
workorders_values.append(
|
||||||
|
self.env['mrp.workorder'].json_workorder_str(special.production_id, special))
|
||||||
|
special.production_id.write({'workorder_ids': workorders_values})
|
||||||
|
else:
|
||||||
|
logging.info(workorder.blocked_by_workorder_ids)
|
||||||
|
if len(workorder.blocked_by_workorder_ids) > 1:
|
||||||
|
if workorder.sequence == 1:
|
||||||
|
workorder.blocked_by_workorder_ids = None
|
||||||
|
else:
|
||||||
|
if workorder.blocked_by_workorder_ids:
|
||||||
|
workorder.blocked_by_workorder_ids = workorder.blocked_by_workorder_ids[0]
|
||||||
|
productions._reset_work_order_sequence()
|
||||||
|
# 退回时不对外协出入库单和采购单做处理
|
||||||
|
# if self.production_id.product_id.categ_id.type == '成品':
|
||||||
|
# productions._reset_subcontract_pick_purchase()
|
||||||
|
# productions.get_subcontract_pick_purchase()
|
||||||
|
productions.is_adjust = True
|
||||||
|
for item in productions:
|
||||||
|
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||||
|
key=lambda a: a.sequence)
|
||||||
|
if workorders[0].state in ['pending']:
|
||||||
|
if workorders[
|
||||||
|
0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
||||||
|
workorders[0].state = 'waiting'
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record model="ir.ui.view" id="sf_production_technology_re_adjust_wizard_form_view">
|
||||||
|
<field name="name">sf.production.technology.re_adjust.wizard.form.view</field>
|
||||||
|
<field name="model">sf.production.technology.re_adjust.wizard</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form>
|
||||||
|
<sheet>
|
||||||
|
<field name="production_id" invisible="1"/>
|
||||||
|
<field name="origin" invisible="1"/>
|
||||||
|
<div>
|
||||||
|
<field name="is_technology_re_adjust" force_save="1"/>
|
||||||
|
当前制造订单,同一销售订单相同产品所生成的制造订单是否统一进行退回调整操作
|
||||||
|
</div>
|
||||||
|
<footer>
|
||||||
|
<button string="确认" name="confirm" type="object" class="oe_highlight" confirm="是否确认退回调整"/>
|
||||||
|
<button string="取消" class="btn btn-secondary" special="cancel"/>
|
||||||
|
</footer>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_sf_production_technology_re_adjust_wizard" model="ir.actions.act_window">
|
||||||
|
<field name="name">工艺退回调整</field>
|
||||||
|
<field name="res_model">sf.production.technology.re_adjust.wizard</field>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<!-- <field name="context">{-->
|
||||||
|
<!-- 'default_production_id': active_id}-->
|
||||||
|
<!-- </field>-->
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
118
sf_manufacturing/wizard/production_technology_wizard.py
Normal file
118
sf_manufacturing/wizard/production_technology_wizard.py
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of YiZuo. See LICENSE file for full copyright and licensing details.
|
||||||
|
import logging
|
||||||
|
from itertools import groupby
|
||||||
|
from odoo import models, api, fields, _
|
||||||
|
|
||||||
|
|
||||||
|
class ProductionTechnologyWizard(models.TransientModel):
|
||||||
|
_name = 'sf.production.technology.wizard'
|
||||||
|
_description = '制造订单工艺确认向导'
|
||||||
|
|
||||||
|
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||||
|
origin = fields.Char(string='源单据')
|
||||||
|
is_technology_confirm = fields.Boolean(default=False)
|
||||||
|
|
||||||
|
def confirm(self):
|
||||||
|
if self.is_technology_confirm is True and self.production_id.product_id.categ_id.type == '成品':
|
||||||
|
domain = [('origin', '=', self.origin), ('state', '=', 'technology_to_confirmed'),
|
||||||
|
('product_id', '=', self.production_id.product_id.id)]
|
||||||
|
else:
|
||||||
|
domain = [('id', '=', self.production_id.id)]
|
||||||
|
technology_designs = self.production_id.technology_design_ids
|
||||||
|
productions = self.env['mrp.production'].search(domain)
|
||||||
|
for production in productions:
|
||||||
|
if production != self.production_id:
|
||||||
|
for td_other in production.technology_design_ids:
|
||||||
|
if td_other.is_auto is False:
|
||||||
|
td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
||||||
|
if not td_del or td_del.active is False:
|
||||||
|
td_other.write({'active': False})
|
||||||
|
for td_main in technology_designs:
|
||||||
|
route_other = production.technology_design_ids.filtered(
|
||||||
|
lambda td: td.route_id.id == td_main.route_id.id)
|
||||||
|
if not route_other and td_main.active is True:
|
||||||
|
production.write({'technology_design_ids': [(0, 0, {
|
||||||
|
'route_id': td_main.route_id.id,
|
||||||
|
'process_parameters_id': False if td_main.process_parameters_id is False else self.env[
|
||||||
|
'sf.production.process.parameter'].search(
|
||||||
|
[('id', '=', td_main.process_parameters_id.id)]).id,
|
||||||
|
'sequence': td_main.sequence})]})
|
||||||
|
else:
|
||||||
|
for ro in route_other:
|
||||||
|
domain = [('production_id', '=', self.production_id.id),
|
||||||
|
('active', 'in', [True, False]),
|
||||||
|
('route_id', '=', ro.route_id.id)]
|
||||||
|
if ro.route_id.routing_type == '表面工艺':
|
||||||
|
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||||
|
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
||||||
|
# display_name = ro.route_id.display_name
|
||||||
|
domain += [('id', '=', ro.id)]
|
||||||
|
elif ro.panel is not False:
|
||||||
|
domain += [('panel', '=', ro.panel)]
|
||||||
|
td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
||||||
|
if td_upd:
|
||||||
|
ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
||||||
|
special_design = self.env['sf.technology.design'].sudo().search(
|
||||||
|
[('routing_tag', '=', 'special'), ('production_id', '=', production.id),
|
||||||
|
('is_auto', '=', False), ('active', 'in', [True, False])])
|
||||||
|
for special in special_design:
|
||||||
|
workorders_values = []
|
||||||
|
if special.active is False:
|
||||||
|
# is_cancel = False
|
||||||
|
# 工单采购单外协出入库单皆需取消
|
||||||
|
domain = [('production_id', '=', special.production_id.id)]
|
||||||
|
if special.process_parameters_id:
|
||||||
|
domain += [('surface_technics_parameters_id', '=', special.process_parameters_id.id), ('state', '!=', 'cancel')]
|
||||||
|
else:
|
||||||
|
domain += [('technology_design_id', '=', special.id), ('state', '!=', 'cancel')]
|
||||||
|
workorder = self.env['mrp.workorder'].search(domain)
|
||||||
|
# previous_workorder = self.env['mrp.workorder'].search(
|
||||||
|
# [('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
||||||
|
# ('production_id', '=', workorder.production_id.id)])
|
||||||
|
# if previous_workorder:
|
||||||
|
# if previous_workorder.supplier_id != workorder.supplier_id:
|
||||||
|
# is_cancel = True
|
||||||
|
# if workorder.state != 'cancel' and is_cancel is True:
|
||||||
|
workorder.write({'state': 'cancel'})
|
||||||
|
workorder.picking_ids.write({'state': 'cancel'})
|
||||||
|
workorder.picking_ids.move_ids.write({'state': 'cancel'})
|
||||||
|
purchase_order = self.env['purchase.order'].search(
|
||||||
|
[('origin', '=', workorder.production_id.name), ('purchase_type', '=', 'consignment')])
|
||||||
|
for line in purchase_order.order_line:
|
||||||
|
if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id:
|
||||||
|
purchase_order.write({'state': 'cancel'})
|
||||||
|
else:
|
||||||
|
if special.production_id.workorder_ids:
|
||||||
|
workorder = self.env['mrp.workorder'].search(
|
||||||
|
[('technology_design_id', '=', special.id), ('production_id', '=', special.production_id.id), ('state', '!=', 'cancel')])
|
||||||
|
if not workorder:
|
||||||
|
if special.route_id.routing_type == '表面工艺':
|
||||||
|
product_production_process = self.env['product.template'].search(
|
||||||
|
[('server_product_process_parameters_id', '=', special.process_parameters_id.id)])
|
||||||
|
workorders_values.append(
|
||||||
|
self.env[
|
||||||
|
'mrp.workorder']._json_workorder_surface_process_str(special.production_id, special,
|
||||||
|
product_production_process.seller_ids[
|
||||||
|
0].partner_id.id))
|
||||||
|
else:
|
||||||
|
workorders_values.append(
|
||||||
|
self.env['mrp.workorder'].json_workorder_str(special.production_id, special))
|
||||||
|
special.production_id.write({'workorder_ids': workorders_values})
|
||||||
|
else:
|
||||||
|
if len(workorder.blocked_by_workorder_ids) > 1:
|
||||||
|
if workorder.sequence == 1:
|
||||||
|
workorder.blocked_by_workorder_ids = None
|
||||||
|
else:
|
||||||
|
if workorder.blocked_by_workorder_ids:
|
||||||
|
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
|
||||||
|
productions._create_workorder(False)
|
||||||
|
if self.production_id.product_id.categ_id.type == '成品':
|
||||||
|
productions.get_subcontract_pick_purchase()
|
||||||
|
productions.is_adjust = False
|
||||||
|
for item in productions:
|
||||||
|
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||||
|
key=lambda a: a.sequence)
|
||||||
|
if workorder[0].state in ['pending']:
|
||||||
|
if workorder[0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
||||||
|
workorder[0].state = 'waiting'
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record model="ir.ui.view" id="sf_production_technology_wizard_form_view">
|
||||||
|
<field name="name">sf.production.technology.wizard.form.view</field>
|
||||||
|
<field name="model">sf.production.technology.wizard</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form>
|
||||||
|
<sheet>
|
||||||
|
<field name="production_id" invisible="1"/>
|
||||||
|
<field name="origin" invisible="1"/>
|
||||||
|
<div>
|
||||||
|
<field name="is_technology_confirm" force_save="1"/>
|
||||||
|
对当前制造订单,同一销售订单相同产品所生成的制造订单统一进行工艺调整与确认
|
||||||
|
</div>
|
||||||
|
<footer>
|
||||||
|
<button string="确认" name="confirm" type="object" class="oe_highlight" confirm="是否确认工艺调整"/>
|
||||||
|
<button string="取消" class="btn btn-secondary" special="cancel"/>
|
||||||
|
</footer>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_sf_production_technology_wizard" model="ir.actions.act_window">
|
||||||
|
<field name="name">工艺确认</field>
|
||||||
|
<field name="res_model">sf.production.technology.wizard</field>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<!-- <field name="context">{-->
|
||||||
|
<!-- 'default_production_id': active_id}-->
|
||||||
|
<!-- </field>-->
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
@@ -46,58 +46,5 @@ class ProductionWizard(models.TransientModel):
|
|||||||
ret = {'programming_list': [], 'is_reprogramming': self.is_reprogramming}
|
ret = {'programming_list': [], 'is_reprogramming': self.is_reprogramming}
|
||||||
if self.is_reprogramming is True:
|
if self.is_reprogramming is True:
|
||||||
self.production_id.update_programming_state()
|
self.production_id.update_programming_state()
|
||||||
else:
|
|
||||||
scrap_cnc = self.production_id.workorder_ids.filtered(lambda crw: crw.routing_type == 'CNC加工').cnc_ids
|
|
||||||
scrap_cmm = self.production_id.workorder_ids.filtered(lambda cm: cm.routing_type == 'CNC加工').cmm_ids
|
|
||||||
for item_line in scrap_cnc:
|
|
||||||
vals = {
|
|
||||||
'sequence_number': item_line.sequence_number,
|
|
||||||
'program_name': item_line.program_name,
|
|
||||||
'cutting_tool_name': item_line.cutting_tool_name,
|
|
||||||
'cutting_tool_no': item_line.cutting_tool_no,
|
|
||||||
'processing_type': item_line.processing_type,
|
|
||||||
'margin_x_y': item_line.margin_x_y,
|
|
||||||
'margin_z': item_line.margin_z,
|
|
||||||
'depth_of_processing_z': item_line.depth_of_processing_z,
|
|
||||||
'cutting_tool_extension_length': item_line.cutting_tool_extension_length,
|
|
||||||
'estimated_processing_time': item_line.estimated_processing_time,
|
|
||||||
'cutting_tool_handle_type': item_line.cutting_tool_handle_type,
|
|
||||||
'ftp_path': item_line.program_path,
|
|
||||||
'processing_panel': item_line.workorder_id.processing_panel,
|
|
||||||
'program_create_date': datetime.strftime(item_line.program_create_date,
|
|
||||||
'%Y-%m-%d %H:%M:%S'),
|
|
||||||
'remark': item_line.remark
|
|
||||||
}
|
|
||||||
ret['programming_list'].append(vals)
|
|
||||||
for cmm_line in scrap_cmm:
|
|
||||||
vals = {
|
|
||||||
'sequence_number': cmm_line.sequence_number,
|
|
||||||
'program_name': cmm_line.program_name,
|
|
||||||
'ftp_path': cmm_line.program_path,
|
|
||||||
'processing_panel': item_line.workorder_id.processing_panel,
|
|
||||||
'program_create_date': datetime.strftime(
|
|
||||||
cmm_line.program_create_date,
|
|
||||||
'%Y-%m-%d %H:%M:%S')
|
|
||||||
}
|
|
||||||
ret['programming_list'].append(vals)
|
|
||||||
|
|
||||||
new_production = self.production_id.recreateManufacturing(ret)
|
new_production = self.production_id.recreateManufacturing(ret)
|
||||||
self.production_id.write({'remanufacture_production_id': new_production.id})
|
self.production_id.write({'remanufacture_production_id': new_production.id})
|
||||||
if self.is_reprogramming is False:
|
|
||||||
for panel in new_production.product_id.model_processing_panel.split(','):
|
|
||||||
scrap_cnc_workorder = max(
|
|
||||||
self.production_id.workorder_ids.filtered(
|
|
||||||
lambda
|
|
||||||
scn: scn.processing_panel == panel and scn.routing_type == 'CNC加工'),
|
|
||||||
key=lambda w: w.create_date)
|
|
||||||
scrap_pre_workorder = max(self.production_id.workorder_ids.filtered(
|
|
||||||
lambda
|
|
||||||
pr: pr.processing_panel == panel and pr.routing_type == '装夹预调'),
|
|
||||||
key=lambda w1: w1.create_date)
|
|
||||||
new_cnc_workorder = new_production.workorder_ids.filtered(
|
|
||||||
lambda
|
|
||||||
nc: nc.processing_panel == panel and nc.routing_type == 'CNC加工')
|
|
||||||
new_cnc_workorder.write({'cnc_worksheet': scrap_cnc_workorder.cnc_worksheet})
|
|
||||||
new_pre_workorder = new_production.workorder_ids.filtered(lambda
|
|
||||||
p: p.routing_type == '装夹预调' and p.processing_panel == panel)
|
|
||||||
new_pre_workorder.write({'processing_drawing': scrap_pre_workorder.processing_drawing})
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import logging
|
|||||||
from odoo.exceptions import UserError, ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from odoo import models, api, fields, _
|
from odoo import models, api, fields, _
|
||||||
|
from odoo.tools import groupby
|
||||||
|
|
||||||
|
|
||||||
class ReworkWizard(models.TransientModel):
|
class ReworkWizard(models.TransientModel):
|
||||||
@@ -13,6 +14,9 @@ class ReworkWizard(models.TransientModel):
|
|||||||
workorder_id = fields.Many2one('mrp.workorder', string='工单')
|
workorder_id = fields.Many2one('mrp.workorder', string='工单')
|
||||||
product_id = fields.Many2one('product.product')
|
product_id = fields.Many2one('product.product')
|
||||||
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||||
|
workorder_ids = fields.Many2many('mrp.workorder', 'rework_wizard_to_work_order', string='所有工单',
|
||||||
|
domain="[('production_id', '=', production_id),('state','=','done')]")
|
||||||
|
hidden_workorder_ids = fields.Char('')
|
||||||
rework_reason = fields.Selection(
|
rework_reason = fields.Selection(
|
||||||
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
|
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
|
||||||
("operate computer", "操机"),
|
("operate computer", "操机"),
|
||||||
@@ -34,6 +38,30 @@ class ReworkWizard(models.TransientModel):
|
|||||||
|
|
||||||
tool_state = fields.Selection(string='功能刀具状态', related='production_id.tool_state')
|
tool_state = fields.Selection(string='功能刀具状态', related='production_id.tool_state')
|
||||||
|
|
||||||
|
@api.onchange('hidden_workorder_ids')
|
||||||
|
def _onchange_hidden_workorder_ids(self):
|
||||||
|
for item in self:
|
||||||
|
if item.hidden_workorder_ids not in ['', None, False]:
|
||||||
|
hidden_workorder_list = item.hidden_workorder_ids.split(',')
|
||||||
|
# 获取加工面对应需要返工的工单
|
||||||
|
rw_ids = item.workorder_ids.filtered(
|
||||||
|
lambda w: str(w.ids[0]) in hidden_workorder_list and w.processing_panel not in ['', None, False])
|
||||||
|
grouped_rw_ids = {key: list(group) for key, group in groupby(rw_ids, key=lambda w: w.processing_panel)}
|
||||||
|
for panel, panel_rw_ids in grouped_rw_ids.items():
|
||||||
|
work_ids = item.workorder_ids.filtered(lambda w: w.state == 'done' and w.processing_panel == panel)
|
||||||
|
if len(work_ids) == 3 and len(panel_rw_ids) != 3:
|
||||||
|
for work_id in work_ids:
|
||||||
|
if work_id not in panel_rw_ids:
|
||||||
|
hidden_workorder_list.append(str(work_id.ids[0]))
|
||||||
|
elif len(work_ids) == 2 and len(panel_rw_ids) < 2 and panel_rw_ids[0].name == 'CNC加工':
|
||||||
|
if rw_ids.filtered(lambda w: (w.sequence < panel_rw_ids[0].sequence
|
||||||
|
and w.processing_panel != panel_rw_ids[0].processing_panel)):
|
||||||
|
hidden_workorder_list.append(str(work_ids.filtered(
|
||||||
|
lambda w: (w.processing_panel == panel_rw_ids[0].processing_panel
|
||||||
|
and w.name == '装夹预调')).ids[0]))
|
||||||
|
hidden_workorder_list.sort()
|
||||||
|
item.hidden_workorder_ids = ','.join(hidden_workorder_list)
|
||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.routing_type in ['装夹预调', 'CNC加工']:
|
if self.routing_type in ['装夹预调', 'CNC加工']:
|
||||||
self.is_clamp_measure = False
|
self.is_clamp_measure = False
|
||||||
@@ -48,100 +76,122 @@ class ReworkWizard(models.TransientModel):
|
|||||||
'test_report': self.workorder_id.detection_report})]})
|
'test_report': self.workorder_id.detection_report})]})
|
||||||
self.workorder_id.button_finish()
|
self.workorder_id.button_finish()
|
||||||
else:
|
else:
|
||||||
if self.production_id.workorder_ids:
|
if self.hidden_workorder_ids:
|
||||||
handle_result = self.production_id.detection_result_ids.filtered(
|
hidden_workorder_list = self.hidden_workorder_ids.split(',')
|
||||||
lambda dr: dr.handle_result == '待处理')
|
rework_workorder_ids = self.workorder_ids.filtered(lambda w: str(w.id) in hidden_workorder_list)
|
||||||
if handle_result:
|
# 限制判断
|
||||||
processing_panels_to_handle = set(handle_item.processing_panel for handle_item in handle_result)
|
# 1、当制造订单内ZM面的工单都已完成时,返工勾选工序时只能勾选上ZM面的所有工序进行返工
|
||||||
processing_panels_choice = set(dr_panel.name for dr_panel in self.processing_panel_id)
|
# 2、当FM工单在CNC工单进行选择返工,并将已全部完成的ZM面工序全部勾选上时,FM工单上所有的已完成的工单(装夹预调工单)也必须进行勾选
|
||||||
# 使用集合的差集操作找出那些待处理结果中有但实际可用加工面中没有的加工面
|
# 获取已完成的标准工单
|
||||||
processing_panels_missing = processing_panels_to_handle - processing_panels_choice
|
# done_normative_workorder_ids = self.workorder_ids.filtered(
|
||||||
# 存在不一致的加工面
|
# lambda w: w.state == 'done' and w.processing_panel is not False)
|
||||||
if processing_panels_missing:
|
# # 获取需要返工的标准工单
|
||||||
processing_panels_str = ','.join(processing_panels_missing)
|
# rework_normative_workorder_ids = rework_workorder_ids.filtered(
|
||||||
raise UserError('您还有待处理的检测结果中为%s的加工面未选择' % processing_panels_str)
|
# lambda w: w.processing_panel is not False)
|
||||||
for panel in self.processing_panel_id:
|
# if rework_normative_workorder_ids:
|
||||||
panel_workorder = self.production_id.workorder_ids.filtered(
|
# for rw in rework_normative_workorder_ids:
|
||||||
lambda ap: ap.processing_panel == panel.name and ap.state != 'rework')
|
# if len(done_normative_workorder_ids.filtered(
|
||||||
if panel_workorder:
|
# lambda w: w.processing_panel == rw.processing_panel)) == 3:
|
||||||
panel_workorder.write({'state': 'rework'})
|
# pass
|
||||||
rework_clamp_workorder = max(panel_workorder.filtered(
|
else:
|
||||||
lambda
|
raise ValidationError('请选择返工工单!!!')
|
||||||
rp: rp.processing_panel == panel.name and rp.routing_type == '装夹预调' and rp.state in [
|
if rework_workorder_ids:
|
||||||
'done', 'rework']))
|
clamp_workorder_ids = None
|
||||||
# panel_workorder.filtered(
|
if rework_workorder_ids:
|
||||||
# lambda wo: wo.routing_type == '装夹预调').workpiece_delivery_ids.filtered(
|
# 限制
|
||||||
# lambda wd: wd.status == '待下发').write({'status': '已取消'})
|
# 1、单独返工CNC工单则不解绑托盘RFID,如单独返工装夹预调工单,则自动解绑托盘RFID;
|
||||||
# workpiece = self.env['sf.workpiece.delivery'].search([('status', '=', '待下发'), (
|
# 2、返工CNC工单和装夹预调工单则自动解绑RFID
|
||||||
# 'workorder_id', '=',
|
clamp_workorder_ids = rework_workorder_ids.filtered(lambda rp: rp.routing_type == '装夹预调')
|
||||||
# panel_workorder.filtered(lambda wd: wd.routing_type == '装夹预调').id)])
|
if clamp_workorder_ids:
|
||||||
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
for clamp_workorder_id in clamp_workorder_ids:
|
||||||
[('product_model_type_id', '=', self.production_id.product_id.product_model_type_id.id)],
|
self.production_id.workorder_ids.filtered(
|
||||||
order='sequence asc'
|
lambda wk: wk.processing_panel == clamp_workorder_id.processing_panel).write(
|
||||||
)
|
{'rfid_code': False})
|
||||||
workorders_values = []
|
# 返工工单状态设置为【返工】
|
||||||
for route in product_routing_workcenter:
|
rework_workorder_ids.write({'state': 'rework'})
|
||||||
if route.is_repeat is True:
|
# 查询返工工单对应的工艺设计记录,并调用方法拼接数据,用于创建新的工单
|
||||||
workorders_values.append(
|
workorders_values = []
|
||||||
self.env['mrp.workorder'].json_workorder_str(panel.name,
|
for work in rework_workorder_ids:
|
||||||
self.production_id, route, False))
|
route = self.production_id.technology_design_ids.filtered(
|
||||||
if workorders_values:
|
lambda item: (item.route_id.name in work.name and item.process_parameters_id
|
||||||
self.production_id.write({'workorder_ids': workorders_values, 'is_rework': True})
|
and item.process_parameters_id == work.surface_technics_parameters_id) or
|
||||||
self.production_id._reset_work_order_sequence()
|
(item.route_id.name == work.name and item.panel
|
||||||
self.production_id.detection_result_ids.filtered(
|
and item.panel == work.processing_panel))
|
||||||
lambda ap1: ap1.processing_panel == panel.name and ap1.handle_result == '待处理').write(
|
if route:
|
||||||
{'handle_result': '已处理'})
|
work_list = self.env['mrp.workorder'].json_workorder_str(self.production_id, route[0])
|
||||||
new_pre_workorder = self.production_id.workorder_ids.filtered(lambda
|
work_list[2].update({'tag_type': '重新加工'})
|
||||||
p: p.routing_type == '装夹预调' and p.processing_panel == panel.name and p.state not in (
|
workorders_values.append(work_list)
|
||||||
'rework', 'done'))
|
# 创建新工单,并进行返工配置的相关操作
|
||||||
if new_pre_workorder and rework_clamp_workorder and self.is_clamp_measure is True:
|
if workorders_values:
|
||||||
new_pre_workorder.write(
|
# 创建新工单、工序排序、完成检测结果单据
|
||||||
{'X1_axis': rework_clamp_workorder.X1_axis, 'Y1_axis': rework_clamp_workorder.Y1_axis
|
self.production_id.write({'workorder_ids': workorders_values, 'is_rework': True})
|
||||||
, 'Z1_axis': rework_clamp_workorder.Z1_axis,
|
new_work_ids = self.production_id.workorder_ids.filtered(lambda kw: kw.sequence == 0)
|
||||||
'X2_axis': rework_clamp_workorder.X2_axis
|
new_pre_workorder_ids = self.production_id.workorder_ids.filtered(
|
||||||
, 'Y2_axis': rework_clamp_workorder.Y2_axis,
|
lambda kw: kw.routing_type == '装夹预调' and kw.sequence == 0)
|
||||||
'Z2_axis': rework_clamp_workorder.Z2_axis
|
self.production_id._reset_work_order_sequence()
|
||||||
, 'X3_axis': rework_clamp_workorder.X3_axis,
|
self.production_id.detection_result_ids.filtered(
|
||||||
'Y3_axis': rework_clamp_workorder.Y3_axis
|
lambda ap1: ap1.handle_result == '待处理').write({'handle_result': '已处理'})
|
||||||
, 'Z3_axis': rework_clamp_workorder.Z3_axis,
|
panels = [] # 返工的加工面
|
||||||
'X4_axis': rework_clamp_workorder.X4_axis
|
# ===================保留装夹测量数据=====================
|
||||||
, 'Y4_axis': rework_clamp_workorder.Y4_axis,
|
if self.is_clamp_measure and clamp_workorder_ids and new_pre_workorder_ids:
|
||||||
'Z4_axis': rework_clamp_workorder.Z4_axis
|
for new_pre_workorder in new_pre_workorder_ids:
|
||||||
, 'X5_axis': rework_clamp_workorder.X5_axis,
|
if new_pre_workorder.processing_panel and new_pre_workorder.processing_panel not in panels:
|
||||||
'Y5_axis': rework_clamp_workorder.Y5_axis
|
panels.append(new_pre_workorder.processing_panel)
|
||||||
, 'Z5_axis': rework_clamp_workorder.Z5_axis,
|
for rework_clamp_workorder in clamp_workorder_ids:
|
||||||
'X6_axis': rework_clamp_workorder.X6_axis
|
if new_pre_workorder.sequence == rework_clamp_workorder.sequence + 1:
|
||||||
, 'Y6_axis': rework_clamp_workorder.Y6_axis,
|
new_pre_workorder.write(
|
||||||
'Z6_axis': rework_clamp_workorder.Z6_axis
|
{'X1_axis': rework_clamp_workorder.X1_axis,
|
||||||
, 'X7_axis': rework_clamp_workorder.X7_axis,
|
'Y1_axis': rework_clamp_workorder.Y1_axis
|
||||||
'Y7_axis': rework_clamp_workorder.Y7_axis
|
, 'Z1_axis': rework_clamp_workorder.Z1_axis,
|
||||||
, 'Z7_axis': rework_clamp_workorder.Z7_axis,
|
'X2_axis': rework_clamp_workorder.X2_axis
|
||||||
'X8_axis': rework_clamp_workorder.X8_axis
|
, 'Y2_axis': rework_clamp_workorder.Y2_axis,
|
||||||
, 'Y8_axis': rework_clamp_workorder.Y8_axis,
|
'Z2_axis': rework_clamp_workorder.Z2_axis
|
||||||
'Z8_axis': rework_clamp_workorder.Z8_axis
|
, 'X3_axis': rework_clamp_workorder.X3_axis,
|
||||||
, 'X9_axis': rework_clamp_workorder.X9_axis,
|
'Y3_axis': rework_clamp_workorder.Y3_axis
|
||||||
'Y9_axis': rework_clamp_workorder.Y9_axis
|
, 'Z3_axis': rework_clamp_workorder.Z3_axis,
|
||||||
, 'Z9_axis': rework_clamp_workorder.Z9_axis,
|
'X4_axis': rework_clamp_workorder.X4_axis
|
||||||
'X10_axis': rework_clamp_workorder.X10_axis
|
, 'Y4_axis': rework_clamp_workorder.Y4_axis,
|
||||||
, 'Y10_axis': rework_clamp_workorder.Y10_axis,
|
'Z4_axis': rework_clamp_workorder.Z4_axis
|
||||||
'Z10_axis': rework_clamp_workorder.Z10_axis
|
, 'X5_axis': rework_clamp_workorder.X5_axis,
|
||||||
, 'X_deviation_angle': rework_clamp_workorder.X_deviation_angle,
|
'Y5_axis': rework_clamp_workorder.Y5_axis
|
||||||
'material_center_point': rework_clamp_workorder.material_center_point
|
, 'Z5_axis': rework_clamp_workorder.Z5_axis,
|
||||||
})
|
'X6_axis': rework_clamp_workorder.X6_axis
|
||||||
if self.is_reprogramming is False:
|
, 'Y6_axis': rework_clamp_workorder.Y6_axis,
|
||||||
if self.programming_state in ['已编程', '已下发']:
|
'Z6_axis': rework_clamp_workorder.Z6_axis
|
||||||
if self.reprogramming_num >= 1 and self.programming_state == '已编程':
|
, 'X7_axis': rework_clamp_workorder.X7_axis,
|
||||||
self.production_id.get_new_program(panel.name)
|
'Y7_axis': rework_clamp_workorder.Y7_axis
|
||||||
if self.reprogramming_num >= 0 and self.programming_state == '已下发':
|
, 'Z7_axis': rework_clamp_workorder.Z7_axis,
|
||||||
|
'X8_axis': rework_clamp_workorder.X8_axis
|
||||||
|
, 'Y8_axis': rework_clamp_workorder.Y8_axis,
|
||||||
|
'Z8_axis': rework_clamp_workorder.Z8_axis
|
||||||
|
, 'X9_axis': rework_clamp_workorder.X9_axis,
|
||||||
|
'Y9_axis': rework_clamp_workorder.Y9_axis
|
||||||
|
, 'Z9_axis': rework_clamp_workorder.Z9_axis,
|
||||||
|
'X10_axis': rework_clamp_workorder.X10_axis
|
||||||
|
, 'Y10_axis': rework_clamp_workorder.Y10_axis,
|
||||||
|
'Z10_axis': rework_clamp_workorder.Z10_axis
|
||||||
|
, 'X_deviation_angle': rework_clamp_workorder.X_deviation_angle,
|
||||||
|
'material_center_point': rework_clamp_workorder.material_center_point
|
||||||
|
})
|
||||||
|
break
|
||||||
|
# =====================不申请重新编程====================
|
||||||
|
if self.is_reprogramming is False:
|
||||||
|
if self.programming_state in ['已编程', '已下发']:
|
||||||
|
if self.reprogramming_num >= 1 and self.programming_state == '已编程':
|
||||||
|
for panel_name in panels:
|
||||||
|
self.production_id.get_new_program(panel_name)
|
||||||
|
if self.reprogramming_num >= 0 and self.programming_state == '已下发':
|
||||||
|
# ============= 处理CNC加工加工工单的 CNC程序和cmm程序 信息=============
|
||||||
|
for cnc_work in new_work_ids.filtered(lambda wk: wk.name == 'CNC加工'):
|
||||||
ret = {'programming_list': []}
|
ret = {'programming_list': []}
|
||||||
cnc_rework = max(
|
old_cnc_rework = max(self.production_id.workorder_ids.filtered(
|
||||||
self.production_id.workorder_ids.filtered(
|
lambda crw: crw.processing_panel == cnc_work.processing_panel
|
||||||
lambda
|
and crw.state == 'rework' and crw.routing_type == 'CNC加工'),
|
||||||
crw: crw.processing_panel == panel.name and crw.state == 'rework' and crw.routing_type == 'CNC加工'),
|
|
||||||
key=lambda w: w.create_date
|
key=lambda w: w.create_date
|
||||||
)
|
)
|
||||||
if cnc_rework.cnc_ids:
|
# 获取当前工单的CNC程序和cmm程序
|
||||||
for item_line in cnc_rework.cnc_ids:
|
if old_cnc_rework.cnc_ids:
|
||||||
|
for item_line in old_cnc_rework.cnc_ids:
|
||||||
vals = {
|
vals = {
|
||||||
'sequence_number': item_line.sequence_number,
|
'sequence_number': item_line.sequence_number,
|
||||||
'program_name': item_line.program_name,
|
'program_name': item_line.program_name,
|
||||||
@@ -156,46 +206,50 @@ class ReworkWizard(models.TransientModel):
|
|||||||
'cutting_tool_handle_type': item_line.cutting_tool_handle_type,
|
'cutting_tool_handle_type': item_line.cutting_tool_handle_type,
|
||||||
'program_path': item_line.program_path,
|
'program_path': item_line.program_path,
|
||||||
'ftp_path': item_line.program_path,
|
'ftp_path': item_line.program_path,
|
||||||
'processing_panel': panel.name,
|
'processing_panel': cnc_work.processing_panel,
|
||||||
'program_create_date': datetime.strftime(item_line.program_create_date,
|
'program_create_date': datetime.strftime(item_line.program_create_date,
|
||||||
'%Y-%m-%d %H:%M:%S'),
|
'%Y-%m-%d %H:%M:%S'),
|
||||||
'remark': item_line.remark
|
'remark': item_line.remark
|
||||||
}
|
}
|
||||||
ret['programming_list'].append(vals)
|
ret['programming_list'].append(vals)
|
||||||
for cmm_line in cnc_rework.cmm_ids:
|
for cmm_line in old_cnc_rework.cmm_ids:
|
||||||
vals = {
|
vals = {
|
||||||
'sequence_number': cmm_line.sequence_number,
|
'sequence_number': cmm_line.sequence_number,
|
||||||
'program_name': cmm_line.program_name,
|
'program_name': cmm_line.program_name,
|
||||||
'program_path': cmm_line.program_path,
|
'program_path': cmm_line.program_path,
|
||||||
'ftp_path': cmm_line.program_path,
|
'ftp_path': cmm_line.program_path,
|
||||||
'processing_panel': panel.name,
|
'processing_panel': cnc_work.processing_panel,
|
||||||
'program_create_date': datetime.strftime(
|
'program_create_date': datetime.strftime(
|
||||||
cmm_line.program_create_date,
|
cmm_line.program_create_date,
|
||||||
'%Y-%m-%d %H:%M:%S')
|
'%Y-%m-%d %H:%M:%S')
|
||||||
}
|
}
|
||||||
ret['programming_list'].append(vals)
|
ret['programming_list'].append(vals)
|
||||||
|
# 获取新的
|
||||||
new_cnc_workorder = self.production_id.workorder_ids.filtered(
|
new_cnc_workorder = self.production_id.workorder_ids.filtered(
|
||||||
lambda ap1: ap1.processing_panel == panel.name and ap1.state not in (
|
lambda ap1: ap1.processing_panel == cnc_work.processing_panel
|
||||||
'rework', 'done') and ap1.routing_type == 'CNC加工')
|
and ap1.state not in (
|
||||||
|
'rework', 'done') and ap1.routing_type == 'CNC加工'
|
||||||
|
)
|
||||||
if not new_cnc_workorder.cnc_ids:
|
if not new_cnc_workorder.cnc_ids:
|
||||||
new_cnc_workorder.write({
|
new_cnc_workorder.write({
|
||||||
'cnc_ids': new_cnc_workorder.cnc_ids.sudo()._json_cnc_processing(panel.name,
|
'cnc_ids': new_cnc_workorder.cnc_ids.sudo()._json_cnc_processing(
|
||||||
ret),
|
cnc_work.processing_panel, ret),
|
||||||
'cmm_ids': new_cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel.name,
|
'cmm_ids': new_cnc_workorder.cmm_ids.sudo()._json_cmm_program(
|
||||||
ret),
|
cnc_work.processing_panel, ret),
|
||||||
'cnc_worksheet': cnc_rework.cnc_worksheet})
|
'cnc_worksheet': old_cnc_rework.cnc_worksheet})
|
||||||
|
# ========== 处理装夹预调 【装夹图纸】 数据 ================
|
||||||
if new_pre_workorder:
|
for new_pre_work in new_pre_workorder_ids:
|
||||||
pre_rework = max(self.production_id.workorder_ids.filtered(
|
pre_rework = max(self.production_id.workorder_ids.filtered(
|
||||||
lambda pr: pr.processing_panel == panel.name and pr.state in (
|
lambda pr: (pr.processing_panel == new_pre_work.processing_panel
|
||||||
'rework') and pr.routing_type == '装夹预调'),
|
and pr.state in ['rework'] and pr.routing_type == '装夹预调')),
|
||||||
key=lambda w1: w1.create_date)
|
key=lambda w1: w1.create_date)
|
||||||
new_pre_workorder.write(
|
new_pre_work.write(
|
||||||
{'processing_drawing': pre_rework.processing_drawing})
|
{'processing_drawing': pre_rework.processing_drawing})
|
||||||
self.production_id.write({'state': 'progress', 'is_rework': False})
|
self.production_id.write({'state': 'progress', 'is_rework': False})
|
||||||
elif self.programming_state in ['待编程', '编程中']:
|
elif self.programming_state in ['待编程', '编程中']:
|
||||||
self.production_id.write(
|
self.production_id.write(
|
||||||
{'programming_state': '编程中', 'work_state': '编程中', 'is_rework': True})
|
{'programming_state': '编程中', 'work_state': '编程中', 'is_rework': True})
|
||||||
|
# ==================申请重新编程=======================
|
||||||
if self.is_reprogramming is True:
|
if self.is_reprogramming is True:
|
||||||
self.production_id.update_programming_state()
|
self.production_id.update_programming_state()
|
||||||
self.production_id.write(
|
self.production_id.write(
|
||||||
|
|||||||
@@ -11,10 +11,20 @@
|
|||||||
<field name="product_id" invisible="True"/>
|
<field name="product_id" invisible="True"/>
|
||||||
<field name="tool_state" invisible="True"/>
|
<field name="tool_state" invisible="True"/>
|
||||||
<field name="routing_type" invisible="True"/>
|
<field name="routing_type" invisible="True"/>
|
||||||
|
<field name="processing_panel_id" invisible="1"/>
|
||||||
|
<field name="hidden_workorder_ids" class="css_not_available_msg"/>
|
||||||
<group>
|
<group>
|
||||||
<field name="processing_panel_id" options="{'no_create': True}"
|
<field name="hidden_workorder_ids"/>
|
||||||
attrs='{"invisible": [("routing_type","=","装夹预调")]}' widget="many2many_tags"/>
|
<field options="{'no_create': True,'no_open': True}" readonly="1" name="workorder_ids"
|
||||||
|
widget="jikimo_subtree_selector_field"
|
||||||
|
jikimo_selector="True" replace_context="hidden_workorder_ids" string="工序"
|
||||||
|
attrs='{"invisible": [("routing_type","=","装夹预调")]}'>
|
||||||
|
<tree create="0" editable='bottom' delete="0">
|
||||||
|
<field name="sequence" readonly="1" string="工序"/>
|
||||||
|
<field name="processing_panel" readonly="1"/>
|
||||||
|
<field name="name" readonly="1"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
</group>
|
</group>
|
||||||
<div attrs='{"invisible": [("routing_type","=","装夹预调")]}'>
|
<div attrs='{"invisible": [("routing_type","=","装夹预调")]}'>
|
||||||
<span style='font-weight:bold;'>保留装夹测量数据
|
<span style='font-weight:bold;'>保留装夹测量数据
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<field name="msgtype">markdown</field>
|
<field name="msgtype">markdown</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 销售订单逾期预警
|
<field name="content">### 销售订单逾期预警
|
||||||
事项:共有[{{warning_num}}]({{url}})个销售订单有逾期风险
|
事项:[共有{{warning_num}}个销售订单有逾期风险]({{url}})
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
<field name="msgtype">markdown</field>
|
<field name="msgtype">markdown</field>
|
||||||
<field name="urgency">urgent</field>
|
<field name="urgency">urgent</field>
|
||||||
<field name="content">### 销售订单已逾期提醒
|
<field name="content">### 销售订单已逾期提醒
|
||||||
事项:共有[{{overdue_num}}]({{url}})个销售订单已逾期
|
事项:[共有{{overdue_num}}个销售订单已逾期]({{url}})
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单逾期预警
|
<field name="content">### 工单逾期预警
|
||||||
事项:共有[{{warning_num}}]({{url}})个工单有逾期风险</field>
|
事项:[共有{{warning_num}}个工单有逾期风险]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_pre_overdue" model="jikimo.message.template">
|
<record id="template_mrp_workorder_pre_overdue" model="jikimo.message.template">
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单已逾期提醒
|
<field name="content">### 工单已逾期提醒
|
||||||
事项:共有[{{overdue_num}}]({{url}})个工单已逾期</field>
|
事项:[共有{{overdue_num}}个工单已逾期]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_cnc_overdue_warning" model="jikimo.message.template">
|
<record id="template_mrp_workorder_cnc_overdue_warning" model="jikimo.message.template">
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单逾期预警
|
<field name="content">### 工单逾期预警
|
||||||
事项:共有[{{warning_num}}]({{url}})个工单有逾期风险</field>
|
事项:[共有{{warning_num}}个工单有逾期风险]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_cnc_overdue" model="jikimo.message.template">
|
<record id="template_mrp_workorder_cnc_overdue" model="jikimo.message.template">
|
||||||
@@ -133,7 +133,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单已逾期提醒
|
<field name="content">### 工单已逾期提醒
|
||||||
事项:共有[{{overdue_num}}]({{url}})个工单已逾期</field>
|
事项:[共有{{overdue_num}}个工单已逾期]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_unclamp_overdue_warning" model="jikimo.message.template">
|
<record id="template_mrp_workorder_unclamp_overdue_warning" model="jikimo.message.template">
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单逾期预警
|
<field name="content">### 工单逾期预警
|
||||||
事项:共有[{{warning_num}}]({{url}})个工单有逾期风险</field>
|
事项:[共有{{warning_num}}个工单有逾期风险]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_unclamp_overdue" model="jikimo.message.template">
|
<record id="template_mrp_workorder_unclamp_overdue" model="jikimo.message.template">
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单已逾期提醒
|
<field name="content">### 工单已逾期提醒
|
||||||
事项:共有[{{overdue_num}}]({{url}})个工单已逾期</field>
|
事项:[共有{{overdue_num}}个工单已逾期]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_surface_overdue_warning" model="jikimo.message.template">
|
<record id="template_mrp_workorder_surface_overdue_warning" model="jikimo.message.template">
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单逾期预警
|
<field name="content">### 工单逾期预警
|
||||||
事项:共有[{{warning_num}}]({{url}})个工单有逾期风险</field>
|
事项:[共有{{warning_num}}个工单有逾期风险]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="template_mrp_workorder_surface_overdue" model="jikimo.message.template">
|
<record id="template_mrp_workorder_surface_overdue" model="jikimo.message.template">
|
||||||
@@ -181,7 +181,7 @@
|
|||||||
<field name="send_type">timing</field>
|
<field name="send_type">timing</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 工单已逾期提醒
|
<field name="content">### 工单已逾期提醒
|
||||||
事项:共有[{{overdue_num}}]({{url}})个工单已逾期</field>
|
事项:[共有{{overdue_num}}个工单已逾期]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@
|
|||||||
<field name="msgtype">markdown</field>
|
<field name="msgtype">markdown</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 待质量判定提醒
|
<field name="content">### 待质量判定提醒
|
||||||
事项:共有[{{judge_num}}]({{url}})个工单需判定质量结果</field>
|
事项:[共有{{judge_num}}个工单需判定质量结果]({{url}})</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="template_maintenance_logs" model="jikimo.message.template">
|
<record id="template_maintenance_logs" model="jikimo.message.template">
|
||||||
<field name="name">设备故障</field>
|
<field name="name">设备故障</field>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class SFMessageSale(models.Model):
|
|||||||
purchase_order_info.add_queue('坯料采购提醒')
|
purchase_order_info.add_queue('坯料采购提醒')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info('add_queue error:%s' % e)
|
logging.info('add_queue error:%s' % e)
|
||||||
|
logging.info('action_confirm res:%s' % res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# 继承并重写jikimo.message.dispatch的_get_message()
|
# 继承并重写jikimo.message.dispatch的_get_message()
|
||||||
@@ -100,15 +101,22 @@ class SFMessageSale(models.Model):
|
|||||||
|
|
||||||
# # 销售订单逾期预警和已逾期
|
# # 销售订单逾期预警和已逾期
|
||||||
def _overdue_or_warning_func(self):
|
def _overdue_or_warning_func(self):
|
||||||
today = datetime.today().date()
|
current_time_strf = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
deadline_check = today + timedelta(days=1)
|
current_time = self.env['sf.sync.common'].sudo().get_add_time(current_time_strf)
|
||||||
logging.info(f"today: {today}, deadline_check: {deadline_check}")
|
today_str = datetime.strptime(current_time, '%Y-%m-%d %H:%M:%S')
|
||||||
|
today = today_str.strftime("%Y-%m-%d")
|
||||||
|
# 计算下一天的日期
|
||||||
|
deadline_check_str = today_str + timedelta(days=1)
|
||||||
|
deadline_check = deadline_check_str.strftime("%Y-%m-%d")
|
||||||
|
logging.info(
|
||||||
|
f"today: {today}, deadline_check: {deadline_check},current_time_strf: {current_time_strf}, current_time: {current_time}'")
|
||||||
sale_order = self.sudo().search(
|
sale_order = self.sudo().search(
|
||||||
[('state', 'in', ['sale']), ('deadline_of_delivery', '!=', False), ('delivery_status', '!=', 'full')])
|
[('state', 'in', ['sale']), ('deadline_of_delivery', '!=', False), ('delivery_status', '!=', 'full')])
|
||||||
for item in sale_order:
|
for item in sale_order:
|
||||||
production = self.env['mrp.production'].sudo().search([('origin', '=', item.name)])
|
production = self.env['mrp.production'].sudo().search([('origin', '=', item.name)])
|
||||||
production_not_done = production.filtered(lambda p: p.state not in ['done', 'scrap', 'cancel'])
|
production_not_done = production.filtered(lambda p: p.state not in ['done', 'scrap', 'cancel'])
|
||||||
production_done_count = len(production.filtered(lambda p: p.state in ['done', 'scrap', 'cancel']))
|
production_done_count = len(production.filtered(lambda p: p.state in ['done', 'scrap', 'cancel']))
|
||||||
|
deadline_of_delivery = item.deadline_of_delivery.strftime("%Y-%m-%d")
|
||||||
if (len(production_not_done) >= 1 and len(production_not_done) != item.mrp_production_count) or len(
|
if (len(production_not_done) >= 1 and len(production_not_done) != item.mrp_production_count) or len(
|
||||||
production_not_done) != production_done_count:
|
production_not_done) != production_done_count:
|
||||||
# logging.info("-----不等于----")
|
# logging.info("-----不等于----")
|
||||||
@@ -116,9 +124,9 @@ class SFMessageSale(models.Model):
|
|||||||
# logging.info(
|
# logging.info(
|
||||||
# f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
# f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||||
# logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
# logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||||
if deadline_check == item.deadline_of_delivery and item.delivery_warning not in ['warning']:
|
if deadline_check == deadline_of_delivery and item.delivery_warning not in ['warning']:
|
||||||
item.delivery_warning = 'warning'
|
item.delivery_warning = 'warning'
|
||||||
elif today >= item.deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
elif today >= deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
||||||
item.delivery_warning = 'overdue'
|
item.delivery_warning = 'overdue'
|
||||||
elif production_done_count == item.mrp_production_count:
|
elif production_done_count == item.mrp_production_count:
|
||||||
# logging.info("-----等于----")
|
# logging.info("-----等于----")
|
||||||
@@ -127,9 +135,9 @@ class SFMessageSale(models.Model):
|
|||||||
# f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
# f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||||
# logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
# logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||||
if item.delivery_status in ['pending', 'partial']:
|
if item.delivery_status in ['pending', 'partial']:
|
||||||
if deadline_check == item.deadline_of_delivery and item.delivery_warning not in ['warning']:
|
if deadline_check == deadline_of_delivery and item.delivery_warning not in ['warning']:
|
||||||
item.delivery_warning = 'warning'
|
item.delivery_warning = 'warning'
|
||||||
elif today >= item.deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
elif today >= deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
||||||
item.delivery_warning = 'overdue'
|
item.delivery_warning = 'overdue'
|
||||||
else:
|
else:
|
||||||
# logging.info("-----1111111----")
|
# logging.info("-----1111111----")
|
||||||
@@ -158,6 +166,23 @@ class SFMessageSale(models.Model):
|
|||||||
if not sale_order_has:
|
if not sale_order_has:
|
||||||
message_name = '销售订单逾期预警' if wo.delivery_warning == 'warning' else '销售订单已逾期'
|
message_name = '销售订单逾期预警' if wo.delivery_warning == 'warning' else '销售订单已逾期'
|
||||||
wo.add_queue(message_name)
|
wo.add_queue(message_name)
|
||||||
|
if wo.delivery_warning == 'overdue':
|
||||||
|
# 把消息队列中销售订单预警的状态改为取消发送
|
||||||
|
business_node_id_warning = business_node_ids['warning']
|
||||||
|
if business_node_id_warning:
|
||||||
|
message_template_warning = self.env["jikimo.message.template"].search([
|
||||||
|
("model", "=", self._name),
|
||||||
|
("bussiness_node_id", "=", business_node_id_warning)
|
||||||
|
], limit=1)
|
||||||
|
if message_template_warning:
|
||||||
|
sale_order_warning = self.env['jikimo.message.queue'].search([
|
||||||
|
('res_id', '=', wo.id),
|
||||||
|
('message_status', '=', 'pending'),
|
||||||
|
('message_template_id', '=', message_template_warning.id)
|
||||||
|
])
|
||||||
|
if sale_order_warning:
|
||||||
|
logging.info('取消发送:%s' % sale_order_warning)
|
||||||
|
sale_order_warning.write({'message_status': 'cancel'})
|
||||||
|
|
||||||
def _recover_sale_time_warning_func(self):
|
def _recover_sale_time_warning_func(self):
|
||||||
sale_order_done = self.sudo().search([('state', 'in', ['sale']), ('delivery_status', '=', 'full')])
|
sale_order_done = self.sudo().search([('state', 'in', ['sale']), ('delivery_status', '=', 'full')])
|
||||||
|
|||||||
@@ -61,20 +61,32 @@ class SFMessageWork(models.Model):
|
|||||||
second=0,
|
second=0,
|
||||||
microsecond=0
|
microsecond=0
|
||||||
)
|
)
|
||||||
logging.info(current_time)
|
# logging.info(current_time)
|
||||||
logging.info(target_time)
|
# logging.info(target_time)
|
||||||
logging.info(target_time - time_range)
|
# logging.info(target_time - time_range)
|
||||||
logging.info(target_time + time_range)
|
# logging.info(target_time + time_range)
|
||||||
if target_time - time_range <= current_time_datetime <= target_time + time_range:
|
if target_time - time_range <= current_time_datetime <= target_time + time_range:
|
||||||
search_condition = [
|
search_condition = [
|
||||||
('delivery_warning', '=', 'warning')] if bussiness_node in template_names['预警'] else [
|
('delivery_warning', '=', 'warning')] if bussiness_node in template_names['预警'] else [
|
||||||
('delivery_warning', '=', 'overdue')]
|
('delivery_warning', '=', 'overdue')]
|
||||||
record = self.sudo().search(search_condition + [('id', '=', int(message_queue_id.res_id))])
|
record = self.sudo().search(search_condition + [('id', '=', int(message_queue_id.res_id))])
|
||||||
if record:
|
if record:
|
||||||
|
bussiness_node = item.bussiness_node_id.name
|
||||||
|
# 分割业务节点名称,提取出业务节点关键字
|
||||||
|
business_node_key = bussiness_node.split('工单')[0].strip()
|
||||||
|
workcenter_mapping = {
|
||||||
|
'装夹预调': '工件装夹',
|
||||||
|
'CNC加工': '自动生产',
|
||||||
|
'解除装夹': '工件拆卸',
|
||||||
|
'表面工艺': '表面工艺外协',
|
||||||
|
}
|
||||||
|
workcenter_name = workcenter_mapping.get(business_node_key)
|
||||||
|
active_id = self.env['mrp.workcenter'].search([('name', 'ilike', workcenter_name)],
|
||||||
|
limit=1).id
|
||||||
i += 1
|
i += 1
|
||||||
if i >= 1:
|
if i >= 1:
|
||||||
action_id = self.env.ref('sf_message.mrp_workorder_action_notify').id
|
action_id = self.env.ref('sf_message.mrp_workorder_action_notify').id
|
||||||
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
url_with_id = f"{url}/web#view_type=list&action={action_id}&active_id={active_id}"
|
||||||
content_template = content.replace('{{url}}', url_with_id)
|
content_template = content.replace('{{url}}', url_with_id)
|
||||||
if bussiness_node in template_names['预警']:
|
if bussiness_node in template_names['预警']:
|
||||||
content = content_template.replace('{{warning_num}}', str(i))
|
content = content_template.replace('{{warning_num}}', str(i))
|
||||||
@@ -98,7 +110,8 @@ class SFMessageWork(models.Model):
|
|||||||
return full_url
|
return full_url
|
||||||
|
|
||||||
def _overdue_or_warning_func(self):
|
def _overdue_or_warning_func(self):
|
||||||
workorders = self.env['mrp.workorder'].search([("state", "in", ["ready", "progress", "to be detected"])])
|
workorders = self.env['mrp.workorder'].search(
|
||||||
|
[("state", "in", ["ready", "progress", "to be detected"]), ('schedule_state', '=', '已排')])
|
||||||
grouped_workorders = {}
|
grouped_workorders = {}
|
||||||
for workorder in workorders:
|
for workorder in workorders:
|
||||||
routing_type = workorder.routing_type
|
routing_type = workorder.routing_type
|
||||||
@@ -117,15 +130,15 @@ class SFMessageWork(models.Model):
|
|||||||
date_planned_finished = datetime.strptime(date_planned_finished_str, '%Y-%m-%d %H:%M:%S')
|
date_planned_finished = datetime.strptime(date_planned_finished_str, '%Y-%m-%d %H:%M:%S')
|
||||||
twelve_hours_ago = current_time_datetime - timedelta(hours=12)
|
twelve_hours_ago = current_time_datetime - timedelta(hours=12)
|
||||||
if current_time_datetime >= date_planned_finished and item.delivery_warning not in ['overdue']:
|
if current_time_datetime >= date_planned_finished and item.delivery_warning not in ['overdue']:
|
||||||
logging.info("------overdue-------")
|
# logging.info("------overdue-------")
|
||||||
logging.info(f"Workorder: {item.production_id.name}, Current Time: {current_time_datetime}, "
|
# logging.info(f"Workorder: {item.production_id.name}, Current Time: {current_time_datetime}, "
|
||||||
f"Planned Finish: {date_planned_finished}")
|
# f"Planned Finish: {date_planned_finished}")
|
||||||
item.delivery_warning = 'overdue'
|
item.delivery_warning = 'overdue'
|
||||||
elif twelve_hours_ago <= current_time_datetime <= date_planned_finished and item.delivery_warning not in [
|
elif twelve_hours_ago <= current_time_datetime <= date_planned_finished and item.delivery_warning not in [
|
||||||
'warning']:
|
'warning']:
|
||||||
logging.info("------warning-------")
|
# logging.info("------warning-------")
|
||||||
logging.info(f"Workorder: {item.production_id.name}, Current Time: {current_time_datetime}, "
|
# logging.info(f"Workorder: {item.production_id.name}, Current Time: {current_time_datetime}, "
|
||||||
f"Planned Finish: {date_planned_finished}")
|
# f"Planned Finish: {date_planned_finished}")
|
||||||
item.delivery_warning = 'warning'
|
item.delivery_warning = 'warning'
|
||||||
business_node_ids = {
|
business_node_ids = {
|
||||||
'装夹预调_overdue': self.env.ref('sf_message.bussiness_mrp_workorder_pre_overdue').id,
|
'装夹预调_overdue': self.env.ref('sf_message.bussiness_mrp_workorder_pre_overdue').id,
|
||||||
@@ -161,6 +174,24 @@ class SFMessageWork(models.Model):
|
|||||||
args = [f'{item.routing_type}{overdue_message}']
|
args = [f'{item.routing_type}{overdue_message}']
|
||||||
# 获取add_queue方法并调用它,传入参数列表
|
# 获取add_queue方法并调用它,传入参数列表
|
||||||
getattr(item, queue_method_name)(*args)
|
getattr(item, queue_method_name)(*args)
|
||||||
|
if item.delivery_warning == 'overdue':
|
||||||
|
# 把消息队列中销售订单预警的状态改为取消发送
|
||||||
|
key = f"{item.routing_type}_{'warning'}"
|
||||||
|
business_node_id_warning = business_node_ids.get(key, None)
|
||||||
|
if business_node_id_warning:
|
||||||
|
message_template_warning = self.env["jikimo.message.template"].search([
|
||||||
|
("model", "=", self._name),
|
||||||
|
("bussiness_node_id", "=", business_node_id_warning)
|
||||||
|
], limit=1)
|
||||||
|
if message_template_warning:
|
||||||
|
work_order_warning = self.env['jikimo.message.queue'].search([
|
||||||
|
('res_id', '=', item.id),
|
||||||
|
('message_status', '=', 'pending'),
|
||||||
|
('message_template_id', '=', message_template_warning.id)
|
||||||
|
])
|
||||||
|
if work_order_warning:
|
||||||
|
logging.info('取消发送:%s' % work_order_warning)
|
||||||
|
work_order_warning.write({'message_status': 'cancel'})
|
||||||
|
|
||||||
def _recover_time_warning_func(self):
|
def _recover_time_warning_func(self):
|
||||||
workorder_done = self.env['mrp.workorder'].search([("state", "in", ["done", "rework", "cancel"])])
|
workorder_done = self.env['mrp.workorder'].search([("state", "in", ["done", "rework", "cancel"])])
|
||||||
|
|||||||
@@ -5,24 +5,28 @@ access_jikimo_message_template_group_purchase,jikimo_message_template,jikimo_mes
|
|||||||
access_jikimo_message_template_group_sf_stock_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_template_group_sf_stock_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_template_group_sf_order_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_template_group_sf_order_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_template_group_sf_tool_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_template_group_sf_tool_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
|
access_jikimo_message_template_group_purchase_director,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_purchase_director,1,1,1,0
|
||||||
|
|
||||||
access_jikimo_message_bussiness_node_group_sale_salemanager,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sale_salemanager,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sale_salemanager,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sale_salemanager,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_purchase,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase,1,1,1,0
|
access_jikimo_message_bussiness_node_group_purchase,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_sf_stock_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sf_stock_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_sf_order_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sf_order_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_sf_tool_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sf_tool_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
|
access_jikimo_message_bussiness_node_group_purchase_director,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase_director,1,1,1,0
|
||||||
|
|
||||||
access_jikimo_message_queue_group_sale_salemanager,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sale_salemanager,1,1,1,0
|
access_jikimo_message_queue_group_sale_salemanager,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sale_salemanager,1,1,1,0
|
||||||
access_jikimo_message_queue_group_purchase,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase,1,1,1,0
|
access_jikimo_message_queue_group_purchase,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase,1,1,1,0
|
||||||
access_jikimo_message_queue_group_sf_stock_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_queue_group_sf_stock_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_queue_group_sf_order_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_queue_group_sf_order_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_queue_group_sf_tool_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_queue_group_sf_tool_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
|
access_jikimo_message_queue_group_purchase_director,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase_director,1,1,1,0
|
||||||
|
|
||||||
access_jikimo_message_reminder_time_group_sale_salemanager,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sale_salemanager,1,1,1,0
|
access_jikimo_message_reminder_time_group_sale_salemanager,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sale_salemanager,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_purchase,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase,1,1,1,0
|
access_jikimo_message_reminder_time_group_purchase,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_sf_stock_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_reminder_time_group_sf_stock_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_sf_order_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_reminder_time_group_sf_order_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_sf_tool_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_reminder_time_group_sf_tool_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
|
access_jikimo_message_reminder_time_group_purchase_director,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase_director,1,1,1,0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
|
@@ -28,8 +28,16 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
domain = [('programming_no', '=', ret['programming_no'])]
|
domain = [('programming_no', '=', ret['programming_no'])]
|
||||||
if ret['manufacturing_type'] in ('scrap', 'invalid_tool_rework'):
|
if ret['manufacturing_type'] in ('scrap', 'invalid_tool_rework'):
|
||||||
domain += [('state', 'not in', ['done', 'scrap', 'cancel'])]
|
domain += [('state', 'not in', ['done', 'scrap', 'cancel'])]
|
||||||
|
else:
|
||||||
|
domain += [('state', 'in', ['confirmed', 'pending_cam'])]
|
||||||
productions = request.env['mrp.production'].with_user(
|
productions = request.env['mrp.production'].with_user(
|
||||||
request.env.ref("base.user_admin")).search(domain)
|
request.env.ref("base.user_admin")).search(domain)
|
||||||
|
productions_technology_to_confirmed = request.env['mrp.production'].with_user(
|
||||||
|
request.env.ref("base.user_admin")).search(
|
||||||
|
[('programming_no', '=', ret['programming_no']), ('state', 'in', ['technology_to_confirmed'])])
|
||||||
|
if productions_technology_to_confirmed:
|
||||||
|
res = {'status': -2, 'message': '查询到待工艺确认的制造订单'}
|
||||||
|
return json.JSONEncoder().encode(res)
|
||||||
if productions:
|
if productions:
|
||||||
# 拉取所有加工面的程序文件
|
# 拉取所有加工面的程序文件
|
||||||
for r in ret['processing_panel'].split(','):
|
for r in ret['processing_panel'].split(','):
|
||||||
@@ -48,26 +56,22 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
for production in productions:
|
for production in productions:
|
||||||
if not production.workorder_ids:
|
production.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
production.product_id.model_processing_panel = ret['processing_panel']
|
for panel in ret['processing_panel'].split(','):
|
||||||
production._create_workorder(ret)
|
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||||
productions.process_range_time()
|
cnc_workorder_has = production.workorder_ids.filtered(
|
||||||
else:
|
lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done',
|
||||||
for panel in ret['processing_panel'].split(','):
|
'rework',
|
||||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
'cancel'] and ach.processing_panel == panel)
|
||||||
cnc_workorder_has = production.workorder_ids.filtered(
|
if cnc_workorder_has:
|
||||||
lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done',
|
if cnc_workorder_has.cnc_ids:
|
||||||
'rework',
|
cnc_workorder_has.cmm_ids.sudo().unlink()
|
||||||
'cancel'] and ach.processing_panel == panel)
|
cnc_workorder_has.cnc_ids.sudo().unlink()
|
||||||
if cnc_workorder_has:
|
# request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
|
||||||
if cnc_workorder_has.cnc_ids:
|
# production)
|
||||||
cnc_workorder_has.cmm_ids.sudo().unlink()
|
cnc_workorder_has.write(
|
||||||
cnc_workorder_has.cnc_ids.sudo().unlink()
|
{'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret),
|
||||||
# request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
|
'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)})
|
||||||
# production)
|
|
||||||
cnc_workorder_has.write(
|
|
||||||
{'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret),
|
|
||||||
'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)})
|
|
||||||
for panel in ret['processing_panel'].split(','):
|
for panel in ret['processing_panel'].split(','):
|
||||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||||
cnc_workorder = productions.workorder_ids.filtered(
|
cnc_workorder = productions.workorder_ids.filtered(
|
||||||
@@ -77,7 +81,6 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
||||||
# panel)
|
# panel)
|
||||||
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
||||||
logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
|
|
||||||
files_panel = os.listdir(program_path_tmp_panel)
|
files_panel = os.listdir(program_path_tmp_panel)
|
||||||
if files_panel:
|
if files_panel:
|
||||||
for file in files_panel:
|
for file in files_panel:
|
||||||
@@ -85,17 +88,13 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
if file_extension.lower() == '.pdf':
|
if file_extension.lower() == '.pdf':
|
||||||
panel_file_path = os.path.join(program_path_tmp_panel, file)
|
panel_file_path = os.path.join(program_path_tmp_panel, file)
|
||||||
logging.info('panel_file_path:%s' % panel_file_path)
|
logging.info('panel_file_path:%s' % panel_file_path)
|
||||||
logging.info('更新工作指令:%s' % cnc_workorder)
|
|
||||||
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||||
logging.info('更新工作指令完成:%s' % cnc_workorder)
|
|
||||||
pre_workorder = productions.workorder_ids.filtered(
|
pre_workorder = productions.workorder_ids.filtered(
|
||||||
lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
|
lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
|
||||||
'cancel'] and ap.processing_panel == panel)
|
'cancel'] and ap.processing_panel == panel)
|
||||||
if pre_workorder:
|
if pre_workorder:
|
||||||
logging.info('更新加工图纸:%s' % pre_workorder)
|
|
||||||
pre_workorder.write(
|
pre_workorder.write(
|
||||||
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||||
logging.info('更新加工图纸完成:%s' % pre_workorder)
|
|
||||||
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
logging.info('已更新制造订单编程状态:%s' % productions.ids)
|
logging.info('已更新制造订单编程状态:%s' % productions.ids)
|
||||||
res.update({
|
res.update({
|
||||||
@@ -112,7 +111,7 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
|
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
else:
|
else:
|
||||||
res = {'status': 0, 'message': '该制造订单暂未开始'}
|
res = {'status': 0, 'message': '没有查询到该制造订单'}
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
res = {'status': -1, 'message': '系统解析失败'}
|
res = {'status': -1, 'message': '系统解析失败'}
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
_logger.info("同步刀具物料每齿走刀量完成")
|
_logger.info("同步刀具物料每齿走刀量完成")
|
||||||
self.env['sf.machining.accuracy'].sync_machining_accuracy_all()
|
self.env['sf.machining.accuracy'].sync_machining_accuracy_all()
|
||||||
_logger.info("同步加工精度完成")
|
_logger.info("同步加工精度完成")
|
||||||
|
self.env['sf.embryo.redundancy'].sync_embryo_redundancy_all()
|
||||||
|
_logger.info("同步坯料冗余完成")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.info("sf_all_sync error: %s" % e)
|
_logger.info("sf_all_sync error: %s" % e)
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ class MrStaticResourceDataSync(models.Model):
|
|||||||
_logger.info("同步刀具物料每齿走刀量完成")
|
_logger.info("同步刀具物料每齿走刀量完成")
|
||||||
self.env['sf.machining.accuracy'].sync_machining_accuracy_all()
|
self.env['sf.machining.accuracy'].sync_machining_accuracy_all()
|
||||||
_logger.info("同步加工精度完成")
|
_logger.info("同步加工精度完成")
|
||||||
|
self.env['sf.embryo.redundancy'].sync_embryo_redundancy_all()
|
||||||
|
_logger.info("同步坯料冗余完成")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback_error = traceback.format_exc()
|
traceback_error = traceback.format_exc()
|
||||||
logging.error("同步静态资源库失败:%s" % traceback_error)
|
logging.error("同步静态资源库失败:%s" % traceback_error)
|
||||||
@@ -3149,7 +3151,7 @@ class MachiningAccuracySync(models.Model):
|
|||||||
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
r = r.json()
|
r = r.json()
|
||||||
result = json.loads(r['result'])
|
result = json.loads(r['result'])
|
||||||
_logger.info('加工精度:%s' % result)
|
# _logger.info('加工精度:%s' % result)
|
||||||
if result['status'] == 1:
|
if result['status'] == 1:
|
||||||
machining_accuracy_all_list = result['machining_accuracy_all_list']
|
machining_accuracy_all_list = result['machining_accuracy_all_list']
|
||||||
# 获取同步的id集合
|
# 获取同步的id集合
|
||||||
@@ -3168,3 +3170,42 @@ class MachiningAccuracySync(models.Model):
|
|||||||
"name": time['name'],
|
"name": time['name'],
|
||||||
"standard_tolerance": time['standard_tolerance'],
|
"standard_tolerance": time['standard_tolerance'],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
class EmbryoRedundancySync(models.Model):
|
||||||
|
_inherit = 'sf.embryo.redundancy'
|
||||||
|
_description = '坯料冗余'
|
||||||
|
url = '/api/embryo_redundancy/list'
|
||||||
|
|
||||||
|
def sync_embryo_redundancy_all(self):
|
||||||
|
config = self.env['res.config.settings'].get_values()
|
||||||
|
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||||
|
strUrl = config['sf_url'] + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
# _logger.info('加工精度:%s' % result)
|
||||||
|
if result['status'] == 1:
|
||||||
|
embryo_redundancy_all_list = result['embryo_redundancy_all_list']
|
||||||
|
# 获取同步的id集合
|
||||||
|
codes = [obj['code'] for obj in embryo_redundancy_all_list]
|
||||||
|
self.env['sf.embryo.redundancy'].sudo().search(
|
||||||
|
[('code', 'not in', codes)]).unlink()
|
||||||
|
for item in embryo_redundancy_all_list:
|
||||||
|
embryo_redundancy = self.env['sf.embryo.redundancy'].sudo().search(
|
||||||
|
[('code', '=', item['code'])])
|
||||||
|
if embryo_redundancy:
|
||||||
|
embryo_redundancy.name = item['name']
|
||||||
|
embryo_redundancy.code = item['code']
|
||||||
|
embryo_redundancy.long = item['long']
|
||||||
|
embryo_redundancy.width = item['width']
|
||||||
|
embryo_redundancy.height = item['height']
|
||||||
|
embryo_redundancy.active = item['active']
|
||||||
|
else:
|
||||||
|
self.env['sf.embryo.redundancy'].sudo().create({
|
||||||
|
"name": item['name'],
|
||||||
|
"code": item['code'],
|
||||||
|
"long": item['long'],
|
||||||
|
"width": item['width'],
|
||||||
|
"height": item['height'],
|
||||||
|
"active": item['active'],
|
||||||
|
})
|
||||||
@@ -93,7 +93,11 @@ class sf_production_plan(models.Model):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
|
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
|
||||||
|
"""
|
||||||
|
修改搜索方法,只有制造订单状态为待排程时才显示
|
||||||
|
"""
|
||||||
|
domain = domain or []
|
||||||
|
domain.append(('production_id.state', 'not in', ['draft', 'technology_to_confirmed']))
|
||||||
info = super(sf_production_plan, self).search_read(domain, fields, offset, limit, order)
|
info = super(sf_production_plan, self).search_read(domain, fields, offset, limit, order)
|
||||||
return info
|
return info
|
||||||
|
|
||||||
@@ -227,45 +231,59 @@ class sf_production_plan(models.Model):
|
|||||||
if not record.production_line_id:
|
if not record.production_line_id:
|
||||||
raise ValidationError("未选择生产线")
|
raise ValidationError("未选择生产线")
|
||||||
else:
|
else:
|
||||||
|
# 自动化产线加工
|
||||||
if record.production_id.workorder_ids:
|
if record.production_id.workorder_ids:
|
||||||
last_cnc_start = record.date_planned_start if record.date_planned_start else datetime.now()
|
# 自动化产线加工
|
||||||
for item in record.production_id.workorder_ids:
|
if record.production_id.production_type == '自动化产线加工':
|
||||||
if item.name == 'CNC加工':
|
# 找到第一张CNC加工工单
|
||||||
# 将同一个面的所有工单筛选出来
|
first_cnc_workorder = record.production_id.workorder_ids.filtered(lambda x: x.name == 'CNC加工')[0]
|
||||||
workorder_list = record.production_id.workorder_ids.filtered(lambda x: x.processing_panel == item.processing_panel)
|
date_start = record.date_planned_start if record.date_planned_start else datetime.now()
|
||||||
routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search(
|
routing_workcenter = first_cnc_workorder.technology_design_id.route_id
|
||||||
[('name', '=', 'CNC加工')], limit=1)
|
# 设置一个小的开始时间
|
||||||
# 设置一个小的开始时间
|
first_cnc_workorder.date_planned_start = datetime.now() - timedelta(days=100)
|
||||||
item.date_planned_start = datetime.now() - timedelta(days=100)
|
first_cnc_workorder.date_planned_finished = date_start + timedelta(
|
||||||
item.date_planned_finished = last_cnc_start + timedelta(
|
minutes=routing_workcenter.time_cycle + routing_workcenter.reserved_duration)
|
||||||
minutes=routing_workcenter.time_cycle)
|
first_cnc_workorder.date_planned_start = date_start
|
||||||
item.date_planned_start = last_cnc_start
|
record.sudo().production_id.plan_start_processing_time = first_cnc_workorder.date_planned_start
|
||||||
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
first_cnc_workorder.duration_expected = routing_workcenter.time_cycle + routing_workcenter.reserved_duration
|
||||||
item.duration_expected = routing_workcenter.time_cycle
|
record.calculate_plan_time(first_cnc_workorder, record.production_id.workorder_ids)
|
||||||
pre_duration , next_duration = record.calculate_plan_time(item, workorder_list)
|
# 找到最后一张CNC加工工单
|
||||||
record.date_planned_finished = item.date_planned_finished
|
last_cnc_workorder = record.production_id.workorder_ids.filtered(lambda x: x.name == 'CNC加工')[-1]
|
||||||
# 计算下一个cnc工单的开始时间
|
record.date_planned_finished = last_cnc_workorder.date_planned_finished
|
||||||
last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration)
|
else:
|
||||||
record.state = 'done'
|
# 人工线下加工只排第一张工单
|
||||||
# record.production_id.schedule_state = '已排'
|
item = record.production_id.workorder_ids[0]
|
||||||
record.sudo().production_id.schedule_state = '已排'
|
wo_start = record.date_planned_start if record.date_planned_start else datetime.now()
|
||||||
record.sudo().production_id.process_state = '待装夹'
|
routing_workcenter = item.technology_design_id.route_id
|
||||||
# self.env['sale.order'].browse(record.production_id.origin).schedule_status = 'to process'
|
item.date_planned_start = datetime.now() - timedelta(days=100)
|
||||||
# sale_obj = self.env['sale.order'].search([('name', '=', record.origin)])
|
item.date_planned_finished = wo_start + timedelta(
|
||||||
# if 'S' in sale_obj.name:
|
minutes=routing_workcenter.time_cycle + routing_workcenter.reserved_duration)
|
||||||
# sale_obj.schedule_status = 'to process'
|
item.date_planned_start = wo_start
|
||||||
mrp_production_ids = record.production_id._get_children().ids
|
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
||||||
print('mrp_production_ids', mrp_production_ids)
|
item.duration_expected = routing_workcenter.time_cycle + routing_workcenter.reserved_duration
|
||||||
for i in mrp_production_ids:
|
record.calculate_plan_time(item, record.production_id.workorder_ids)
|
||||||
record.env['mrp.production'].sudo().browse(i).schedule_state = '已排'
|
last_cnc_workorder = record.production_id.workorder_ids[-1]
|
||||||
# record.production_id.date_planned_start = record.date_planned_start
|
record.date_planned_finished = last_cnc_workorder.date_planned_finished
|
||||||
# record.production_id.date_planned_finished = record.date_planned_finished
|
record.state = 'done'
|
||||||
record.sudo().production_id.production_line_id = record.production_line_id.id
|
# record.production_id.schedule_state = '已排'
|
||||||
if record.production_id.workorder_ids:
|
record.sudo().production_id.schedule_state = '已排'
|
||||||
record.sudo().production_id.workorder_ids.filtered(
|
record.sudo().production_id.process_state = '待装夹'
|
||||||
lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write(
|
# self.env['sale.order'].browse(record.production_id.origin).schedule_status = 'to process'
|
||||||
{'production_line_id': record.production_line_id.id,
|
# sale_obj = self.env['sale.order'].search([('name', '=', record.origin)])
|
||||||
'plan_start_processing_time': record.date_planned_start})
|
# if 'S' in sale_obj.name:
|
||||||
|
# sale_obj.schedule_status = 'to process'
|
||||||
|
# mrp_production_ids = record.production_id._get_children().ids
|
||||||
|
# print('mrp_production_ids', mrp_production_ids)
|
||||||
|
# for i in mrp_production_ids:
|
||||||
|
# record.env['mrp.production'].sudo().browse(i).schedule_state = '已排'
|
||||||
|
# record.production_id.date_planned_start = record.date_planned_start
|
||||||
|
# record.production_id.date_planned_finished = record.date_planned_finished
|
||||||
|
record.sudo().production_id.production_line_id = record.production_line_id.id
|
||||||
|
if record.production_id.workorder_ids:
|
||||||
|
record.sudo().production_id.workorder_ids.filtered(
|
||||||
|
lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write(
|
||||||
|
{'production_line_id': record.production_line_id.id,
|
||||||
|
'plan_start_processing_time': record.date_planned_start})
|
||||||
|
|
||||||
# record.date_planned_finished = record.date_planned_start + timedelta(days=3)
|
# record.date_planned_finished = record.date_planned_start + timedelta(days=3)
|
||||||
# record.state = 'done'
|
# record.state = 'done'
|
||||||
@@ -301,44 +319,40 @@ class sf_production_plan(models.Model):
|
|||||||
def calculate_plan_time(self, item, workorder_list):
|
def calculate_plan_time(self, item, workorder_list):
|
||||||
"""
|
"""
|
||||||
根据CNC工单的时间去计算之前的其他工单的开始结束时间
|
根据CNC工单的时间去计算之前的其他工单的开始结束时间
|
||||||
|
param:
|
||||||
|
item: 基准工单(根据该工单的开始结束时间去计算其他工单的开始结束时间)
|
||||||
|
workorder_list: 需排程的工单列表
|
||||||
"""
|
"""
|
||||||
item_position = 0
|
item_position = 0
|
||||||
for index, workorder in enumerate(workorder_list):
|
for index, workorder in enumerate(workorder_list):
|
||||||
if workorder.id == item.id:
|
if workorder.id == item.id:
|
||||||
item_position = index
|
item_position = index
|
||||||
break
|
break
|
||||||
routing_workcenters = self.env['mrp.routing.workcenter'].sudo().search([])
|
|
||||||
# 记录所有前序工序时长
|
|
||||||
previous_workorder_duration = 0
|
|
||||||
for i in range(item_position, -1, -1):
|
for i in range(item_position, -1, -1):
|
||||||
if i < 1:
|
if i < 1:
|
||||||
break
|
break
|
||||||
current_workorder = workorder_list[i]
|
current_workorder = workorder_list[i]
|
||||||
next_workorder = workorder_list[i - 1]
|
next_workorder = workorder_list[i - 1]
|
||||||
routing_workcenter = routing_workcenters.filtered(lambda x: x.name == next_workorder.name)[0]
|
routing_workcenter = next_workorder.technology_design_id.route_id
|
||||||
# 设置一个小的开始时间
|
# 设置一个小的开始时间
|
||||||
next_workorder.date_planned_start = datetime.now() - timedelta(days=100)
|
next_workorder.date_planned_start = datetime.now() - timedelta(days=100)
|
||||||
next_workorder.date_planned_finished = current_workorder.date_planned_start
|
next_workorder.date_planned_finished = current_workorder.date_planned_start
|
||||||
next_workorder.date_planned_start = next_workorder.date_planned_finished - timedelta(
|
next_workorder.date_planned_start = next_workorder.date_planned_finished - timedelta(
|
||||||
minutes=routing_workcenter.time_cycle)
|
minutes=routing_workcenter.time_cycle + routing_workcenter.reserved_duration)
|
||||||
next_workorder.duration_expected = routing_workcenter.time_cycle
|
next_workorder.duration_expected = routing_workcenter.time_cycle + routing_workcenter.reserved_duration
|
||||||
previous_workorder_duration += routing_workcenter.time_cycle
|
|
||||||
# 记录所有后续工序时长
|
|
||||||
next_workorder_duration = 0
|
|
||||||
for i in range(item_position, len(workorder_list) - 1):
|
for i in range(item_position, len(workorder_list) - 1):
|
||||||
if i > len(workorder_list) - 1:
|
if i > len(workorder_list) - 1:
|
||||||
break
|
break
|
||||||
current_workorder = workorder_list[i]
|
current_workorder = workorder_list[i]
|
||||||
next_workorder = workorder_list[i + 1]
|
next_workorder = workorder_list[i + 1]
|
||||||
routing_workcenter = routing_workcenters.filtered(lambda x: x.name == next_workorder.name)[0]
|
routing_workcenter = next_workorder.technology_design_id.route_id
|
||||||
# 设置一个小的开始时间
|
# 设置一个小的开始时间
|
||||||
next_workorder.date_planned_start = datetime.now() - timedelta(days=100)
|
next_workorder.date_planned_start = datetime.now() - timedelta(days=100)
|
||||||
next_workorder.date_planned_finished = current_workorder.date_planned_finished + timedelta(
|
next_workorder.date_planned_finished = current_workorder.date_planned_finished + timedelta(
|
||||||
minutes=routing_workcenter.time_cycle)
|
minutes=routing_workcenter.time_cycle + routing_workcenter.reserved_duration)
|
||||||
next_workorder.date_planned_start = current_workorder.date_planned_finished
|
next_workorder.date_planned_start = current_workorder.date_planned_finished
|
||||||
next_workorder.duration_expected = routing_workcenter.time_cycle
|
next_workorder.duration_expected = routing_workcenter.time_cycle + routing_workcenter.reserved_duration
|
||||||
next_workorder_duration += routing_workcenter.time_cycle
|
|
||||||
return previous_workorder_duration, next_workorder_duration
|
|
||||||
|
|
||||||
def calculate_plan_time_after(self, item, workorder_id_list):
|
def calculate_plan_time_after(self, item, workorder_id_list):
|
||||||
"""
|
"""
|
||||||
@@ -414,6 +428,14 @@ class sf_production_plan(models.Model):
|
|||||||
print(ret)
|
print(ret)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise UserError(e)
|
raise UserError(e)
|
||||||
|
|
||||||
|
# 增加制造订单类型
|
||||||
|
production_type = fields.Selection(
|
||||||
|
[('自动化产线加工', '自动化产线加工'), ('人工线下加工', '人工线下加工')],
|
||||||
|
string='制造类型',
|
||||||
|
related='production_id.production_type',
|
||||||
|
store=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# 机台作业计划
|
# 机台作业计划
|
||||||
@@ -437,8 +459,12 @@ class MrpProductionInheritForPlan(models.Model):
|
|||||||
def toggle_active(self):
|
def toggle_active(self):
|
||||||
# 调用父类方法切换 active 状态
|
# 调用父类方法切换 active 状态
|
||||||
res = super(MrpProductionInheritForPlan, self).toggle_active()
|
res = super(MrpProductionInheritForPlan, self).toggle_active()
|
||||||
|
stage_active = self.filtered('active')
|
||||||
|
stage_inactive = self - stage_active
|
||||||
self.env['sf.production.plan'].search(
|
self.env['sf.production.plan'].search(
|
||||||
[('production_id', '=', self.id), '|', ('active', '=', False), ('active', '=', True)]).write(
|
[('production_id', 'in', stage_active.ids)]).write(
|
||||||
{'active': self.active})
|
{'active': True})
|
||||||
|
self.env['sf.production.plan'].search(
|
||||||
|
[('production_id', 'in', stage_inactive.ids)]).write(
|
||||||
|
{'active': False})
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
<field name="production_line_id"/>
|
<field name="production_line_id"/>
|
||||||
<field name="date_planned_start"/>
|
<field name="date_planned_start"/>
|
||||||
<field name="date_planned_finished"/>
|
<field name="date_planned_finished"/>
|
||||||
|
<field name="production_type" widget="badge" decoration-warning="production_type == '人工线下加工'" decoration-success="production_type == '自动化产线加工'"/>
|
||||||
<field name="actual_start_time" optional='hide'/>
|
<field name="actual_start_time" optional='hide'/>
|
||||||
<field name="actual_end_time" optional='hide'/>
|
<field name="actual_end_time" optional='hide'/>
|
||||||
<field name="actual_process_time" optional='hide'/>
|
<field name="actual_process_time" optional='hide'/>
|
||||||
@@ -89,7 +90,7 @@
|
|||||||
<group string="加工信息">
|
<group string="加工信息">
|
||||||
|
|
||||||
<field name="date_planned_start" placeholder="如果不选择计划开始时间,会取当前时间来做排程" required="1"/>
|
<field name="date_planned_start" placeholder="如果不选择计划开始时间,会取当前时间来做排程" required="1"/>
|
||||||
<field name="date_planned_finished" required="1"/>
|
<field name="date_planned_finished" required="0" invisible="1"/>
|
||||||
<field name="actual_process_time"/>
|
<field name="actual_process_time"/>
|
||||||
<field name="actual_start_time"/>
|
<field name="actual_start_time"/>
|
||||||
<field name="actual_end_time"/>
|
<field name="actual_end_time"/>
|
||||||
@@ -256,7 +257,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<record id="sf_production_plan_action" model="ir.actions.act_window">
|
<record id="sf_production_plan_action" model="ir.actions.act_window">
|
||||||
<field name="name">制造订单生产计划</field>
|
<field name="name">CNC产线计划排程</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">sf.production.plan</field>
|
<field name="res_model">sf.production.plan</field>
|
||||||
<field name="view_mode">gantt,tree,form</field>
|
<field name="view_mode">gantt,tree,form</field>
|
||||||
@@ -264,7 +265,7 @@
|
|||||||
|
|
||||||
<!-- 这个也是制造订单生产计划,只是把tree视图放在了默认位置 -->
|
<!-- 这个也是制造订单生产计划,只是把tree视图放在了默认位置 -->
|
||||||
<record id="sf_production_plan_action1" model="ir.actions.act_window">
|
<record id="sf_production_plan_action1" model="ir.actions.act_window">
|
||||||
<field name="name">制造订单生产计划</field>
|
<field name="name">CNC产线计划排程</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">sf.production.plan</field>
|
<field name="res_model">sf.production.plan</field>
|
||||||
<field name="view_mode">tree,gantt,form</field>
|
<field name="view_mode">tree,gantt,form</field>
|
||||||
|
|||||||
@@ -37,52 +37,4 @@ class Action_Plan_All_Wizard(models.TransientModel):
|
|||||||
# 判断能否排成
|
# 判断能否排成
|
||||||
self.plan_ids.deal_processing_schedule(self.date_planned_start)
|
self.plan_ids.deal_processing_schedule(self.date_planned_start)
|
||||||
self.plan_ids.do_production_schedule()
|
self.plan_ids.do_production_schedule()
|
||||||
# for plan in temp_plan_ids:
|
|
||||||
# # 处理每个计划
|
|
||||||
# # 比如更新计划状态、分配资源等
|
|
||||||
# # 示例:plan.state = 'scheduled'
|
|
||||||
# print('处理计划:', plan.id)
|
|
||||||
# # 拿到计划对象
|
|
||||||
# plan_obj = self.env['sf.production.plan'].browse(plan.id)
|
|
||||||
# plan_obj.production_line_id = self.production_line_id.id
|
|
||||||
# plan.date_planned_start = self.date_planned_start
|
|
||||||
# plan_obj.do_production_schedule()
|
|
||||||
# plan_obj.state = 'done'
|
|
||||||
_logger.info('处理计划: %s 完成', self.plan_ids.ids)
|
_logger.info('处理计划: %s 完成', self.plan_ids.ids)
|
||||||
|
|
||||||
# # 获取当前生产线
|
|
||||||
# production_line_id = self.production_line_id
|
|
||||||
# # 获取当前生产线的所有生产订单
|
|
||||||
# production_order_ids = self.env['mrp.production'].search([('production_line_id', '=', production_line_id.id)])
|
|
||||||
# # 获取当前生产线的所有生产订单的id
|
|
||||||
# production_order_id_list = []
|
|
||||||
# for production_order_id in production_order_ids:
|
|
||||||
# production_order_id_list.append(production_order_id.id)
|
|
||||||
# # 获取当前生产线的所有生产订单的排程状态
|
|
||||||
# production_order_plan_state_list = []
|
|
||||||
# for production_order_id in production_order_ids:
|
|
||||||
# production_order_plan_state_list.append(production_order_id.plan_state)
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是已排程,则报错
|
|
||||||
# if all(production_order_plan_state == '已排程' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都已排程,请勿重复排程!')
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是未排程,则报错
|
|
||||||
# if all(production_order_plan_state == '未排程' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都未排程,请先排程!')
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是已完成,则报错
|
|
||||||
# if all(production_order_plan_state == '已完成' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都已完成,请勿重复排程!')
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是已取消,则报错
|
|
||||||
# if all(production_order_plan_state == '已取消' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都已取消,请勿重复排程!')
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是已暂停,则报错
|
|
||||||
# if all(production_order_plan_state == '已暂停' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都已暂停,请勿重复排程!')
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是已完成,则报错
|
|
||||||
# if all(production_order_plan_state == '已完成' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都已完成,请勿重复排程!')
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是已取消,则报错
|
|
||||||
# if all(production_order_plan_state == '已取消' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都已取消,请勿重复排程!')
|
|
||||||
# # 如果当前生产线的所有生产订单的排程状态都是已暂停,则报错
|
|
||||||
# if all(production_order_plan_state == '已暂停' for production_order_plan_state in production_order_plan_state_list):
|
|
||||||
# raise UserError('当前生产线的所有生产订单都已暂停,请勿重复排程!')
|
|
||||||
|
|||||||
@@ -7059,7 +7059,7 @@ msgstr ""
|
|||||||
#. module: sf_dlm
|
#. module: sf_dlm
|
||||||
#: model:product.template,name:sf_dlm.product_template_sf_product_template
|
#: model:product.template,name:sf_dlm.product_template_sf_product_template
|
||||||
msgid "CNC加工产品模板"
|
msgid "CNC加工产品模板"
|
||||||
msgstr "冲压模具滑块"
|
msgstr "自动化产线加工模板"
|
||||||
|
|
||||||
#. module: sf_tool_management
|
#. module: sf_tool_management
|
||||||
#: model:ir.model,name:sf_tool_management.model_sf_cnc_processing
|
#: model:ir.model,name:sf_tool_management.model_sf_cnc_processing
|
||||||
@@ -15907,7 +15907,7 @@ msgstr "内部参考"
|
|||||||
#: model_terms:ir.ui.view,arch_db:account.account_journal_dashboard_kanban_view
|
#: model_terms:ir.ui.view,arch_db:account.account_journal_dashboard_kanban_view
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Internal Transfer"
|
msgid "Internal Transfer"
|
||||||
msgstr "内部转账"
|
msgstr "厂内出入库"
|
||||||
|
|
||||||
#. module: account
|
#. module: account
|
||||||
#: model:ir.model.fields,field_description:account.field_res_config_settings__transfer_account_id
|
#: model:ir.model.fields,field_description:account.field_res_config_settings__transfer_account_id
|
||||||
@@ -16130,6 +16130,11 @@ msgstr "在手库存"
|
|||||||
msgid "Inventory Overview"
|
msgid "Inventory Overview"
|
||||||
msgstr "库存概览"
|
msgstr "库存概览"
|
||||||
|
|
||||||
|
#. module: stock
|
||||||
|
#: model:ir.actions.act_window,name:stock.stock_picking_type_action
|
||||||
|
msgid "Internal Transfers"
|
||||||
|
msgstr "库存概览"
|
||||||
|
|
||||||
#. module: stock
|
#. module: stock
|
||||||
#: model:ir.model.fields,field_description:stock.field_stock_quant__inventory_quantity_set
|
#: model:ir.model.fields,field_description:stock.field_stock_quant__inventory_quantity_set
|
||||||
msgid "Inventory Quantity Set"
|
msgid "Inventory Quantity Set"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class SfQualityCncTest(models.Model):
|
|||||||
('pass', '合格'),
|
('pass', '合格'),
|
||||||
('fail', '不合格')], string='判定结果')
|
('fail', '不合格')], string='判定结果')
|
||||||
number = fields.Integer('数量', default=1)
|
number = fields.Integer('数量', default=1)
|
||||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], string="检测结果")
|
test_results = fields.Selection([("合格", "合格")], string="检测结果")
|
||||||
reason = fields.Selection(
|
reason = fields.Selection(
|
||||||
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"),
|
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"),
|
||||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因")
|
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因")
|
||||||
@@ -33,6 +33,7 @@ class SfQualityCncTest(models.Model):
|
|||||||
|
|
||||||
machining_drawings = fields.Binary('2D加工图纸', related='workorder_id.machining_drawings', readonly=True)
|
machining_drawings = fields.Binary('2D加工图纸', related='workorder_id.machining_drawings', readonly=True)
|
||||||
quality_standard = fields.Binary('质检标准', related='workorder_id.quality_standard', readonly=True)
|
quality_standard = fields.Binary('质检标准', related='workorder_id.quality_standard', readonly=True)
|
||||||
|
part_name = fields.Char(related='workorder_id.part_name', string='零件名称')
|
||||||
|
|
||||||
def submit_pass(self):
|
def submit_pass(self):
|
||||||
if self.test_results in ['返工', '报废']:
|
if self.test_results in ['返工', '报废']:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ access_quality_point_group_sf_mrp_manager,quality_point_group_sf_mrp_manager,qua
|
|||||||
access_quality_check_group_quality,quality_check_group_quality,quality.model_quality_check,sf_base.group_quality,1,1,1,0
|
access_quality_check_group_quality,quality_check_group_quality,quality.model_quality_check,sf_base.group_quality,1,1,1,0
|
||||||
access_quality_check_group_quality_director,quality_check_group_quality_director,quality.model_quality_check,sf_base.group_quality_director,1,1,1,0
|
access_quality_check_group_quality_director,quality_check_group_quality_director,quality.model_quality_check,sf_base.group_quality_director,1,1,1,0
|
||||||
access_quality_check_group_plan_dispatch,quality_check_group_plan_dispatch,quality.model_quality_check,sf_base.group_plan_dispatch,1,0,0,0
|
access_quality_check_group_plan_dispatch,quality_check_group_plan_dispatch,quality.model_quality_check,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
|
access_quality_check_group_sf_stock_user,quality_check_group_sf_stock_user,quality.model_quality_check,sf_base.group_sf_stock_user,1,0,0,0
|
||||||
access_quality_check_group_plan_director,quality_check_group_plan_director,quality.model_quality_check,sf_base.group_plan_director,1,0,0,0
|
access_quality_check_group_plan_director,quality_check_group_plan_director,quality.model_quality_check,sf_base.group_plan_director,1,0,0,0
|
||||||
access_quality_check_group_purchase,quality_check_group_purchase,quality.model_quality_check,sf_base.group_purchase,1,0,0,0
|
access_quality_check_group_purchase,quality_check_group_purchase,quality.model_quality_check,sf_base.group_purchase,1,0,0,0
|
||||||
access_quality_check_group_purchase_director,quality_check_group_purchase_director,quality.model_quality_check,sf_base.group_purchase_director,1,0,0,0
|
access_quality_check_group_purchase_director,quality_check_group_purchase_director,quality.model_quality_check,sf_base.group_purchase_director,1,0,0,0
|
||||||
|
|||||||
|
@@ -89,6 +89,7 @@
|
|||||||
<field name="model_file" widget="Viewer3D"/>
|
<field name="model_file" widget="Viewer3D"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
|
<field name="part_name"/>
|
||||||
<field name="part_number"/>
|
<field name="part_number"/>
|
||||||
<field name="processing_panel"/>
|
<field name="processing_panel"/>
|
||||||
</group>
|
</group>
|
||||||
@@ -174,8 +175,8 @@
|
|||||||
<field name="name">驾驶舱</field>
|
<field name="name">驾驶舱</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">quality.cnc.test</field>
|
<field name="res_model">quality.cnc.test</field>
|
||||||
<field name="view_mode">kanban,tree,form</field>
|
<field name="view_mode">tree,kanban,form</field>
|
||||||
<field name="view_id" ref="quality_cnc_test_view_kanban"/>
|
<field name="view_id" ref="quality_cnc_test_view_tree"/>
|
||||||
<field name="search_view_id" ref="quality_cnc_test_search"/>
|
<field name="search_view_id" ref="quality_cnc_test_search"/>
|
||||||
<field name="domain">[]</field>
|
<field name="domain">[]</field>
|
||||||
<field name="context">{ 'search_default_filter_waiting':1}</field>
|
<field name="context">{ 'search_default_filter_waiting':1}</field>
|
||||||
|
|||||||
@@ -23,10 +23,10 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="quality_control.quality_alert_action_check" model="ir.actions.act_window">
|
<record id="quality_alert_action_check" model="ir.actions.act_window">
|
||||||
<field name="name">质量缺陷单</field>
|
<field name="name">质量缺陷</field>
|
||||||
<field name="res_model">quality.alert</field>
|
<field name="res_model">quality.alert</field>
|
||||||
<field name="view_mode">kanban,tree,form,pivot,graph,calendar</field>
|
<field name="view_mode">tree,kanban,form,pivot,graph,calendar</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_smiling_face">
|
<p class="o_view_nocontent_smiling_face">
|
||||||
Create a new quality alert
|
Create a new quality alert
|
||||||
@@ -34,6 +34,13 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="quality_control.menu_quality_alert"
|
||||||
|
name="质量缺陷"
|
||||||
|
action="quality_alert_action_check"
|
||||||
|
parent="quality_control.menu_quality_control"
|
||||||
|
sequence="20"/>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="quality_point_view_form_inherit_sf">
|
<record model="ir.ui.view" id="quality_point_view_form_inherit_sf">
|
||||||
<field name="name">quality.point.form.inherit.sf</field>
|
<field name="name">quality.point.form.inherit.sf</field>
|
||||||
<field name="model">quality.point</field>
|
<field name="model">quality.point</field>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import hashlib
|
|||||||
import requests
|
import requests
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from stl import mesh
|
|
||||||
# from OCC.Core.GProp import GProp_GProps
|
# from OCC.Core.GProp import GProp_GProps
|
||||||
from OCC.Extend.DataExchange import read_step_file
|
from OCC.Extend.DataExchange import read_step_file
|
||||||
from OCC.Extend.DataExchange import write_stl_file
|
from OCC.Extend.DataExchange import write_stl_file
|
||||||
@@ -228,6 +227,7 @@ class QuickEasyOrder(models.Model):
|
|||||||
'quality_standard_mimetype': '',
|
'quality_standard_mimetype': '',
|
||||||
'machining_drawings': item.machining_drawings,
|
'machining_drawings': item.machining_drawings,
|
||||||
'quality_standard': '',
|
'quality_standard': '',
|
||||||
|
'part_name': '',
|
||||||
})
|
})
|
||||||
# res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list'])
|
# res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list'])
|
||||||
product_id = self.env.ref('sf_dlm.product_template_sf').sudo()
|
product_id = self.env.ref('sf_dlm.product_template_sf').sudo()
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ class ReSaleOrder(models.Model):
|
|||||||
tracking=3,
|
tracking=3,
|
||||||
default='draft')
|
default='draft')
|
||||||
deadline_of_delivery = fields.Date('订单交期', tracking=True)
|
deadline_of_delivery = fields.Date('订单交期', tracking=True)
|
||||||
person_of_delivery = fields.Char('交货人')
|
# person_of_delivery = fields.Char('收货人')
|
||||||
telephone_of_delivery = fields.Char('交货人电话号码')
|
# telephone_of_delivery = fields.Char('电话号码')
|
||||||
address_of_delivery = fields.Char('交货人地址')
|
# address_of_delivery = fields.Char('联系地址')
|
||||||
payments_way = fields.Selection([('现结', '现结'), ('月结', '月结')], '结算方式', default='现结', tracking=True)
|
payments_way = fields.Selection([('现结', '现结'), ('月结', '月结')], '结算方式', default='现结', tracking=True)
|
||||||
pay_way = fields.Selection([('转账', '转账'), ('微信', '微信'), ('支付宝', '支付宝')], '支付方式')
|
pay_way = fields.Selection([('转账', '转账'), ('微信', '微信'), ('支付宝', '支付宝')], '支付方式')
|
||||||
check_status = fields.Selection([('pending', '待审核'), ('approved', '已审核'), ('fail', '不通过')], '审核状态')
|
check_status = fields.Selection([('pending', '待审核'), ('approved', '已审核'), ('fail', '不通过')], '审核状态')
|
||||||
@@ -60,7 +60,7 @@ class ReSaleOrder(models.Model):
|
|||||||
|
|
||||||
# 业务平台分配工厂后在智能工厂先创建销售订单
|
# 业务平台分配工厂后在智能工厂先创建销售订单
|
||||||
def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address,
|
def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address,
|
||||||
deadline_of_delivery, payments_way, pay_way):
|
deadline_of_delivery, payments_way, pay_way, state='sale'):
|
||||||
now_time = datetime.datetime.now()
|
now_time = datetime.datetime.now()
|
||||||
partner = self.get_customer()
|
partner = self.get_customer()
|
||||||
data = {
|
data = {
|
||||||
@@ -69,7 +69,7 @@ class ReSaleOrder(models.Model):
|
|||||||
'name': self.env['ir.sequence'].next_by_code('sale.order', sequence_date=now_time),
|
'name': self.env['ir.sequence'].next_by_code('sale.order', sequence_date=now_time),
|
||||||
'partner_id': partner.id,
|
'partner_id': partner.id,
|
||||||
'check_status': 'approved',
|
'check_status': 'approved',
|
||||||
'state': 'sale',
|
'state': state,
|
||||||
'user_id': partner.user_id.id,
|
'user_id': partner.user_id.id,
|
||||||
'person_of_delivery': delivery_name,
|
'person_of_delivery': delivery_name,
|
||||||
'telephone_of_delivery': delivery_telephone,
|
'telephone_of_delivery': delivery_telephone,
|
||||||
@@ -131,10 +131,11 @@ class ReSaleOrder(models.Model):
|
|||||||
product.materials_id.name),
|
product.materials_id.name),
|
||||||
'price_unit': product.list_price,
|
'price_unit': product.list_price,
|
||||||
'product_uom_qty': item['number'],
|
'product_uom_qty': item['number'],
|
||||||
'model_glb_file': base64.b64decode(item['model_file']),
|
'model_glb_file': base64.b64decode(item['model_file']) if item['model_file'] else None,
|
||||||
'remark': item.get('remark'),
|
'remark': item.get('remark'),
|
||||||
'is_incoming_material': item.get('is_incoming_material'),
|
'embryo_redundancy_id': item.get('embryo_redundancy_id'),
|
||||||
'incoming_size': item.get('incoming_size'),
|
'is_incoming_material': True if item.get('embryo_redundancy_id') else False,
|
||||||
|
'manual_quotation': item.get('manual_quotation')
|
||||||
}
|
}
|
||||||
return self.env['sale.order.line'].with_context(skip_procurement=True).create(vals)
|
return self.env['sale.order.line'].with_context(skip_procurement=True).create(vals)
|
||||||
|
|
||||||
@@ -175,8 +176,14 @@ class ResaleOrderLine(models.Model):
|
|||||||
check_status = fields.Selection(related='order_id.check_status')
|
check_status = fields.Selection(related='order_id.check_status')
|
||||||
remark = fields.Char('备注')
|
remark = fields.Char('备注')
|
||||||
|
|
||||||
is_incoming_material = fields.Boolean('是否带料', default=False)
|
is_incoming_material = fields.Boolean('客供料', compute='_compute_is_incoming_material', store=True)
|
||||||
incoming_size = fields.Char('带料尺寸')
|
embryo_redundancy_id = fields.Many2one('sf.embryo.redundancy', '坯料冗余')
|
||||||
|
manual_quotation = fields.Boolean('人工编程', default=False)
|
||||||
|
|
||||||
|
@api.depends('embryo_redundancy_id')
|
||||||
|
def _compute_is_incoming_material(self):
|
||||||
|
for line in self:
|
||||||
|
line.is_incoming_material = True if line.embryo_redundancy_id else False
|
||||||
|
|
||||||
@api.depends('product_template_id')
|
@api.depends('product_template_id')
|
||||||
def _compute_model_glb_file(self):
|
def _compute_model_glb_file(self):
|
||||||
@@ -208,6 +215,9 @@ class RePurchaseOrder(models.Model):
|
|||||||
compute='_compute_user_id',
|
compute='_compute_user_id',
|
||||||
store=True)
|
store=True)
|
||||||
|
|
||||||
|
purchase_type = fields.Selection([('standard', '标准采购'), ('consignment', '委外加工')], string='采购类型',
|
||||||
|
default='standard')
|
||||||
|
|
||||||
@api.depends('partner_id')
|
@api.depends('partner_id')
|
||||||
def _compute_user_id(self):
|
def _compute_user_id(self):
|
||||||
if not self.user_id:
|
if not self.user_id:
|
||||||
@@ -237,42 +247,28 @@ class RePurchaseOrder(models.Model):
|
|||||||
raise UserError('请对【产品】中的【税】进行选择')
|
raise UserError('请对【产品】中的【税】进行选择')
|
||||||
|
|
||||||
def get_purchase_order(self, consecutive_process_parameters, production, product_id_to_production_names):
|
def get_purchase_order(self, consecutive_process_parameters, production, product_id_to_production_names):
|
||||||
server_product_process = []
|
|
||||||
production_process = product_id_to_production_names.get(
|
|
||||||
production.product_id.id)
|
|
||||||
for pp in consecutive_process_parameters:
|
for pp in consecutive_process_parameters:
|
||||||
if pp.gain_way == '外协':
|
server_product_process = []
|
||||||
|
purchase_order = pp._get_surface_technics_purchase_ids()
|
||||||
|
if purchase_order:
|
||||||
|
purchase_order.write({'state': 'draft'})
|
||||||
|
else:
|
||||||
server_template = self.env['product.template'].search(
|
server_template = self.env['product.template'].search(
|
||||||
[('server_product_process_parameters_id', '=', pp.id),
|
[('server_product_process_parameters_id', '=', pp.surface_technics_parameters_id.id),
|
||||||
('detailed_type', '=', 'service')])
|
('detailed_type', '=', 'service')])
|
||||||
purchase_order_line = self.env['purchase.order.line'].search(
|
server_product_process.append((0, 0, {
|
||||||
[('product_id', '=', server_template.product_variant_id.id),
|
'product_id': server_template.product_variant_id.id,
|
||||||
('product_qty', '=', len(production_process))], limit=1, order='id desc')
|
'product_qty': 1,
|
||||||
if not purchase_order_line:
|
'product_uom': server_template.uom_id.id
|
||||||
server_product_process.append((0, 0, {
|
}))
|
||||||
'product_id': server_template.product_variant_id.id,
|
purchase_order = self.env['purchase.order'].sudo().create({
|
||||||
'product_qty': len(production_process),
|
'partner_id': server_template.seller_ids[0].partner_id.id,
|
||||||
'product_uom': server_template.uom_id.id
|
'origin': production.name,
|
||||||
}))
|
'state': 'draft',
|
||||||
else:
|
'purchase_type': 'consignment',
|
||||||
for item in purchase_order_line:
|
'order_line': server_product_process})
|
||||||
if production.name in production_process:
|
pp.purchase_id = [(6, 0, [purchase_order.id])]
|
||||||
purchase_order = self.env['purchase.order'].search(
|
# self.env.cr.commit()
|
||||||
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
|
|
||||||
('id', '=', item.order_id.id)])
|
|
||||||
if not purchase_order:
|
|
||||||
server_product_process.append((0, 0, {
|
|
||||||
'product_id': server_template.product_variant_id.id,
|
|
||||||
'product_qty': len(production_process),
|
|
||||||
'product_uom': server_template.uom_id.id
|
|
||||||
}))
|
|
||||||
if server_product_process:
|
|
||||||
self.env['purchase.order'].sudo().create({
|
|
||||||
'partner_id': server_template.seller_ids.partner_id.id,
|
|
||||||
'origin': ','.join(production_process),
|
|
||||||
'state': 'draft',
|
|
||||||
'order_line': server_product_process})
|
|
||||||
# self.env.cr.commit()
|
|
||||||
|
|
||||||
@api.onchange('order_line')
|
@api.onchange('order_line')
|
||||||
def _onchange_order_line(self):
|
def _onchange_order_line(self):
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ access_sf_detection_result_group_sale_director,sf_detection_result_group_sale_di
|
|||||||
access_stock_scrap_group_sale_salemanager,stock_scrap_group_sale_salemanager,stock.model_stock_scrap,sf_base.group_sale_salemanager,1,0,0,0
|
access_stock_scrap_group_sale_salemanager,stock_scrap_group_sale_salemanager,stock.model_stock_scrap,sf_base.group_sale_salemanager,1,0,0,0
|
||||||
access_stock_scrap_group_sale_director,stock_scrap_group_sale_director,stock.model_stock_scrap,sf_base.group_sale_director,1,0,0,0
|
access_stock_scrap_group_sale_director,stock_scrap_group_sale_director,stock.model_stock_scrap,sf_base.group_sale_director,1,0,0,0
|
||||||
|
|
||||||
|
access_account_move_group_plan_dispatch,account_move_group_plan_dispatch,account.model_account_move,sf_base.group_plan_dispatch,1,1,1,0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
|
@@ -6,14 +6,20 @@
|
|||||||
<field name="model">purchase.order</field>
|
<field name="model">purchase.order</field>
|
||||||
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//header/button[@name='action_view_picking']" position="attributes">
|
||||||
|
<attribute name="invisible">1</attribute>
|
||||||
|
</xpath>
|
||||||
<xpath expr="//header/button[@name='action_rfq_send'][1]" position="before">
|
<xpath expr="//header/button[@name='action_rfq_send'][1]" position="before">
|
||||||
<button name="button_confirm" type="object" states="sent" string="Confirm Order"
|
<button name="button_confirm" type="object" states="sent" string="Confirm Order"
|
||||||
context="{'validate_analytic': True}" class="oe_highlight" id="bid_confirm"
|
context="{'validate_analytic': True}" class="oe_highlight" id="bid_confirm"
|
||||||
data-hotkey="v"/>
|
data-hotkey="v"/>
|
||||||
<button name="button_confirm" type="object" states="draft" context="{'validate_analytic': True}"
|
<button name="button_confirm" type="object" states="draft" context="{'validate_analytic': True}"
|
||||||
string="Confirm Order" id="draft_confirm"/>
|
string="Confirm Order" id="draft_confirm"/>
|
||||||
<button name="button_cancel" states="draft,to approve,sent,purchase" string="Cancel" type="object" data-hotkey="x" />
|
<button name="action_view_picking"
|
||||||
|
string="接收产品" class="oe_highlight" type="object"
|
||||||
|
attrs="{'invisible': ['|', '|' , ('is_shipped', '=', True), ('state','not in', ('purchase','done')), ('incoming_picking_count', '=', 0)]}"
|
||||||
|
data-hotkey="y" groups="stock.group_stock_user"/>
|
||||||
|
<button name="button_cancel" states="draft,to approve,sent,purchase" string="取消" type="object" data-hotkey="x" />
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//header/button[@name='button_cancel'][2]" position="attributes">
|
<xpath expr="//header/button[@name='button_cancel'][2]" position="attributes">
|
||||||
<attribute name="invisible">1</attribute>
|
<attribute name="invisible">1</attribute>
|
||||||
@@ -152,6 +158,11 @@
|
|||||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
||||||
</attribute>
|
</attribute>
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
|
<!-- 添加采购类型字段 -->
|
||||||
|
<field name="partner_ref" position="after">
|
||||||
|
<field name="purchase_type" string="采购类型" readonly="1"/>
|
||||||
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -207,6 +218,7 @@
|
|||||||
<field name="context">
|
<field name="context">
|
||||||
{"search_default_categ_id":1,"search_default_filter_to_purchase":1, "purchase_product_template": 1}
|
{"search_default_categ_id":1,"search_default_filter_to_purchase":1, "purchase_product_template": 1}
|
||||||
</field>
|
</field>
|
||||||
|
<field name="view_mode">tree,kanban,form,activity</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
<!-- <field name="process_id"/>-->
|
<!-- <field name="process_id"/>-->
|
||||||
<field name="parameter_ids" widget="many2many_tags" string="表面工艺参数"
|
<field name="parameter_ids" widget="many2many_tags" string="表面工艺参数"
|
||||||
options="{'no_create': True}"/>
|
options="{'no_create': True}"/>
|
||||||
<field name="machining_precision" required="1"/>
|
<!-- <field name="machining_precision" required="1"/>-->
|
||||||
<field name="processing_time"/>
|
<field name="processing_time"/>
|
||||||
<field name="quantity" options="{'format': false}"/>
|
<field name="quantity" options="{'format': false}"/>
|
||||||
<field name="unit_price"/>
|
<field name="unit_price"/>
|
||||||
@@ -128,9 +128,9 @@
|
|||||||
<!-- action="account.res_partner_action_customer"-->
|
<!-- action="account.res_partner_action_customer"-->
|
||||||
<!-- groups="sales_team.group_sale_salesman"-->
|
<!-- groups="sales_team.group_sale_salesman"-->
|
||||||
<!-- sequence="40"/>-->
|
<!-- sequence="40"/>-->
|
||||||
<menuitem sequence="21" name="快速订单" id="menu_quick_easy_order"
|
<!-- <menuitem sequence="21" name="快速订单" id="menu_quick_easy_order"-->
|
||||||
action="action_quick_easy_order"
|
<!-- action="action_quick_easy_order"-->
|
||||||
parent="sale.sale_order_menu"
|
<!-- parent="sale.sale_order_menu"-->
|
||||||
groups="sales_team.group_sale_salesman,sf_base.group_sale_salemanager,sf_base.group_sale_director"/>
|
<!-- groups="sales_team.group_sale_salesman,sf_base.group_sale_salemanager,sf_base.group_sale_director"/>-->
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -95,9 +95,9 @@
|
|||||||
<attribute name="attrs">{'readonly': [('state', 'in', ['cancel','sale'])]}</attribute>
|
<attribute name="attrs">{'readonly': [('state', 'in', ['cancel','sale'])]}</attribute>
|
||||||
</field>
|
</field>
|
||||||
<field name="payment_term_id" position="after">
|
<field name="payment_term_id" position="after">
|
||||||
<field name="deadline_of_delivery" readonly="0"/>
|
<field name="deadline_of_delivery" readonly="0"/>
|
||||||
<field name="payments_way" attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
<field name="payments_way" invisible="1"/>
|
||||||
<field name="pay_way" attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
<field name="pay_way" invisible="1"/>
|
||||||
<!-- <field name="schedule_status" readonly="1"/> -->
|
<!-- <field name="schedule_status" readonly="1"/> -->
|
||||||
</field>
|
</field>
|
||||||
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="before">
|
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="before">
|
||||||
@@ -118,8 +118,8 @@
|
|||||||
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="replace">
|
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="replace">
|
||||||
<field name="name" widget="section_and_note_text" optional="show"
|
<field name="name" widget="section_and_note_text" optional="show"
|
||||||
string="参数说明(长/宽/高/体积/精度/材质)"/>
|
string="参数说明(长/宽/高/体积/精度/材质)"/>
|
||||||
<field name="is_incoming_material" optional="hide"/>
|
<field name="manual_quotation" readonly="1"/>
|
||||||
<field name="incoming_size" optional="hide"/>
|
<field name="is_incoming_material" readonly="1"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<field name="user_id" position="attributes">
|
<field name="user_id" position="attributes">
|
||||||
<attribute name="attrs">{'readonly': [('state', 'in', ['cancel','sale'])]}</attribute>
|
<attribute name="attrs">{'readonly': [('state', 'in', ['cancel','sale'])]}</attribute>
|
||||||
@@ -166,8 +166,8 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
<!--新增带料字段-->
|
<!--新增带料字段-->
|
||||||
<xpath expr="//field[@name='order_line']/form//group//group//field[@name='analytic_distribution']" position="after">
|
<xpath expr="//field[@name='order_line']/form//group//group//field[@name='analytic_distribution']" position="after">
|
||||||
|
<field name="manual_quotation" />
|
||||||
<field name="is_incoming_material"/>
|
<field name="is_incoming_material"/>
|
||||||
<field name="incoming_size" attrs="{'invisible': [('is_incoming_material', '=', False)],'readonly':1}"/>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -181,17 +181,27 @@
|
|||||||
<attribute name="string">下单日期</attribute>
|
<attribute name="string">下单日期</attribute>
|
||||||
</field>
|
</field>
|
||||||
<field name="sale_order_template_id" position="after">
|
<field name="sale_order_template_id" position="after">
|
||||||
<field name="person_of_delivery" string="交货人"
|
|
||||||
attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
|
||||||
<field name="telephone_of_delivery" string="交货人联系方式"
|
|
||||||
attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
|
||||||
<field name="address_of_delivery" string="交货人地址"
|
|
||||||
attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
|
||||||
<field name="remark" attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
<field name="remark" attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="view_order_form_inherit_sale_stock_sf">
|
||||||
|
<field name="name">view_order_form_inherit_sale_stock.sf</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="inherit_id" ref="sale_stock.view_order_form_inherit_sale_stock"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='picking_policy']" position="before">
|
||||||
|
<field name="person_of_delivery" string="收货人"
|
||||||
|
attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
||||||
|
<field name="telephone_of_delivery" string="电话号码"
|
||||||
|
attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
||||||
|
<field name="address_of_delivery" string="联系地址"
|
||||||
|
attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="view_quotation_with_onboarding_tree_inherit_sf" model="ir.ui.view">
|
<record id="view_quotation_with_onboarding_tree_inherit_sf" model="ir.ui.view">
|
||||||
<field name="name">sale.order.quotation.tree.inherit.sf</field>
|
<field name="name">sale.order.quotation.tree.inherit.sf</field>
|
||||||
<field name="model">sale.order</field>
|
<field name="model">sale.order</field>
|
||||||
@@ -207,12 +217,12 @@
|
|||||||
<field name="create_date" position="attributes">
|
<field name="create_date" position="attributes">
|
||||||
<attribute name="string">下单时间</attribute>
|
<attribute name="string">下单时间</attribute>
|
||||||
</field>
|
</field>
|
||||||
<field name="state" position="after">
|
<!-- <field name="state" position="after">
|
||||||
<field name="check_status" widget="badge"
|
<field name="check_status" widget="badge"
|
||||||
decoration-success="check_status == 'approved'"
|
decoration-success="check_status == 'approved'"
|
||||||
decoration-warning="check_status == 'pending'"
|
decoration-warning="check_status == 'pending'"
|
||||||
decoration-danger="check_status == 'fail'"/>
|
decoration-danger="check_status == 'fail'"/>
|
||||||
</field>
|
</field> -->
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -273,6 +283,8 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="sale.product_template_action" model="ir.actions.act_window">
|
<record id="sale.product_template_action" model="ir.actions.act_window">
|
||||||
|
<field name="view_mode">tree,kanban,form,activity</field>
|
||||||
|
<field name="view_id" ref="product.product_template_tree_view"/>
|
||||||
<field name="context">{"search_default_categ_id":1,
|
<field name="context">{"search_default_categ_id":1,
|
||||||
"search_default_filter_to_sell":1,"sale_multi_pricelist_product_template": 1}
|
"search_default_filter_to_sell":1,"sale_multi_pricelist_product_template": 1}
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
'data': [
|
'data': [
|
||||||
# 'security/ir.model.access.csv',
|
# 'security/ir.model.access.csv',
|
||||||
'views/stock_picking.xml',
|
'views/stock_picking.xml',
|
||||||
'views/stock_product_template.xml'
|
'views/stock_product_template.xml',
|
||||||
],
|
],
|
||||||
# only loaded in demonstration mode
|
# only loaded in demonstration mode
|
||||||
'demo': [
|
'demo': [
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
<record id="stock.product_template_action_product" model="ir.actions.act_window">
|
<record id="stock.product_template_action_product" model="ir.actions.act_window">
|
||||||
|
<field name="view_mode">tree,kanban,form,activity</field>
|
||||||
<field name="context">
|
<field name="context">
|
||||||
{"search_default_categ_id":1,"search_default_consumable": 1, 'default_detailed_type': 'product'}
|
{"search_default_categ_id":1,"search_default_consumable": 1, 'default_detailed_type': 'product'}
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -200,6 +200,8 @@ class MrpProduction(models.Model):
|
|||||||
self[0].write({'is_rework': False})
|
self[0].write({'is_rework': False})
|
||||||
# 修改制造订单 编程状态变为“编程中” 制造订单状态为‘返工’
|
# 修改制造订单 编程状态变为“编程中” 制造订单状态为‘返工’
|
||||||
self.write({'programming_state': '编程中', 'work_state': '编程中', 'state': 'rework'})
|
self.write({'programming_state': '编程中', 'work_state': '编程中', 'state': 'rework'})
|
||||||
|
self[0].workorder_ids.filtered(
|
||||||
|
lambda a: a.name == '装夹预调' and a.state not in ['rework', 'done', 'cancel'])._compute_state()
|
||||||
if missing_tool_1:
|
if missing_tool_1:
|
||||||
logging.info(f'线边、机内缺刀:{missing_tool_1}')
|
logging.info(f'线边、机内缺刀:{missing_tool_1}')
|
||||||
# 修改 修改cnc程序的‘刀具状态’ 为 ‘缺刀’
|
# 修改 修改cnc程序的‘刀具状态’ 为 ‘缺刀’
|
||||||
@@ -219,5 +221,6 @@ class MrpProduction(models.Model):
|
|||||||
logging.info('调用CAM工单程序用刀计划创建方法!!!')
|
logging.info('调用CAM工单程序用刀计划创建方法!!!')
|
||||||
self.env['sf.cam.work.order.program.knife.plan'].sudo().create_cam_work_plan(cnc_ids)
|
self.env['sf.cam.work.order.program.knife.plan'].sudo().create_cam_work_plan(cnc_ids)
|
||||||
if not invalid_tool and not missing_tool_1:
|
if not invalid_tool and not missing_tool_1:
|
||||||
|
self.sudo().write({'tool_state': '0'})
|
||||||
logging.info('校验cnc用刀正常!!!')
|
logging.info('校验cnc用刀正常!!!')
|
||||||
logging.info('工单cnc程序用刀校验完成!!!')
|
logging.info('工单cnc程序用刀校验完成!!!')
|
||||||
|
|||||||
@@ -450,7 +450,7 @@
|
|||||||
<field name="production_line_name_id" optional="hide"/>
|
<field name="production_line_name_id" optional="hide"/>
|
||||||
<field name="machine_tool_name_id" optional="hide"/>
|
<field name="machine_tool_name_id" optional="hide"/>
|
||||||
<field name="applicant" optional="hide"/>
|
<field name="applicant" optional="hide"/>
|
||||||
<field name="apply_time"/>
|
<field name="create_date" string="申请时间"/>
|
||||||
<field name="assemble_status" widget='badge'
|
<field name="assemble_status" widget='badge'
|
||||||
decoration-info="assemble_status == '0'"
|
decoration-info="assemble_status == '0'"
|
||||||
decoration-warning="assemble_status == '01'"
|
decoration-warning="assemble_status == '01'"
|
||||||
|
|||||||
@@ -1106,6 +1106,9 @@ class SfProcurementGroup(models.Model):
|
|||||||
class SfPickingType(models.Model):
|
class SfPickingType(models.Model):
|
||||||
_inherit = 'stock.picking.type'
|
_inherit = 'stock.picking.type'
|
||||||
|
|
||||||
|
code = fields.Selection([('incoming', 'Receipt'), ('outgoing', 'Delivery'), ('internal', '厂内出入库')],
|
||||||
|
'Type of Operation', required=True)
|
||||||
|
|
||||||
def _default_show_operations(self):
|
def _default_show_operations(self):
|
||||||
return self.user_has_groups(
|
return self.user_has_groups(
|
||||||
'stock.group_production_lot,'
|
'stock.group_production_lot,'
|
||||||
@@ -1119,6 +1122,8 @@ class SfPickingType(models.Model):
|
|||||||
action = super(SfPickingType, self)._get_action(action_xmlid)
|
action = super(SfPickingType, self)._get_action(action_xmlid)
|
||||||
if not self.env.user.has_group('base.group_system'):
|
if not self.env.user.has_group('base.group_system'):
|
||||||
action['context']['create'] = False
|
action['context']['create'] = False
|
||||||
|
if self.sequence_code in ['DL', 'INT', 'PC']:
|
||||||
|
action['context']['search_default_retrospect_ref'] = 1
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -602,7 +602,7 @@ var GanttRow = Widget.extend({
|
|||||||
// pill._color = self._getColor(pill[self.colorField]);
|
// pill._color = self._getColor(pill[self.colorField]);
|
||||||
// 设置pill背景颜色2 修改时间2024年6月25日17:09:43
|
// 设置pill背景颜色2 修改时间2024年6月25日17:09:43
|
||||||
let isDelay = false
|
let isDelay = false
|
||||||
if(pill.state != 'processing' && pill.state != 'finished') { // 判断待加工
|
if(pill.state != 'processing' && pill.state != 'finished' && pill.order_deadline) { // 判断待加工
|
||||||
isDelay = pill.order_deadline.isBefore(new Date())
|
isDelay = pill.order_deadline.isBefore(new Date())
|
||||||
}
|
}
|
||||||
if(isDelay) {
|
if(isDelay) {
|
||||||
|
|||||||
Reference in New Issue
Block a user