Compare commits
8 Commits
feature/72
...
feature/72
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14f1e4f04a | ||
|
|
e0c1e27344 | ||
|
|
8434172fec | ||
|
|
a920d4b4b8 | ||
|
|
4609ddfa7a | ||
|
|
e73c0b15ea | ||
|
|
f4829f57a1 | ||
|
|
cdf6a36c30 |
@@ -67,6 +67,77 @@ class BasicParametersFixture(models.Model):
|
|||||||
mounting_hole_depth = fields.Float('安装孔深度(mm)', digits=(16, 2))
|
mounting_hole_depth = fields.Float('安装孔深度(mm)', digits=(16, 2))
|
||||||
centering_diameter = fields.Float('定心直径(mm)', digits=(16, 2))
|
centering_diameter = fields.Float('定心直径(mm)', digits=(16, 2))
|
||||||
|
|
||||||
|
# ‘磁吸托盘’ 字段
|
||||||
|
magnet_tray_length = fields.Float('磁吸托盘长度(mm)', digits=(16, 2))
|
||||||
|
magnet_tray_width = fields.Float('磁吸托盘宽度(mm)', digits=(16, 2))
|
||||||
|
magnet_tray_height = fields.Float('磁吸托盘厚度(mm)', digits=(16, 2))
|
||||||
|
magnet_tray_diameter = fields.Float('磁吸托盘直径(mm)', digits=(16, 2))
|
||||||
|
magnet_tray_weight = fields.Float('磁吸托盘重量(kg)', digits=(16, 2))
|
||||||
|
|
||||||
|
magnet_max_adsorp_length = fields.Float('磁吸托盘最大吸附长度(mm)', digits=(16, 2))
|
||||||
|
magnet_max_adsorp_width = fields.Float('磁吸托盘最大吸附宽度(mm)', digits=(16, 2))
|
||||||
|
magnet_max_adsorp_height = fields.Float('磁吸托盘最大吸附厚度(mm)', digits=(16, 2))
|
||||||
|
magnet_max_adsorp_diameter = fields.Float('磁吸托盘最大吸附直径(mm)', digits=(16, 2))
|
||||||
|
magnet_max_adsorp_force = fields.Float('磁吸托盘最大吸附力(N)', digits=(16, 2))
|
||||||
|
|
||||||
|
magnet_unlocking_method = fields.Selection(
|
||||||
|
[('手动', '手动'), ('气动', '气动'), ('液压', '液压'), ('电动', '电动'), ('其他', '其他')],
|
||||||
|
string='磁吸托盘锁紧方式'
|
||||||
|
)
|
||||||
|
magnet_flatness = fields.Char('磁吸托盘平面精度(mm)', size=20)
|
||||||
|
magnet_max_load = fields.Float('磁吸托盘最大负载(kg)', digits=(16, 2))
|
||||||
|
|
||||||
|
# --- 定位隔板字段 ---
|
||||||
|
partition_length_outer = fields.Float('外框长度(mm)', digits=(16, 2))
|
||||||
|
partition_width_outer = fields.Float('外框宽度(mm)', digits=(16, 2))
|
||||||
|
partition_length_inner = fields.Float('内框长度(mm)', digits=(16, 2))
|
||||||
|
partition_width_inner = fields.Float('内框宽度(mm)', digits=(16, 2))
|
||||||
|
partition_left_margin = fields.Float('左边距(mm)', digits=(16, 2))
|
||||||
|
partition_bottom_margin = fields.Float('下边距(mm)', digits=(16, 2))
|
||||||
|
partition_unit_length = fields.Float('定位单元长度(mm)', digits=(16, 2))
|
||||||
|
partition_unit_width = fields.Float('定位单元宽度(mm)', digits=(16, 2))
|
||||||
|
partition_unit_row_spacing = fields.Float('单元行间距(mm)', digits=(16, 2))
|
||||||
|
partition_unit_col_spacing = fields.Float('单元列间距(mm)', digits=(16, 2))
|
||||||
|
partition_unit_rows = fields.Integer('单元行数')
|
||||||
|
partition_unit_cols = fields.Integer('单元列数')
|
||||||
|
partition_base_unit_row_spacing = fields.Float('基准单元行间距(mm)', digits=(16, 2))
|
||||||
|
partition_base_unit_col_spacing = fields.Float('基准单元列间距(mm)', digits=(16, 2))
|
||||||
|
partition_offset_x = fields.Float('X方向偏移(mm)', digits=(16, 2))
|
||||||
|
partition_offset_y = fields.Float('Y方向偏移(mm)', digits=(16, 2))
|
||||||
|
partition_materials_model_id = fields.Many2one('sf.materials.model', '定位隔板材质')
|
||||||
|
partition_joint_type = fields.Selection([
|
||||||
|
('bolt', '螺栓连接'),
|
||||||
|
('magnet', '磁吸连接'),
|
||||||
|
('snap', '卡扣连接'),
|
||||||
|
], string='连接方式')
|
||||||
|
partition_partner_id = fields.Many2one('res.partner', string='供应商/客户')
|
||||||
|
|
||||||
|
# ‘气吸托盘’ 字段
|
||||||
|
air_tray_length = fields.Float('气吸托盘长度(mm)', digits=(16, 2))
|
||||||
|
air_tray_width = fields.Float('气吸托盘宽度(mm)', digits=(16, 2))
|
||||||
|
air_tray_height = fields.Float('气吸托盘高度(mm)', digits=(16, 2))
|
||||||
|
air_tray_diameter = fields.Float('气吸托盘直径(mm)', digits=(16, 2))
|
||||||
|
air_tray_weight = fields.Float('气吸托盘重量(kg)', digits=(16, 2))
|
||||||
|
|
||||||
|
air_max_adsorp_length = fields.Float('气吸托盘最大吸附长度(mm)', digits=(16, 2))
|
||||||
|
air_max_adsorp_width = fields.Float('气吸托盘最大吸附宽度(mm)', digits=(16, 2))
|
||||||
|
air_max_adsorp_height = fields.Float('气吸托盘最大吸附厚度(mm)', digits=(16, 2))
|
||||||
|
air_max_adsorp_diameter = fields.Float('气吸托盘最大吸附直径(mm)', digits=(16, 2))
|
||||||
|
air_max_adsorp_force = fields.Float('气吸托盘最大吸附力(N)', digits=(16, 2))
|
||||||
|
|
||||||
|
air_unlocking_method = fields.Selection(
|
||||||
|
[('手动', '手动'), ('气动', '气动'), ('液压', '液压'), ('电动', '电动'), ('其他', '其他')],
|
||||||
|
string='气吸托盘锁紧方式'
|
||||||
|
)
|
||||||
|
air_flatness = fields.Char('气吸托盘平面精度(mm)', size=20)
|
||||||
|
air_max_load = fields.Float('气吸托盘最大负载(kg)', digits=(16, 2))
|
||||||
|
air_boolean_chip_blowing_function = fields.Boolean('气吸托盘是否有吹屑功能')
|
||||||
|
air_way_to_install = fields.Selection(
|
||||||
|
[('接口式', '接口式'), ('螺栓固定', '螺栓固定'), ('磁吸式', '磁吸式'), ('其他', '其他')],
|
||||||
|
string='气吸托盘安装方式'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
code = fields.Char('编码')
|
code = fields.Char('编码')
|
||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
@@ -85,6 +156,12 @@ class BasicParametersFixture(models.Model):
|
|||||||
return self._json_adapter_board_fixture_param(fixture_materials_data)
|
return self._json_adapter_board_fixture_param(fixture_materials_data)
|
||||||
elif fixture_materials_name == '三爪卡盘':
|
elif fixture_materials_name == '三爪卡盘':
|
||||||
return self._json_scroll_chuck_param(fixture_materials_data)
|
return self._json_scroll_chuck_param(fixture_materials_data)
|
||||||
|
elif fixture_materials_name == '磁吸托盘':
|
||||||
|
return self._json_magnet_tray_param(fixture_materials_data)
|
||||||
|
elif fixture_materials_name == '定位隔板':
|
||||||
|
return self._json_positioning_partition_param(fixture_materials_data)
|
||||||
|
elif fixture_materials_name == '气吸托盘':
|
||||||
|
return self._json_air_tray_param(fixture_materials_data)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _json_zero_chuck_param(self, obj):
|
def _json_zero_chuck_param(self, obj):
|
||||||
@@ -284,3 +361,90 @@ class BasicParametersFixture(models.Model):
|
|||||||
'centering_diameter': obj['centering_diameter'],
|
'centering_diameter': obj['centering_diameter'],
|
||||||
'type_of_drive': obj['type_of_drive'],
|
'type_of_drive': obj['type_of_drive'],
|
||||||
'active': obj['active']}
|
'active': obj['active']}
|
||||||
|
|
||||||
|
def _json_magnet_tray_param(self, obj):
|
||||||
|
"""磁吸托盘:将data数据转换成list数据"""
|
||||||
|
return {
|
||||||
|
'code': obj['code'],
|
||||||
|
'fixture_model_id': self.env['sf.fixture.model'].sudo().search(
|
||||||
|
[('code', '=', obj.get('fixture_model_code'))]).id,
|
||||||
|
'name': obj['name'],
|
||||||
|
'length': obj['length'],
|
||||||
|
'width': obj['width'],
|
||||||
|
'height': obj['height'],
|
||||||
|
'diameter': obj['diameter'],
|
||||||
|
'weight': obj['weight'],
|
||||||
|
'max_adsorp_length': obj['max_adsorp_length'],
|
||||||
|
'max_adsorp_width': obj['max_adsorp_width'],
|
||||||
|
'max_adsorp_height': obj['max_adsorp_height'],
|
||||||
|
'max_adsorp_diameter': obj.get('max_adsorp_diameter'),
|
||||||
|
'max_adsorp_force': obj['max_adsorp_force'],
|
||||||
|
'flatness': obj.get('flatness'),
|
||||||
|
'max_load': obj.get('max_load'),
|
||||||
|
'unlocking_method': obj.get('unlocking_method'),
|
||||||
|
'materials_model_id': self.env['sf.materials.model'].sudo().search(
|
||||||
|
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]
|
||||||
|
).id if obj.get('materials_model_id') else False,
|
||||||
|
'active': obj.get('active', True),
|
||||||
|
}
|
||||||
|
|
||||||
|
def _json_positioning_partition_param(self, obj):
|
||||||
|
"""定位隔板:将data数据转换成字段字典"""
|
||||||
|
return {
|
||||||
|
'code': obj.get('code'),
|
||||||
|
'fixture_model_id': self.env['sf.fixture.model'].sudo().search(
|
||||||
|
[('code', '=', obj.get('fixture_model_code'))], limit=1).id,
|
||||||
|
'name': obj.get('name'),
|
||||||
|
'partition_length_outer': obj.get('length_outer'),
|
||||||
|
'partition_width_outer': obj.get('width_outer'),
|
||||||
|
'partition_length_inner': obj.get('length_inner'),
|
||||||
|
'partition_width_inner': obj.get('width_inner'),
|
||||||
|
'partition_left_margin': obj.get('left_margin'),
|
||||||
|
'partition_bottom_margin': obj.get('bottom_margin'),
|
||||||
|
'partition_unit_length': obj.get('unit_length'),
|
||||||
|
'partition_unit_width': obj.get('unit_width'),
|
||||||
|
'partition_unit_row_spacing': obj.get('unit_row_spacing'),
|
||||||
|
'partition_unit_col_spacing': obj.get('unit_col_spacing'),
|
||||||
|
'partition_unit_rows': obj.get('unit_rows'),
|
||||||
|
'partition_unit_cols': obj.get('unit_cols'),
|
||||||
|
'partition_base_unit_row_spacing': obj.get('base_unit_row_spacing'),
|
||||||
|
'partition_base_unit_col_spacing': obj.get('base_unit_col_spacing'),
|
||||||
|
'partition_offset_x': obj.get('offset_x'),
|
||||||
|
'partition_offset_y': obj.get('offset_y'),
|
||||||
|
'partition_materials_model_id': self.env['sf.materials.model'].sudo().search(
|
||||||
|
[('materials_no', '=', obj.get('materials_model_id')), ('active', '=', True)], limit=1).id
|
||||||
|
if obj.get('materials_model_id') else False,
|
||||||
|
'partition_partner_id': self.env['res.partner'].sudo().search(
|
||||||
|
[('name', '=', obj.get('partner_name'))], limit=1).id
|
||||||
|
if obj.get('partner_name') else False,
|
||||||
|
'partition_joint_type': obj.get('joint_type'),
|
||||||
|
'active': obj.get('active', True),
|
||||||
|
}
|
||||||
|
|
||||||
|
def _json_air_tray_param(self, obj):
|
||||||
|
"""气吸托盘:将data数据转换成list数据"""
|
||||||
|
return {
|
||||||
|
'code': obj['code'],
|
||||||
|
'fixture_model_id': self.env['sf.fixture.model'].sudo().search(
|
||||||
|
[('code', '=', obj.get('fixture_model_code'))]).id,
|
||||||
|
'name': obj['name'],
|
||||||
|
'length': obj['length'],
|
||||||
|
'width': obj['width'],
|
||||||
|
'height': obj['height'],
|
||||||
|
'diameter': obj['diameter'],
|
||||||
|
'weight': obj['weight'],
|
||||||
|
'max_adsorp_length': obj['max_adsorp_length'],
|
||||||
|
'max_adsorp_width': obj['max_adsorp_width'],
|
||||||
|
'max_adsorp_height': obj['max_adsorp_height'],
|
||||||
|
'max_adsorp_diameter': obj.get('max_adsorp_diameter'),
|
||||||
|
'max_adsorp_force': obj['max_adsorp_force'],
|
||||||
|
'flatness': obj.get('flatness'),
|
||||||
|
'max_load': obj.get('max_load'),
|
||||||
|
'unlocking_method': obj.get('unlocking_method'),
|
||||||
|
'boolean_chip_blowing_function': obj.get('blowing_function', False),
|
||||||
|
'way_to_install': obj.get('way_to_install'),
|
||||||
|
'materials_model_id': self.env['sf.materials.model'].sudo().search(
|
||||||
|
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]
|
||||||
|
).id if obj.get('materials_model_id') else False,
|
||||||
|
'active': obj.get('active', True),
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class FixtureModel(models.Model):
|
|||||||
glb_url = fields.Char(string="图片")
|
glb_url = fields.Char(string="图片")
|
||||||
status = fields.Boolean('状态')
|
status = fields.Boolean('状态')
|
||||||
active = fields.Boolean('有效', default=False)
|
active = fields.Boolean('有效', default=False)
|
||||||
|
code = fields.Char(string='编码', readonly=True)
|
||||||
|
|
||||||
zero_chuck_ids = fields.One2many('sf.fixture.materials.basic.parameters', 'fixture_model_id',
|
zero_chuck_ids = fields.One2many('sf.fixture.materials.basic.parameters', 'fixture_model_id',
|
||||||
string='零点卡盘基本参数')
|
string='零点卡盘基本参数')
|
||||||
@@ -46,11 +47,16 @@ class FixtureModel(models.Model):
|
|||||||
string='虎钳夹具基本参数')
|
string='虎钳夹具基本参数')
|
||||||
magnet_fixture_ids = fields.One2many('sf.fixture.materials.basic.parameters', 'fixture_model_id',
|
magnet_fixture_ids = fields.One2many('sf.fixture.materials.basic.parameters', 'fixture_model_id',
|
||||||
string='磁吸夹具基本参数')
|
string='磁吸夹具基本参数')
|
||||||
|
magnet_tray_ids = fields.One2many('sf.fixture.materials.basic.parameters', 'fixture_model_id',
|
||||||
|
string='磁吸托盘基本参数')
|
||||||
|
positioning_partition_ids = fields.One2many('sf.fixture.materials.basic.parameters','fixture_model_id',
|
||||||
|
string='定位隔板基本参数')
|
||||||
adapter_board_fixture_ids = fields.One2many('sf.fixture.materials.basic.parameters', 'fixture_model_id',
|
adapter_board_fixture_ids = fields.One2many('sf.fixture.materials.basic.parameters', 'fixture_model_id',
|
||||||
string='转接板(锁板)夹具基本参数')
|
string='转接板(锁板)夹具基本参数')
|
||||||
scroll_chuck_ids = fields.One2many('sf.fixture.materials.basic.parameters', 'fixture_model_id',
|
scroll_chuck_ids = fields.One2many('sf.fixture.materials.basic.parameters', 'fixture_model_id',
|
||||||
string='三爪卡盘基本参数')
|
string='三爪卡盘基本参数')
|
||||||
code = fields.Char(string='编码', readonly=True)
|
air_tray_ids = fields.One2many('sf.fixture.materials.basic.parameters', 'fixture_model_id',
|
||||||
|
string='气吸托盘基本参数')
|
||||||
|
|
||||||
# def _get_code(self, fixture_model_type_code):
|
# def _get_code(self, fixture_model_type_code):
|
||||||
# fixture_model = self.env['sf.fixture.model'].sudo().search(
|
# fixture_model = self.env['sf.fixture.model'].sudo().search(
|
||||||
|
|||||||
@@ -328,6 +328,80 @@
|
|||||||
<field name="type_of_drive"/>
|
<field name="type_of_drive"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="air_tray_ids"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', '!=', '气吸托盘')]}">
|
||||||
|
<tree editable="bottom" class="center" delete="0">
|
||||||
|
<field name="code" invisible="1"/>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="length"/>
|
||||||
|
<field name="width"/>
|
||||||
|
<field name="height"/>
|
||||||
|
<field name="diameter"/>
|
||||||
|
<field name="weight" string="重量(kg)"/>
|
||||||
|
<field name="max_adsorp_length"/>
|
||||||
|
<field name="max_adsorp_width"/>
|
||||||
|
<field name="max_adsorp_height"/>
|
||||||
|
<field name="max_adsorp_diameter"/>
|
||||||
|
<field name="max_adsorp_force"/>
|
||||||
|
<field name="flatness"/>
|
||||||
|
<field name="max_load"/>
|
||||||
|
<field name="unlocking_method"/>
|
||||||
|
<field name="boolean_chip_blowing_function"/>
|
||||||
|
<field name="way_to_install"/>
|
||||||
|
<field name="materials_model_id" options="{'no_create': True}" placeholder="请选择"/>
|
||||||
|
<field name="active" invisible="1"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
<field name="magnet_tray_ids"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', '!=', '磁吸托盘')]}">
|
||||||
|
<tree editable="bottom" class="center" delete="0">
|
||||||
|
<field name="code" invisible="1"/>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="length"/>
|
||||||
|
<field name="width"/>
|
||||||
|
<field name="height"/>
|
||||||
|
<field name="diameter"/>
|
||||||
|
<field name="weight" string="重量(kg)"/>
|
||||||
|
<field name="max_adsorp_length"/>
|
||||||
|
<field name="max_adsorp_width"/>
|
||||||
|
<field name="max_adsorp_height"/>
|
||||||
|
<field name="max_adsorp_diameter"/>
|
||||||
|
<field name="max_adsorp_force"/>
|
||||||
|
<field name="flatness"/>
|
||||||
|
<field name="max_load"/>
|
||||||
|
<field name="unlocking_method"/>
|
||||||
|
<field name="materials_model_id" options="{'no_create': True}" placeholder="请选择"/>
|
||||||
|
<field name="active" invisible="1"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
<field name="positioning_partition_ids"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', '!=', '定位隔板')]}">
|
||||||
|
<tree editable="bottom" class="center" delete="0">
|
||||||
|
<field name="code" invisible="1"/>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="partition_length_outer"/>
|
||||||
|
<field name="partition_width_outer"/>
|
||||||
|
<field name="partition_length_inner"/>
|
||||||
|
<field name="partition_width_inner"/>
|
||||||
|
<field name="partition_left_margin"/>
|
||||||
|
<field name="partition_bottom_margin"/>
|
||||||
|
<field name="partition_unit_length"/>
|
||||||
|
<field name="partition_unit_width"/>
|
||||||
|
<field name="partition_unit_row_spacing"/>
|
||||||
|
<field name="partition_unit_col_spacing"/>
|
||||||
|
<field name="partition_unit_rows"/>
|
||||||
|
<field name="partition_unit_cols"/>
|
||||||
|
<field name="station_count" readonly="1"/>
|
||||||
|
<field name="partition_base_unit_row_spacing"/>
|
||||||
|
<field name="partition_base_unit_col_spacing"/>
|
||||||
|
<field name="partition_offset_x"/>
|
||||||
|
<field name="partition_offset_y"/>
|
||||||
|
<field name="partition_joint_type"/>
|
||||||
|
<field name="partition_partner_id" options="{'no_create': True}" placeholder="请选择"/>
|
||||||
|
<field name="partition_materials_model_id" options="{'no_create': True}" placeholder="请选择"/>
|
||||||
|
<field name="active" invisible="1"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
<field name="scroll_chuck_ids"
|
<field name="scroll_chuck_ids"
|
||||||
attrs="{'invisible': [('fixture_material_type', '!=', '三爪卡盘')]}">
|
attrs="{'invisible': [('fixture_material_type', '!=', '三爪卡盘')]}">
|
||||||
<tree editable="bottom" class="center" delete="0">
|
<tree editable="bottom" class="center" delete="0">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['sf_plan'], #'jikimo_printing',
|
'depends': ['sf_plan','jikimo_printing'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'data/stock_route_group.xml',
|
'data/stock_route_group.xml',
|
||||||
|
|||||||
@@ -7,29 +7,7 @@ from odoo.tools import float_compare
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
import re
|
import re
|
||||||
#本地环境问题 不加报错
|
|
||||||
class ProductCategory(models.Model):
|
|
||||||
_inherit = 'product.category'
|
|
||||||
|
|
||||||
negative_inventory_allowed = fields.Boolean(string="允许负库存", default=False)
|
|
||||||
|
|
||||||
class StockPicking(models.Model):
|
|
||||||
_inherit = 'stock.picking'
|
|
||||||
|
|
||||||
whether_show_quality_check = fields.Boolean(string="是否显示质检")
|
|
||||||
|
|
||||||
class ProductTemplate(models.Model):
|
|
||||||
_inherit = 'product.template'
|
|
||||||
|
|
||||||
blank_type = fields.Selection([
|
|
||||||
('圆料', '圆料'),
|
|
||||||
('方料', '方料'),
|
|
||||||
], string='坯料分类')
|
|
||||||
|
|
||||||
blank_precision = fields.Selection([
|
|
||||||
('精坯', '精坯'),
|
|
||||||
('粗坯', '粗坯'),
|
|
||||||
], string='坯料类型')
|
|
||||||
|
|
||||||
class SfProductionDemandPlan(models.Model):
|
class SfProductionDemandPlan(models.Model):
|
||||||
_name = 'sf.production.demand.plan'
|
_name = 'sf.production.demand.plan'
|
||||||
@@ -710,49 +688,19 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
self.action_confirm()
|
self.action_confirm()
|
||||||
|
|
||||||
def action_confirm(self):
|
def action_confirm(self):
|
||||||
"""
|
self = self.with_context(
|
||||||
确认需求计划行,创建 BOM、触发库存规则,并更新状态。
|
demand_plan_line_id=self.id
|
||||||
"""
|
)
|
||||||
# 将当前需求计划行 ID 写入上下文,便于后续方法使用
|
|
||||||
self = self.with_context(demand_plan_line_id=self.id)
|
|
||||||
|
|
||||||
# 创建物料清单(BOM),根据供货方式进行不同的处理
|
|
||||||
self.mrp_bom_create()
|
self.mrp_bom_create()
|
||||||
|
|
||||||
# 启动库存规则(创建采购、生产等)
|
|
||||||
self._action_launch_stock_rule()
|
self._action_launch_stock_rule()
|
||||||
|
|
||||||
# 根据供货方式设置状态字段
|
|
||||||
if self.supply_method in ('automation', 'manual'):
|
if self.supply_method in ('automation', 'manual'):
|
||||||
self.write({'status': '50'}) # 自动/手工 供货:待排产
|
self.write({'status': '50'})
|
||||||
self.update_sale_order_state()
|
self.update_sale_order_state()
|
||||||
else:
|
else:
|
||||||
self.write({'status': '60'}) # 外购/外协/客户自供:无需排产
|
self.write({'status': '60'})
|
||||||
self.update_sale_order_state()
|
self.update_sale_order_state()
|
||||||
|
|
||||||
|
|
||||||
def _get_embryo_template_by_supply_method(self):
|
|
||||||
"""
|
|
||||||
根据供货方式返回对应的胚料模板 product.template 记录。
|
|
||||||
"""
|
|
||||||
supply_map = {
|
|
||||||
'automation': self.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo(),
|
|
||||||
'outsourcing': self.env.ref('sf_dlm.product_embryo_sf_outsource').sudo(),
|
|
||||||
'purchase': self.env.ref('sf_dlm.product_embryo_sf_purchase').sudo(),
|
|
||||||
'manual': self.env.ref('jikimo_sale_multiple_supply_methods.product_template_manual_processing').sudo(),
|
|
||||||
'material_customer_provided': self.env.ref('jikimo_sale_multiple_supply_methods.product_template_embryo_customer_provided').sudo(),
|
|
||||||
}
|
|
||||||
template = supply_map.get(self.supply_method)
|
|
||||||
if not template:
|
|
||||||
raise UserError(f"未配置供货方式 {self.supply_method} 对应的胚料模板")
|
|
||||||
return template
|
|
||||||
|
|
||||||
|
|
||||||
def mrp_bom_create(self):
|
def mrp_bom_create(self):
|
||||||
"""
|
|
||||||
创建 BOM(包含胚料与成品 BOM),用于后续生产或采购流程。
|
|
||||||
"""
|
|
||||||
# 如果同一计划中已有对应的 BOM 可复用,则直接使用
|
|
||||||
if self.supply_method in ('automation', 'manual'):
|
if self.supply_method in ('automation', 'manual'):
|
||||||
line_ids = self.demand_plan_id.line_ids.filtered(
|
line_ids = self.demand_plan_id.line_ids.filtered(
|
||||||
lambda p: p.supply_method in ('automation', 'manual') and p.status in ('50', '60'))
|
lambda p: p.supply_method in ('automation', 'manual') and p.status in ('50', '60'))
|
||||||
@@ -765,32 +713,32 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
if line_ids:
|
if line_ids:
|
||||||
self.bom_id = line_ids[0].bom_id.id
|
self.bom_id = line_ids[0].bom_id.id
|
||||||
return
|
return
|
||||||
|
|
||||||
# 根据供货方式选择模板和 BOM 类型
|
|
||||||
bom_type = ''
|
bom_type = ''
|
||||||
|
# 根据供货方式修改成品模板
|
||||||
if self.supply_method == 'automation':
|
if self.supply_method == 'automation':
|
||||||
bom_type = 'normal'
|
bom_type = 'normal'
|
||||||
product_template_id = self.env.ref('sf_dlm.product_template_sf').sudo().product_tmpl_id
|
product_template_id = self.env.ref('sf_dlm.product_template_sf').sudo().product_tmpl_id
|
||||||
elif self.supply_method == 'outsourcing':
|
elif self.supply_method == 'outsourcing':
|
||||||
bom_type = 'subcontract'
|
bom_type = 'subcontract'
|
||||||
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_outsourcing').sudo()
|
product_template_id = self.env.ref(
|
||||||
|
'jikimo_sale_multiple_supply_methods.product_template_outsourcing').sudo()
|
||||||
elif self.supply_method == 'purchase':
|
elif self.supply_method == 'purchase':
|
||||||
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_purchase').sudo()
|
product_template_id = self.env.ref(
|
||||||
|
'jikimo_sale_multiple_supply_methods.product_template_purchase').sudo()
|
||||||
elif self.supply_method == 'manual':
|
elif self.supply_method == 'manual':
|
||||||
bom_type = 'normal'
|
bom_type = 'normal'
|
||||||
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_manual_processing').sudo()
|
product_template_id = self.env.ref(
|
||||||
|
'jikimo_sale_multiple_supply_methods.product_template_manual_processing').sudo()
|
||||||
|
|
||||||
# 使用模板复制内容到当前产品
|
# 复制成品模板上的属性
|
||||||
self.product_id.product_tmpl_id.copy_template(product_template_id)
|
self.product_id.product_tmpl_id.copy_template(product_template_id)
|
||||||
|
|
||||||
# 构造 BOM 编码(包含时间戳)
|
|
||||||
future_time = datetime.now() + timedelta(hours=8)
|
future_time = datetime.now() + timedelta(hours=8)
|
||||||
|
# 生成BOM单据编码
|
||||||
code = f"{self.product_id.default_code}-{bom_type}-{future_time.strftime('%Y%m%d%H%M%S')}"
|
code = f"{self.product_id.default_code}-{bom_type}-{future_time.strftime('%Y%m%d%H%M%S')}"
|
||||||
|
|
||||||
order_id = self.sale_order_id
|
order_id = self.sale_order_id
|
||||||
product = self.product_id
|
product = self.product_id
|
||||||
|
# 拼接方法需要的item结构,成品的模型数据信息就是坯料的数据信息
|
||||||
# 构造胚料产品的参数
|
|
||||||
item = {
|
item = {
|
||||||
'texture_code': product.materials_id.materials_no,
|
'texture_code': product.materials_id.materials_no,
|
||||||
'texture_type_code': product.materials_type_id.materials_no,
|
'texture_type_code': product.materials_type_id.materials_no,
|
||||||
@@ -803,81 +751,110 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
'embryo_redundancy_id': self.sale_order_line_id.embryo_redundancy_id,
|
'embryo_redundancy_id': self.sale_order_line_id.embryo_redundancy_id,
|
||||||
'model_id': self.model_id
|
'model_id': self.model_id
|
||||||
}
|
}
|
||||||
|
|
||||||
# 从产品名中提取编号(如 S12345-3)
|
|
||||||
product_name = ''
|
product_name = ''
|
||||||
match = re.search(r'(S\d{5}-\d+)', product.name)
|
match = re.search(r'(S\d{5}-\d+)', product.name)
|
||||||
product_seria = 0
|
product_seria = 0
|
||||||
|
# 如果匹配成功,提取结果
|
||||||
if match:
|
if match:
|
||||||
product_name = match.group(0)
|
product_name = match.group(0)
|
||||||
|
# 获取成品名结尾-n的n
|
||||||
product_seria = int(product_name.split('-')[-1])
|
product_seria = int(product_name.split('-')[-1])
|
||||||
|
|
||||||
# 如果供货方式不是采购,则需要先创建胚料产品
|
# 成品供货方式为采购则不生成bom
|
||||||
if self.supply_method != 'purchase':
|
if self.supply_method != 'purchase':
|
||||||
# 判断是否为客户自供
|
# 当成品上带有客供料选项时,生成坯料时选择“客供料”路线
|
||||||
if self.sale_order_line_id.embryo_redundancy_id:
|
if self.sale_order_line_id.embryo_redundancy_id:
|
||||||
embryo_template = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_embryo_customer_provided').sudo()
|
# 将成品模板的内容复制到成品上
|
||||||
embryo_key = 'material_customer_provided'
|
customer_provided_embryo = self.env.ref(
|
||||||
else:
|
'jikimo_sale_multiple_supply_methods.product_template_embryo_customer_provided').sudo()
|
||||||
embryo_template = self._get_embryo_template_by_supply_method()
|
# 创建坯料,客供料的批量不需要创建bom
|
||||||
embryo_key = self.supply_method
|
material_customer_provided_embryo = self.env['product.template'].sudo().no_bom_product_create(
|
||||||
|
customer_provided_embryo.with_context(active_test=False).product_variant_id,
|
||||||
# 获取批次追踪方式
|
item,
|
||||||
tracking_method = embryo_template.tracking
|
order_id, 'material_customer_provided', product_seria, product)
|
||||||
|
# 成品配置bom
|
||||||
# 创建胚料产品(无 BOM 产品)
|
product_bom_material_customer_provided = self.env['mrp.bom'].with_user(
|
||||||
embryo_product = self.env['product.template'].sudo().no_bom_product_create(
|
self.env.ref("base.user_admin")).bom_create(
|
||||||
embryo_template.with_context(active_test=False).product_variant_id,
|
product, bom_type, 'product', code)
|
||||||
item,
|
product_bom_material_customer_provided.with_user(
|
||||||
order_id,
|
self.env.ref("base.user_admin")).bom_create_line_has(
|
||||||
embryo_key,
|
material_customer_provided_embryo)
|
||||||
product_seria,
|
self.bom_id = product_bom_material_customer_provided.id
|
||||||
product
|
elif self.product_id.materials_type_id.gain_way == '自加工':
|
||||||
)
|
self_machining_id = self.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo()
|
||||||
|
# 创建坯料
|
||||||
if embryo_product == -3:
|
self_machining_embryo = self.env['product.template'].sudo().no_bom_product_create(
|
||||||
raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配')
|
self_machining_id,
|
||||||
|
item,
|
||||||
# 设置胚料 BOM 类型
|
order_id, 'self_machining', product_seria, product)
|
||||||
if embryo_key in ('automation', 'manual', 'material_customer_provided'):
|
# 创建坯料的bom
|
||||||
embryo_bom_type = 'normal'
|
self_machining_bom = self.env['mrp.bom'].with_user(
|
||||||
elif embryo_key == 'outsourcing':
|
self.env.ref("base.user_admin")).bom_create(
|
||||||
embryo_bom_type = 'subcontract'
|
self_machining_embryo, 'normal', False)
|
||||||
elif embryo_key == 'purchase':
|
# 创建坯料里bom的组件
|
||||||
embryo_bom_type = 'purchase'
|
self_machining_bom_line = self_machining_bom.with_user(
|
||||||
else:
|
self.env.ref("base.user_admin")).bom_create_line(
|
||||||
embryo_bom_type = 'normal'
|
self_machining_embryo)
|
||||||
|
if not self_machining_bom_line:
|
||||||
# 创建胚料 BOM 及 BOM 行
|
raise UserError('该订单模型的材料型号暂未有原材料,请先配置再进行分配')
|
||||||
embryo_bom = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).bom_create(
|
# 产品配置bom
|
||||||
embryo_product, embryo_bom_type, True, tracking=tracking_method)
|
product_bom_self_machining = self.env['mrp.bom'].with_user(
|
||||||
|
self.env.ref("base.user_admin")).bom_create(
|
||||||
embryo_bom_line = embryo_bom.with_user(self.env.ref("base.user_admin")).bom_create_line(embryo_product)
|
product, bom_type, 'product', code)
|
||||||
if not embryo_bom_line:
|
product_bom_self_machining.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
|
||||||
raise UserError('该订单模型的材料型号暂未有原材料,请先配置再进行分配')
|
self_machining_embryo)
|
||||||
|
self.bom_id = product_bom_self_machining.id
|
||||||
# 创建成品 BOM(包含胚料)
|
elif self.product_id.materials_type_id.gain_way == '外协':
|
||||||
product_bom = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).bom_create(
|
outsource_id = self.env.ref('sf_dlm.product_embryo_sf_outsource').sudo()
|
||||||
product, bom_type, 'product', code, tracking=tracking_method)
|
# 创建坯料
|
||||||
product_bom.with_user(self.env.ref("base.user_admin")).bom_create_line_has(embryo_product)
|
outsource_embryo = self.env['product.template'].sudo().no_bom_product_create(outsource_id,
|
||||||
|
item,
|
||||||
# 赋值 BOM ID
|
order_id,
|
||||||
self.bom_id = product_bom.id
|
'subcontract',
|
||||||
|
product_seria,
|
||||||
|
product)
|
||||||
|
if outsource_embryo == -3:
|
||||||
|
raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配')
|
||||||
|
# 创建坯料的bom
|
||||||
|
outsource_bom = self.env['mrp.bom'].with_user(self.env.ref("base.user_admin")).bom_create(
|
||||||
|
outsource_embryo,
|
||||||
|
'subcontract', True)
|
||||||
|
# 创建坯料的bom的组件
|
||||||
|
outsource_bom_line = outsource_bom.with_user(
|
||||||
|
self.env.ref("base.user_admin")).bom_create_line(outsource_embryo)
|
||||||
|
if not outsource_bom_line:
|
||||||
|
raise UserError('该订单模型的材料型号暂未有原材料,请先配置再进行分配')
|
||||||
|
# 产品配置bom
|
||||||
|
product_bom_outsource = self.env['mrp.bom'].with_user(
|
||||||
|
self.env.ref("base.user_admin")).bom_create(product, bom_type, 'product', code)
|
||||||
|
product_bom_outsource.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
|
||||||
|
outsource_embryo)
|
||||||
|
self.bom_id = product_bom_outsource.id
|
||||||
|
elif self.product_id.materials_type_id.gain_way == '采购':
|
||||||
|
purchase_id = self.env.ref('sf_dlm.product_embryo_sf_purchase').sudo()
|
||||||
|
purchase_embryo = self.env['product.template'].sudo().no_bom_product_create(purchase_id,
|
||||||
|
item,
|
||||||
|
order_id,
|
||||||
|
'purchase',
|
||||||
|
product_seria,
|
||||||
|
product)
|
||||||
|
if purchase_embryo and purchase_embryo == -3:
|
||||||
|
raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配')
|
||||||
|
else:
|
||||||
|
# 产品配置bom
|
||||||
|
product_bom_purchase = self.env['mrp.bom'].with_user(
|
||||||
|
self.env.ref("base.user_admin")).bom_create(product, bom_type, 'product', code)
|
||||||
|
product_bom_purchase.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
|
||||||
|
purchase_embryo)
|
||||||
|
self.bom_id = product_bom_purchase.id
|
||||||
|
|
||||||
def _action_launch_stock_rule(self):
|
def _action_launch_stock_rule(self):
|
||||||
"""
|
|
||||||
触发库存规则(如采购、生产),并确认相关拣货单。
|
|
||||||
"""
|
|
||||||
procurements = []
|
procurements = []
|
||||||
|
|
||||||
group_id = self.sale_order_id.procurement_group_id
|
group_id = self.sale_order_id.procurement_group_id
|
||||||
if not group_id:
|
if not group_id:
|
||||||
# 没有分组则创建
|
|
||||||
group_id = self.env['procurement.group'].create(self._prepare_procurement_group_vals())
|
group_id = self.env['procurement.group'].create(self._prepare_procurement_group_vals())
|
||||||
self.sale_order_id.procurement_group_id = group_id
|
self.sale_order_id.procurement_group_id = group_id
|
||||||
else:
|
else:
|
||||||
# 若已有分组但字段有变动则更新
|
|
||||||
updated_vals = {}
|
updated_vals = {}
|
||||||
if group_id.partner_id != self.sale_order_id.partner_shipping_id:
|
if group_id.partner_id != self.sale_order_id.partner_shipping_id:
|
||||||
updated_vals.update({'partner_id': self.sale_order_id.partner_shipping_id.id})
|
updated_vals.update({'partner_id': self.sale_order_id.partner_shipping_id.id})
|
||||||
@@ -885,42 +862,27 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
updated_vals.update({'move_type': self.sale_order_id.picking_policy})
|
updated_vals.update({'move_type': self.sale_order_id.picking_policy})
|
||||||
if updated_vals:
|
if updated_vals:
|
||||||
group_id.write(updated_vals)
|
group_id.write(updated_vals)
|
||||||
|
|
||||||
# 构造 procurement 所需的字段
|
|
||||||
values = self._prepare_procurement_values(group_id=group_id)
|
values = self._prepare_procurement_values(group_id=group_id)
|
||||||
|
|
||||||
# 单位换算
|
|
||||||
line_uom = self.sale_order_line_id.product_uom
|
line_uom = self.sale_order_line_id.product_uom
|
||||||
quant_uom = self.product_id.uom_id
|
quant_uom = self.product_id.uom_id
|
||||||
plan_uom_qty, procurement_uom = line_uom._adjust_uom_quantities(self.plan_uom_qty, quant_uom)
|
plan_uom_qty, procurement_uom = line_uom._adjust_uom_quantities(self.plan_uom_qty, quant_uom)
|
||||||
|
|
||||||
# 创建 procurement 请求
|
|
||||||
procurements.append(self.env['procurement.group'].Procurement(
|
procurements.append(self.env['procurement.group'].Procurement(
|
||||||
self.product_id, plan_uom_qty, procurement_uom,
|
self.product_id, plan_uom_qty, procurement_uom,
|
||||||
self.sale_order_id.partner_shipping_id.property_stock_customer,
|
self.sale_order_id.partner_shipping_id.property_stock_customer,
|
||||||
self.product_id.display_name, self.sale_order_id.name, self.sale_order_id.company_id, values))
|
self.product_id.display_name, self.sale_order_id.name, self.sale_order_id.company_id, values))
|
||||||
|
|
||||||
# 执行调度
|
|
||||||
if procurements:
|
if procurements:
|
||||||
procurement_group = self.env['procurement.group']
|
procurement_group = self.env['procurement.group']
|
||||||
if self.env.context.get('import_file'):
|
if self.env.context.get('import_file'):
|
||||||
procurement_group = procurement_group.with_context(import_file=False)
|
procurement_group = procurement_group.with_context(import_file=False)
|
||||||
procurement_group.run(procurements)
|
procurement_group.run(procurements)
|
||||||
|
|
||||||
# 确认相关的拣货单
|
|
||||||
orders = self.mapped('sale_order_id')
|
orders = self.mapped('sale_order_id')
|
||||||
for order in orders:
|
for order in orders:
|
||||||
pickings_to_confirm = order.picking_ids.filtered(lambda p: p.state not in ['cancel', 'done'])
|
pickings_to_confirm = order.picking_ids.filtered(lambda p: p.state not in ['cancel', 'done'])
|
||||||
if pickings_to_confirm:
|
if pickings_to_confirm:
|
||||||
pickings_to_confirm.action_confirm()
|
pickings_to_confirm.action_confirm()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _prepare_procurement_group_vals(self):
|
def _prepare_procurement_group_vals(self):
|
||||||
"""
|
|
||||||
构造创建 procurement group 所需的字段。
|
|
||||||
"""
|
|
||||||
return {
|
return {
|
||||||
'name': self.sale_order_id.name,
|
'name': self.sale_order_id.name,
|
||||||
'move_type': self.sale_order_id.picking_policy,
|
'move_type': self.sale_order_id.picking_policy,
|
||||||
@@ -928,18 +890,11 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
'partner_id': self.sale_order_id.partner_shipping_id.id,
|
'partner_id': self.sale_order_id.partner_shipping_id.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _prepare_procurement_values(self, group_id=False):
|
def _prepare_procurement_values(self, group_id=False):
|
||||||
"""
|
|
||||||
构造单个 procurement 请求所需的字段字典。
|
|
||||||
"""
|
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|
||||||
# 交货日期与计划日期
|
|
||||||
date_deadline = self.sale_order_id.commitment_date or (
|
date_deadline = self.sale_order_id.commitment_date or (
|
||||||
self.sale_order_id.date_order + timedelta(days=self.sale_order_line_id.customer_lead or 0.0))
|
self.sale_order_id.date_order + timedelta(days=self.sale_order_line_id.customer_lead or 0.0))
|
||||||
date_planned = date_deadline - timedelta(days=self.sale_order_id.company_id.security_lead)
|
date_planned = date_deadline - timedelta(days=self.sale_order_id.company_id.security_lead)
|
||||||
|
|
||||||
values = {
|
values = {
|
||||||
'group_id': group_id,
|
'group_id': group_id,
|
||||||
'sale_line_id': self.sale_order_line_id.id,
|
'sale_line_id': self.sale_order_line_id.id,
|
||||||
@@ -955,6 +910,4 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
'sequence': self.sale_order_line_id.sequence,
|
'sequence': self.sale_order_line_id.sequence,
|
||||||
'demand_plan_line_id': self.id
|
'demand_plan_line_id': self.id
|
||||||
}
|
}
|
||||||
|
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
|||||||
@@ -513,112 +513,191 @@
|
|||||||
</notebook>
|
</notebook>
|
||||||
</page>
|
</page>
|
||||||
<page string="夹具物料参数" attrs="{'invisible': [('categ_type', '!=', '夹具')]}">
|
<page string="夹具物料参数" attrs="{'invisible': [('categ_type', '!=', '夹具')]}">
|
||||||
<group>
|
|
||||||
<group>
|
<group>
|
||||||
<field name="brand_id" placeholder="请选择" options="{'no_create': True}"/>
|
<group>
|
||||||
<field name="multi_mounting_type_id" placeholder="请选择" options="{'no_create': True}"
|
<field name="brand_id" placeholder="请选择" options="{'no_create': True}"/>
|
||||||
attrs="{'required': [('categ_type', '=', '夹具')]}"/>
|
<field name="multi_mounting_type_id" placeholder="请选择" options="{'no_create': True}"
|
||||||
<field name="length" string="长度(mm)"/>
|
attrs="{'required': [('categ_type', '=', '夹具')]}"/>
|
||||||
<field name="width" string="宽度(mm)"/>
|
<field name="length" string="长度(mm)"/>
|
||||||
<field name="height" string="高度(mm)"/>
|
<field name="width" string="宽度(mm)"/>
|
||||||
<field name="height_tolerance_value"
|
<field name="height" string="高度(mm)"/>
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸夹具'])]}"/>
|
<field name="height_tolerance_value"
|
||||||
<field name="diameter"
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸夹具'])]}"/>
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘', '零点托盘', '三爪卡盘'])]}"/>
|
<field name="diameter"
|
||||||
<field name="weight"/>
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘', '零点托盘', '三爪卡盘', '磁吸托盘', '气吸托盘'])]}"/>
|
||||||
<field name="chucking_power_max"
|
<field name="weight"/>
|
||||||
attrs="{'invisible': [('fixture_material_type', '=','磁吸夹具')]}"/>
|
<field name="chucking_power_max"
|
||||||
<field name="carrying_capacity_max"/>
|
attrs="{'invisible': [('fixture_material_type', '=','磁吸夹具')]}"/>
|
||||||
<field name="rigidity"/>
|
<field name="carrying_capacity_max"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸夹具'])]}"/>
|
||||||
|
<field name="rigidity"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<!-- 夹持工件尺寸 -->
|
||||||
|
<label for="gripper_length_min" string="夹持工件最小尺寸"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}"/>
|
||||||
|
<div class="o_address_format"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}">
|
||||||
|
<label for="gripper_length_min" string="长"/>
|
||||||
|
<field name="gripper_length_min" class="o_address_zip"/>
|
||||||
|
<span>&nbsp;</span>
|
||||||
|
<label for="gripper_width_min" string="宽"/>
|
||||||
|
<field name="gripper_width_min" class="o_address_zip"/>
|
||||||
|
<span>&nbsp;</span>
|
||||||
|
<label for="gripper_height_min" string="高"/>
|
||||||
|
<field name="gripper_height_min" class="o_address_zip"/>
|
||||||
|
</div>
|
||||||
|
<label for="gripper_length_max" string="夹持工件最大尺寸"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}"/>
|
||||||
|
<div class="o_address_format"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}">
|
||||||
|
<label for="gripper_length_max" string="长"/>
|
||||||
|
<field name="gripper_length_max" class="o_address_zip"/>
|
||||||
|
<span>&nbsp;</span>
|
||||||
|
<label for="gripper_width_max" string="宽"/>
|
||||||
|
<field name="gripper_width_max" class="o_address_zip"/>
|
||||||
|
<span>&nbsp;</span>
|
||||||
|
<label for="gripper_height_max" string="高"/>
|
||||||
|
<field name="gripper_height_max" class="o_address_zip"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<field name="gripper_diameter_min" string="夹持工件最小直径(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}"/>
|
||||||
|
<field name="gripper_diameter_max" string="夹持工件最大直径(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}"/>
|
||||||
|
<field name="clamping_diameter" string="装夹直径(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘','零点托盘'])]}"/>
|
||||||
|
<field name="clamping_num" placeholder="请选择" string="装夹单元数"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', '!=', '零点卡盘')]}"/>
|
||||||
|
<field name="repeated_positioning_accuracy" placeholder="请输入重复定位孔精度"
|
||||||
|
string="重复定位精度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘','零点托盘'])]}"/>
|
||||||
|
<field name="orientation_dish_diameter" string="定位盘直径(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘'])]}"/>
|
||||||
|
<field name="boolean_transposing_hole" string="是否有转位孔"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘'])]}"/>
|
||||||
|
<field name="connector_diameter" placeholder="请选择" string="连接头直径(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点托盘'])]}"/>
|
||||||
|
<field name="way_to_install" placeholder="请选择" string="安装方式"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点托盘','气吸托盘'])]}"/>
|
||||||
|
<field name="rated_air_pressure" string="额定气压(Mpa)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具'])]}"/>
|
||||||
|
|
||||||
|
<field name="transverse_groove" string="横向配合槽n(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['虎钳夹具'])]}"/>
|
||||||
|
<field name="longitudinal_fitting_groove" string="纵向配合槽l(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['虎钳夹具'])]}"/>
|
||||||
|
|
||||||
|
<field name="rated_adsorption_force" string="额定吸附力(N/cm²)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸夹具'])]}"/>
|
||||||
|
<field name="magnetic_field_height" string="磁场高度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸夹具'])]}"/>
|
||||||
|
<field name="magnetic_pole_plate_grinding_allowance" string="磁极板磨削余量(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸夹具'])]}"/>
|
||||||
|
|
||||||
|
<!-- 磁吸托盘字段 -->
|
||||||
|
<field name="magnet_tray_length" string="磁吸托盘长度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
<field name="magnet_tray_width" string="磁吸托盘宽度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
<field name="magnet_tray_height" string="磁吸托盘厚度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
<field name="magnet_tray_diameter" string="磁吸托盘直径(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
<field name="magnet_tray_weight" string="磁吸托盘重量(kg)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
|
||||||
|
<field name="magnet_max_adsorp_length" string="磁吸托盘最大吸附长度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
<field name="magnet_max_adsorp_width" string="磁吸托盘最大吸附宽度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
<field name="magnet_max_adsorp_height" string="磁吸托盘最大吸附厚度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
<field name="magnet_max_adsorp_diameter" string="磁吸托盘最大吸附直径(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
<field name="magnet_max_adsorp_force" string="磁吸托盘最大吸附力(N)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
|
||||||
|
<field name="magnet_unlocking_method" string="磁吸托盘锁紧方式"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
<field name="magnet_flatness" string="磁吸托盘平面精度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
<field name="magnet_max_load" string="磁吸托盘最大负载(kg)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸托盘'])]}"/>
|
||||||
|
|
||||||
|
<!-- 气吸托盘字段 -->
|
||||||
|
<field name="air_tray_length" string="气吸托盘长度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_tray_width" string="气吸托盘宽度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_tray_height" string="气吸托盘高度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_tray_diameter" string="气吸托盘直径(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_tray_weight" string="气吸托盘重量(kg)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
|
||||||
|
<field name="air_max_adsorp_length" string="气吸托盘最大吸附长度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_max_adsorp_width" string="气吸托盘最大吸附宽度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_max_adsorp_height" string="气吸托盘最大吸附高度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_max_adsorp_diameter" string="气吸托盘最大吸附直径(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_max_adsorp_force" string="气吸托盘最大吸附力(N)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
|
||||||
|
<field name="air_unlocking_method" string="气吸托盘锁紧方式"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_flatness" string="气吸托盘平面精度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_max_load" string="气吸托盘最大负载(kg)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_boolean_chip_blowing_function" string="气吸托盘是否有吹屑功能"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
<field name="air_way_to_install" string="气吸托盘安装方式"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气吸托盘'])]}"/>
|
||||||
|
|
||||||
|
<!-- 定位隔板字段 -->
|
||||||
|
<field name="length_outer" string="外框长(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['定位隔板'])]}"/>
|
||||||
|
<field name="width_outer" string="外框宽(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['定位隔板'])]}"/>
|
||||||
|
<field name="length_inner" string="内框长(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['定位隔板'])]}"/>
|
||||||
|
<field name="width_inner" string="内框宽(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['定位隔板'])]}"/>
|
||||||
|
<field name="thickness" string="厚度(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['定位隔板'])]}"/>
|
||||||
|
<field name="unit_location" string="定位单元位置"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['定位隔板'])]}"/>
|
||||||
|
<field name="offset_x" string="X方向偏移(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['定位隔板'])]}"/>
|
||||||
|
<field name="offset_y" string="Y方向偏移(mm)"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['定位隔板'])]}"/>
|
||||||
|
<field name="materials_model_id_positioning" string="材质"
|
||||||
|
placeholder="请选择" options="{'no_create': True}"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['定位隔板'])]}"/>
|
||||||
|
<field name="station_count" string="定位单元数"
|
||||||
|
attrs="{'readonly': True, 'invisible': [('fixture_material_type', 'not in', ['定位隔板'])]}"/>
|
||||||
|
|
||||||
|
<field name="boolean_chip_blowing_function" string="是否有吹屑功能"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘','零点托盘','气吸托盘'])]}"/>
|
||||||
|
<field name="materials_model_id" placeholder="请选择" options="{'no_create': True}"/>
|
||||||
|
<field name="interface_materials_model_id" placeholder="请选择" string="接口类型"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具'])]}"/>
|
||||||
|
<field name="type_of_drive" placeholder="请选择" string="驱动方式"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点托盘','气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}"/>
|
||||||
|
<field name="unlocking_method" string="解锁方式" placeholder="请选择"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘','气吸托盘', '磁吸托盘'])]}"/>
|
||||||
|
<field name="machine_tool_type_id" string="适用机床型号" placeholder="请选择"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘'])]}"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
</page>
|
||||||
<label for="gripper_length_min" string="夹持工件最小尺寸"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}"/>
|
|
||||||
<div class="o_address_format"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}">
|
|
||||||
<label for="gripper_length_min" string="长"/>
|
|
||||||
<field name="gripper_length_min" class="o_address_zip"/>
|
|
||||||
<span>&nbsp;</span>
|
|
||||||
<label for="gripper_width_min" string="宽"/>
|
|
||||||
<field name="gripper_width_min" class="o_address_zip"/>
|
|
||||||
<span>&nbsp;</span>
|
|
||||||
<label for="gripper_height_min" string="高"/>
|
|
||||||
<field name="gripper_height_min" class="o_address_zip"/>
|
|
||||||
</div>
|
|
||||||
<label for="gripper_length_max" string="夹持工件最大尺寸"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}"/>
|
|
||||||
<div class="o_address_format"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}">
|
|
||||||
<label for="gripper_length_max" string="长"/>
|
|
||||||
<field name="gripper_length_max" class="o_address_zip"/>
|
|
||||||
<span>&nbsp;</span>
|
|
||||||
<label for="gripper_width_max" string="宽"/>
|
|
||||||
<field name="gripper_width_max" class="o_address_zip"/>
|
|
||||||
<span>&nbsp;</span>
|
|
||||||
<label for="gripper_width_max" string="高"/>
|
|
||||||
<field name="gripper_width_max" class="o_address_zip"/>
|
|
||||||
</div>
|
|
||||||
<field name="gripper_diameter_min" string="夹持工件最小直径(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}"/>
|
|
||||||
<field name="gripper_diameter_max" string="夹持工件最大直径(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}"/>
|
|
||||||
<field name="clamping_diameter" string="装夹直径(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘','零点托盘'])]}"/>
|
|
||||||
<field name="clamping_num" placeholder="请选择" string="装夹单元数"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', '!=', '零点卡盘')]}"/>
|
|
||||||
<field name="repeated_positioning_accuracy" placeholder="请输入重复定位孔精度"
|
|
||||||
string="重复定位精度(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘','零点托盘'])]}"/>
|
|
||||||
<field name="orientation_dish_diameter" string="定位盘直径(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘'])]}"/>
|
|
||||||
<field name="boolean_transposing_hole" string="是否有转位孔"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘'])]}"/>
|
|
||||||
<field name="connector_diameter" placeholder="请选择" string="连接头直径(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点托盘'])]}"/>
|
|
||||||
<field name="way_to_install" placeholder="请选择" string="安装方式"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点托盘'])]}"/>
|
|
||||||
<field name="rated_air_pressure" string="额定气压(Mpa)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具'])]}"/>
|
|
||||||
|
|
||||||
<field name="transverse_groove" string="横向配合槽n(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['虎钳夹具'])]}"/>
|
|
||||||
<field name="longitudinal_fitting_groove" string="纵向配合槽l(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['虎钳夹具'])]}"/>
|
|
||||||
|
|
||||||
<field name="rated_adsorption_force" string="额定吸附力(N/cm²)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸夹具'])]}"/>
|
|
||||||
<field name="magnetic_field_height" string="磁场高度(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸夹具'])]}"/>
|
|
||||||
<field name="magnetic_pole_plate_grinding_allowance" string="磁极板磨削余量(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['磁吸夹具'])]}"/>
|
|
||||||
|
|
||||||
<field name="screw_size" string="螺牙大小(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['转接板(锁板)夹具'])]}"/>
|
|
||||||
<field name="via_hole_diameter" string="过孔直径(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['转接板(锁板)夹具'])]}"/>
|
|
||||||
|
|
||||||
<field name="mounting_hole_depth" string="安装孔深度(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['三爪卡盘'])]}"/>
|
|
||||||
<field name="centering_diameter" string="定心直径(mm)"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['三爪卡盘'])]}"/>
|
|
||||||
|
|
||||||
<field name="boolean_chip_blowing_function" string="是否有吹屑功能"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘','零点托盘'])]}"/>
|
|
||||||
<field name="materials_model_id" placeholder="请选择" options="{'no_create': True}"/>
|
|
||||||
<field name="interface_materials_model_id" placeholder="请选择" string="接口类型"
|
|
||||||
options="{'no_create': True}"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['气动夹具','虎钳夹具','磁吸夹具'])]}"/>
|
|
||||||
<field name="type_of_drive" placeholder="请选择" string="驱动方式"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点托盘','气动夹具','虎钳夹具','磁吸夹具','转接板(锁板)夹具','三爪卡盘'])]}"/>
|
|
||||||
<field name="unlocking_method" string="解锁方式" placeholder="请选择"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘'])]}"/>
|
|
||||||
<field name="machine_tool_type_id" string="适用机床型号" placeholder="请选择"
|
|
||||||
options="{'no_create': True}"
|
|
||||||
attrs="{'invisible': [('fixture_material_type', 'not in', ['零点卡盘'])]}"/>
|
|
||||||
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
</page>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -1215,9 +1215,69 @@ class ResProductFixture(models.Model):
|
|||||||
mounting_hole_depth = fields.Float('安装孔深度(mm)', digits=(16, 2))
|
mounting_hole_depth = fields.Float('安装孔深度(mm)', digits=(16, 2))
|
||||||
centering_diameter = fields.Float('定心直径(mm)', digits=(16, 2))
|
centering_diameter = fields.Float('定心直径(mm)', digits=(16, 2))
|
||||||
|
|
||||||
|
# ‘磁吸托盘’ 字段
|
||||||
|
magnet_tray_length = fields.Float('磁吸托盘长度(mm)', digits=(16, 2))
|
||||||
|
magnet_tray_width = fields.Float('磁吸托盘宽度(mm)', digits=(16, 2))
|
||||||
|
magnet_tray_height = fields.Float('磁吸托盘厚度(mm)', digits=(16, 2))
|
||||||
|
magnet_tray_diameter = fields.Float('磁吸托盘直径(mm)', digits=(16, 2))
|
||||||
|
magnet_tray_weight = fields.Float('磁吸托盘重量(kg)', digits=(16, 2))
|
||||||
|
|
||||||
|
magnet_max_adsorp_length = fields.Float('磁吸托盘最大吸附长度(mm)', digits=(16, 2))
|
||||||
|
magnet_max_adsorp_width = fields.Float('磁吸托盘最大吸附宽度(mm)', digits=(16, 2))
|
||||||
|
magnet_max_adsorp_height = fields.Float('磁吸托盘最大吸附厚度(mm)', digits=(16, 2))
|
||||||
|
magnet_max_adsorp_diameter = fields.Float('磁吸托盘最大吸附直径(mm)', digits=(16, 2))
|
||||||
|
magnet_max_adsorp_force = fields.Float('磁吸托盘最大吸附力(N)', digits=(16, 2))
|
||||||
|
|
||||||
|
magnet_unlocking_method = fields.Selection(
|
||||||
|
[('手动', '手动'), ('气动', '气动'), ('液压', '液压'), ('电动', '电动'), ('其他', '其他')],
|
||||||
|
string='磁吸托盘锁紧方式'
|
||||||
|
)
|
||||||
|
magnet_flatness = fields.Char('磁吸托盘平面精度(mm)', size=20)
|
||||||
|
magnet_max_load = fields.Float('磁吸托盘最大负载(kg)', digits=(16, 2))
|
||||||
|
|
||||||
|
# 定位隔板字段
|
||||||
|
length_outer = fields.Float('外框长(mm)', digits=(16, 2))
|
||||||
|
width_outer = fields.Float('外框宽(mm)', digits=(16, 2))
|
||||||
|
length_inner = fields.Float('内框长(mm)', digits=(16, 2))
|
||||||
|
width_inner = fields.Float('内框宽(mm)', digits=(16, 2))
|
||||||
|
thickness = fields.Float('厚度(mm)', digits=(16, 2))
|
||||||
|
|
||||||
|
unit_location = fields.Char('定位单元位置')
|
||||||
|
offset_x = fields.Float('X方向偏移(mm)', digits=(16, 2))
|
||||||
|
offset_y = fields.Float('Y方向偏移(mm)', digits=(16, 2))
|
||||||
|
|
||||||
|
materials_model_id_positioning = fields.Many2one(
|
||||||
|
'sf.materials.model', string='材质', ondelete='set null', index=True)
|
||||||
|
station_count = fields.Integer('定位单元数', readonly=True)
|
||||||
|
|
||||||
|
# ‘气吸托盘’ 字段
|
||||||
|
air_tray_length = fields.Float('气吸托盘长度(mm)', digits=(16, 2))
|
||||||
|
air_tray_width = fields.Float('气吸托盘宽度(mm)', digits=(16, 2))
|
||||||
|
air_tray_height = fields.Float('气吸托盘高度(mm)', digits=(16, 2))
|
||||||
|
air_tray_diameter = fields.Float('气吸托盘直径(mm)', digits=(16, 2))
|
||||||
|
air_tray_weight = fields.Float('气吸托盘重量(kg)', digits=(16, 2))
|
||||||
|
|
||||||
|
air_max_adsorp_length = fields.Float('气吸托盘最大吸附长度(mm)', digits=(16, 2))
|
||||||
|
air_max_adsorp_width = fields.Float('气吸托盘最大吸附宽度(mm)', digits=(16, 2))
|
||||||
|
air_max_adsorp_height = fields.Float('气吸托盘最大吸附厚度(mm)', digits=(16, 2))
|
||||||
|
air_max_adsorp_diameter = fields.Float('气吸托盘最大吸附直径(mm)', digits=(16, 2))
|
||||||
|
air_max_adsorp_force = fields.Float('气吸托盘最大吸附力(N)', digits=(16, 2))
|
||||||
|
|
||||||
|
air_unlocking_method = fields.Selection(
|
||||||
|
[('手动', '手动'), ('气动', '气动'), ('液压', '液压'), ('电动', '电动'), ('其他', '其他')],
|
||||||
|
string='气吸托盘锁紧方式'
|
||||||
|
)
|
||||||
|
air_flatness = fields.Char('气吸托盘平面精度(mm)', size=20)
|
||||||
|
air_max_load = fields.Float('气吸托盘最大负载(kg)', digits=(16, 2))
|
||||||
|
air_boolean_chip_blowing_function = fields.Boolean('气吸托盘是否有吹屑功能')
|
||||||
|
air_way_to_install = fields.Selection(
|
||||||
|
[('接口式', '接口式'), ('螺栓固定', '螺栓固定'), ('磁吸式', '磁吸式'), ('其他', '其他')],
|
||||||
|
string='气吸托盘安装方式'
|
||||||
|
)
|
||||||
|
|
||||||
@api.onchange('specification_fixture_id')
|
@api.onchange('specification_fixture_id')
|
||||||
def _onchange_specification_fixture_id(self):
|
def _onchange_specification_fixture_id(self):
|
||||||
if self.specification_fixture_id:
|
if self.specification_fixture_id:
|
||||||
self.length = self.specification_fixture_id.length
|
self.length = self.specification_fixture_id.length
|
||||||
self.width = self.specification_fixture_id.width
|
self.width = self.specification_fixture_id.width
|
||||||
self.height = self.specification_fixture_id.height
|
self.height = self.specification_fixture_id.height
|
||||||
@@ -1258,7 +1318,46 @@ class ResProductFixture(models.Model):
|
|||||||
self.via_hole_diameter = self.specification_fixture_id.via_hole_diameter
|
self.via_hole_diameter = self.specification_fixture_id.via_hole_diameter
|
||||||
self.mounting_hole_depth = self.specification_fixture_id.mounting_hole_depth
|
self.mounting_hole_depth = self.specification_fixture_id.mounting_hole_depth
|
||||||
self.centering_diameter = self.specification_fixture_id.centering_diameter
|
self.centering_diameter = self.specification_fixture_id.centering_diameter
|
||||||
|
self.magnet_tray_length = self.specification_fixture_id.magnet_tray_length
|
||||||
|
self.magnet_tray_width = self.specification_fixture_id.magnet_tray_width
|
||||||
|
self.magnet_tray_height = self.specification_fixture_id.magnet_tray_height
|
||||||
|
self.magnet_tray_diameter = self.specification_fixture_id.magnet_tray_diameter
|
||||||
|
self.magnet_tray_weight = self.specification_fixture_id.magnet_tray_weight
|
||||||
|
self.magnet_max_adsorp_length = self.specification_fixture_id.magnet_max_adsorp_length
|
||||||
|
self.magnet_max_adsorp_width = self.specification_fixture_id.magnet_max_adsorp_width
|
||||||
|
self.magnet_max_adsorp_height = self.specification_fixture_id.magnet_max_adsorp_height
|
||||||
|
self.magnet_max_adsorp_diameter = self.specification_fixture_id.magnet_max_adsorp_diameter
|
||||||
|
self.magnet_max_adsorp_force = self.specification_fixture_id.magnet_max_adsorp_force
|
||||||
|
self.magnet_unlocking_method = self.specification_fixture_id.magnet_unlocking_method
|
||||||
|
self.magnet_flatness = self.specification_fixture_id.magnet_flatness
|
||||||
|
self.magnet_max_load = self.specification_fixture_id.magnet_max_load
|
||||||
|
# 定位隔板字段
|
||||||
|
self.length_outer = self.specification_fixture_id.length_outer
|
||||||
|
self.width_outer = self.specification_fixture_id.width_outer
|
||||||
|
self.length_inner = self.specification_fixture_id.length_inner
|
||||||
|
self.width_inner = self.specification_fixture_id.width_inner
|
||||||
|
self.thickness = self.specification_fixture_id.thickness
|
||||||
|
self.unit_location = self.specification_fixture_id.unit_location
|
||||||
|
self.offset_x = self.specification_fixture_id.offset_x
|
||||||
|
self.offset_y = self.specification_fixture_id.offset_y
|
||||||
|
self.materials_model_id_positioning = self.specification_fixture_id.materials_model_id_positioning
|
||||||
|
self.station_count = self.specification_fixture_id.station_count
|
||||||
|
# 气吸托盘字段
|
||||||
|
self.air_tray_length = self.specification_fixture_id.air_tray_length
|
||||||
|
self.air_tray_width = self.specification_fixture_id.air_tray_width
|
||||||
|
self.air_tray_height = self.specification_fixture_id.air_tray_height
|
||||||
|
self.air_tray_diameter = self.specification_fixture_id.air_tray_diameter
|
||||||
|
self.air_tray_weight = self.specification_fixture_id.air_tray_weight
|
||||||
|
self.air_max_adsorp_length = self.specification_fixture_id.air_max_adsorp_length
|
||||||
|
self.air_max_adsorp_width = self.specification_fixture_id.air_max_adsorp_width
|
||||||
|
self.air_max_adsorp_height = self.specification_fixture_id.air_max_adsorp_height
|
||||||
|
self.air_max_adsorp_diameter = self.specification_fixture_id.air_max_adsorp_diameter
|
||||||
|
self.air_max_adsorp_force = self.specification_fixture_id.air_max_adsorp_force
|
||||||
|
self.air_unlocking_method = self.specification_fixture_id.air_unlocking_method
|
||||||
|
self.air_flatness = self.specification_fixture_id.air_flatness
|
||||||
|
self.air_max_load = self.specification_fixture_id.air_max_load
|
||||||
|
self.air_boolean_chip_blowing_function = self.specification_fixture_id.air_boolean_chip_blowing_function
|
||||||
|
self.air_way_to_install = self.specification_fixture_id.air_way_to_install
|
||||||
|
|
||||||
class SfMaintenanceEquipmentAndProductTemplate(models.Model):
|
class SfMaintenanceEquipmentAndProductTemplate(models.Model):
|
||||||
_inherit = 'maintenance.equipment'
|
_inherit = 'maintenance.equipment'
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
from . import controllers
|
from . import controllers
|
||||||
from . import sync_controller
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
# study/jikimo_sf/sf_mrs_connect/controllers/sync_controller.py
|
|
||||||
from odoo import http
|
|
||||||
from odoo.http import request
|
|
||||||
|
|
||||||
class FixtureSyncController(http.Controller):
|
|
||||||
|
|
||||||
@http.route('/api/fixture_model/sync_from_mrs', type='json', auth='none', csrf=False)
|
|
||||||
def sync_model(self, **kw):
|
|
||||||
code = kw.get('code')
|
|
||||||
if not code:
|
|
||||||
return {'status':'fail','msg':'code missing'}
|
|
||||||
request.env['sf.fixture.model'].sudo().sync_from_mrs(code)
|
|
||||||
return {'status':'success'}
|
|
||||||
|
|
||||||
@http.route('/api/fixture_param/sync_from_mrs', type='json', auth='none', csrf=False)
|
|
||||||
def sync_param(self, **kw):
|
|
||||||
code = kw.get('code')
|
|
||||||
if not code:
|
|
||||||
return {'status':'fail','msg':'code missing'}
|
|
||||||
request.env['sf.fixture.materials.basic.parameters']\
|
|
||||||
.sudo().sync_from_mrs(code)
|
|
||||||
return {'status':'success'}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# study/jikimo_sf/sf_mrs_connect/models/common.py
|
|
||||||
import time, hashlib
|
|
||||||
|
|
||||||
class Common:
|
|
||||||
@staticmethod
|
|
||||||
def get_headers(token, secret_key):
|
|
||||||
ts = str(int(time.time()))
|
|
||||||
sign = hashlib.sha256(f"{token}{secret_key}{ts}".encode()).hexdigest()
|
|
||||||
return {
|
|
||||||
"token": token,
|
|
||||||
"sign": sign,
|
|
||||||
"timestamp": ts,
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
# study/jikimo_sf/sf_mrs_connect/models/redis_utils.py
|
|
||||||
import redis, json, logging
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
class RedisClient:
|
|
||||||
def __init__(self, host='localhost', port=6379, db=0):
|
|
||||||
try:
|
|
||||||
self.client = redis.Redis(host=host, port=port, db=db, decode_responses=True)
|
|
||||||
except Exception as e:
|
|
||||||
_logger.error(f"Redis init error: {e}")
|
|
||||||
self.client = None
|
|
||||||
|
|
||||||
def get_json(self, key):
|
|
||||||
if not self.client:
|
|
||||||
return None
|
|
||||||
try:
|
|
||||||
data = self.client.get(key)
|
|
||||||
return json.loads(data) if data else None
|
|
||||||
except Exception as e:
|
|
||||||
_logger.error(f"Redis GET error [{key}]: {e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
def set_json(self, key, value, ex=3600):
|
|
||||||
if not self.client:
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
self.client.set(key, json.dumps(value, ensure_ascii=False), ex=ex)
|
|
||||||
except Exception as e:
|
|
||||||
_logger.error(f"Redis SET error [{key}]: {e}")
|
|
||||||
@@ -5,11 +5,10 @@ import base64
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from odoo import models,api,fields
|
from odoo import models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
from .redis_utils import RedisClient
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
from .common import Common
|
|
||||||
from odoo.addons.jikimo_sf.sf_base.commons.common import Common
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -1508,157 +1507,161 @@ class SyncMulti_Mounting_Type(models.Model):
|
|||||||
raise ValidationError("联装类型认证未通过")
|
raise ValidationError("联装类型认证未通过")
|
||||||
|
|
||||||
|
|
||||||
# class SyncFixtureModel(models.Model):
|
class SyncFixtureModel(models.Model):
|
||||||
# _inherit = 'sf.fixture.model'
|
_inherit = 'sf.fixture.model'
|
||||||
# _description = '同步夹具型号列表'
|
_description = '同步夹具型号列表'
|
||||||
|
|
||||||
# url = '/api/fixture_model/list'
|
url = '/api/fixture_model/list'
|
||||||
|
|
||||||
# # 定时同步夹具型号列表
|
# 定时同步夹具型号列表
|
||||||
# def sync_fixture_model_yesterday(self):
|
def sync_fixture_model_yesterday(self):
|
||||||
# config = self.env['res.config.settings'].get_values()
|
config = self.env['res.config.settings'].get_values()
|
||||||
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||||
# strUrl = config['sf_url'] + self.url
|
strUrl = config['sf_url'] + self.url
|
||||||
# r = requests.post(strUrl, json={}, data=None, headers=headers)
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
# r = r.json()
|
r = r.json()
|
||||||
# result = json.loads(r['result'])
|
result = json.loads(r['result'])
|
||||||
# if result['status'] == 1:
|
if result['status'] == 1:
|
||||||
# if result.get('fixture_model_yesterday_list'):
|
if result.get('fixture_model_yesterday_list'):
|
||||||
# for item in result['fixture_model_yesterday_list']:
|
for item in result['fixture_model_yesterday_list']:
|
||||||
# if item:
|
if item:
|
||||||
# fixture_model = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
|
fixture_model = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
|
||||||
# val = {
|
val = {
|
||||||
# "name": item['name'],
|
"name": item['name'],
|
||||||
# "code": item['code'],
|
"code": item['code'],
|
||||||
# "fixture_material_id": self.env['sf.fixture.material'].search(
|
"fixture_material_id": self.env['sf.fixture.material'].search(
|
||||||
# [('code', '=', item['fixture_material_code'])]).id,
|
[('code', '=', item['fixture_material_code'])]).id,
|
||||||
# "multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
||||||
# [('code', '=', item['multi_mounting_type_code'])]).id,
|
[('code', '=', item['multi_mounting_type_code'])]).id,
|
||||||
# "brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
||||||
# "model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||||
# "status": item['status'],
|
"status": item['status'],
|
||||||
# "active": item['active'],
|
"active": item['active'],
|
||||||
# }
|
}
|
||||||
# if not fixture_model:
|
if not fixture_model:
|
||||||
# self.create(val)
|
self.create(val)
|
||||||
# else:
|
else:
|
||||||
# fixture_model.write(val)
|
fixture_model.write(val)
|
||||||
|
|
||||||
# else:
|
else:
|
||||||
# raise ValidationError("夹具型号认证未通过")
|
raise ValidationError("夹具型号认证未通过")
|
||||||
|
|
||||||
# # 定时同步所有夹具型号列表
|
# 定时同步所有夹具型号列表
|
||||||
# def sync_all_fixture_model(self):
|
def sync_all_fixture_model(self):
|
||||||
# config = self.env['res.config.settings'].get_values()
|
config = self.env['res.config.settings'].get_values()
|
||||||
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||||
# strUrl = config['sf_url'] + self.url
|
strUrl = config['sf_url'] + self.url
|
||||||
# r = requests.post(strUrl, json={}, data=None, headers=headers)
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
# r = r.json()
|
r = r.json()
|
||||||
# result = json.loads(r['result'])
|
result = json.loads(r['result'])
|
||||||
# # print('result:%s' % result)
|
# print('result:%s' % result)
|
||||||
# if result['status'] == 1:
|
if result['status'] == 1:
|
||||||
# if result.get('fixture_model_all_list'):
|
if result.get('fixture_model_all_list'):
|
||||||
# for item in result['fixture_model_all_list']:
|
for item in result['fixture_model_all_list']:
|
||||||
# if item:
|
if item:
|
||||||
# fixture_model = self.search([('code', '=', item['code']), ('active', 'in', [True, False])])
|
fixture_model = self.search([('code', '=', item['code']), ('active', 'in', [True, False])])
|
||||||
# val = {
|
val = {
|
||||||
# "name": item['name'],
|
"name": item['name'],
|
||||||
# "code": item['code'],
|
"code": item['code'],
|
||||||
# "fixture_material_id": self.env['sf.fixture.material'].search(
|
"fixture_material_id": self.env['sf.fixture.material'].search(
|
||||||
# [('code', '=', item['fixture_material_code'])]).id,
|
[('code', '=', item['fixture_material_code'])]).id,
|
||||||
# "multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
||||||
# [('code', '=', item['multi_mounting_type_code'])]).id,
|
[('code', '=', item['multi_mounting_type_code'])]).id,
|
||||||
# "brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
||||||
# "model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||||
# "status": item['status'],
|
"status": item['status'],
|
||||||
# "active": item['active'],
|
"active": item['active'],
|
||||||
# }
|
}
|
||||||
# if not fixture_model:
|
if not fixture_model:
|
||||||
# self.create(val)
|
self.create(val)
|
||||||
# else:
|
else:
|
||||||
# fixture_model.write(val)
|
fixture_model.write(val)
|
||||||
# else:
|
else:
|
||||||
# raise ValidationError("夹具型号认证未通过")
|
raise ValidationError("夹具型号认证未通过")
|
||||||
|
|
||||||
|
|
||||||
# class SyncfixtureMaterialsBasicParameters(models.Model):
|
class SyncfixtureMaterialsBasicParameters(models.Model):
|
||||||
# _inherit = 'sf.fixture.materials.basic.parameters'
|
_inherit = 'sf.fixture.materials.basic.parameters'
|
||||||
# _description = '同步夹具型号基本参数列表'
|
_description = '同步夹具型号基本参数列表'
|
||||||
|
|
||||||
# url = '/api/fixture_parameters/list'
|
url = '/api/fixture_parameters/list'
|
||||||
|
|
||||||
# # 定时同步夹具型号基本信息
|
# 定时同步夹具型号基本信息
|
||||||
# def sync_fixture_materials_basic_parameters_yesterday(self):
|
def sync_fixture_materials_basic_parameters_yesterday(self):
|
||||||
# config = self.env['res.config.settings'].get_values()
|
config = self.env['res.config.settings'].get_values()
|
||||||
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||||
# strUrl = config['sf_url'] + self.url
|
strUrl = config['sf_url'] + self.url
|
||||||
# r = requests.post(strUrl, json={}, data=None, headers=headers)
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
# r = r.json()
|
r = r.json()
|
||||||
# result = json.loads(r['result'])
|
result = json.loads(r['result'])
|
||||||
# if result['status'] == 1:
|
if result['status'] == 1:
|
||||||
# if result.get('fixture_parameters_yesterday_list'):
|
if result.get('fixture_parameters_yesterday_list'):
|
||||||
# all_list = result.get('fixture_parameters_yesterday_list')
|
all_list = result.get('fixture_parameters_yesterday_list')
|
||||||
# if all_list.get('zero_chuck_all_list'):
|
if all_list.get('zero_chuck_all_list'):
|
||||||
# self._write_or_create(all_list.get('zero_chuck_yesterday_list'), '零点卡盘')
|
self._write_or_create(all_list.get('zero_chuck_yesterday_list'), '零点卡盘')
|
||||||
# if all_list.get('zero_tray_all_list'):
|
if all_list.get('zero_tray_all_list'):
|
||||||
# self._write_or_create(all_list.get('zero_tray_yesterday_list'), '零点托盘')
|
self._write_or_create(all_list.get('zero_tray_yesterday_list'), '零点托盘')
|
||||||
# if all_list.get('pneumatic_fixture_all_list'):
|
if all_list.get('pneumatic_fixture_all_list'):
|
||||||
# self._write_or_create(all_list.get('pneumatic_fixture_yesterday_list'), '气动夹具')
|
self._write_or_create(all_list.get('pneumatic_fixture_yesterday_list'), '气动夹具')
|
||||||
# if all_list.get('jaw_vice_all_list'):
|
if all_list.get('jaw_vice_all_list'):
|
||||||
# self._write_or_create(all_list.get('jaw_vice_yesterday_list'), '虎钳夹具')
|
self._write_or_create(all_list.get('jaw_vice_yesterday_list'), '虎钳夹具')
|
||||||
# if all_list.get('magnet_fixture_all_list'):
|
if all_list.get('magnet_fixture_all_list'):
|
||||||
# self._write_or_create(all_list.get('magnet_fixture_yesterday_list'), '磁吸夹具')
|
self._write_or_create(all_list.get('magnet_fixture_yesterday_list'), '磁吸夹具')
|
||||||
# if all_list.get('adapter_board_all_list'):
|
if all_list.get('adapter_board_all_list'):
|
||||||
# self._write_or_create(all_list.get('adapter_board_yesterday_list'), '转接板(锁板)夹具')
|
self._write_or_create(all_list.get('adapter_board_yesterday_list'), '转接板(锁板)夹具')
|
||||||
# if all_list.get('scroll_chuck_all_list'):
|
if all_list.get('scroll_chuck_all_list'):
|
||||||
# self._write_or_create(all_list.get('scroll_chuck_yesterday_list'), '三爪卡盘')
|
self._write_or_create(all_list.get('scroll_chuck_yesterday_list'), '三爪卡盘')
|
||||||
# if all_list.get('air_tray_all_list'):
|
if all_list.get('air_blow_tray_all_list'):
|
||||||
# self._write_or_create(all_list.get('air_tray_all_list'),'气吹托盘')
|
self._write_or_create(all_list.get('air_tray_yesterday_list'), '气吸托盘')
|
||||||
# if all_list.get('magnet_tray_all_list'):
|
if all_list.get('magnet_tray_all_list'):
|
||||||
# self._write_or_create(all_list.get('magnet_tray_all_list'),'磁吸托盘')
|
self._write_or_create(all_list.get('magnet_tray_yesterday_list'), '磁吸托盘')
|
||||||
# else:
|
if all_list.get('positioning_partition_all_list'):
|
||||||
# raise ValidationError("夹具型号基本参数认证未通过")
|
self._write_or_create(all_list.get('positioning_partition_all_list'), '定位隔板')
|
||||||
|
else:
|
||||||
|
raise ValidationError("夹具型号基本参数认证未通过")
|
||||||
|
|
||||||
# # 定时同步所有夹具型号基本信息
|
# 定时同步所有夹具型号基本信息
|
||||||
# def sync_all_fixture_materials_basic_parameters(self):
|
def sync_all_fixture_materials_basic_parameters(self):
|
||||||
# config = self.env['res.config.settings'].get_values()
|
config = self.env['res.config.settings'].get_values()
|
||||||
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||||
# strUrl = config['sf_url'] + self.url
|
strUrl = config['sf_url'] + self.url
|
||||||
# r = requests.post(strUrl, json={}, data=None, headers=headers)
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
# r = r.json()
|
r = r.json()
|
||||||
# result = json.loads(r['result'])
|
result = json.loads(r['result'])
|
||||||
# if result['status'] == 1:
|
if result['status'] == 1:
|
||||||
# if result.get('fixture_parameters_all_list'):
|
if result.get('fixture_parameters_all_list'):
|
||||||
# all_list = result.get('fixture_parameters_all_list')
|
all_list = result.get('fixture_parameters_all_list')
|
||||||
# if all_list.get('zero_chuck_all_list'):
|
if all_list.get('zero_chuck_all_list'):
|
||||||
# self._write_or_create(all_list.get('zero_chuck_all_list'), '零点卡盘')
|
self._write_or_create(all_list.get('zero_chuck_all_list'), '零点卡盘')
|
||||||
# if all_list.get('zero_tray_all_list'):
|
if all_list.get('zero_tray_all_list'):
|
||||||
# self._write_or_create(all_list.get('zero_tray_all_list'), '零点托盘')
|
self._write_or_create(all_list.get('zero_tray_all_list'), '零点托盘')
|
||||||
# if all_list.get('pneumatic_fixture_all_list'):
|
if all_list.get('pneumatic_fixture_all_list'):
|
||||||
# self._write_or_create(all_list.get('pneumatic_fixture_all_list'), '气动夹具')
|
self._write_or_create(all_list.get('pneumatic_fixture_all_list'), '气动夹具')
|
||||||
# if all_list.get('jaw_vice_all_list'):
|
if all_list.get('jaw_vice_all_list'):
|
||||||
# self._write_or_create(all_list.get('jaw_vice_all_list'), '虎钳夹具')
|
self._write_or_create(all_list.get('jaw_vice_all_list'), '虎钳夹具')
|
||||||
# if all_list.get('magnet_fixture_all_list'):
|
if all_list.get('magnet_fixture_all_list'):
|
||||||
# self._write_or_create(all_list.get('magnet_fixture_all_list'), '磁吸夹具')
|
self._write_or_create(all_list.get('magnet_fixture_all_list'), '磁吸夹具')
|
||||||
# if all_list.get('adapter_board_all_list'):
|
if all_list.get('adapter_board_all_list'):
|
||||||
# self._write_or_create(all_list.get('adapter_board_all_list'), '转接板(锁板)夹具')
|
self._write_or_create(all_list.get('adapter_board_all_list'), '转接板(锁板)夹具')
|
||||||
# if all_list.get('scroll_chuck_all_list'):
|
if all_list.get('scroll_chuck_all_list'):
|
||||||
# self._write_or_create(all_list.get('scroll_chuck_all_list'), '三爪卡盘')
|
self._write_or_create(all_list.get('scroll_chuck_all_list'), '三爪卡盘')
|
||||||
# if all_list.get('air_tray_all_list'):
|
if all_list.get('air_blow_tray_all_list'):
|
||||||
# self._write_or_create(all_list.get('air_tray_all_list'),'气吹托盘')
|
self._write_or_create(all_list.get('air_tray_all_list'), '气吸托盘')
|
||||||
# if all_list.get('magnet_tray_all_list'):
|
if all_list.get('magnet_tray_all_list'):
|
||||||
# self._write_or_create(all_list.get('magnet_tray_all_list'),'磁吸托盘')
|
self._write_or_create(all_list.get('magnet_tray_all_list'), '磁吸托盘')
|
||||||
# else:
|
if all_list.get('positioning_partition_all_list'):
|
||||||
# raise ValidationError("夹具型号基本参数认证未通过")
|
self._write_or_create(all_list.get('positioning_partition_all_list'), '定位隔板')
|
||||||
|
else:
|
||||||
|
raise ValidationError("夹具型号基本参数认证未通过")
|
||||||
|
|
||||||
# def _write_or_create(self, fixture_parameters_list, material_name):
|
def _write_or_create(self, fixture_parameters_list, material_name):
|
||||||
# for item in fixture_parameters_list:
|
for item in fixture_parameters_list:
|
||||||
# if item:
|
if item:
|
||||||
# basic_parameters = self.search([('code', '=', item.get('code')), ('active', 'in', [True, False])])
|
basic_parameters = self.search([('code', '=', item.get('code')), ('active', 'in', [True, False])])
|
||||||
# if not basic_parameters:
|
if not basic_parameters:
|
||||||
# self.create(self._get_basic_parameters_list(item, material_name))
|
self.create(self._get_basic_parameters_list(item, material_name))
|
||||||
# else:
|
else:
|
||||||
# basic_parameters.write(self._get_basic_parameters_list(item, material_name))
|
basic_parameters.write(self._get_basic_parameters_list(item, material_name))
|
||||||
|
|
||||||
|
|
||||||
class SyncFunctionalFixtureType(models.Model):
|
class SyncFunctionalFixtureType(models.Model):
|
||||||
@@ -3241,93 +3244,3 @@ class EmbryoRedundancySync(models.Model):
|
|||||||
"active": item['active'],
|
"active": item['active'],
|
||||||
"remark": item['remark'],
|
"remark": item['remark'],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SyncFixtureModel(models.Model):
|
|
||||||
_inherit = 'sf.fixture.model'
|
|
||||||
_description = 'Redis 优先同步夹具型号'
|
|
||||||
|
|
||||||
def sync_all_fixture_model(self):
|
|
||||||
rc = RedisClient()
|
|
||||||
key = 'mrs:fixture_model_all_list'
|
|
||||||
all_list = rc.get_json(key)
|
|
||||||
if not all_list:
|
|
||||||
raise ValidationError(f"Redis 中未找到 key={key}")
|
|
||||||
|
|
||||||
for item in all_list:
|
|
||||||
if not item or not item.get('code'):
|
|
||||||
continue
|
|
||||||
|
|
||||||
record = self.search([('code', '=', item['code'])], limit=1)
|
|
||||||
vals = {
|
|
||||||
'name': item['name'],
|
|
||||||
'code': item['code'],
|
|
||||||
'fixture_material_id': self.env['sf.fixture.material']
|
|
||||||
.search([('code', '=', item['fixture_material_code'])], limit=1).id,
|
|
||||||
'multi_mounting_type_id': self.env['sf.multi_mounting.type']
|
|
||||||
.search([('code', '=', item['multi_mounting_type_code'])], limit=1).id,
|
|
||||||
'brand_id': self.env['sf.machine.brand']
|
|
||||||
.search([('code', '=', item['brand_code'])], limit=1).id,
|
|
||||||
'model_file': base64.b64decode(item['model_file']) if item.get('model_file') else False,
|
|
||||||
'status': item['status'],
|
|
||||||
'active': item['active'],
|
|
||||||
}
|
|
||||||
if record:
|
|
||||||
record.write(vals)
|
|
||||||
else:
|
|
||||||
self.create(vals)
|
|
||||||
|
|
||||||
|
|
||||||
class SyncfixtureMaterialsBasicParameters(models.Model):
|
|
||||||
_inherit = 'sf.fixture.materials.basic.parameters'
|
|
||||||
_description = 'Redis 优先同步夹具基本参数'
|
|
||||||
|
|
||||||
def sync_all_fixture_materials_basic_parameters(self):
|
|
||||||
rc = RedisClient()
|
|
||||||
key = 'mrs:fixture_param_all_list'
|
|
||||||
all_list = rc.get_json(key)
|
|
||||||
if not all_list:
|
|
||||||
raise ValidationError(f"Redis 中未找到 key={key}")
|
|
||||||
|
|
||||||
def _sync_list(param_list, material_name):
|
|
||||||
for item in param_list or []:
|
|
||||||
if not item or not item.get('code'):
|
|
||||||
continue
|
|
||||||
record = self.search([('code', '=', item['code'])], limit=1)
|
|
||||||
vals = self._get_basic_parameters_list(item, material_name)
|
|
||||||
if record:
|
|
||||||
record.write(vals)
|
|
||||||
else:
|
|
||||||
self.create(vals)
|
|
||||||
|
|
||||||
_sync_list(all_list.get('zero_chuck_all_list'), '零点卡盘')
|
|
||||||
_sync_list(all_list.get('zero_tray_all_list'), '零点托盘')
|
|
||||||
_sync_list(all_list.get('pneumatic_fixture_all_list'), '气动夹具')
|
|
||||||
_sync_list(all_list.get('jaw_vice_all_list'), '虎钳夹具')
|
|
||||||
_sync_list(all_list.get('magnet_fixture_all_list'), '磁吸夹具')
|
|
||||||
_sync_list(all_list.get('adapter_board_all_list'), '转接板(锁板)夹具')
|
|
||||||
_sync_list(all_list.get('scroll_chuck_all_list'), '三爪卡盘')
|
|
||||||
_sync_list(all_list.get('air_tray_all_list'), '气吹托盘')
|
|
||||||
_sync_list(all_list.get('magnet_tray_all_list'), '磁吸托盘')
|
|
||||||
|
|
||||||
def _get_basic_parameters_list(self, item, material_name):
|
|
||||||
"""
|
|
||||||
统一结构化 item 数据,供写入模型字段使用(你应当根据 material_name 自定义字段映射)
|
|
||||||
"""
|
|
||||||
return {
|
|
||||||
'name': item.get('name'),
|
|
||||||
'code': item.get('code'),
|
|
||||||
'length': item.get('length'),
|
|
||||||
'width': item.get('width'),
|
|
||||||
'height': item.get('height'),
|
|
||||||
'diameter': item.get('diameter'),
|
|
||||||
'weight': item.get('weight'),
|
|
||||||
'fixture_model_id': self.env['sf.fixture.model'].search([('code', '=', item.get('fixture_model_code'))], limit=1).id,
|
|
||||||
'materials_model_id': self.env['sf.materials.model'].search([('code', '=', item.get('material_code'))], limit=1).id,
|
|
||||||
'active': item.get('active', True),
|
|
||||||
# 你可以根据 material_name 判断类型并补充字段
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user