-
-
-
-
+
+
+
+
+
+
+
+
+
+
![Product]()
+
+
+
+
+
+ 规格:
+
+
+
[]
+
+
+
+
+ Variants
-
-
-
-
- 规格:
-
-
[]
-
-
- Variants
-
-
-
-
-
-
-
+
+
+
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index d7c911fa..e825ef48 100644
--- a/sf_manufacturing/views/mrp_workorder_view.xml
+++ b/sf_manufacturing/views/mrp_workorder_view.xml
@@ -104,22 +104,31 @@
+
+ ('is_user_working', '!=', False),('user_permissions','=',False)]}"
+ groups="sf_base.group_sf_mrp_user"/>
+ groups="sf_base.group_sf_mrp_user"
+ attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
+ groups="sf_base.group_sf_mrp_user"
+ attrs="{'invisible': ['|', '|','|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'),('user_permissions','=',False),('state','=','done')]}"/>
+ groups="sf_base.group_sf_mrp_user"
+ attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('state','=','done')]}"/>
+
+
-
+
@@ -229,11 +238,12 @@
-
-
-
-
-
+
+
+
+
+
+
@@ -390,15 +400,27 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -440,16 +462,16 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -479,14 +501,68 @@
[('schedule_state', '=', '已排')]
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ 工件配送
+ sf.workpiece.delivery
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 工件配送
+ sf.workpiece.delivery
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 工件配送
+ sf.workpiece.delivery
+ tree,search
+
diff --git a/sf_manufacturing/views/sf_maintenance_equipment.xml b/sf_manufacturing/views/sf_maintenance_equipment.xml
index a2d9437d..b398f994 100644
--- a/sf_manufacturing/views/sf_maintenance_equipment.xml
+++ b/sf_manufacturing/views/sf_maintenance_equipment.xml
@@ -1,7 +1,7 @@
-
+ 设备增加刀具库位table
sf_manufacturing_equipment.form
maintenance.equipment
@@ -13,17 +13,6 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sf_manufacturing/views/stock_picking_view.xml b/sf_manufacturing/views/stock_picking_view.xml
index a287fbec..13bb12c2 100644
--- a/sf_manufacturing/views/stock_picking_view.xml
+++ b/sf_manufacturing/views/stock_picking_view.xml
@@ -1,6 +1,17 @@
+
+ stock.move.operations.form.inherit.sf
+ stock.move
+
+
+
+
+
+
+
+
stock.picking.form.inherit.sf
stock.picking
diff --git a/sf_manufacturing/wizard/__init__.py b/sf_manufacturing/wizard/__init__.py
new file mode 100644
index 00000000..5cfab982
--- /dev/null
+++ b/sf_manufacturing/wizard/__init__.py
@@ -0,0 +1 @@
+from . import workpiece_delivery_wizard
diff --git a/sf_manufacturing/wizard/workpiece_delivery_views.xml b/sf_manufacturing/wizard/workpiece_delivery_views.xml
new file mode 100644
index 00000000..96e1d4ff
--- /dev/null
+++ b/sf_manufacturing/wizard/workpiece_delivery_views.xml
@@ -0,0 +1,27 @@
+
+
+
+ sf.workpiece.delivery.wizard.form.view
+ sf.workpiece.delivery.wizard
+
+
+
+
+
+
+ 工件配送向导
+ sf.workpiece.delivery.wizard
+ form
+ new
+
+
+
\ No newline at end of file
diff --git a/sf_manufacturing/wizard/workpiece_delivery_wizard.py b/sf_manufacturing/wizard/workpiece_delivery_wizard.py
new file mode 100644
index 00000000..d990e307
--- /dev/null
+++ b/sf_manufacturing/wizard/workpiece_delivery_wizard.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# Part of YiZuo. See LICENSE file for full copyright and licensing details.
+from odoo.exceptions import UserError, ValidationError
+from datetime import datetime
+from odoo import models, api, fields
+
+
+class WorkpieceDeliveryWizard(models.TransientModel):
+ _name = 'sf.workpiece.delivery.wizard'
+ _description = '工件配送'
+
+ delivery_id = fields.Many2one('sf.workpiece.delivery', string='配送')
+
+ def confirm(self):
+ self.delivery_id._delivery_avg()
+
diff --git a/sf_mrs_connect/models/res_config_setting.py b/sf_mrs_connect/models/res_config_setting.py
index d74db38b..3f2b698f 100644
--- a/sf_mrs_connect/models/res_config_setting.py
+++ b/sf_mrs_connect/models/res_config_setting.py
@@ -14,6 +14,7 @@ class ResConfigSettings(models.TransientModel):
sf_secret_key = fields.Char(string='密钥', default='wBmxej38OkErKhD6')
sf_url = fields.Char(string='访问地址', default='https://sf.cs.jikimo.com')
bfm_url = fields.Char(string='业务平台后端访问地址', default='https://bfm.jikimo.com')
+ agv_url = fields.Char(string='avg访问地址', default='http://IP:PORT/rcms/services/rest')
ftp_host = fields.Char(string='FTP的ip')
ftp_port = fields.Char(string='FTP端口')
ftp_user = fields.Char(string='FTP用户')
@@ -33,8 +34,8 @@ class ResConfigSettings(models.TransientModel):
_logger.info("同步资源库表面工艺类别完成")
self.env['sf.production.process'].sync_all_production_process()
_logger.info("同步资源库表面工艺完成")
- # self.env['sf.processing.technology'].sync_all_processing_technology()
- # _logger.info("同步资源库加工工艺")
+ self.env['sf.processing.technology'].sync_all_processing_technology()
+ _logger.info("同步资源库加工工艺")
self.env['sf.machine.brand.tags'].sync_all_machine_brand_tags()
_logger.info("同步资源库品牌类别完成")
self.env['sf.machine.brand'].sync_all_machine_brand()
@@ -44,23 +45,23 @@ class ResConfigSettings(models.TransientModel):
self.env['sf.machine_tool.category'].sync_all_machine_tool_category()
_logger.info("同步资源库机床类型完成")
self.env['sf.production.process.parameter'].sync_all_production_process_parameter()
- _logger.info("同步刀具物料完成")
+ _logger.info("同步材料型号可选参数完成")
self.env['sf.cutting.tool.material'].sync_all_cutting_tool_material()
- _logger.info("同步刀具类型完成")
+ _logger.info("同步刀具物料完成")
self.env['sf.cutting.tool.type'].sync_all_tool_type()
- _logger.info("同步功能刀具类型完成")
+ _logger.info("同步刀具类型完成")
self.env['sf.functional.cutting.tool.model'].sync_all_functional_cutting_tool_model()
- _logger.info("同步夹具物料完成")
+ _logger.info("同步功能刀具类型完成")
self.env['sf.fixture.material'].sync_all_fixture_material()
- _logger.info("同步联装类型完成")
+ _logger.info("同步夹具物料完成")
self.env['sf.multi_mounting.type'].sync_all_multi_mounting_type()
- _logger.info("同步夹具型号完成")
+ _logger.info("同步联装类型完成")
self.env['sf.fixture.model'].sync_all_fixture_model()
- _logger.info("同步夹具型号类型完成")
+ _logger.info("同步夹具型号完成")
self.env['sf.functional.fixture.type'].sync_all_functional_fixture_type()
- _logger.info("同步功能夹具类型完成")
+ _logger.info("同步夹具型号类型完成")
self.env['sf.machine_tool.type'].sync_all_machine_tool_type()
- _logger.info("同步资源库机床型号完成")
+ _logger.info("同步功能夹具类型完成")
self.env['maintenance.equipment.image'].sync_all_maintenance_equipment_image()
_logger.info("同步能力特征库完成")
self.env['sf.cutting_tool.standard.library'].sync_all_cutting_tool_standard_library()
diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py
index df9437ba..334e6f8b 100644
--- a/sf_mrs_connect/models/sync_common.py
+++ b/sf_mrs_connect/models/sync_common.py
@@ -92,7 +92,8 @@ class sfProductionMaterials(models.Model):
if result['status'] == 1:
for item in result['production_materials_yesterday_list']:
if item:
- materials = self.search([("materials_no", '=', item['materials_no'])])
+ materials = self.search(
+ [("materials_no", '=', item['materials_no'], ('active', 'in', [True, False]))])
if materials:
materials.name = item['name']
materials.remark = item['remark']
@@ -118,7 +119,8 @@ class sfProductionMaterials(models.Model):
if result['status'] == 1:
for item in result['production_materials_all_list']:
if item:
- materials = self.search([("materials_no", '=', item['materials_no'])])
+ materials = self.search(
+ [("materials_no", '=', item['materials_no']), ('active', 'in', [True, False])])
if not materials:
self.create({
"name": item['name'],
@@ -150,7 +152,8 @@ class sfMaterialModel(models.Model):
if result['status'] == 1:
for item in result['materials_model_yesterday_list']:
if item:
- materials_model = self.search([("materials_no", '=', item['materials_no'])])
+ materials_model = self.search(
+ [("materials_no", '=', item['materials_no']), ('active', 'in', [True, False])])
materials = self.env['sf.production.materials'].search(
[("materials_no", '=', item['materials_id.materials_no'])])
if materials_model:
@@ -196,7 +199,8 @@ class sfMaterialModel(models.Model):
if result['status'] == 1:
for item in result['materials_model_all_list']:
if item:
- materials_model = self.search([("materials_no", '=', item['materials_no'])])
+ materials_model = self.search(
+ [("materials_no", '=', item['materials_no']), ('active', 'in', [True, False])])
materials = self.env['sf.production.materials'].search(
[("materials_no", '=', item['materials_id.materials_no'])])
if not materials_model:
@@ -256,7 +260,8 @@ class sfProductionProcessCategory(models.Model):
if result['status'] == 1:
for item in result['production_process_category_yesterday_list']:
if item:
- production_process_category = self.search([("code", '=', item['code'])])
+ production_process_category = self.search(
+ [("code", '=', item['code']), ('active', 'in', [True, False])])
if production_process_category:
production_process_category.name = item['name']
production_process_category.code = item['code']
@@ -281,7 +286,7 @@ class sfProductionProcessCategory(models.Model):
if result['status'] == 1:
for item in result['production_process_category_all_list']:
if item:
- category = self.search([("code", '=', item['code'])])
+ category = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
if not category:
self.create({
"name": item['name'],
@@ -311,17 +316,7 @@ class sfProductionProcess(models.Model):
if result['status'] == 1:
for item in result['production_process_yesterday_list']:
if item:
- brand = self.env['sf.production.process'].search(
- [("code", '=', item['code'])])
- if brand:
- brand.name = item['name'],
- brand.category_id = self.env['sf.production.process.category'].search(
- [("code", '=', item['category_code'])]).id,
- brand.code = item['code'],
- brand.remark = item['remark'],
- brand.active = item['active'],
- brand.remark = item['remark']
- production_process = self.search([("code", '=', item['code'])])
+ production_process = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
category = self.env['sf.production.process.category'].search(
[("code", '=', item['category_code'])])
if production_process:
@@ -332,8 +327,7 @@ class sfProductionProcess(models.Model):
else:
self.create({
"name": item['name'],
- "category_id": self.env['sf.production.process.category'].search(
- [("code", '=', item['category_code'])]).id,
+ "category_id": category.id,
"code": item['code'],
"remark": item['remark'],
"active": item['active'],
@@ -352,7 +346,7 @@ class sfProductionProcess(models.Model):
if result['status'] == 1:
for item in result['production_process_all_list']:
if item:
- production_process = self.search([("code", '=', item['code'])])
+ production_process = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
category = self.env['sf.production.process.category'].search(
[("code", '=', item['category_code'])])
if not production_process:
@@ -388,7 +382,7 @@ class sfProcessingTechnology(models.Model):
if result['status'] == 1:
for item in result['processing_technology_yesterday_list']:
if item:
- processing_technology = self.search([("code", '=', item['code'])])
+ processing_technology = self.search([("code", '=', item['process_encode']), ('active', 'in', [True, False])])
if processing_technology:
processing_technology.name = item['name']
processing_technology.remark = item['remark']
@@ -396,7 +390,7 @@ class sfProcessingTechnology(models.Model):
else:
self.create({
"name": item['name'],
- "code": item['code'],
+ "code": item['process_encode'],
"remark": item['remark'],
"active": item['active'],
})
@@ -414,11 +408,11 @@ class sfProcessingTechnology(models.Model):
if result['status'] == 1:
for item in result['processing_technology_all_list']:
if item:
- processing_technology = self.search([("code", '=', item['code'])])
+ processing_technology = self.search([("code", '=', item['process_encode']), ('active', 'in', [True, False])])
if not processing_technology:
self.create({
"name": item['name'],
- "code": item['code'],
+ "code": item['process_encode'],
"remark": item['remark'],
"active": item['active'],
})
@@ -496,7 +490,7 @@ class MachineControlSystem(models.Model):
if result['status'] == 1:
for item in result['machine_control_system_yesterday_list']:
if item:
- control_system = self.search([("code", '=', item['code'])])
+ control_system = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
brand = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])])
if control_system:
control_system.name = item['name']
@@ -525,7 +519,7 @@ class MachineControlSystem(models.Model):
if result['status'] == 1:
for item in result['machine_control_system_all_list']:
if item:
- control_system = self.search([("code", '=', item['code'])])
+ control_system = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
brand = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])])
if not control_system:
self.create({
@@ -559,7 +553,7 @@ class MachineBrand(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['machine_brand_yesterday_list']:
- brand = self.search([("code", '=', item['code'])])
+ brand = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
if brand:
brand.name = item['name']
brand.image_brand = '' if not item['image_brand'] else base64.b64decode(item['image_brand'])
@@ -588,7 +582,7 @@ class MachineBrand(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['machine_brand_all_list']:
- brand = self.search([("code", '=', item['code'])])
+ brand = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
if not brand:
self.create({
"name": item['name'],
@@ -628,7 +622,7 @@ class MachineToolType(models.Model):
else:
image = ''
taper_type_id = self.env['spindle.taper.type'].search([('name', '=', item['taper_type_id'])])
- machine_tool_type = self.search([("code", '=', item['code'])])
+ machine_tool_type = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
control_system = self.env['sf.machine.control_system'].search(
[('code', '=', item['control_system_id'])])
jg_image_id = self.env['maintenance.equipment.image'].search([('name', 'in', item['jg_image_id'])])
@@ -822,7 +816,7 @@ class MachineToolType(models.Model):
'name': item['taper_type_id']
})
- machine_tool_type = self.search([("code", '=', item['code'])])
+ machine_tool_type = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
control_system = self.env['sf.machine.control_system'].search(
[('code', '=', item['control_system_id'])])
brand = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])])
@@ -1013,7 +1007,7 @@ class sfProcessingOrder(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['processing_order_yesterday_list']:
- processing_order = self.search([("id", '=', item['id'])])
+ processing_order = self.search([("id", '=', item['id']), ('active', 'in', [True, False])])
if processing_order:
processing_order.sequence = item['sequence']
else:
@@ -1033,7 +1027,7 @@ class sfProcessingOrder(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['processing_order_all_list']:
- processing_order = self.search([("id", '=', item['id'])])
+ processing_order = self.search([("id", '=', item['id']), ('active', 'in', [True, False])])
if not processing_order:
self.create({
"sequence": item['sequence'],
@@ -1060,7 +1054,8 @@ class sfProductionProcessParameter(models.Model):
if result['status'] == 1:
for item in result['mrs_production_process_parameter_yesterday_list']:
if item:
- production_process_parameter = self.search([("code", '=', item['code'])])
+ production_process_parameter = self.search(
+ [("code", '=', item['code']), ('active', 'in', [True, False])])
process = self.env['sf.production.process'].search(
[('code', '=', item['process_id_code'])])
if production_process_parameter:
@@ -1093,7 +1088,7 @@ class sfProductionProcessParameter(models.Model):
for item in result['mrs_production_process_parameter_all_list']:
if item:
production_process_parameter = self.search(
- [("code", '=', item['code'])])
+ [("code", '=', item['code']), ('active', 'in', [True, False])])
process = self.env['sf.production.process'].search(
[('code', '=', item['process_id_code'])], limit=1)
if not production_process_parameter:
@@ -1130,7 +1125,7 @@ class MachineToolCategory(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['machine_tool_category_yesterday_list']:
- machine_tool_category = self.search([("code", '=', item['code'])])
+ machine_tool_category = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
if machine_tool_category:
machine_tool_category.name = item['name']
machine_tool_category.category = item['category']
@@ -1157,7 +1152,7 @@ class MachineToolCategory(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['machine_tool_category_all_list']:
- machine_tool_category = self.search([("code", '=', item['code'])])
+ machine_tool_category = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
if not machine_tool_category:
self.create({
"name": item['name'],
@@ -1195,7 +1190,8 @@ class sfSyncCutting_tool_Material(models.Model):
if result.get('mrs_cutting_tool_material_yesterday_list'):
for item in result['mrs_cutting_tool_material_yesterday_list']:
if item:
- cutting_tool_material = self.search([("code", '=', item['code'])])
+ cutting_tool_material = self.search(
+ [("code", '=', item['code']), ('active', 'in', [True, False])])
if not cutting_tool_material:
self.create({
"name": item['name'],
@@ -1225,7 +1221,8 @@ class sfSyncCutting_tool_Material(models.Model):
if result.get('mrs_cutting_tool_material_all_list'):
for item in result['mrs_cutting_tool_material_all_list']:
if item:
- cutting_tool_material = self.search([("code", '=', item['code'])])
+ cutting_tool_material = self.search(
+ [("code", '=', item['code']), ('active', 'in', [True, False])])
if not cutting_tool_material:
self.create({
"name": item['name'],
@@ -1262,7 +1259,8 @@ class SyncFunctionalCuttingToolModel(models.Model):
if result.get('mrs_functional_cutting_tool_model_yesterday_list'):
for item in result['mrs_functional_cutting_tool_model_yesterday_list']:
if item:
- functional_cutting_tool_model = self.search([("code", '=', item['code'])])
+ functional_cutting_tool_model = self.search(
+ [("code", '=', item['code']), ('active', 'in', [True, False])])
if not functional_cutting_tool_model:
self.create({
"name": item['name'],
@@ -1292,7 +1290,8 @@ class SyncFunctionalCuttingToolModel(models.Model):
if result.get('mrs_functional_cutting_tool_model_all_list'):
for item in result['mrs_functional_cutting_tool_model_all_list']:
if item:
- functional_cutting_tool_model = self.search([("code", '=', item['code'])])
+ functional_cutting_tool_model = self.search(
+ [("code", '=', item['code']), ('active', 'in', [True, False])])
if not functional_cutting_tool_model:
self.create({
"name": item['name'],
@@ -1329,7 +1328,7 @@ class SyncFixtureMaterial(models.Model):
if result.get('fixture_material_yesterday_list'):
for item in result['fixture_material_yesterday_list']:
if item:
- fixture_material = self.search([("code", '=', item['code'])])
+ fixture_material = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
if not fixture_material:
self.create({
"name": item['name'],
@@ -1361,7 +1360,7 @@ class SyncFixtureMaterial(models.Model):
if result.get('fixture_material_all_list'):
for item in result['fixture_material_all_list']:
if item:
- fixture_material = self.search([("code", '=', item['code'])])
+ fixture_material = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
if not fixture_material:
self.create({
"name": item['name'],
@@ -1399,7 +1398,8 @@ class SyncMulti_Mounting_Type(models.Model):
if result.get('multi_mounting_type_yesterday_list'):
for item in result['multi_mounting_type_yesterday_list']:
if item:
- multi_mounting_type = self.search([("code", '=', item['code'])])
+ multi_mounting_type = self.search(
+ [("code", '=', item['code']), ('active', 'in', [True, False])])
if not multi_mounting_type:
self.create({
"name": item['name'],
@@ -1429,7 +1429,8 @@ class SyncMulti_Mounting_Type(models.Model):
if result.get('multi_mounting_type_all_list'):
for item in result['multi_mounting_type_all_list']:
if item:
- multi_mounting_type = self.search([("code", '=', item['code'])])
+ multi_mounting_type = self.search(
+ [("code", '=', item['code']), ('active', 'in', [True, False])])
if not multi_mounting_type:
self.create({
"name": item['name'],
@@ -1674,7 +1675,8 @@ class SyncFunctionalFixtureType(models.Model):
if result.get('functional_fixture_type_yesterday_list'):
for item in result['functional_fixture_type_yesterday_list']:
if item:
- functional_fixture_type = self.search([("code", '=', item['code'])])
+ functional_fixture_type = self.search(
+ [("code", '=', item['code']), ('active', 'in', [True, False])])
if not functional_fixture_type:
self.create({
"name": item['name'],
@@ -1703,7 +1705,8 @@ class SyncFunctionalFixtureType(models.Model):
if result.get('functional_fixture_type_all_list'):
for item in result['functional_fixture_type_all_list']:
if item:
- functional_fixture_type = self.search([("code", '=', item['code'])])
+ functional_fixture_type = self.search(
+ [("code", '=', item['code']), ('active', 'in', [True, False])])
if not functional_fixture_type:
self.create({
"name": item['name'],
@@ -1739,7 +1742,7 @@ class SfToolType(models.Model):
if result['status'] == 1:
for item in result['mrs_cutting_tool_type_yesterday_list']:
if item:
- cutting_tool_type = self.search([("code", '=', item['code'])])
+ cutting_tool_type = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
cutting_tool_material = self.env['sf.cutting.tool.material'].search(
[("code", '=', item['cutting_tool_material_code'])])
if not cutting_tool_type:
@@ -1771,7 +1774,7 @@ class SfToolType(models.Model):
if result['status'] == 1:
for item in result['mrs_cutting_tool_type_all_list']:
if item:
- cutting_tool_type = self.search([("code", '=', item['code'])])
+ cutting_tool_type = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
cutting_tool_material = self.env['sf.cutting.tool.material'].search(
[("code", '=', item['cutting_tool_material_code'])])
if not cutting_tool_type:
@@ -1811,7 +1814,8 @@ class SfMaintenanceEquipmentImage(models.Model):
if result['status'] == 1:
for item in result['ability_feature_library_yesterday_list']:
if item:
- ability_feature_library = self.search([("name", '=', item['name'])])
+ ability_feature_library = self.search(
+ [("name", '=', item['name']), ('active', 'in', [True, False])])
if not ability_feature_library:
self.create({
"name": item['name'],
@@ -1839,7 +1843,8 @@ class SfMaintenanceEquipmentImage(models.Model):
if result['status'] == 1:
for item in result['ability_feature_library_all_list']:
if item:
- ability_feature_library = self.search([("name", '=', item['name'])])
+ ability_feature_library = self.search(
+ [("name", '=', item['name']), ('active', 'in', [True, False])])
if not ability_feature_library:
self.create({
"name": item['name'],
@@ -1872,7 +1877,7 @@ class MaterialApply(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['material_apply_yesterday_list']:
- material_apply = self.search([("name", '=', item['name'])])
+ material_apply = self.search([("name", '=', item['name']), ('active', 'in', [True, False])])
if material_apply:
material_apply.name = item['name']
material_apply.active = item['active']
@@ -1894,7 +1899,7 @@ class MaterialApply(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['material_apply_all_list']:
- material_apply = self.search([("name", '=', item['name'])])
+ material_apply = self.search([("name", '=', item['name']), ('active', 'in', [True, False])])
if not material_apply:
self.create({
"name": item['name'],
@@ -1922,7 +1927,7 @@ class ModelInternationalStandards(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['mrs_international_standards_yesterday_list']:
- international_standards = self.search([("name", '=', item['name'])])
+ international_standards = self.search([("name", '=', item['name']), ('active', 'in', [True, False])])
if international_standards:
international_standards.name = item['name']
international_standards.active = item['active']
@@ -1945,7 +1950,7 @@ class ModelInternationalStandards(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['mrs_international_standards_all_list']:
- international_standards = self.search([("name", '=', item['name'])])
+ international_standards = self.search([("name", '=', item['name']), ('active', 'in', [True, False])])
if not international_standards:
self.create({
"name": item['name'],
@@ -1973,7 +1978,7 @@ class CuttingSpeed(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['cutting_speed_yesterday_list']:
- cutting_speed = self.search([("name", '=', item['name'])])
+ cutting_speed = self.search([("name", '=', item['name']), ('active', 'in', [True, False])])
if not cutting_speed:
self.create({
'name': item['name'],
@@ -2027,7 +2032,7 @@ class CuttingSpeed(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['cutting_speed_all_list']:
- cutting_speed = self.search([("name", '=', item['name'])])
+ cutting_speed = self.search([("name", '=', item['name']), ('active', 'in', [True, False])])
if not cutting_speed:
self.create({
'name': item['name'],
@@ -2087,7 +2092,7 @@ class CuttingWidthDepth(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['cutting_width_depth_yesterday_list']:
- cutting_width_depth = self.search([("name", '=', item['name'])])
+ cutting_width_depth = self.search([("name", '=', item['name']), ('active', 'in', [True, False])])
if not cutting_width_depth:
self.create({
'name': item['name'],
@@ -2104,7 +2109,7 @@ class CuttingWidthDepth(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['cutting_width_depth_all_list']:
- cutting_width_depth = self.search([("name", '=', item['name'])])
+ cutting_width_depth = self.search([("name", '=', item['name']), ('active', 'in', [True, False])])
if not cutting_width_depth:
self.create({
'name': item['name'],
@@ -2127,7 +2132,7 @@ class CuttingSpeed(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['feed_per_tooth_yesterday_list']:
- feed_per_tooth = self.search([("name", '=', item['name'])])
+ feed_per_tooth = self.search([("name", '=', item['name']), ('active', 'in', [True, False])])
if not feed_per_tooth:
self.create({
'name': item['name'],
@@ -2165,7 +2170,7 @@ class CuttingSpeed(models.Model):
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['feed_per_tooth_all_list']:
- feed_per_tooth = self.search([("name", '=', item['name'])])
+ feed_per_tooth = self.search([("name", '=', item['name']), ('active', 'in', [True, False])])
if not feed_per_tooth:
self.create({
'name': item['name'],
@@ -2211,7 +2216,8 @@ class Cutting_tool_standard_library(models.Model):
if result['status'] == 1:
for item in result['cutting_tool_standard_library_yesterday_list']:
cutting_tool_standard_library = self.search(
- [("code", '=', item['code'].replace("JKM", result['factory_short_name']))])
+ [("code", '=', item['code'].replace("JKM", result['factory_short_name']),
+ ('active', 'in', [True, False]))])
cutting_tool_type = self.env['sf.cutting.tool.type'].search(
[("code", '=', item['cutting_tool_type_code'])])
cutting_tool_material = self.env['sf.cutting.tool.material'].search(
@@ -2317,7 +2323,8 @@ class Cutting_tool_standard_library(models.Model):
if result['status'] == 1:
for item in result['cutting_tool_standard_library_all_list']:
cutting_tool_standard_library = self.search(
- [("code", '=', item['code'].replace("JKM", result['factory_short_name']))])
+ [("code", '=', item['code'].replace("JKM", result['factory_short_name']),
+ ('active', 'in', [True, False]))])
cutting_tool_type = self.env['sf.cutting.tool.type'].search(
[("code", '=', item['cutting_tool_type_code'])])
cutting_tool_material = self.env['sf.cutting.tool.material'].search(
@@ -2431,7 +2438,8 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_integral_tool'])
if basic_parameters_integral_tool_list:
for integral_tool_item in basic_parameters_integral_tool_list:
- integral_tool = self.search([('code', '=', integral_tool_item['code'])])
+ integral_tool = self.search(
+ [('code', '=', integral_tool_item['code']), ('active', 'in', [True, False])])
if not integral_tool:
self.create({
'name': integral_tool_item['name'],
@@ -2483,7 +2491,7 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_blade'])
if basic_parameters_blade_list:
for blade_item in basic_parameters_blade_list:
- blade = self.search([('code', '=', blade_item['code'])])
+ blade = self.search([('code', '=', blade_item['code']), ('active', 'in', [True, False])])
if not blade:
self.create({
'name': blade_item['name'],
@@ -2547,7 +2555,7 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_chuck'])
if basic_parameters_chuck_list:
for chuck_item in basic_parameters_chuck_list:
- chuck = self.search([('code', '=', chuck_item['code'])])
+ chuck = self.search([('code', '=', chuck_item['code']), ('active', 'in', [True, False])])
if not chuck:
self.create({
'name': chuck_item['name'],
@@ -2591,7 +2599,8 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_cutter_arbor'])
if basic_parameters_cutter_arbor_list:
for cutter_arbor_item in basic_parameters_cutter_arbor_list:
- cutter_arbor = self.search([('code', '=', cutter_arbor_item['code'])])
+ cutter_arbor = self.search(
+ [('code', '=', cutter_arbor_item['code']), ('active', 'in', [True, False])])
if not cutter_arbor:
self.create({
'name': cutter_arbor_item['name'],
@@ -2659,7 +2668,8 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_cutter_head'])
if basic_parameters_cutter_head_list:
for cutter_head_item in basic_parameters_cutter_head_list:
- cutter_head = self.search([('code', '=', cutter_head_item['code'])])
+ cutter_head = self.search(
+ [('code', '=', cutter_head_item['code']), ('active', 'in', [True, False])])
if not cutter_head:
self.create({
'name': cutter_head_item['name'],
@@ -2713,7 +2723,8 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_knife_handle'])
if basic_parameters_knife_handle_list:
for knife_handle_item in basic_parameters_knife_handle_list:
- knife_handle = self.search([('code', '=', knife_handle_item['code'])])
+ knife_handle = self.search(
+ [('code', '=', knife_handle_item['code']), ('active', 'in', [True, False])])
if not knife_handle:
self.create({
'name': knife_handle_item['name'],
@@ -2780,7 +2791,8 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_integral_tool'])
if basic_parameters_integral_tool_list:
for integral_tool_item in basic_parameters_integral_tool_list:
- integral_tool = self.search([('code', '=', integral_tool_item['code'])])
+ integral_tool = self.search(
+ [('code', '=', integral_tool_item['code']), ('active', 'in', [True, False])])
if not integral_tool:
self.create({
'name': integral_tool_item['name'],
@@ -2835,7 +2847,7 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_blade'])
if basic_parameters_blade_list:
for blade_item in basic_parameters_blade_list:
- blade = self.search([('code', '=', blade_item['code'])])
+ blade = self.search([('code', '=', blade_item['code']), ('active', 'in', [True, False])])
if not blade:
self.create({
'name': blade_item['name'],
@@ -2901,7 +2913,7 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_chuck'])
if basic_parameters_chuck_list:
for chuck_item in basic_parameters_chuck_list:
- chuck = self.search([('code', '=', chuck_item['code'])])
+ chuck = self.search([('code', '=', chuck_item['code']), ('active', 'in', [True, False])])
if not chuck:
self.create({
'name': chuck_item['name'],
@@ -2947,7 +2959,8 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_cutter_arbor'])
if basic_parameters_cutter_arbor_list:
for cutter_arbor_item in basic_parameters_cutter_arbor_list:
- cutter_arbor = self.search([('code', '=', cutter_arbor_item['code'])])
+ cutter_arbor = self.search(
+ [('code', '=', cutter_arbor_item['code']), ('active', 'in', [True, False])])
if not cutter_arbor:
self.create({
'name': cutter_arbor_item['name'],
@@ -3017,7 +3030,8 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_cutter_head'])
if basic_parameters_cutter_head_list:
for cutter_head_item in basic_parameters_cutter_head_list:
- cutter_head = self.search([('code', '=', cutter_head_item['code'])])
+ cutter_head = self.search(
+ [('code', '=', cutter_head_item['code']), ('active', 'in', [True, False])])
if not cutter_head:
self.create({
'name': cutter_head_item['name'],
@@ -3073,7 +3087,8 @@ class CuttingToolBasicParameters(models.Model):
result['cutting_tool_basic_parameters_all_list']['basic_parameters_knife_handle'])
if basic_parameters_knife_handle_list:
for knife_handle_item in basic_parameters_knife_handle_list:
- knife_handle = self.search([('code', '=', knife_handle_item['code'])])
+ knife_handle = self.search(
+ [('code', '=', knife_handle_item['code']), ('active', 'in', [True, False])])
if not knife_handle:
self.create({
'name': knife_handle_item['name'],
diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py
index f3a91ed5..cc82cbe1 100644
--- a/sf_plan/models/custom_plan.py
+++ b/sf_plan/models/custom_plan.py
@@ -67,6 +67,12 @@ class sf_production_plan(models.Model):
sequence = fields.Integer(string='序号', copy=False, readonly=True, index=True)
current_operation_name = fields.Char(string='当前工序名称', size=64, default='生产计划')
+ @api.onchange('production_line_id')
+ def _compute_production_line_id(self):
+ for item in self:
+ item.production_id.production_line_id = item.production_line_id.id
+ item.production_id.plan_start_processing_time = item.date_planned_start
+
@api.onchange('state')
def _onchange_state(self):
if self.state == 'finished':
@@ -194,7 +200,8 @@ class sf_production_plan(models.Model):
record.date_planned_start, record.date_planned_finished = \
item.date_planned_start, item.date_planned_finished
record.state = 'done'
- record.production_id.schedule_state = '已排'
+ # record.production_id.schedule_state = '已排'
+ record.sudo().production_id.schedule_state = '已排'
# self.env['sale.order'].browse(record.production_id.origin).schedule_status = 'to process'
sale_obj = self.env['sale.order'].search([('name', '=', record.origin)])
if 'S' in sale_obj.name:
@@ -202,7 +209,7 @@ class sf_production_plan(models.Model):
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'].browse(i).schedule_state = '已排'
+ 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
else:
@@ -323,33 +330,6 @@ class sf_production_plan(models.Model):
raise UserError(e)
-# # sf生产排程
-# class sf_produce_plan(models.Model):
-# _name = 'sf.produce.plan'
-# _description = 'sf生产排程'
-
-# # 重写create方法,使得创建坯料预制排程时,如果给出了计划结束时间,则计划开始时间为计划结束时间减去坯料预制时间
-# @api.model
-# def create(self, vals):
-# # 评估结束时间
-# vals['plan_end_time'] = self._get_plan_end_time(vals['plan_start_time'], vals['quantity'])
-# return super(sf_pl_plan, self).create(vals)
-
-# # 当不设置计划结束时间时,增加计算计划结束时间的方法
-# @api.onchange('plan_start_time', 'quantity')
-# def _onchange_plan_start_time(self):
-# if self.plan_start_time and self.quantity:
-# self.plan_end_time = self._get_plan_end_time(self.plan_start_time, self.quantity)
-#
-# # 计算计划结束时间
-# def _get_plan_end_time(self, plan_start_time, quantity):
-# # 坯料预制时间
-# pl_time = 0.5
-# # 计划结束时间 = 计划开始时间 + 坯料预制时间
-# plan_end_time = plan_start_time + pl_time
-# return plan_end_time
-#
-
# 机台作业计划
class machine_work_schedule(models.Model):
_name = 'sf.machine.schedule'
diff --git a/sf_plan/views/change_manufactuing.xml b/sf_plan/views/change_manufactuing.xml
index d1500bbd..d6d01ce9 100644
--- a/sf_plan/views/change_manufactuing.xml
+++ b/sf_plan/views/change_manufactuing.xml
@@ -10,10 +10,11 @@
-
-
-
-
+
+
+
+
@@ -27,32 +28,33 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
custom.mrp.bom.form
mrp.bom
@@ -62,10 +64,12 @@
@@ -81,10 +85,12 @@
@@ -100,10 +106,12 @@
@@ -119,10 +127,12 @@
@@ -138,10 +148,12 @@
@@ -157,10 +169,12 @@
diff --git a/sf_plan/views/view.xml b/sf_plan/views/view.xml
index 7f5a1969..dfaa1ca8 100644
--- a/sf_plan/views/view.xml
+++ b/sf_plan/views/view.xml
@@ -5,13 +5,16 @@
sf.production.plan.tree
sf.production.plan
-
+
-
+
@@ -20,8 +23,12 @@
-
-
+
+
@@ -32,14 +39,17 @@
-
+
sf.production.plan.search
sf.production.plan
@@ -151,7 +161,7 @@
default_scale="day"
scales="day,week,month,year"
precision="{'day': 'hour:quarter', 'week': 'day:half', 'month': 'day', 'year': 'month:quarter'}">
-
+
@@ -191,65 +201,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
sf.machine.schedule.tree
sf.machine.schedule
@@ -268,7 +219,7 @@
gantt,tree,form
-
+
制造订单生产计划
ir.actions.act_window
@@ -284,11 +235,11 @@
groups="sf_base.group_plan_dispatch"
/>
-
-
-
-
-
+
+
+
+
+
制造订单
@@ -305,17 +256,17 @@
-
+
机台作业计划
ir.actions.act_window
sf.machine.schedule
tree
- 暂无机台作业计划
+ 暂无机台作业计划
- 跟进请求的处理,并且和合作者沟通。
+ 跟进请求的处理,并且和合作者沟通。
@@ -327,13 +278,21 @@
action="mrp_custom_action"
parent="sf_production_plan_menu"
/>
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sf_quality/models/__init__.py b/sf_quality/models/__init__.py
index 79a87b7d..71468786 100644
--- a/sf_quality/models/__init__.py
+++ b/sf_quality/models/__init__.py
@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import custom_quality
+from . import quality
diff --git a/sf_quality/models/quality.py b/sf_quality/models/quality.py
new file mode 100644
index 00000000..ace40ff9
--- /dev/null
+++ b/sf_quality/models/quality.py
@@ -0,0 +1,34 @@
+import json
+import requests
+from odoo import fields, models, api
+from odoo.exceptions import ValidationError
+from odoo.addons.sf_base.commons.common import Common
+
+
+class QualityCheck(models.Model):
+ _inherit = "quality.check"
+ _description = '零件特采'
+
+ # ==========零件特采接口==========
+ def _register_tool_groups(self):
+ create_url = '/AutoDeviceApi/FeedBackOut'
+ sf_sync_config = self.env['res.config.settings'].get_values()
+ token = sf_sync_config['token']
+ sf_secret_key = sf_sync_config['sf_secret_key']
+ headers = Common.get_headers(self, token, sf_secret_key)
+ strurl = sf_sync_config['sf_url'] + create_url
+ val = {
+ 'RfidCode': None,
+ }
+ kw = json.dumps(val, ensure_ascii=False)
+ r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
+ ret = r.json()
+ if r == 200:
+ return "零件特采发送成功"
+ else:
+ raise ValidationError("零件特采发送失败")
+
+ # @api.onchange('quality_state')
+ # def _onchange_quality_state(self):
+ # if self.quality_state in ['pass', 'fail']:
+ # self._register_tool_groups()
diff --git a/sf_sale/models/auto_quatotion_common.py b/sf_sale/models/auto_quatotion_common.py
index 09ea3f0f..4feaa7dd 100644
--- a/sf_sale/models/auto_quatotion_common.py
+++ b/sf_sale/models/auto_quatotion_common.py
@@ -8,6 +8,7 @@ __author__ = 'jinling.yang'
_logger = logging.getLogger(__name__)
+
class AutoQuatotion(models.Model):
_name = 'sf.auto_quatotion.common'
_description = u'自动报价公用类'
diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py
index 8a7e68f6..c802aefa 100644
--- a/sf_sale/models/sale_order.py
+++ b/sf_sale/models/sale_order.py
@@ -7,6 +7,7 @@ from odoo.exceptions import UserError
class ReSaleOrder(models.Model):
_inherit = 'sale.order'
+ logistics_way = fields.Selection([('自提', '自提'), ('到付', '到付'), ('在线支付', '在线支付')], string='物流方式')
state = fields.Selection(
selection=[
('draft', "报价"),
@@ -19,7 +20,6 @@ class ReSaleOrder(models.Model):
readonly=True, copy=False, index=True,
tracking=3,
default='draft')
-
deadline_of_delivery = fields.Date('订单交期', tracking=True)
person_of_delivery = fields.Char('交货人')
telephone_of_delivery = fields.Char('交货人电话号码')
@@ -141,6 +141,8 @@ class RePurchaseOrder(models.Model):
if not self.user_id:
if self.partner_id:
self.user_id = self.partner_id.purchase_user_id.id
+ self.check_status = 'pending'
+ self.state = 'purchase'
else:
self.user_id = self.env.user.id
diff --git a/sf_sale/security/ir.model.access.csv b/sf_sale/security/ir.model.access.csv
index 25b2dce0..6dc34877 100644
--- a/sf_sale/security/ir.model.access.csv
+++ b/sf_sale/security/ir.model.access.csv
@@ -71,10 +71,11 @@ access_purchase_order_wizard_group_purchase,purchase_order_wizard_group_purchase
access_purchase_order_wizard_group_purchase_director,purchase_order_wizard_group_purchase_director,model_purchase_order_wizard,sf_base.group_purchase_director,1,1,1,0
access_crm_tag_group_sale_salemanager,crm_tag_group_sale_salemanager,sales_team.model_crm_tag,sf_base.group_sale_salemanager,1,0,0,0
access_crm_tag_group_sale_director,crm_tag_group_sale_director,sales_team.model_crm_tag,sf_base.group_sale_director,1,1,1,0
-
access_sale_order,sale.order,sale.model_sale_order,sf_base.group_plan_dispatch,1,1,0,0
access_res_partner_group_sale_salemanager,res_partner_group_sale_salemanager,base.model_res_partner,sf_base.group_sale_salemanager,1,0,1,0
access_res_partner_group_sale_director,res_partner_group_sale_director,base.model_res_partner,sf_base.group_sale_director,1,0,1,0
+access_sale_order_cancel_group_sale_salemanager,sale_order_cancel_group_sale_salemanager,sale.model_sale_order_cancel,sf_base.group_sale_salemanager,1,1,1,0
+access_sale_order_cancel_group_sale_director,sale_order_cancel_group_sale_director,sale.model_sale_order_cancel,sf_base.group_sale_director,1,1,1,0
access_res_partner_group_purchase,res_partner_group_purchase,base.model_res_partner,sf_base.group_purchase,1,0,1,0
access_res_partner_group_purchase_director,res_partner_group_purchase_director,base.model_res_partner,sf_base.group_purchase_director,1,0,1,0
access_sale_advance_payment_inv_group_sale_salemanager,sale_advance_payment_inv_group_sale_salemanager,sale.model_sale_advance_payment_inv,sf_base.group_sale_salemanager,1,1,1,0
diff --git a/sf_sale/views/purchase_order_view.xml b/sf_sale/views/purchase_order_view.xml
index 423742b8..844d9c92 100644
--- a/sf_sale/views/purchase_order_view.xml
+++ b/sf_sale/views/purchase_order_view.xml
@@ -8,24 +8,23 @@
+
-
-
-
- res.partner.property.form.inherit.sf
+
+ res.partner.account.form.inherit.sf
res.partner
@@ -65,6 +103,79 @@
widget="many2one_avatar_user"
attrs="{'required' : [('supplier_rank','>', 0)],'readonly': [('customer_rank','>', 0)]}"/>
+
+ {'readonly': [('id','!=', False)]}
+
+
+ {'readonly': [('id','!=', False)]}
+
+
+ {'readonly': [('id','!=', False)]}
+
+
+ {'readonly': [('id','!=', False)]}
+
+
+
+
+
+ res.partner.delivery.form.inherit.sf
+ res.partner
+
+
+
+ {'readonly': [('id','!=', False)]}
+
+
+
+
+
+ res.partner.stock.form.inherit.sf
+ res.partner
+
+
+
+ {'readonly': [('id','!=', False)]}
+
+
+ {'readonly': [('id','!=', False)]}
+
+
+
+
+
+ res.partner.mrp.subcontracting.form.inherit.sf
+ res.partner
+
+
+
+ {'readonly': [('id','!=', False)]}
+
+
+
+
+
+ res.partner.purchase.form.inherit.sf
+ res.partner
+
+
+
+ {'readonly': [('id','!=', False)]}
+
+
+ {'readonly': [('id','!=', False)]}
+
+
+
+
+
+ res.partner.team.form.inherit.sf
+ res.partner
+
+
+
+ {'readonly': [('id','!=', False)]}
+
diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml
index f6bef6a6..e6e7e8a2 100644
--- a/sf_sale/views/sale_order_view.xml
+++ b/sf_sale/views/sale_order_view.xml
@@ -87,8 +87,11 @@
attrs="{'invisible': ['|','&',('check_status', '!=', 'approved'),('state', 'in', ['draft','cancel']),'&','&',('check_status', '=', 'approved'),('state', 'in', ['sale','cancel']),('schedule_status', 'not in', False)]}"/>
- {'invisible': ['|',('state', 'in', ['cancel']),('check_status', 'in',
- [False,'approved'])]}
+ {'invisible': ['|','&',('state', 'in',
+ ['cancel','draft']),('check_status',
+ 'in',
+ [False,'approved']),'&','&',('check_status', '=', 'approved'),('state', 'in',
+ ['sale','cancel','draft']),('schedule_status', 'not in', False)]}
diff --git a/sf_tool_management/__init__.py b/sf_tool_management/__init__.py
index fb05df81..ea8e8e0b 100644
--- a/sf_tool_management/__init__.py
+++ b/sf_tool_management/__init__.py
@@ -1,6 +1,7 @@
# -*-coding:utf-8-*-
from . import models
from . import wizard
+from . import controllers
from odoo import api, SUPERUSER_ID
diff --git a/sf_tool_management/__manifest__.py b/sf_tool_management/__manifest__.py
index e334c32a..faf3927b 100644
--- a/sf_tool_management/__manifest__.py
+++ b/sf_tool_management/__manifest__.py
@@ -16,6 +16,7 @@
'security/ir.model.access.csv',
'wizard/wizard_view.xml',
'views/tool_base_views.xml',
+ 'views/sf_maintenance_equipment.xml',
'views/menu_view.xml',
'views/tool_material_search.xml',
],
diff --git a/sf_tool_management/controllers/__init__.py b/sf_tool_management/controllers/__init__.py
new file mode 100644
index 00000000..e046e49f
--- /dev/null
+++ b/sf_tool_management/controllers/__init__.py
@@ -0,0 +1 @@
+from . import controllers
diff --git a/sf_tool_management/controllers/controllers.py b/sf_tool_management/controllers/controllers.py
new file mode 100644
index 00000000..0e60a57f
--- /dev/null
+++ b/sf_tool_management/controllers/controllers.py
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+import logging
+import json
+import base64
+from odoo import http
+from odoo.http import request
+
+
+class Manufacturing_Connect(http.Controller):
+
+ @http.route('/AutoDeviceApi/FeedBackOut', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
+ cors="*")
+ def get_equipment_tool_Info(self, **kw):
+ """
+ 机床当前刀库实时信息
+ :param kw:
+ :return:
+ """
+ logging.info('get_equipment_tool_Info:%s' % kw)
+ try:
+ datas = request.httprequest.data
+ ret = json.loads(datas)
+ ret = json.loads(ret['result'])
+ logging.info('DeviceId:%s' % ret)
+ equipment = request.env['maintenance.equipment'].sudo().search([('name', '=', ret['DeviceId'])])
+
+ res = {'Succeed': True, 'Datas': []}
+ if equipment:
+ for item in equipment:
+ data = []
+ for equipment_tool_id in item.product_template_ids:
+ functional_tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search(
+ [('code', '=', equipment_tool_id.tool_code)])
+ alarm_time = None
+ if functional_tool_id.functional_tool_status == '报警':
+ alarm_time = self.env['sf.functional.tool.warning'].sudo().search(
+ [('code', '=', equipment_tool_id.tool_code)]).alarm_time
+ equipment_tool = {
+ 'RfidCode': None,
+ 'ToolId': equipment_tool_id.code,
+ 'ToolName': equipment_tool_id.functional_tool_name_id.name,
+ 'MaxLife': equipment_tool_id.life_value_max,
+ 'UseLife': equipment_tool_id.used_value,
+ 'AddDatetime': equipment_tool_id.tool_install_time,
+ 'State': functional_tool_id.functional_tool_status,
+ 'WarnDate': alarm_time if alarm_time else False
+ }
+ data.append(equipment_tool)
+ res['Datas'].append({
+ 'DeviceId': item.name,
+ 'Data': data
+ })
+ except Exception as e:
+ res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
+ logging.info('get_equipment_tool_Info error:%s' % e)
+ return json.JSONEncoder().encode(res)
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 149ccb5a..b55d7003 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -1,9 +1,12 @@
# -*- coding: utf-8 -*-
import re
+import json
+import requests
from datetime import timedelta
-from odoo import fields, models, api
from odoo import SUPERUSER_ID
+from odoo import fields, models, api
from odoo.exceptions import ValidationError
+from odoo.addons.sf_base.commons.common import Common
class FunctionalCuttingToolEntity(models.Model):
@@ -12,6 +15,7 @@ class FunctionalCuttingToolEntity(models.Model):
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
code = fields.Char('编码', related='functional_tool_name_id.code')
+ rfid = fields.Char('rfid', readonly=True)
name = fields.Char(related='functional_tool_name_id.name')
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称', readonly=True)
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
@@ -44,13 +48,13 @@ class FunctionalCuttingToolEntity(models.Model):
if record.barcode_id.quant_ids:
for quant_id in record.barcode_id.quant_ids:
if quant_id.inventory_quantity_auto_apply > 0:
- record.current_location_id = quant_id.location_id
- record.current_location = quant_id.location_id.name
+ record.sudo().current_location_id = quant_id.location_id
+ record.sudo().current_location = quant_id.location_id.name
if record.current_location_id:
- record.get_location_num()
+ record.sudo().get_location_num()
else:
- record.current_location_id = False
- record.current_location = False
+ record.sudo().current_location_id = False
+ record.sudo().current_location = False
def get_location_num(self):
"""
@@ -128,24 +132,24 @@ class FunctionalCuttingToolEntity(models.Model):
print('111')
if record.cutting_tool_integral_model_id:
print(record.cutting_tool_integral_model_id)
- record.suitable_machining_method_ids = record.cutting_tool_integral_model_id.suitable_machining_method_ids.ids
- record.blade_tip_characteristics_id = record.cutting_tool_integral_model_id.blade_tip_characteristics_id.id
- record.handle_type_id = record.cutting_tool_integral_model_id.handle_type_id.id
- record.cutting_direction_ids = record.cutting_tool_integral_model_id.cutting_direction_ids.ids
- record.suitable_coolant_ids = record.cutting_tool_integral_model_id.suitable_coolant_ids.ids
+ record.sudo().suitable_machining_method_ids = record.cutting_tool_integral_model_id.suitable_machining_method_ids.ids
+ record.sudo().blade_tip_characteristics_id = record.cutting_tool_integral_model_id.blade_tip_characteristics_id.id
+ record.sudo().handle_type_id = record.cutting_tool_integral_model_id.handle_type_id.id
+ record.sudo().cutting_direction_ids = record.cutting_tool_integral_model_id.cutting_direction_ids.ids
+ record.sudo().suitable_coolant_ids = record.cutting_tool_integral_model_id.suitable_coolant_ids.ids
print(record.cutting_tool_integral_model_id.blade_tip_characteristics_id.ids)
elif record.cutting_tool_blade_model_id:
- record.suitable_machining_method_ids = record.cutting_tool_blade_model_id.suitable_machining_method_ids.ids
- record.blade_tip_characteristics_id = record.cutting_tool_blade_model_id.blade_tip_characteristics_id.id
- record.handle_type_id = record.cutting_tool_blade_model_id.handle_type_id.id
- record.cutting_direction_ids = record.cutting_tool_blade_model_id.cutting_direction_ids.ids
- record.suitable_coolant_ids = record.cutting_tool_blade_model_id.suitable_coolant_ids.ids
+ record.sudo().suitable_machining_method_ids = record.cutting_tool_blade_model_id.suitable_machining_method_ids.ids
+ record.sudo().blade_tip_characteristics_id = record.cutting_tool_blade_model_id.blade_tip_characteristics_id.id
+ record.sudo().handle_type_id = record.cutting_tool_blade_model_id.handle_type_id.id
+ record.sudo().cutting_direction_ids = record.cutting_tool_blade_model_id.cutting_direction_ids.ids
+ record.sudo().suitable_coolant_ids = record.cutting_tool_blade_model_id.suitable_coolant_ids.ids
else:
- record.suitable_machining_method_ids = []
- record.blade_tip_characteristics_id = None
- record.handle_type_id = None
- record.cutting_direction_ids = []
- record.suitable_coolant_ids = []
+ record.sudo().suitable_machining_method_ids = []
+ record.sudo().blade_tip_characteristics_id = None
+ record.sudo().handle_type_id = None
+ record.sudo().cutting_direction_ids = []
+ record.sudo().suitable_coolant_ids = []
def _get_functional_tool_model_ids(self, functional_tool_model_code):
functional_tool_model_ids = []
@@ -174,12 +178,41 @@ class FunctionalCuttingToolEntity(models.Model):
('coarse_middle_thin', '=', self.coarse_middle_thin)]
return result
+ # ==========刀具组接口==========
+ def _register_functional_tool_groups(self, obj):
+ create_url = '/AutoDeviceApi/FeedBackOut'
+ sf_sync_config = self.env['res.config.settings'].get_values()
+ token = sf_sync_config['token']
+ sf_secret_key = sf_sync_config['sf_secret_key']
+ headers = Common.get_headers(obj, token, sf_secret_key)
+ strurl = sf_sync_config['sf_url'] + create_url
+ val = {
+ 'ToolName': obj.name,
+ 'GroupName': obj.tool_groups_id.name,
+ 'ToolId': obj.code
+ }
+ kw = json.dumps(val, ensure_ascii=False)
+ r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
+ ret = r.json()
+ if r == 200:
+ return "刀具组发送成功"
+ else:
+ raise ValidationError("刀具组发送失败")
+
+ # @api.model_create_multi
+ # def create(self, vals):
+ # obj = super(FunctionalCuttingToolEntity, self).create(vals)
+ # # 调用刀具组接口
+ # self._register_functional_tool_groups(obj)
+ # return obj
+
class FunctionalToolWarning(models.Model):
_name = 'sf.functional.tool.warning'
_description = '功能刀具预警'
code = fields.Char('编码', related='functional_tool_name_id.code')
+ rfid = fields.Char('rfid', related='functional_tool_name_id.rfid')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
name = fields.Char('名称', invisible=True, readonly=True, related='functional_tool_name_id.name')
# 机床信息
@@ -240,7 +273,7 @@ class FunctionalToolWarning(models.Model):
class StockMoveLine(models.Model):
_inherit = 'stock.move.line'
_description = '功能刀具出入库记录'
- # _order = 'install_tool_time desc'
+ _order = 'date desc'
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称')
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
@@ -250,6 +283,7 @@ class StockMoveLine(models.Model):
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', related='functional_tool_name_id.knife_tip_r_angle')
install_tool_time = fields.Datetime("刀具组装时间", related='functional_tool_name_id.tool_loading_time')
code = fields.Char('编码', related='functional_tool_name_id.code')
+ rfid = fields.Char('rfid', related='functional_tool_name_id.rfid')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
@api.model
@@ -310,9 +344,9 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
def _compute_name(self):
for obj in self:
if obj.tool_groups_id:
- obj.name = '%s-D%sR%s' % (obj.tool_groups_id.name, obj.diameter, obj.knife_tip_r_angle)
+ obj.sudo().name = '%s-D%sR%s' % (obj.tool_groups_id.name, obj.diameter, obj.knife_tip_r_angle)
else:
- obj.name = None
+ obj.sudo().name = None
@api.constrains('min_stock_num', 'max_stock_num')
def _check_stock_num(self):
@@ -330,26 +364,26 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
for tool in self:
if tool:
# 判断功能刀具组装单是否已经完成
- tool.estimate_functional_tool_assembly_ids(tool)
- tool.get_stock_num(tool)
+ tool.sudo().estimate_functional_tool_assembly_ids(tool)
+ tool.sudo().get_stock_num(tool)
# 计算当前库存量
- tool.tool_stock_total = tool.tool_stock_num + tool.side_shelf_num + tool.on_tool_stock_num
+ tool.sudo().tool_stock_total = tool.tool_stock_num + tool.side_shelf_num + tool.on_tool_stock_num
# 如果当前库存量小于最低库存量,计算批次补货量
- tool.open_batch_replenishment_num(tool)
+ tool.sudo().open_batch_replenishment_num(tool)
def open_batch_replenishment_num(self, tool):
"""
计算批次补货量
"""
if tool.tool_stock_total < tool.min_stock_num:
- tool.batch_replenishment_num = tool.max_stock_num - tool.tool_stock_total
+ tool.sudo().batch_replenishment_num = tool.max_stock_num - tool.tool_stock_total
# 根据判断创建功能刀具组装单
if not tool.sf_functional_tool_assembly_ids and re.match(r'^\d+$', str(tool.id)):
for i in range(tool.batch_replenishment_num):
- tool.create_functional_tool_assembly(tool)
+ tool.sudo().create_functional_tool_assembly(tool)
print(i, ": ", tool.sf_functional_tool_assembly_ids)
else:
- tool.batch_replenishment_num = 0
+ tool.sudo().batch_replenishment_num = 0
def create_functional_tool_assembly(self, tool):
"""
@@ -369,7 +403,7 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
'whether_standard_knife': tool.whether_standard_knife,
'reason_for_applying': '安全库存',
})
- tool.sf_functional_tool_assembly_ids = [(4, functional_tool_assembly.id)]
+ tool.sudo().sf_functional_tool_assembly_ids = [(4, functional_tool_assembly.id)]
def estimate_functional_tool_assembly_ids(self, tool):
"""
@@ -378,24 +412,24 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
for sf_functional_tool_assembly_id in tool.sf_functional_tool_assembly_ids:
if sf_functional_tool_assembly_id.assemble_status == '0':
return False
- tool.sf_functional_tool_assembly_ids = []
+ tool.sudo().sf_functional_tool_assembly_ids = []
def get_stock_num(self, tool):
"""
计算刀具房数量、线边刀库数量、机内刀库数量
"""
if tool:
- tool.tool_stock_num = 0
- tool.side_shelf_num = 0
- tool.on_tool_stock_num = 0
+ tool.sudo().tool_stock_num = 0
+ tool.sudo().side_shelf_num = 0
+ tool.sudo().on_tool_stock_num = 0
if tool.sf_functional_cutting_tool_entity_ids:
for cutting_tool in tool.sf_functional_cutting_tool_entity_ids:
if cutting_tool.tool_room_num > 0:
- tool.tool_stock_num += 1
+ tool.sudo().tool_stock_num += 1
elif cutting_tool.line_edge_knife_library_num > 0:
- tool.side_shelf_num += 1
+ tool.sudo().side_shelf_num += 1
elif cutting_tool.machine_knife_library_num > 0:
- tool.on_tool_stock_num += 1
+ tool.sudo().on_tool_stock_num += 1
def create_or_edit_safety_stock(self, vals, sf_functional_cutting_tool_entity_ids):
"""
@@ -445,6 +479,7 @@ class MachineTableToolChangingApply(models.Model):
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', store=True,
domain=[('product_id.name', '=', '功能刀具')],
related='functional_tool_name_id.barcode_id')
+ rfid = fields.Char('rfid', related='functional_tool_name_id.rfid')
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', domain=[('assemble_status', '=', '1')],
string='功能刀具名称')
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
@@ -471,7 +506,7 @@ class MachineTableToolChangingApply(models.Model):
reason_for_applying = fields.Char(string='申请原因', readonly=True)
remark = fields.Char(string='备注说明', readonly=False)
- status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移'), ('3', '已组装')],
+ status = fields.Selection([('0', '未操作'), ('1', '已申请换刀'), ('2', '已转移'), ('3', '已组装')],
string='操作状态', default='0')
sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装单', readonly=True)
@@ -480,21 +515,21 @@ class MachineTableToolChangingApply(models.Model):
def _compute_functional_tool_status(self):
for record in self:
if record.alarm_value < record.used_value:
- record.functional_tool_status = '报警'
+ record.sudo().functional_tool_status = '报警'
else:
- record.functional_tool_status = '正常'
+ record.sudo().functional_tool_status = '正常'
@api.depends('maintenance_equipment_id')
def _compute_machine_table_type_id(self):
for record in self:
if record:
- record.production_line_id = record.maintenance_equipment_id.production_line_id.id
- record.machine_table_type_id = record.maintenance_equipment_id.category_id.id
- record.machine_tool_code = record.maintenance_equipment_id.code
+ record.sudo().production_line_id = record.maintenance_equipment_id.production_line_id.id
+ record.sudo().machine_table_type_id = record.maintenance_equipment_id.category_id.id
+ record.sudo().machine_tool_code = record.maintenance_equipment_id.code
else:
- record.production_line_id = None
- record.machine_table_type_id = None
- record.machine_tool_code = None
+ record.sudo().production_line_id = None
+ record.sudo().machine_table_type_id = None
+ record.sudo().machine_tool_code = None
@api.constrains("cutter_spacing_code_id")
def _check_cutter_spacing_code_id(self):
@@ -594,16 +629,16 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
_name = 'sf.cam.work.order.program.knife.plan'
_description = 'CAM工单程序用刀计划'
- name = fields.Char(string='工单任务编号', readonly=False)
- cam_procedure_code = fields.Char(string='CAM程序编号', readonly=False)
- cam_cutter_spacing_code = fields.Char(string='CAM刀位号', readonly=False)
+ name = fields.Char('工单任务编号')
+ cam_procedure_code = fields.Char('程序名')
+ filename = fields.Char('文件')
+ cam_cutter_spacing_code = fields.Char('刀号')
tool_position_interface_type = fields.Selection(
[('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'),
('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'),
('直装固定式', '直装固定式')], string='刀位接口型号')
- production_line_id = fields.Many2one('sf.production.line', string='生产线', readonly=False,
- group_expand='_read_group_names')
- machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=False,
+ production_line_id = fields.Many2one('sf.production.line', string='生产线', group_expand='_read_group_names')
+ machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称',
domain="[('production_line_id', '=', production_line_id)]")
machine_table_name = fields.Char(string='机台号', readonly=True, related='machine_table_name_id.name')
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', required=True,
@@ -616,8 +651,9 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号',
domain=[('product_id.name', '=', '功能刀具')])
- functional_tool_name = fields.Char(string='功能刀具名称', required=True)
+ functional_tool_name = fields.Char(string='功能刀具名称', compute='_compute_functional_tool_name')
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False)
+ tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组')
diameter = fields.Integer(string='刀具直径(mm)', readonly=False)
tool_included_angle = fields.Float(string='刀尖R角(mm)', readonly=False)
tool_loading_length = fields.Float(string='总长度(mm)', readonly=False)
@@ -629,12 +665,28 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
L_D = fields.Float(string='L/D值', readonly=False)
clearance_length = fields.Float(string='避空长(mm)', readonly=False)
required_cutting_time = fields.Integer(string='需切削时长', readonly=False)
+ process_type = fields.Char('加工类型')
+ margin_x_y = fields.Float('余量_X/Y')
+ margin_z = fields.Float('余量_Z')
+ finish_depth = fields.Float('加工深度')
+ shank_model = fields.Char('刀柄型号')
+ estimated_processing_time = fields.Char('预计加工时间')
plan_execute_status = fields.Selection([('0', '待下发'), ('1', '执行中'), ('2', '已完成')],
string='计划执行状态', default='0', readonly=False)
sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True)
+ @api.depends('diameter', 'tool_included_angle', 'tool_groups_id')
+ def _compute_functional_tool_name(self):
+ for obj in self:
+ if obj.tool_groups_id:
+ obj.functional_tool_name = '%s-D%sR%s' % (
+ obj.tool_groups_id.name, obj.diameter,
+ obj.tool_included_angle)
+ else:
+ obj.functional_tool_name = None
+
@api.model
def _read_group_names(self, categories, domain, order):
names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
@@ -646,27 +698,34 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
:return:
"""
record = self.env['sf.functional.tool.assembly'].create({
- 'barcode_id': self.barcode_id.id,
- 'functional_tool_name_id': self.functional_tool_name_id.id,
+ 'functional_tool_name': self.functional_tool_name,
'functional_tool_type_id': self.functional_tool_type_id.id,
+ 'tool_groups_id': self.tool_groups_id.id,
'functional_tool_diameter': self.diameter,
- 'functional_tool_length': self.tool_loading_length,
- 'loading_task_source': '0',
- 'coarse_middle_thin': None,
- 'tool_loading_length': None,
- 'applicant': self.env.user.name,
- 'reason_for_applying': self.reason_for_applying,
- 'use_tool_time': self.need_knife_time,
+ 'knife_tip_r_angle': self.tool_included_angle,
+ 'tool_loading_length': self.tool_loading_length,
+ 'functional_tool_length': self.extension_length,
+ 'effective_length': self.effective_length,
+ 'whether_standard_knife': self.whether_standard_knife,
+ 'coarse_middle_thin': self.coarse_middle_thin,
+ 'new_former': self.new_former,
+ 'production_line_name_id': self.production_line_id.id,
'machine_tool_name_id': self.machine_table_name_id.id,
- 'machine_tool_code': self.cam_procedure_code,
- 'cutter_spacing_code': self.cam_cutter_spacing_code,
+ 'cutter_spacing_code_id': self.env['maintenance.equipment.tool'].sudo().search(
+ [('code', '=', self.cam_cutter_spacing_code), ('equipment_id', '=', self.machine_table_name_id.id)]).id,
+
+ 'loading_task_source': '0',
+ 'applicant': self.env.user.name,
+ 'use_tool_time': self.need_knife_time,
+ 'reason_for_applying': '工单用刀',
+
'sf_cam_work_order_program_knife_plan_id': self.id
})
self.sf_functional_tool_assembly_id = record.id
# 将计划执行状态改为执行中
self.env['sf.cam.work.order.program.knife.plan'].search(
- [('barcode_id', '=', self.barcode_id.id)]).write(
+ [('name', '=', self.name), ('functional_tool_name', '=', self.functional_tool_name)]).write(
{'plan_execute_status': '1',
'applicant': self.env.user.name})
@@ -676,16 +735,50 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
:return:
"""
self.env['sf.functional.tool.assembly'].search(
- [('barcode_id', '=', self.barcode_id.id),
+ [('assembly_order_code', '=', self.sf_functional_tool_assembly_id.assembly_order_code),
('loading_task_source', '=', '0')]).unlink()
# 将计划执行状态改为待执行,同时清除申请人、功能刀具组装字段数据
self.env['sf.cam.work.order.program.knife.plan'].search(
- [('barcode_id', '=', self.barcode_id.id)]).write(
+ [('name', '=', self.name), ('functional_tool_name', '=', self.functional_tool_name)]).write(
{'plan_execute_status': '0',
'applicant': None,
'sf_functional_tool_assembly_id': None})
+ def create_cam_work_plan(self, cnc_processing):
+ """
+ 根据传入的工单信息,查询是否有需要的功能刀具,如果没有则生成CAM工单程序用刀计划
+ """
+ status = False
+ if cnc_processing.functional_tool_type_id and cnc_processing.cutting_tool_name:
+ functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search(
+ [('sf_cutting_tool_type_id', '=', cnc_processing.functional_tool_type_id.id),
+ ('name', '=', cnc_processing.cutting_tool_name)])
+ if functional_tools:
+ for functional_tool in functional_tools:
+ if functional_tool.on_tool_stock_num == 0:
+ # self.env['sf.cnc.processing'].register_cnc_processing(cnc_processing)
+ if functional_tool.tool_stock_num == 0 and functional_tool.side_shelf_num == 0:
+ status = True
+ else:
+ status = True
+ if status:
+ self.env['sf.cam.work.order.program.knife.plan'].sudo().create({
+ 'name': cnc_processing.workorder_id.production_id.name,
+ 'cam_procedure_code': cnc_processing.program_name,
+ 'filename': cnc_processing.cnc_id.name,
+ 'functional_tool_type_id': cnc_processing.functional_tool_type_id.id,
+ 'functional_tool_name': cnc_processing.cutting_tool_name,
+ 'cam_cutter_spacing_code': cnc_processing.cutting_tool_no,
+ 'process_type': cnc_processing.processing_type,
+ 'margin_x_y': float(cnc_processing.margin_x_y),
+ 'margin_z': float(cnc_processing.margin_z),
+ 'finish_depth': float(cnc_processing.depth_of_processing_z),
+ 'extension_length': float(cnc_processing.cutting_tool_extension_length),
+ 'shank_model': cnc_processing.cutting_tool_handle_type,
+ 'estimated_processing_time': cnc_processing.estimated_processing_time,
+ })
+
class FunctionalToolAssembly(models.Model):
_name = 'sf.functional.tool.assembly'
@@ -698,6 +791,7 @@ class FunctionalToolAssembly(models.Model):
obj.name = obj.after_assembly_functional_tool_name
code = fields.Char('功能刀具编码', readonly=True)
+ rfid = fields.Char('rfid', readonly=True)
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=True)
name = fields.Char(string='名称', readonly=True, compute='_compute_name')
assembly_order_code = fields.Char(string='组装单编码', readonly=True)
diff --git a/sf_tool_management/models/maintenance_equipment.py b/sf_tool_management/models/maintenance_equipment.py
index f5371a3f..1f42430c 100644
--- a/sf_tool_management/models/maintenance_equipment.py
+++ b/sf_tool_management/models/maintenance_equipment.py
@@ -1,9 +1,22 @@
-from odoo import models, api
+from odoo import models, api, fields
class SfMaintenanceEquipmentTool(models.Model):
_inherit = 'maintenance.equipment.tool'
+ functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具名称')
+
+ image = fields.Binary('图片', related='functional_tool_name_id.image')
+ tool_code = fields.Char('功能刀具编码', related='functional_tool_name_id.code')
+ functional_tool_type = fields.Char('功能刀具类型', related='functional_tool_name_id.sf_cutting_tool_type_id.name')
+ tool_groups = fields.Char('刀具组', related='functional_tool_name_id.tool_groups_id.name')
+ diameter = fields.Integer('直径(mm)', related='functional_tool_name_id.functional_tool_diameter')
+ knife_tip_r_angle = fields.Float('刀尖R角(mm)', related='functional_tool_name_id.knife_tip_r_angle')
+ life_value_max = fields.Integer('最大寿命值(min)', related='functional_tool_name_id.max_lifetime_value')
+ alarm_value = fields.Integer('报警值(min)', related='functional_tool_name_id.alarm_value')
+ used_value = fields.Integer('已使用值(min)', related='functional_tool_name_id.used_value')
+ tool_install_time = fields.Datetime('机内装刀时间')
+
@api.model_create_multi
def create(self, vals_list):
tools = super().create(vals_list)
diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py
new file mode 100644
index 00000000..63dd1029
--- /dev/null
+++ b/sf_tool_management/models/mrp_workorder.py
@@ -0,0 +1,38 @@
+import json
+import requests
+from odoo import fields, models, api
+from odoo.exceptions import ValidationError
+from odoo.addons.sf_base.commons.common import Common
+
+
+class CNCprocessing(models.Model):
+ _inherit = 'sf.cnc.processing'
+ _description = 'CNC加工用刀检测'
+
+ # ==========MES装刀指令接口==========
+ def register_cnc_processing(self, cnc_processing):
+ create_url = '/AutoDeviceApi/FeedBackOut'
+ sf_sync_config = self.env['res.config.settings'].get_values()
+ token = sf_sync_config['token']
+ sf_secret_key = sf_sync_config['sf_secret_key']
+ headers = Common.get_headers(self, token, sf_secret_key)
+ strurl = sf_sync_config['sf_url'] + create_url
+ val = {
+ 'DeviceId': cnc_processing.workorder_id.machine_tool_name,
+ 'RfidCode': None,
+ 'ToolId': cnc_processing.cutting_tool_no
+ }
+ kw = json.dumps(val, ensure_ascii=False)
+ r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
+ ret = r.json()
+ if r == 200:
+ return "MES装刀指令发送成功"
+ else:
+ raise ValidationError("MES装刀指令发送失败")
+
+ @api.model_create_multi
+ def create(self, vals):
+ obj = super(CNCprocessing, self).create(vals)
+ # 调用CAM工单程序用刀计划创建方法
+ self.env['sf.cam.work.order.program.knife.plan'].create_cam_work_plan(obj)
+ return obj
diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv
index cc72f699..9dc6faeb 100644
--- a/sf_tool_management/security/ir.model.access.csv
+++ b/sf_tool_management/security/ir.model.access.csv
@@ -1,20 +1,34 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_sf_functional_cutting_tool_entity,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,base.group_user,1,1,1,1
-access_sf_functional_tool_warning,sf.functional.tool.warning,model_sf_functional_tool_warning,base.group_user,1,1,1,1
-access_sf_real_time_distribution_of_functional_tools,sf.real.time.distribution.of.functional.tools,model_sf_real_time_distribution_of_functional_tools,base.group_user,1,1,1,1
+access_sf_functional_cutting_tool_entity,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,sf_base.group_sf_tool_user,1,1,1,1
+access_sf_functional_tool_warning,sf.functional.tool.warning,model_sf_functional_tool_warning,sf_base.group_sf_tool_user,1,1,1,1
+access_sf_real_time_distribution_of_functional_tools,sf.real.time.distribution.of.functional.tools,model_sf_real_time_distribution_of_functional_tools,sf_base.group_sf_tool_user,1,1,1,1
-access_sf_cam_work_order_program_knife_plan,sf.cam.work.order.program.knife.plan,model_sf_cam_work_order_program_knife_plan,base.group_user,1,1,1,1
-access_sf_machine_table_tool_changing_apply,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,base.group_user,1,1,1,1
+access_sf_cam_work_order_program_knife_plan,sf.cam.work.order.program.knife.plan,model_sf_cam_work_order_program_knife_plan,sf_base.group_sf_tool_user,1,1,1,1
+access_sf_machine_table_tool_changing_apply,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,sf_base.group_sf_tool_user,1,1,1,1
-access_sf_tool_change_requirement_information,sf.tool.change.requirement.information,model_sf_tool_change_requirement_information,base.group_user,1,1,1,1
-access_sf_tool_transfer_request_information,sf.tool.transfer.request.information,model_sf_tool_transfer_request_information,base.group_user,1,1,1,1
-
-access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,base.group_user,1,1,1,1
-access_sf_functional_tool_assembly_order,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,base.group_user,1,1,1,1
-access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_search,base.group_user,1,1,1,1
-
+access_sf_tool_change_requirement_information,sf.tool.change.requirement.information,model_sf_tool_change_requirement_information,sf_base.group_sf_tool_user,1,1,1,1
+access_sf_tool_transfer_request_information,sf.tool.transfer.request.information,model_sf_tool_transfer_request_information,sf_base.group_sf_tool_user,1,1,1,1
+access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_sf_tool_user,1,1,1,1
+access_sf_functional_tool_assembly_order,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_sf_tool_user,1,1,1,1
+access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_sf_tool_user,1,1,1,1
+
+
+access_sf_functional_cutting_tool_entity_group_plan_dispatch,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,sf_base.group_plan_dispatch,1,0,0,0
+access_sf_functional_tool_warning_group_plan_dispatch,sf.functional.tool.warning,model_sf_functional_tool_warning,sf_base.group_plan_dispatch,1,0,0,0
+access_sf_real_time_distribution_of_functional_tools_group_plan_dispatch,sf.real.time.distribution.of.functional.tools,model_sf_real_time_distribution_of_functional_tools,sf_base.group_plan_dispatch,1,0,0,0
+
+access_sf_cam_work_order_program_knife_plan_group_plan_dispatch,sf.cam.work.order.program.knife.plan,model_sf_cam_work_order_program_knife_plan,sf_base.group_plan_dispatch,1,0,0,0
+access_sf_machine_table_tool_changing_apply_group_plan_dispatch,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,sf_base.group_plan_dispatch,1,0,0,0
+
+
+access_sf_tool_change_requirement_information_group_plan_dispatch,sf.tool.change.requirement.information,model_sf_tool_change_requirement_information,sf_base.group_plan_dispatch,1,0,0,0
+access_sf_tool_transfer_request_information_group_plan_dispatch,sf.tool.transfer.request.information,model_sf_tool_transfer_request_information,sf_base.group_plan_dispatch,1,0,0,0
+
+access_sf_functional_tool_assembly_group_plan_dispatch,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_plan_dispatch,1,0,0,0
+access_sf_functional_tool_assembly_order_group_plan_dispatch,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_plan_dispatch,1,0,0,0
+access_sf_tool_material_search_group_plan_dispatch,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_plan_dispatch,1,0,0,0
diff --git a/sf_tool_management/views/sf_maintenance_equipment.xml b/sf_tool_management/views/sf_maintenance_equipment.xml
new file mode 100644
index 00000000..fd863a84
--- /dev/null
+++ b/sf_tool_management/views/sf_maintenance_equipment.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ sf_manufacturing_equipment.form
+ maintenance.equipment
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index dd8e3bf0..59229492 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -7,7 +7,8 @@
sf.functional.cutting.tool.entity
-
+
+
@@ -43,7 +44,7 @@
-
-