接收从智能工厂传过来的订单等数据并创建编程单
This commit is contained in:
@@ -6,6 +6,7 @@ class ModelType(models.Model):
|
||||
_description = '模型类型'
|
||||
|
||||
name = fields.Char('名称')
|
||||
embryo_tolerance = fields.Integer('胚料的容余量')
|
||||
routing_tmpl_ids = fields.One2many('sf.model.type.routing.sort', 'model_type_id', '工序模板')
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class ResProductTemplate(models.Model):
|
||||
model_long = fields.Float('模型长[mm]', digits=(16, 3))
|
||||
model_width = fields.Float('模型宽[mm]', digits=(16, 3))
|
||||
model_height = fields.Float('模型高[mm]', digits=(16, 3))
|
||||
model_volume = fields.Float('模型体积[mm³]', digits=(16, 3))
|
||||
model_volume = fields.Float('模型体积[mm³]', digits=(16, 3), compute='_compute_model_volume', store=True)
|
||||
model_precision = fields.Float('精度要求', digits=(16, 3))
|
||||
model_type_id = fields.Many2one('sf.model.type', string='模型类型')
|
||||
model_processing_panel = fields.Char('模型加工面板')
|
||||
@@ -20,19 +20,22 @@ class ResProductTemplate(models.Model):
|
||||
model_number = fields.Integer('模型数量', default=1)
|
||||
model_remark = fields.Char('模型备注说明')
|
||||
|
||||
long = fields.Float('长[mm]', digits=(16, 3), onchange='count_embryo_size')
|
||||
width = fields.Float('宽[mm]', digits=(16, 3), onchange='count_embryo_size')
|
||||
height = fields.Float('高[mm]', digits=(16, 3), onchange='count_embryo_size')
|
||||
long = fields.Float('长[mm]', digits=(16, 3), onchange='add_product_size')
|
||||
width = fields.Float('宽[mm]', digits=(16, 3), onchange='add_product_size')
|
||||
height = fields.Float('高[mm]', digits=(16, 3), onchange='add_product_size')
|
||||
materials_id = fields.Many2one('mrs.production.materials', string='材料')
|
||||
materials_type_id = fields.Many2one('mrs.materials.model', string='材料型号')
|
||||
|
||||
|
||||
volume = fields.Float(compute='_compute_volume', store=True)
|
||||
|
||||
@api.depends('long', 'width', 'height')
|
||||
def _compute_volume(self):
|
||||
self.volume = self.long * self.width * self.height
|
||||
|
||||
@api.depends('model_long', 'model_width', 'model_height')
|
||||
def _compute_model_volume(self):
|
||||
self.model_volume = self.model_long * self.model_width * self.model_height
|
||||
|
||||
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
|
||||
def product_create(self, product_id, item, order_id, order_number, i):
|
||||
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
|
||||
@@ -63,24 +66,23 @@ class ResProductTemplate(models.Model):
|
||||
copy_product_id.sudo().write(vals)
|
||||
return copy_product_id
|
||||
|
||||
# 在产品上增加模型类型和加工的面(例如:A、B) ,
|
||||
# 并根据模型类型计算出产品的胚料尺寸;
|
||||
# @api.onchange('model_type_id')
|
||||
# def count_embryo_size(self):
|
||||
# if not self.model_type_id:
|
||||
# return
|
||||
# bom = self.env['product.product'].search(
|
||||
# [('categ_id.is_embryo', '=', True), ('product_tmpl_id', '=', self.id)],
|
||||
# limit=1,
|
||||
# order='volume desc'
|
||||
# )
|
||||
# for item in self:
|
||||
# item.embryo_long = bom.embryo_long + 1
|
||||
# item.embryo_width = bom.embryo_width + 1
|
||||
# item.embryo_height = bom.embryo_height + 1
|
||||
|
||||
|
||||
|
||||
# 根据模型类型默认给模型的长高宽加配置的长度;
|
||||
@api.onchange('model_type_id')
|
||||
def add_product_size(self):
|
||||
if not self.model_type_id:
|
||||
return
|
||||
model_type = self.env['sf.model.type'].search(
|
||||
[('id', '=', self.model_type_id.id)])
|
||||
print(self.model_long)
|
||||
print(self.model_width)
|
||||
print(self.model_height)
|
||||
for item in self:
|
||||
print(item.model_long)
|
||||
print(item.model_width)
|
||||
print(item.model_height)
|
||||
item.model_long = item.model_long + model_type.embryo_tolerance
|
||||
item.model_width = item.model_width + model_type.embryo_tolerance
|
||||
item.model_height = item.model_width + model_type.embryo_tolerance
|
||||
|
||||
|
||||
class ResProductCategory(models.Model):
|
||||
@@ -134,14 +136,3 @@ class ResMrpBom(models.Model):
|
||||
'product_uom_id': 1
|
||||
}
|
||||
return self.env['mrp.bom.line'].create(vals)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -531,12 +531,16 @@
|
||||
<form string="模型类型">
|
||||
<group>
|
||||
<field name="name" required="1"/>
|
||||
<field name="embryo_tolerance" required="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name='routing_tmpl_ids'>
|
||||
<tree editable='bottom'>
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="sequence" widget="handle" string="序号"/>
|
||||
<field name="route_workcenter_id" string="工序"/>
|
||||
<field name="routing_type" string="类型"/>
|
||||
<field name="is_repeat" string="重复"/>
|
||||
<field name="workcenter_ids" string="工作中心" widget="many2many_tags" />
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
""",
|
||||
'category': '',
|
||||
'website': 'https://www.sf.jikimo.com',
|
||||
'depends': ['mrp'],
|
||||
'depends': ['mrp', 'sf_base'],
|
||||
'data': [
|
||||
'views/sf_production.xml',
|
||||
'views/mrp_routing_workcenter_view.xml'
|
||||
|
||||
|
||||
],
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
import base64
|
||||
import logging
|
||||
import math
|
||||
import json
|
||||
import requests
|
||||
|
||||
from io import BytesIO
|
||||
from odoo import api, fields, models, SUPERUSER_ID
|
||||
from pystrich.code128 import Code128Encoder
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -244,7 +247,40 @@ class MrpWorkOrder(models.Model):
|
||||
productions.create_workorder1(self.processing_panel)
|
||||
return ""
|
||||
|
||||
# cnc程序获取
|
||||
|
||||
def fetchCNC(self):
|
||||
cnc_process = self.env['mrp.workorder'].search(
|
||||
[("routing_type", '=', 'CNC加工'),
|
||||
("production_id", '=', self.production_id.id)],
|
||||
limit=1,
|
||||
order='id asc'
|
||||
)
|
||||
vals = {
|
||||
'model_long': cnc_process.product_id.model_long,
|
||||
'model_width': cnc_process.product_id.model_width,
|
||||
'model_height': cnc_process.product_id.model_height,
|
||||
'model_volume': cnc_process.product_id.model_volume,
|
||||
'model_price': cnc_process.product_id.model_price,
|
||||
'model_total_amount': cnc_process.product_id.model_total_amount,
|
||||
'model_materials_code': cnc_process.product_id.materials_id.materials_no,
|
||||
'model_materials_type_code': cnc_process.product_id.materials_type_id.materials_no,
|
||||
'model_surface_process_code': cnc_process.product_id.model_surface_process_id.process_encode,
|
||||
'model_process_parameters_code': cnc_process.product_id.model_process_parameters_id.process_encode,
|
||||
'model_remark': cnc_process.product_id.model_remark
|
||||
}
|
||||
res = [{'order_no': self.product_id.barcode, 'production_no': self.production_id.name,
|
||||
'intelligent_programming_str': vals,
|
||||
'machine_tool_code': cnc_process.workcenter_id.machine_tool_id.code}]
|
||||
configsettings = self.env['res.config.settings'].get_values()
|
||||
token = configsettings['token']
|
||||
mrs_secret_key = configsettings['mrs_secret_key']
|
||||
config_header = Common.get_headers(self, token, mrs_secret_key)
|
||||
url = '/api/intelligent_programming/create'
|
||||
config_url = configsettings['mrs_url'] + url
|
||||
res_str = json.dumps(res)
|
||||
ret = requests.post(config_url, json={"result": res_str}, data=None, headers=config_header)
|
||||
|
||||
return ""
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user