diff --git a/sf_base/__manifest__.py b/sf_base/__manifest__.py
index 0640922a..bcb25c81 100644
--- a/sf_base/__manifest__.py
+++ b/sf_base/__manifest__.py
@@ -18,7 +18,6 @@
'views/common_view.xml',
'views/fixture_view.xml',
'views/functional_fixture_view.xml',
- # 'views/quick_easy_order_view.xml',
'views/menu_view.xml',
"views/tool_views.xml",
"views/tool_menu.xml",
diff --git a/sf_base/models/__init__.py b/sf_base/models/__init__.py
index 20bf8c6b..483787eb 100644
--- a/sf_base/models/__init__.py
+++ b/sf_base/models/__init__.py
@@ -3,7 +3,7 @@ from . import common
from . import tool_base_new
from . import fixture
from . import functional_fixture
-# from . import quick_easy_order
+
diff --git a/sf_base/models/fixture.py b/sf_base/models/fixture.py
index 727f58bc..bbaecb7c 100644
--- a/sf_base/models/fixture.py
+++ b/sf_base/models/fixture.py
@@ -26,7 +26,6 @@ class FixtureModel(models.Model):
_name = 'sf.fixture.model'
_description = "夹具型号"
- code = fields.Char(string='编码')
name = fields.Char(string="名称", size=15)
fixture_material_id = fields.Many2one('sf.fixture.material', string="夹具物料", )
fixture_material_type = fields.Char(string="夹具物料类型", related='fixture_material_id.name', store=True)
@@ -53,10 +52,38 @@ class FixtureModel(models.Model):
screw_size = fields.Integer(string="螺牙大小[mm]", size=6)
active = fields.Boolean('有效', default=True)
- # @api.model
- # def create(self, vals):
- # obj = super(FixtureModel, self).create(vals)
- # return obj
+ def _get_code(self, fixture_model_type_code):
+ fixture_model = self.env['sf.fixture.model'].sudo().search(
+ [('code', 'ilike', fixture_model_type_code)],
+ limit=1,
+ order="id desc")
+ if not fixture_model:
+ num = "%03d" % 1
+ else:
+ m = int(fixture_model.code[-3:]) + 1
+ num = "%03d" % m
+ return "%s%s" % (fixture_model_type_code, num)
+ code = fields.Char(string='编码', readonly=True)
+ def _onchange_fixture_material_id(self, fixture_material_id):
+ if fixture_material_id:
+ if fixture_material_id.name == "气动夹具":
+ code = self._get_code("JKM-C-JJWL-QDJJ-")
+ elif fixture_material_id.name == "转接板(锁板)夹具":
+ code = self._get_code("JKM-C-JJWL-ZJBJJ-")
+ elif fixture_material_id.name == "磁吸夹具":
+ code = self._get_code("JKM-C-JJWL-CXJJ-")
+ elif fixture_material_id.name == "虎钳夹具":
+ code = self._get_code("JKM-C-JJWL-HQJJ-")
+ else:
+ code = self._get_code("JKM-C-JJWL-LDKP-")
+ return code
+ @api.model
+ def create(self, vals):
+ obj = super(FixtureModel, self).create(vals)
+ if obj.fixture_material_id:
+ code = self._onchange_fixture_material_id(obj.fixture_material_id)
+ obj.code = code
+ return obj
diff --git a/sf_base/models/quick_easy_order.py b/sf_base/models/quick_easy_order.py
deleted file mode 100644
index c39b3fc5..00000000
--- a/sf_base/models/quick_easy_order.py
+++ /dev/null
@@ -1,26 +0,0 @@
-from odoo import models, fields
-import datetime
-import base64
-
-
-class QuickEasyOrder(models.Model):
- _name = 'quick.easy.order'
- _description = '简易下单'
-
- name = fields.Char('订单编号', default=lambda self: self.env['ir.sequence'].next_by_code('quick.easy.order'))
- machining_precision = fields.Selection([
- ('0.10', '±0.10mm'),
- ('0.05', '±0.05mm'),
- ('0.03', '±0.03mm'),
- ('0.02', '±0.02mm'),
- ('0.01', '±0.01mm')], string='加工精度')
- material_id = fields.Many2one('sf.production.materials', '材料')
- material_model_id = fields.Many2one('sf.materials.model', '型号')
- process_id = fields.Many2one('sf.production.process', string='表面工艺')
- parameter_ids = fields.One2many('sf.production.process.parameter', 'process_id', string='可选参数')
- quantity = fields.Integer('数量')
- price = fields.Float('总价')
- model_file = fields.Binary('模型文件')
- upload_model_file = fields.Many2many('ir.attachment', 'upload_qf_model_file_attachment_ref', string='上传模型文件')
- delivery_time = fields.Date('交货日期')
- customer_id = fields.Many2one('res.partner', string='客户', default=lambda self: self.env.user.partner_id.id)
diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py
index 575afd5f..2891da17 100644
--- a/sf_base/models/tool_base_new.py
+++ b/sf_base/models/tool_base_new.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
from odoo import fields, models, api
+
+
# from datetime import datetime
# from odoo.exceptions import ValidationError
@@ -95,7 +97,6 @@ class CuttingToolModel(models.Model):
_description = '刀具型号'
name = fields.Char('名称')
- code = fields.Char('编码')
cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', string='刀具物料')
cutting_tool_type = fields.Char(string="刀具物料类型", related='cutting_tool_material_id.name', store=True)
cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='刀具类型',
@@ -177,12 +178,43 @@ class CuttingToolModel(models.Model):
)
active = fields.Boolean('有效', default=True)
- # @api.model
- # def create(self, vals):
- # if vals.get('name', '/') == '/' or vals.get('name', '/') is False:
- # vals['name'] = '/'
- # obj = super(CuttingToolModel, self).create(vals)
- # return obj
+ def _get_code(self, cutting_tool_type_code):
+ cutting_tool_model = self.search(
+ [('code', 'ilike', cutting_tool_type_code)],
+ limit=1,
+ order="id desc")
+ if not cutting_tool_model:
+ num = "%03d" % 1
+ else:
+ m = int(cutting_tool_model.code[-3:]) + 1
+ num = "%03d" % m
+ return "%s%s" % (cutting_tool_type_code, num)
+
+ code = fields.Char(string='编码', readonly=True)
+
+ def _onchange_cutting_tool_material_id(self, cutting_tool_material_id):
+ if cutting_tool_material_id:
+ if cutting_tool_material_id.name == "整体式刀具":
+ code = self._get_code("JKM-T-DJWL-ZTDJ-")
+ elif cutting_tool_material_id.name == "刀片":
+ code = self._get_code("JKM-T-DJWL-DPIA-")
+ elif cutting_tool_material_id.name == "刀杆":
+ code = self._get_code("JKM-T-DJWL-DGAN-")
+ elif cutting_tool_material_id.name == "刀盘":
+ code = self._get_code("JKM-T-DJWL-DPAN-")
+ elif cutting_tool_material_id.name == "夹头":
+ code = self._get_code("JKM-T-DJWL-DJIA-")
+ else:
+ code = self._get_code("JKM-T-DJWL-DBIN-")
+ return code
+
+ @api.model
+ def create(self, vals):
+ obj = super(CuttingToolModel, self).create(vals)
+ if obj.cutting_tool_material_id:
+ code = self._onchange_cutting_tool_material_id(obj.cutting_tool_material_id)
+ obj.code = code
+ return obj
# 刀具类型
diff --git a/sf_base/views/fixture_view.xml b/sf_base/views/fixture_view.xml
index e363b039..487899eb 100644
--- a/sf_base/views/fixture_view.xml
+++ b/sf_base/views/fixture_view.xml
@@ -163,7 +163,7 @@
夹具型号
sf.fixture.model
-
+
@@ -177,11 +177,11 @@
夹具型号
sf.fixture.model
-
-
+
+
+
+
+
diff --git a/sf_sale/models/__init__.py b/sf_sale/models/__init__.py
index 577497ab..d1850ec0 100644
--- a/sf_sale/models/__init__.py
+++ b/sf_sale/models/__init__.py
@@ -1,4 +1,5 @@
-from. import sale_order
-from. import quick_easy_order
+from . import sale_order
+from . import quick_easy_order
+from . import auto_quatotion_common
diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py
index 369851b3..fe7aa0a4 100644
--- a/sf_sale/models/quick_easy_order.py
+++ b/sf_sale/models/quick_easy_order.py
@@ -82,13 +82,13 @@ class QuickEasyOrder(models.Model):
# 将attach的datas内容转为glb文件
def transition_glb_file(self, report_path, model_code):
shapes = read_step_file(report_path)
- output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl')
- # output_file = os.path.join('/tmp', str(model_code) + '.stl')
+ #output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl')
+ output_file = os.path.join('/tmp', str(model_code) + '.stl')
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
# 转化为glb
- output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.glb')
- # output_glb_file = os.path.join('/tmp', str(model_code) + '.glb')
- util_path = get_resource_path('mrs_base', 'static/util')
+ #output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.glb')
+ output_glb_file = os.path.join('/tmp', str(model_code) + '.glb')
+ util_path = get_resource_path('sf_dlm', 'static/util')
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
os.system(cmd)
# 转base64
@@ -138,7 +138,7 @@ class QuickEasyOrder(models.Model):
:return:
"""
web_base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url', default='')
- logging.info("自动报价返回值: %s" % ret)
+ logging.info("web_base_url: %s" % web_base_url)
url = '/api/bfm_process_order/list'
res = {'order_number': obj.name, 'delivery_end_date': str(datetime.now()),
'delivery_name': 'XXXXX', 'delivery_telephone': 'XXXXX',
@@ -153,10 +153,10 @@ class QuickEasyOrder(models.Model):
barcode = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
logging.info('model_file-size: %s' % len(item.model_file))
val = {
- 'model_long': 100,
- 'model_width': 100,
- 'model_height': 100,
- 'model_volume': 300,
+ 'model_long': item.model_length,
+ 'model_width': item.model_width,
+ 'model_height': item.model_height,
+ 'model_volume': item.model_volume,
'model_machining_precision': item.machining_precision,
'model_name': attachment.name,
'model_data': base64_datas,
@@ -203,7 +203,7 @@ class QuickEasyOrder(models.Model):
def model_coloring(self):
url = '/api/library_of_models/create'
config = self.env['res.config.settings'].get_values()
- config_header = Common.get_headers(self, config['sf_token'], config['sf_key_secret'])
+ config_header = Common.get_headers(self, config['token'], config['sf_secret_key'])
order = self.search([('id', '=', self.id)])
logging.info('order: %s' % order.name)
if order:
@@ -240,16 +240,15 @@ class QuickEasyOrder(models.Model):
# 自动报价
def _get_price(self, order):
-
url = '/api/automatic_quotes'
config = self.env['res.config.settings'].sudo().get_values()
- config_header = Common.get_headers(self, config['sf_token'], config['sf_key_secret'])
+ config_header = Common.get_headers(self, config['token'], config['sf_secret_key'])
logging.info("报价接口..........% s" % order.name)
try:
if order:
vals = {}
# mrs合作伙伴token
- vals['token'] = config['sf_token']
+ vals['token'] = config['token']
vals['accuracy'] = order.machining_precision
vals['number'] = order.quantity
vals['process_code'] = 0