diff --git a/sf_base/models/base.py b/sf_base/models/base.py index 0a1face8..f6a945aa 100644 --- a/sf_base/models/base.py +++ b/sf_base/models/base.py @@ -31,13 +31,13 @@ class MachineBrand(models.Model): _name = 'sf.machine.brand' _description = '品牌' + code = fields.Char('编码') name = fields.Char('名称') tag_ids = fields.Many2many('sf.machine.brand.tags', 'rel_machine_brand_tags', string='类别') image_brand = fields.Image("品牌图片") manufacturer_model_number = fields.Char('厂家型号', size=10) + remark = fields.Text('备注') active = fields.Boolean('有效', default=True) - code = fields.Char('编码') - # 机床 class MachineTool(models.Model): diff --git a/sf_base/models/fixture.py b/sf_base/models/fixture.py index d5ad7fe6..d929cad9 100644 --- a/sf_base/models/fixture.py +++ b/sf_base/models/fixture.py @@ -1,4 +1,8 @@ from odoo import models, fields, api +from odoo.addons.sf_base.commons.common import Common +from odoo.exceptions import ValidationError +import requests +import json class FixtureMaterial(models.Model): @@ -40,14 +44,17 @@ class FixtureModel(models.Model): width = fields.Char(string="宽度[mm]", size=6) height = fields.Char(string="高度[mm]", size=6) weight = fields.Char(string="重量[kg]", size=4) - clamp_workpiece_length_max = fields.Char(string="夹持工件长度MAX[mm]", size=6) - clamp_workpiece_width_max = fields.Char(string="夹持工件宽度MAX[mm]", size=6) - clamp_workpiece_height_max = fields.Char(string="夹持工件高度MAX[mm]", size=6) - clamp_workpiece_diameter_max = fields.Char(string="夹持工件直径MAX[mm]", size=6) - maximum_carrying_weight = fields.Char(string="最大承载重量[kg]", size=4) - maximum_clamping_force = fields.Char(string="最大夹持力[n]", size=8) + clamp_workpiece_length_max = fields.Integer(string="夹持工件长度MAX[mm]", size=6) + clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度MAX[mm]", size=6) + clamp_workpiece_height_max = fields.Integer(string="夹持工件高度MAX[mm]", size=6) + clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径MAX[mm]", size=6) + maximum_carrying_weight = fields.Float(string="最大承载重量[kg]", size=4) + maximum_clamping_force = fields.Integer(string="最大夹持力[n]", size=8) materials_model_id = fields.Many2one('sf.materials.model', string="材料型号") - driving_way = fields.Char(string="驱动方式") - apply_machine_tool_type_id = fields.Many2one('sf.machine_tool.type', string="适用机床型号") + driving_way = fields.Selection([('气动', '气动'), ('液压', '液压'), ('机械', '机械')], string="驱动方式") + apply_machine_tool_type_ids = fields.Many2many('sf.machine_tool.type', 'rel_fixture_model_machine_tool_type', + string="适用机床型号") through_hole_size = fields.Integer(string="过孔大小[mm]", size=6) screw_size = fields.Integer(string="螺牙大小[mm]", size=6) + + diff --git a/sf_base/models/functional_fixture.py b/sf_base/models/functional_fixture.py index 4ef466f7..86cc015f 100644 --- a/sf_base/models/functional_fixture.py +++ b/sf_base/models/functional_fixture.py @@ -1,4 +1,8 @@ from odoo import models, fields, api +from odoo.addons.sf_base.commons.common import Common +from odoo.exceptions import ValidationError +import requests +import json class FunctionalFixtureType(models.Model): @@ -16,7 +20,6 @@ class FunctionalFixture(models.Model): _description = "功能夹具" code = fields.Char(string='编码', readonly=True) - name = fields.Char(string="名称", size=15, required=True) type_id = fields.Many2one('sf.functional.fixture.type', string="功能夹具类型", required=True) type = fields.Char(related='type_id.name', string="功能夹具类别", store=True) zero_chuck_model_ids = fields.Many2many('sf.fixture.model', 'rel_fixture_model_zero_chuck', string="零点卡盘型号", @@ -33,11 +36,124 @@ class FunctionalFixture(models.Model): domain=[('fixture_material_type', '=', '磁吸托盘')]) vice_tray_model_ids = fields.Many2many('sf.fixture.model', 'rel_fixture_model_vice_tray', string="虎钳托盘型号", domain=[('fixture_material_type', '=', '虎钳托盘')]) + registration_status = fields.Selection([("已注册", "已注册"), ("未注册", "未注册")], string="注册状态", default='未注册', tracking=True) - def _get_fixture_model_ids(self, fixture_model_code): - fixture_model_ids = [] - for item in fixture_model_code: - fixture_model = self.env['sf.fixture.model'].search([('code', '=', item)]) - if fixture_model: - fixture_model_ids.append(fixture_model.id) - return [(6, 0, fixture_model_ids)] + + @api.onchange('type_id') + def _onchange_type_id(self): + if self.type_id: + functional_fixture_type = self.search( + [('type', '=', self.type)], limit=1, order='id desc') + if not functional_fixture_type: + num = "%04d" % 1 + else: + m = int(functional_fixture_type.code[-3:]) + 1 + num = "%04d" % m + self.code = "%s%s-%s" % ('JKM-C-GNJJ-', self.type_id.code, num) + + _sql_constraints = [ + ('code_uniq', 'unique (code)', + '编码不能重复') + + ] + + @api.depends('transfer_tray_model_ids', 'pneumatic_tray_model_ids', 'magnetic_tray_model_ids', + 'vice_tray_model_ids', 'type') + def _get_name(self): + for record in self: + if record.type: + if not record.transfer_tray_model_ids and not record.pneumatic_tray_model_ids and not record.magnetic_tray_model_ids and not record.vice_tray_model_ids: + record.name = '' + if record.transfer_tray_model_ids: + for i in record.transfer_tray_model_ids: + record.name = '%s%s%s' % ( + i.display_name.split('-')[0], record.type, '功能夹具') + if record.pneumatic_tray_model_ids: + for i in record.pneumatic_tray_model_ids: + record.name = '%s%s%s' % ( + i.display_name.split('-')[0], record.type, '功能夹具') + if record.magnetic_tray_model_ids: + for i in record.magnetic_tray_model_ids: + record.name = '%s%s%s' % ( + i.display_name.split('-')[0], record.type, '功能夹具') + if record.vice_tray_model_ids: + for i in record.vice_tray_model_ids: + record.name = '%s%s%s' % ( + i.display_name.split('-')[0], record.type, '功能夹具') + else: + record.name = '' + + name = fields.Char(string="名称", compute=_get_name, readonly=True) + + def _json_zero_chuck_model_item_code(self, item): + code_arr = [] + for i in item.zero_chuck_model_ids: + code_arr.append(i.code) + return code_arr + + def _json_transfer_tray_model_item_code(self, item): + code_arr = [] + for i in item.transfer_tray_model_ids: + code_arr.append(i.code) + return code_arr + + def _json_vice_tray_item_code(self, item): + code_arr = [] + for i in item.vice_tray_model_ids: + code_arr.append(i.code) + return code_arr + + def _json_magnetic_tray_model_item_code(self, item): + code_arr = [] + for i in item.magnetic_tray_model_ids: + code_arr.append(i.code) + return code_arr + + def _json_pneumatic_tray_model_item_code(self, item): + code_arr = [] + for i in item.pneumatic_tray_model_ids: + code_arr.append(i.code) + return code_arr + + # 注册到cloud的功能夹具中 + def register_functional_fixture(self): + registration_url = 'api/functional_fixture/create' + 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'] + self.registration_url + objs_self = self.search([('code', '=', self.code)]) + functional_fixture_list = [] + if objs_self: + for item in objs_self: + val = { + 'factory_token': token, + 'name': item.name, + 'code': item.code, + 'type_code': self.env['sf.functional.fixture.type'].search( + [('id', '=', item.type_id.id)]).code, + 'zero_chuck_model_codes': self.env['sf.functional.fixture']._json_zero_chuck_model_item_code( + item), + 'transfer_tray_model_codes': self.env['sf.functional.fixture']._json_transfer_tray_model_item_code( + item), + 'pneumatic_tray_model_codes': self.env[ + 'sf.functional.fixture']._json_pneumatic_tray_model_item_code( + item), + 'magnetic_tray_model_codes': self.env['sf.functional.fixture']._json_magnetic_tray_model_item_code( + item), + 'vice_tray_model_codes': self.env['sf.functional.fixture']._json_vice_tray_item_code( + item), + } + functional_fixture_list.append(val) + # kw = machine_tool_list + kw = json.dumps(functional_fixture_list, ensure_ascii=False) + r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers) + ret = r.json() + self.code = ret['message'] + + if r == 200: + self.registration_status = "已注册" + return "功能夹具注册成功" + else: + raise ValidationError("没有功能夹具注册信息") diff --git a/sf_base/views/base_view.xml b/sf_base/views/base_view.xml index 274d9d64..eadd81f2 100644 --- a/sf_base/views/base_view.xml +++ b/sf_base/views/base_view.xml @@ -25,43 +25,49 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - + + form.sf.machine.brand + sf.machine.brand + +
+ + + + + + + + + + + + + + + + + + + +
+
+
品牌 ir.actions.act_window sf.machine.brand - tree + tree,form #------------------机床型号------------------ @@ -81,7 +87,7 @@ tree.sf.machine_tool.type sf.machine_tool.type - + @@ -96,81 +102,110 @@ sf.machine_tool.type
- + - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -207,7 +242,7 @@ tree.sf.machine_tool.category sf.machine_tool.category - + @@ -216,42 +251,35 @@ - - form.sf.machine_tool.category - sf.machine_tool.category - -
- - - - - - - - - + + + + + + + + + + + + + + - - - + + + -
-
-
+ + + 机床类型 ir.actions.act_window sf.machine_tool.category - tree,form - -

- [机床类型] 还没有哦!点左上角的[创建]按钮,沙发归你了! -

-

-

-
+ tree
#------------------机床注册------------------ @@ -378,13 +406,13 @@
- #------------------控制系统------------------ + #------------------数控系统------------------ search.sf.machine.control_system sf.machine.control_system - + @@ -395,7 +423,7 @@ tree.sf.machine.control_system sf.machine.control_system - + @@ -424,7 +452,7 @@ - 控制系统 + 数控系统 ir.actions.act_window sf.machine.control_system tree diff --git a/sf_base/views/common_view.xml b/sf_base/views/common_view.xml index f73e4dcf..e15d644c 100644 --- a/sf_base/views/common_view.xml +++ b/sf_base/views/common_view.xml @@ -2,24 +2,24 @@ - - sf.processing.technology - -
- - - - - - - - - - - -
-
-
+ + + + + + + + + + + + + + + + + + sf.processing.technology @@ -75,7 +75,7 @@ sf.production.process.category - + @@ -131,7 +131,7 @@ - + @@ -186,44 +186,50 @@ sf.materials.model -
- + + - - - + + + + + + + + + + + + + + + + + + + + + + + - - - + - - - - - - - - - - - - - - - +
sf.materials.model - - - - - + + + + + + @@ -247,28 +253,33 @@ sf.production.materials
- + - + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - +
@@ -372,14 +383,16 @@
- - - + + + + + + + + - - - - +
diff --git a/sf_base/views/fixture_view.xml b/sf_base/views/fixture_view.xml index cef36ff2..65cf2ce1 100644 --- a/sf_base/views/fixture_view.xml +++ b/sf_base/views/fixture_view.xml @@ -177,15 +177,15 @@
- + - + - + - + @@ -193,60 +193,68 @@ attrs="{'invisible': [('model_file', '=', False)]}"/> - - - - - - - - - - - - - + + + + + + + + + +
diff --git a/sf_base/views/functional_fixture_view.xml b/sf_base/views/functional_fixture_view.xml index 0a763393..4239ceba 100644 --- a/sf_base/views/functional_fixture_view.xml +++ b/sf_base/views/functional_fixture_view.xml @@ -81,7 +81,7 @@ 功能夹具 sf.functional.fixture - + @@ -93,7 +93,12 @@ 功能夹具 sf.functional.fixture -
+ + + + + + @@ -101,15 +106,19 @@ - + + options="{'no_create': True}" + attrs='{"invisible": [("type","!=","转接板(锁板)式")],"required": [("type", "=", "转接板(锁板)式")]}'/> + options="{'no_create': True}" + attrs='{"invisible": [("type","!=","气动式")],"required": [("type", "=", "气动式")]}'/> + options="{'no_create': True}" + attrs='{"invisible": [("type","!=","磁吸式")],"required": [("type", "=", "磁吸式")]}'/> + options="{'no_create': True}" + attrs='{"invisible": [("type","!=","虎钳式")],"required": [("type", "=", "虎钳式")]}'/> diff --git a/sf_base/views/menu_view.xml b/sf_base/views/menu_view.xml index 1806e42a..9525bbd3 100644 --- a/sf_base/views/menu_view.xml +++ b/sf_base/views/menu_view.xml @@ -139,7 +139,7 @@ diff --git a/sf_base/views/tool_menu.xml b/sf_base/views/tool_menu.xml index a1c976d5..91d95b37 100644 --- a/sf_base/views/tool_menu.xml +++ b/sf_base/views/tool_menu.xml @@ -7,14 +7,14 @@ 刀具物料 ir.actions.act_window sf.cutting.tool.material - tree,form + tree 刀具类型 ir.actions.act_window sf.cutting.tool.type - tree,form + tree @@ -35,7 +35,7 @@ 功能刀具类型 ir.actions.act_window sf.functional.cutting.tool.model - tree,form + tree diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index 4b02fefb..ccb98a7d 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -1,99 +1,114 @@ - - - sf.cutting.tool.material.tree - sf.cutting.tool.material - - - - - - - - + + + sf.cutting.tool.material.tree + sf.cutting.tool.material + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sf.cutting.tool.material.search + sf.cutting.tool.material + + + + + + + + + + + + sf.functional.cutting.tool.tree + sf.functional.cutting.tool + + + + + + + + + + + + + + + + + + sf.functional.cutting.tool.form + sf.functional.cutting.tool + + + + + + + + + + + + + + + + + + + + - - sf.cutting.tool.material.form - sf.cutting.tool.material - - - - - - - - - - - - - - - - - - - - - sf.cutting.tool.material.search - sf.cutting.tool.material - - - - - - - - - - - - sf.functional.cutting.tool.tree - sf.functional.cutting.tool - - - - - - - - - - - - - - - - - - sf.functional.cutting.tool.form - sf.functional.cutting.tool - -
- - - - - - - - - - - - - - - - - - - - @@ -114,284 +129,365 @@ - - -
-
-
+
+
+ +
+
- - sf.functional.cutting.tool.search - sf.functional.cutting.tool - - - - - - - + + sf.functional.cutting.tool.search + sf.functional.cutting.tool + + + + + + + - - - sf.cutter.function.tree - sf.functional.cutting.tool.model - - - - - - - - - - sf.cutter.function.form - sf.functional.cutting.tool.model - -
- - - - - - - - - - - -
-
-
+ + + sf.cutter.function.tree + sf.functional.cutting.tool.model + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - sf.cutter.function.search - sf.functional.cutting.tool.model - - - - - - - + + + sf.cutter.function.search + sf.functional.cutting.tool.model + + + + + + + - - - sf.cutting.tool.model.tree - sf.cutting.tool.model - - - - - - - - - + + + sf.cutting.tool.model.tree + sf.cutting.tool.model + + + + + + + + + - - sf.cutting.tool.model.form - sf.cutting.tool.model - -
- - - - - - - - - - + + sf.cutting.tool.model.form + sf.cutting.tool.model + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - + + + sf.cutting.tool.model.search + sf.cutting.tool.model + + + + + + + + - - - - - + + + sf.cutting.tool.type.tree + sf.cutting.tool.type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- - - - sf.cutting.tool.model.search - sf.cutting.tool.model - - - - - - - - - - - - - sf.cutting.tool.type.tree - sf.cutting.tool.type - - - - - - - - - - - - sf.cutting.tool.type.form - sf.cutting.tool.type - -
- - - - - - - - - - - - -
-
-
- - - - sf.cutting.tool.type.search - sf.cutting.tool.type - - - - - - - - + + + sf.cutting.tool.type.search + sf.cutting.tool.type + + + + + + + +
diff --git a/sf_dlm/views/product_template_view.xml b/sf_dlm/views/product_template_view.xml index e7bd62a9..3fcdcf1b 100644 --- a/sf_dlm/views/product_template_view.xml +++ b/sf_dlm/views/product_template_view.xml @@ -278,7 +278,7 @@ attrs='{"invisible": [("fixture_material_type","!=",("转接板(锁板)托盘"))]}'/> - diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 710fdb63..85f8313f 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -147,7 +147,8 @@ class ResProductMo(models.Model): fixture_maximum_carrying_weight = fields.Float(string="最大承载重量[kg]", digits=(16, 4)) fixture_maximum_clamping_force = fields.Integer(string="最大夹持力[n]", size=8) fixture_driving_way = fields.Char(string="驱动方式") - fixture_apply_machine_tool_type_id = fields.Many2one('sf.machine_tool.type', string="适用机床型号") + fixture_apply_machine_tool_type_ids = fields.Many2many('sf.machine_tool.type', 'rel_product_machine_tool_type', + string="适用机床型号") fixture_through_hole_size = fields.Integer(string="过孔大小[mm]", size=6) fixture_screw_size = fields.Integer(string="螺牙大小[mm]", size=6) @@ -205,7 +206,7 @@ class ResProductMo(models.Model): item.fixture_clamp_workpiece_width_max = item.fixture_model_id.clamp_workpiece_width_max item.fixture_clamp_workpiece_height_max = item.fixture_model_id.clamp_workpiece_height_max item.fixture_clamp_workpiece_diameter_max = item.fixture_model_id.clamp_workpiece_diameter_max - item.fixture_apply_machine_tool_type_id = item.fixture_model_id.apply_machine_tool_type_id.id + item.fixture_apply_machine_tool_type_id = self._get_ids(item.fixture_model_id.apply_machine_tool_type_ids) @api.onchange('cutting_tool_model_id') def _onchange_cutting_tool_model_id(self):