Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/修改机床参数bug
This commit is contained in:
@@ -67,6 +67,10 @@ class MrsMaterialModel(models.Model):
|
||||
mf_materia_post = fields.Char("热处理后密度")
|
||||
density = fields.Float("密度(kg/m³)")
|
||||
materials_id = fields.Many2one('sf.production.materials', "材料名")
|
||||
tensile_strength = fields.Float("拉伸强度(n/mm²)")
|
||||
hardness = fields.Float("硬度(hrc)")
|
||||
rough_machining = fields.Float("粗加工Vc(m/min)")
|
||||
finish_machining = fields.Float("精加工Vc(m/min)")
|
||||
remark = fields.Text("备注")
|
||||
gain_way = fields.Selection(
|
||||
[("自加工", "自加工"), ("外协", "外协"), ("采购", "采购")],
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<tree string="表面工艺类别" default_order="sequence, id" create="0" edit="0" delete="1">
|
||||
<field name="sequence" widget="handle" string="序号"/>
|
||||
<field name="code" />
|
||||
<field name="code"/>
|
||||
<field name="name" string="名称"/>
|
||||
</tree>
|
||||
</field>
|
||||
@@ -105,8 +105,8 @@
|
||||
<field name="model">sf.production.process</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="表面工艺" create="0" edit="0" delete="1">
|
||||
<field name="process_encode" />
|
||||
<field name="name" string="名称"/>
|
||||
<field name="process_encode"/>
|
||||
<field name="name" string="名称"/>
|
||||
<field name="remark"/>
|
||||
</tree>
|
||||
</field>
|
||||
@@ -204,12 +204,15 @@
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name" readonly="1"/>
|
||||
<field name="name" readonly="1"/>
|
||||
<field name="gain_way" required="1"/>
|
||||
<field name="tensile_strength" required="1"/>
|
||||
<field name="hardness" required="1"/>
|
||||
<field name="density" readonly="1"/>
|
||||
</group>
|
||||
<group>
|
||||
|
||||
<field name="rough_machining" required="1"/>
|
||||
<field name="finish_machining" required="1"/>
|
||||
<field name="need_h" default="false" readonly="1"/>
|
||||
<field name="mf_materia_post" attrs="{'invisible':[('need_h','=',False)]} "
|
||||
readonly="1"/>
|
||||
@@ -242,8 +245,13 @@
|
||||
<field name="materials_no" readonly="1"/>
|
||||
<field name="name" readonly="1"/>
|
||||
<field name="gain_way"/>
|
||||
<field name="need_h" readonly="1"/>
|
||||
<field name="density" readonly="1"/>
|
||||
<field name="tensile_strength"/>
|
||||
<field name="hardness"/>
|
||||
<field name="need_h"/>
|
||||
<field name="density"/>
|
||||
<field name="rough_machining"/>
|
||||
<field name="finish_machining"/>
|
||||
<field name="remark"/>
|
||||
<field name='materials_id' invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
@@ -353,26 +361,26 @@
|
||||
</record>
|
||||
|
||||
|
||||
<!-- <record model="ir.ui.view" id="sf_tray_form">-->
|
||||
<!-- <field name="name">sf.tray.form</field>-->
|
||||
<!-- <field name="model">sf.tray</field>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <form string="托盘">-->
|
||||
<!-- <header>-->
|
||||
<!-- <field name='state' widget="radio" options="{'horizontal': True}"/>-->
|
||||
<!-- </header>-->
|
||||
<!-- <sheet>-->
|
||||
<!-- <group name="group1">-->
|
||||
<!-- <group>-->
|
||||
<!-- <field name="code" required="1"/>-->
|
||||
<!-- </group>-->
|
||||
<!-- <group>-->
|
||||
<!-- <field name="name" required="1"/>-->
|
||||
<!-- </group>-->
|
||||
<!-- </group>-->
|
||||
<!-- </sheet>-->
|
||||
<!-- </form>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
<!-- <record model="ir.ui.view" id="sf_tray_form">-->
|
||||
<!-- <field name="name">sf.tray.form</field>-->
|
||||
<!-- <field name="model">sf.tray</field>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <form string="托盘">-->
|
||||
<!-- <header>-->
|
||||
<!-- <field name='state' widget="radio" options="{'horizontal': True}"/>-->
|
||||
<!-- </header>-->
|
||||
<!-- <sheet>-->
|
||||
<!-- <group name="group1">-->
|
||||
<!-- <group>-->
|
||||
<!-- <field name="code" required="1"/>-->
|
||||
<!-- </group>-->
|
||||
<!-- <group>-->
|
||||
<!-- <field name="name" required="1"/>-->
|
||||
<!-- </group>-->
|
||||
<!-- </group>-->
|
||||
<!-- </sheet>-->
|
||||
<!-- </form>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -22,11 +22,10 @@
|
||||
'views/ftp_button.xml',
|
||||
|
||||
'views/compensation.xml',
|
||||
|
||||
'views/SfWorkOrderBarcodes.xml',
|
||||
# 'views/SfWorkOrderBarcodes.xml',
|
||||
'views/WorkCenterBarcodes.xml',
|
||||
'views/Stock_picking_Barcodes.xml',
|
||||
'views/machine_monitor.xml',
|
||||
# 'views/machine_monitor.xml',
|
||||
'views/machine_info_present.xml',
|
||||
'views/delivery_record.xml',
|
||||
'views/res_config_settings_views.xml',
|
||||
|
||||
@@ -13,6 +13,11 @@ from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.addons.sf_machine_connect.models import py2opcua, ftp_operate
|
||||
|
||||
import shutil
|
||||
from io import BytesIO
|
||||
from zipfile import ZipFile
|
||||
from odoo.exceptions import MissingError
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -537,21 +542,69 @@ class WorkCenterBarcode(models.Model):
|
||||
else:
|
||||
return False
|
||||
|
||||
def cnc_file_download(self):
|
||||
"""
|
||||
一个下载当前cnc所有nc文件为一个zip包的功能
|
||||
"""
|
||||
self.ensure_one()
|
||||
|
||||
class CuttingTimeToolType(models.Model):
|
||||
_inherit = 'sf.cutting_tool.type'
|
||||
total_cut_time = fields.Char(string='总切削时长')
|
||||
predict_life_time = fields.Char(string='预估寿命')
|
||||
# 只能看到未被占用的刀位,或者有提示说占没占用
|
||||
tool_position = fields.Char(string='选择刀位')
|
||||
# cnc_ids = fields.One2many(string='选择机床')
|
||||
is_connect_tool_position = fields.Boolean(string='是否已绑定刀位', default=False)
|
||||
# 如果没有附件,直接返回
|
||||
if not self.cnc_ids:
|
||||
return
|
||||
|
||||
def tool_connect_machine(self):
|
||||
pass
|
||||
# 处理第一个附件的文件名
|
||||
first_attachment = self.cnc_ids[0].cnc_id
|
||||
file_name = first_attachment.display_name.split('-')[0] + '.zip'
|
||||
|
||||
def tool_unconnect_machine(self):
|
||||
pass
|
||||
# 创建一个内存文件和一个zip文件
|
||||
memory_file = BytesIO()
|
||||
with ZipFile(memory_file, 'w') as zipf:
|
||||
# 遍历需要下载的附件
|
||||
for item in self.cnc_ids:
|
||||
a = item.cnc_id
|
||||
datas = base64.standard_b64decode(a.datas)
|
||||
|
||||
# 将nc文件写入zip文件
|
||||
zipf.writestr(a.display_name, datas)
|
||||
|
||||
# 然后可以创建一个ir.attachment对象,将生成的zip文件保存为一个新的附件
|
||||
memory_file.seek(0)
|
||||
output = base64.b64encode(memory_file.read())
|
||||
memory_file.close()
|
||||
|
||||
attachment_data = {
|
||||
'name': file_name,
|
||||
'type': 'binary',
|
||||
'res_model': self._name,
|
||||
'res_id': self.id,
|
||||
'datas': output
|
||||
}
|
||||
attachment = self.env['ir.attachment'].create(attachment_data)
|
||||
|
||||
# 返回附件的下载链接
|
||||
download_url = '/web/content/%s?download=true' % attachment.id
|
||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': str(base_url) + download_url,
|
||||
'target': 'self',
|
||||
}
|
||||
|
||||
|
||||
# class CuttingTimeToolType(models.Model):
|
||||
# _inherit = 'sf.cutting_tool.type'
|
||||
# total_cut_time = fields.Char(string='总切削时长')
|
||||
# predict_life_time = fields.Char(string='预估寿命')
|
||||
# # 只能看到未被占用的刀位,或者有提示说占没占用
|
||||
# tool_position = fields.Char(string='选择刀位')
|
||||
# # cnc_ids = fields.One2many(string='选择机床')
|
||||
# is_connect_tool_position = fields.Boolean(string='是否已绑定刀位', default=False)
|
||||
#
|
||||
# def tool_connect_machine(self):
|
||||
# pass
|
||||
#
|
||||
# def tool_unconnect_machine(self):
|
||||
# pass
|
||||
|
||||
|
||||
class DeliveryRecord(models.Model):
|
||||
@@ -579,4 +632,3 @@ class DeliveryRecord(models.Model):
|
||||
# return super().create(values)
|
||||
# except:
|
||||
# raise Exception('b_purchase_order.py:create()')
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="inherit_id" ref="sf_manufacturing.view_mrp_production_workorder_tray_form_inherit_sf"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//header" position="inside">
|
||||
<button string="程序下载" name="cnc_file_download" type="object" class="oe_highlight"/>
|
||||
</xpath>
|
||||
<xpath expr="//page//field[@name='cnc_ids']" position="before">
|
||||
<group>
|
||||
<group>
|
||||
|
||||
@@ -99,25 +99,33 @@ class sfMaterialModel(models.Model):
|
||||
if result['status'] == 1:
|
||||
for item in result['materials_model_yesterday_list']:
|
||||
if item:
|
||||
brand = self.env['sf.materials.model'].search(
|
||||
materials_model = self.env['sf.materials.model'].search(
|
||||
[("materials_no", '=', item['materials_no'])])
|
||||
if brand:
|
||||
brand.id = item['id'],
|
||||
brand.name = item['name'],
|
||||
brand.materials_no = item['materials_no'],
|
||||
brand.remark = item['remark'],
|
||||
brand.active = item['active'],
|
||||
brand.mf_materia_post = item['mf_materia_post'],
|
||||
brand.materials_id = self.env['sf.production.materials'].search(
|
||||
if materials_model:
|
||||
materials_model.id = item['id'],
|
||||
materials_model.name = item['name'],
|
||||
materials_model.materials_no = item['materials_no'],
|
||||
materials_model.remark = item['remark'],
|
||||
materials_model.tensile_strength = item['tensile_strength'],
|
||||
materials_model.hardness = item['hardness'],
|
||||
materials_model.materials_no = item['materials_no'],
|
||||
materials_model.rough_machining = item['rough_machining'],
|
||||
materials_model.finish_machining = item['finish_machining'],
|
||||
materials_model.mf_materia_post = item['mf_materia_post'],
|
||||
materials_model.materials_id = self.env['sf.production.materials'].search(
|
||||
[("materials_no", '=', item['materials_id.materials_no'])]).id,
|
||||
brand.need_h = item['need_h'],
|
||||
brand.density = item['density']
|
||||
materials_model.need_h = item['need_h'],
|
||||
materials_model.density = item['density']
|
||||
else:
|
||||
self.env['sf.materials.model'].create({
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"materials_no": item['materials_no'],
|
||||
"remark": item['remark'],
|
||||
"tensile_strength": item['tensile_strength'],
|
||||
"hardness": item['hardness'],
|
||||
"rough_machining": item['rough_machining'],
|
||||
"finish_machining": item['finish_machining'],
|
||||
"active": item['active'],
|
||||
"materials_id": self.env['sf.production.materials'].search(
|
||||
[("materials_no", '=', item['materials_id.materials_no'])]).id,
|
||||
@@ -143,14 +151,18 @@ class sfMaterialModel(models.Model):
|
||||
if result['status'] == 1:
|
||||
for item in result['materials_model_all_list']:
|
||||
if item:
|
||||
brand = self.env['sf.materials.model'].search(
|
||||
materials_model = self.env['sf.materials.model'].search(
|
||||
[("materials_no", '=', item['materials_no'])])
|
||||
if not brand:
|
||||
if not materials_model:
|
||||
self.env['sf.materials.model'].create({
|
||||
"name": item['name'],
|
||||
"materials_no": item['materials_no'],
|
||||
"remark": item['remark'],
|
||||
"active": item['active'],
|
||||
"tensile_strength": item['tensile_strength'],
|
||||
"hardness": item['hardness'],
|
||||
"rough_machining": item['rough_machining'],
|
||||
"finish_machining": item['finish_machining'],
|
||||
"materials_id": self.env['sf.production.materials'].search(
|
||||
[("materials_no", '=', item['materials_id.materials_no'])]).id,
|
||||
"need_h": item['need_h'],
|
||||
@@ -573,7 +585,6 @@ class MachineBrand(models.Model):
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
|
||||
|
||||
class MachineToolType(models.Model):
|
||||
_inherit = 'sf.machine_tool.type'
|
||||
_description = '机床型号'
|
||||
@@ -1492,7 +1503,6 @@ class SyncFixtureModel(models.Model):
|
||||
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
||||
[('code', '=', item['multi_mounting_type_code'])]).id,
|
||||
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
||||
"manufacturer_model_number": item['manufacturer_model_number'],
|
||||
"clamping_way": item['clamping_way'],
|
||||
"port_type": item['port_type'],
|
||||
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||
@@ -1522,7 +1532,6 @@ class SyncFixtureModel(models.Model):
|
||||
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
||||
[('code', '=', item['multi_mounting_type_code'])]).id,
|
||||
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
||||
"manufacturer_model_number": item['manufacturer_model_number'],
|
||||
"clamping_way": item['clamping_way'],
|
||||
"port_type": item['port_type'],
|
||||
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||
@@ -1574,7 +1583,6 @@ class SyncFixtureModel(models.Model):
|
||||
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
||||
[('code', '=', item['multi_mounting_type_code'])]).id,
|
||||
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
||||
"manufacturer_model_number": item['manufacturer_model_number'],
|
||||
"clamping_way": item['clamping_way'],
|
||||
"port_type": item['port_type'],
|
||||
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||
@@ -1604,7 +1612,6 @@ class SyncFixtureModel(models.Model):
|
||||
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
||||
[('code', '=', item['multi_mounting_type_code'])]).id,
|
||||
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
||||
"manufacturer_model_number": item['manufacturer_model_number'],
|
||||
"clamping_way": item['clamping_way'],
|
||||
"port_type": item['port_type'],
|
||||
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||
@@ -2031,8 +2038,7 @@ class SfToolModel(models.Model):
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
|
||||
# 同步所有刀具型号列表
|
||||
# 同步所有刀具型号列表
|
||||
def sync_all_tool_model(self):
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
|
||||
Reference in New Issue
Block a user