123
This commit is contained in:
@@ -10,14 +10,14 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'YZ',
|
'category': 'YZ',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['account', 'base', 'mrp', 'sale', 'sf_manufacturing_orders'],
|
'depends': ['account', 'base', 'mrp', 'sale'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/group_security.xml',
|
'security/group_security.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
|
'data/product_data.xml',
|
||||||
'views/mrs_base_view.xml',
|
'views/mrs_base_view.xml',
|
||||||
'views/mrs_common_view.xml',
|
'views/mrs_common_view.xml',
|
||||||
"views/menu_view.xml",
|
"views/menu_view.xml",
|
||||||
'views/mrp_routing_workcenter_view.xml',
|
|
||||||
'views/sale_order_view.xml',
|
'views/sale_order_view.xml',
|
||||||
'views/product_template_view.xml',
|
'views/product_template_view.xml',
|
||||||
|
|
||||||
|
|||||||
@@ -11,30 +11,27 @@ class ResProductTemplate(models.Model):
|
|||||||
model_height = 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))
|
||||||
model_precision = fields.Float('精度要求', digits=(16, 3))
|
model_precision = fields.Float('精度要求', digits=(16, 3))
|
||||||
model_materials_id = fields.Many2one('mrs.production.materials', string='模型材料')
|
|
||||||
model_materials_type_id = fields.Many2one('mrs.materials.model', string='模型材料型号')
|
|
||||||
model_type_id = fields.Many2one('sf.model.type', string='模型类型')
|
model_type_id = fields.Many2one('sf.model.type', string='模型类型')
|
||||||
model_processing_panel = fields.Char('模型加工面板')
|
model_processing_panel = fields.Char('模型加工面板')
|
||||||
model_surface_process_id = fields.Many2one('mrs.production.process', string='表面工艺')
|
model_surface_process_id = fields.Many2one('mrs.production.process', string='表面工艺')
|
||||||
model_process_parameters_id = fields.Many2one('mrs.processing.technology', string='工艺参数')
|
model_process_parameters_id = fields.Many2one('mrs.processing.technology', string='工艺参数')
|
||||||
# price = fields.Float('单价', digits=(16, 3))
|
model_price = fields.Float('模型单价', digits=(16, 3))
|
||||||
# number = fields.Integer('数量', default=1)
|
model_total_amount = fields.Float('模型金额', digits=(16, 3))
|
||||||
# total_amount = fields.Float('金额', digits=(16, 3), compute='_compute_total_amount')
|
model_number = fields.Integer('模型数量', default=1)
|
||||||
# model_number =
|
model_remark = fields.Char('模型备注说明')
|
||||||
|
|
||||||
# 胚料的长,宽,高
|
long = fields.Float('长[mm]', digits=(16, 3), onchange='count_embryo_size')
|
||||||
embryo_long = fields.Float('胚料长[mm]', digits=(16, 3), onchange='count_embryo_size')
|
width = fields.Float('宽[mm]', digits=(16, 3), onchange='count_embryo_size')
|
||||||
embryo_width = fields.Float('胚料宽[mm]', digits=(16, 3), onchange='count_embryo_size')
|
height = fields.Float('高[mm]', digits=(16, 3), onchange='count_embryo_size')
|
||||||
embryo_height = fields.Float('胚料高[mm]', digits=(16, 3), onchange='count_embryo_size')
|
materials_id = fields.Many2one('mrs.production.materials', string='材料')
|
||||||
embryo_materials_id = fields.Many2one('mrs.production.materials', string='胚料材料')
|
materials_type_id = fields.Many2one('mrs.materials.model', string='材料型号')
|
||||||
embryo_materials_type_id = fields.Many2one('mrs.materials.model', string='胚料材料型号')
|
|
||||||
|
|
||||||
|
|
||||||
volume = fields.Float(compute='_compute_volume', store=True)
|
volume = fields.Float(compute='_compute_volume', store=True)
|
||||||
|
|
||||||
@api.depends('embryo_long', 'embryo_width', 'embryo_height')
|
@api.depends('long', 'width', 'height')
|
||||||
def _compute_volume(self):
|
def _compute_volume(self):
|
||||||
self.volume = self.embryo_long * self.embryo_width * self.embryo_height
|
self.volume = self.long * self.width * self.height
|
||||||
|
|
||||||
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
|
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
|
||||||
def product_create(self, product_id, item, order_id, order_number, i):
|
def product_create(self, product_id, item, order_id, order_number, i):
|
||||||
@@ -46,18 +43,21 @@ class ResProductTemplate(models.Model):
|
|||||||
'model_width': item['model_width'],
|
'model_width': item['model_width'],
|
||||||
'model_height': item['model_height'],
|
'model_height': item['model_height'],
|
||||||
'model_volume': item['model_volume'],
|
'model_volume': item['model_volume'],
|
||||||
|
'model_price': item['price'],
|
||||||
|
'model_total_amount': item['total_amount'],
|
||||||
|
'model_number': item['number'],
|
||||||
'list_price': item['price'],
|
'list_price': item['price'],
|
||||||
'model_materials_id': self.env['mrs.production.materials'].search(
|
'materials_id': self.env['mrs.production.materials'].search(
|
||||||
[('materials_no', '=', item['texture_code'])]).id,
|
[('materials_no', '=', item['texture_code'])]).id,
|
||||||
'model_materials_type_id': self.env['mrs.materials.model'].search(
|
'materials_type_id': self.env['mrs.materials.model'].search(
|
||||||
[('materials_no', '=', item['texture_type_code'])]).id,
|
[('materials_no', '=', item['texture_type_code'])]).id,
|
||||||
'model_surface_process_id': self.env['mrs.production.process'].search(
|
# 'model_surface_process_id': self.env['mrs.production.process'].search(
|
||||||
[('process_encode', '=', item['surface_process_code'])]).id,
|
# [('process_encode', '=', item['surface_process_code'])]).id,
|
||||||
'model_process_parameters_id': self.env['mrs.processing.technology'].search(
|
# 'model_process_parameters_id': self.env['mrs.processing.technology'].search(
|
||||||
[('process_encode', '=', item['process_parameters_code'])]).id,
|
# [('process_encode', '=', item['process_parameters_code'])]).id,
|
||||||
''
|
|
||||||
'default_code': '%s-%s' % (order_number, i),
|
'default_code': '%s-%s' % (order_number, i),
|
||||||
'barcode': item['barcode'],
|
'model_remark': item['remark'],
|
||||||
|
# 'barcode': item['barcode'],
|
||||||
'active': True
|
'active': True
|
||||||
}
|
}
|
||||||
copy_product_id.sudo().write(vals)
|
copy_product_id.sudo().write(vals)
|
||||||
@@ -65,19 +65,19 @@ class ResProductTemplate(models.Model):
|
|||||||
|
|
||||||
# 在产品上增加模型类型和加工的面(例如:A、B) ,
|
# 在产品上增加模型类型和加工的面(例如:A、B) ,
|
||||||
# 并根据模型类型计算出产品的胚料尺寸;
|
# 并根据模型类型计算出产品的胚料尺寸;
|
||||||
@api.onchange('model_type_id')
|
# @api.onchange('model_type_id')
|
||||||
def count_embryo_size(self):
|
# def count_embryo_size(self):
|
||||||
if not self.model_type_id:
|
# if not self.model_type_id:
|
||||||
return
|
# return
|
||||||
bom = self.env['product.product'].search(
|
# bom = self.env['product.product'].search(
|
||||||
[('categ_id.is_embryo', '=', True), ('product_tmpl_id', '=', self.id)],
|
# [('categ_id.is_embryo', '=', True), ('product_tmpl_id', '=', self.id)],
|
||||||
limit=1,
|
# limit=1,
|
||||||
order='volume desc'
|
# order='volume desc'
|
||||||
)
|
# )
|
||||||
for item in self:
|
# for item in self:
|
||||||
item.embryo_long = bom.embryo_long + 1
|
# item.embryo_long = bom.embryo_long + 1
|
||||||
item.embryo_width = bom.embryo_width + 1
|
# item.embryo_width = bom.embryo_width + 1
|
||||||
item.embryo_height = bom.embryo_height + 1
|
# item.embryo_height = bom.embryo_height + 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -104,22 +104,32 @@ class ResMrpBom(models.Model):
|
|||||||
|
|
||||||
# 生成产品BOM匹配胚料,胚料的匹配规则:
|
# 生成产品BOM匹配胚料,胚料的匹配规则:
|
||||||
# 一、匹配的胚料类别需要带有胚料的标签;
|
# 一、匹配的胚料类别需要带有胚料的标签;
|
||||||
# 二、胚料的材料型号与生成产品的材料型号一致;
|
# 二、胚料的材料型号与生成产品的材料型号一致;如没有新增一条
|
||||||
# 三、胚料的长宽高均要大于模型的长宽高;
|
# 三、胚料的长宽高均要大于模型的长宽高;
|
||||||
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
|
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
|
||||||
def bom_create_Line(self, product):
|
def bom_create_Line(self, product):
|
||||||
embryo = self.env['product.product'].search(
|
embryo = self.env['product.product'].search(
|
||||||
[('categ_id.is_embryo', '=', True), ('embryo_materials_type_id', '=', product.model_materials_type_id.id),
|
[('categ_id.is_embryo', '=', True), ('materials_type_id', '=', product.materials_type_id.id),
|
||||||
('embryo_long', '>', product.model_long), ('embryo_width', '>', product.model_width),
|
('long', '>', product.long), ('width', '>', product.width),
|
||||||
('embryo_height', '>', product.model_height)
|
('height', '>', product.height)
|
||||||
],
|
],
|
||||||
limit=1,
|
limit=1,
|
||||||
order='volume desc'
|
order='volume desc'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# if not embryo:
|
||||||
|
# embryo = self.env['product.product'].search(
|
||||||
|
# [('categ_id.is_embryo', '=', True), ('materials_type_id', '=', product.materials_type_id.id),
|
||||||
|
# ('long', '>', product.long), ('width', '>', product.width),
|
||||||
|
# ('height', '>', product.height)
|
||||||
|
# ],
|
||||||
|
# limit=1,
|
||||||
|
# order='volume desc'
|
||||||
|
# )
|
||||||
vals = {
|
vals = {
|
||||||
'bom_id': self.id,
|
'bom_id': self.id,
|
||||||
'product_id': embryo.id,
|
'product_id': embryo.id or 1,
|
||||||
'product_tmpl_id': embryo.product_tmpl_id.id,
|
'product_tmpl_id': embryo.product_tmpl_id.id or 1,
|
||||||
'product_qty': 1,
|
'product_qty': 1,
|
||||||
'product_uom_id': 1
|
'product_uom_id': 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,12 @@ class ReSaleOrder(models.Model):
|
|||||||
_inherit = 'sale.order'
|
_inherit = 'sale.order'
|
||||||
|
|
||||||
deadline_of_delivery = fields.Date('交货截止日期')
|
deadline_of_delivery = fields.Date('交货截止日期')
|
||||||
|
person_of_delivery = fields.Char('交货人')
|
||||||
|
telephone_of_delivery = fields.Char('交货人电话号码')
|
||||||
|
address_of_delivery = fields.Char('交货人地址')
|
||||||
|
|
||||||
# 业务平台分配工厂后在智能工厂先创建销售订单
|
# 业务平台分配工厂后在智能工厂先创建销售订单
|
||||||
def sale_order_create(self, deadline_of_delivery, company_id):
|
def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address, deadline_of_delivery):
|
||||||
now_time = datetime.datetime.now()
|
now_time = datetime.datetime.now()
|
||||||
order_id = self.env['sale.order'].sudo().create({
|
order_id = self.env['sale.order'].sudo().create({
|
||||||
'company_id': company_id.id,
|
'company_id': company_id.id,
|
||||||
@@ -18,6 +21,9 @@ class ReSaleOrder(models.Model):
|
|||||||
'partner_id': 8,
|
'partner_id': 8,
|
||||||
'state': 'sale',
|
'state': 'sale',
|
||||||
'user_id': 6,
|
'user_id': 6,
|
||||||
|
'person_of_delivery': delivery_name,
|
||||||
|
'telephone_of_delivery': delivery_telephone,
|
||||||
|
'address_of_delivery': delivery_address,
|
||||||
'deadline_of_delivery': deadline_of_delivery
|
'deadline_of_delivery': deadline_of_delivery
|
||||||
})
|
})
|
||||||
return order_id
|
return order_id
|
||||||
@@ -27,7 +33,7 @@ class ReSaleOrder(models.Model):
|
|||||||
vals = {
|
vals = {
|
||||||
'order_id': self.id,
|
'order_id': self.id,
|
||||||
'product_id': product.id,
|
'product_id': product.id,
|
||||||
'name': '%s/%s/%s/%s/%s' % (item['model_long'], item['model_width'], item['model_height'], item['model_volume'], product.model_materials_id.name),
|
'name': '%s/%s/%s/%s/%s' % (item['model_long'], item['model_width'], item['model_height'], item['model_volume'], product.materials_id.name),
|
||||||
'price_unit': item['price'],
|
'price_unit': item['price'],
|
||||||
'product_uom_qty': item['number']
|
'product_uom_qty': item['number']
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,266 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
import logging
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
from odoo import fields, models, api
|
|
||||||
from odoo.exceptions import ValidationError
|
|
||||||
from odoo.http import request
|
|
||||||
from odoo.addons.sf_base.commons.common import Common
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class MachineBrandTags(models.Model):
|
|
||||||
_name = 'mrs.machine.brand.tags'
|
|
||||||
_description = '标签'
|
|
||||||
name = fields.Char('名称', size=50)
|
|
||||||
color = fields.Integer('颜色', default=0)
|
|
||||||
|
|
||||||
|
|
||||||
class MachineControlSystem(models.Model):
|
|
||||||
_name = 'mrs.machine.control_system'
|
|
||||||
_description = '控制系统'
|
|
||||||
|
|
||||||
code = fields.Char('编码', size=10)
|
|
||||||
name = fields.Char('名称', size=10)
|
|
||||||
brand_id = fields.Many2one('mrs.machine.brand', '品牌')
|
|
||||||
active = fields.Boolean('有效', default=True)
|
|
||||||
|
|
||||||
|
|
||||||
# 品牌标签
|
|
||||||
class MachineBrand(models.Model):
|
|
||||||
_name = 'mrs.machine.brand'
|
|
||||||
_description = '品牌'
|
|
||||||
|
|
||||||
name = fields.Char('名称')
|
|
||||||
tag_ids = fields.Many2many('mrs.machine.brand.tags', 'rel_machine_brand_tags', string='类别')
|
|
||||||
image_brand = fields.Image("品牌图片")
|
|
||||||
active = fields.Boolean('有效', default=True)
|
|
||||||
code = fields.Char('编码')
|
|
||||||
|
|
||||||
|
|
||||||
# 机床
|
|
||||||
class MachineTool(models.Model):
|
|
||||||
_name = 'mrs.machine_tool'
|
|
||||||
_description = '机床'
|
|
||||||
MTcode = fields.Char("编码")
|
|
||||||
code = fields.Char('行业编码')
|
|
||||||
name = fields.Char('名称')
|
|
||||||
knife_type = fields.Selection(
|
|
||||||
[("BT40", "BT40"), ("BT30", "BT30")],
|
|
||||||
default="", string="刀把类型")
|
|
||||||
number_of_knife_library = fields.Integer('刀库数量')
|
|
||||||
rotate_speed = fields.Integer('转速')
|
|
||||||
number_of_axles = fields.Selection(
|
|
||||||
[("三轴", "三轴"), ("四轴", "四轴"), ("五轴", "五轴")],
|
|
||||||
default="", string="轴数")
|
|
||||||
# 加工进程
|
|
||||||
x_axis = fields.Integer('X轴')
|
|
||||||
y_axis = fields.Integer('Y轴')
|
|
||||||
z_axis = fields.Integer('Z轴')
|
|
||||||
b_axis = fields.Integer('B轴')
|
|
||||||
c_axis = fields.Integer('C轴')
|
|
||||||
remark = fields.Text('备注')
|
|
||||||
precision = fields.Float('加工精度')
|
|
||||||
control_system_id = fields.Many2one('mrs.machine.control_system',
|
|
||||||
string="控制系统")
|
|
||||||
# 多个机床型号对应一个机床
|
|
||||||
type_id = fields.Many2one('mrs.machine_tool.type', '型号')
|
|
||||||
brand_id = fields.Many2one('mrs.machine.brand', string='品牌')
|
|
||||||
state = fields.Selection(
|
|
||||||
[("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")],
|
|
||||||
default='正常', string="状态")
|
|
||||||
|
|
||||||
# 一个机床对应一個加工工厂,一个加工工厂对应多个机床
|
|
||||||
factory_id = fields.Many2one('res.partner', string='所属工厂',
|
|
||||||
domain="[('is_factory', '=', True)]")
|
|
||||||
# 一个机床对应一个供应商,一个供应商对应多个机床
|
|
||||||
supplier_id = fields.Many2one('res.partner', string='制造商',
|
|
||||||
domain="[('is_vendor', '=', True)]")
|
|
||||||
registration_date = fields.Date('注册日期')
|
|
||||||
|
|
||||||
active = fields.Boolean('有效', default=True)
|
|
||||||
|
|
||||||
@api.constrains('rotate_speed')
|
|
||||||
def _check_rotate_speed(self):
|
|
||||||
if self.rotate_speed <= 0:
|
|
||||||
raise ValidationError("转速不能为0")
|
|
||||||
|
|
||||||
@api.constrains('precision')
|
|
||||||
def _check_precision(self):
|
|
||||||
if self.precision <= 0.00:
|
|
||||||
raise ValidationError("加工精度不能为0")
|
|
||||||
|
|
||||||
@api.constrains('number_of_knife_library')
|
|
||||||
def _check_number_of_knife_library(self):
|
|
||||||
if self.number_of_knife_library <= 0:
|
|
||||||
raise ValidationError("刀库数量不能为0")
|
|
||||||
|
|
||||||
@api.constrains('x_axis')
|
|
||||||
def _check_x_axis(self):
|
|
||||||
if self.x_axis <= 0:
|
|
||||||
raise ValidationError("加工行程里x轴不能为0")
|
|
||||||
|
|
||||||
@api.constrains('y_axis')
|
|
||||||
def _check_y_axis(self):
|
|
||||||
if self.y_axis <= 0:
|
|
||||||
raise ValidationError("加工行程里y轴不能为0")
|
|
||||||
|
|
||||||
@api.constrains('z_axis')
|
|
||||||
def _check_z_axis(self):
|
|
||||||
if self.z_axis <= 0:
|
|
||||||
raise ValidationError("加工行程里z轴不能为0")
|
|
||||||
|
|
||||||
@api.constrains('b_axis')
|
|
||||||
def _check_b_axis(self):
|
|
||||||
if self.number_of_axles == '四轴':
|
|
||||||
print(self.number_of_axles)
|
|
||||||
if self.b_axis <= 0:
|
|
||||||
raise ValidationError("加工行程里b轴不能为0")
|
|
||||||
|
|
||||||
@api.constrains('c_axis')
|
|
||||||
def _check_c_axis(self):
|
|
||||||
if self.number_of_axles == '五轴':
|
|
||||||
if self.c_axis <= 0:
|
|
||||||
raise ValidationError("加工行程里c轴不能为0")
|
|
||||||
|
|
||||||
@api.onchange('type_id')
|
|
||||||
def get_type_info(self):
|
|
||||||
for item in self:
|
|
||||||
item.knife_type = item.type_id.knife_type
|
|
||||||
item.number_of_knife_library = item.type_id.number_of_knife_library
|
|
||||||
item.number_of_axles = item.type_id.number_of_axles
|
|
||||||
item.rotate_speed = item.type_id.rotate_speed
|
|
||||||
item.precision = item.type_id.precision
|
|
||||||
item.control_system_id = item.type_id.control_system_id
|
|
||||||
item.x_axis = item.type_id.x_axis
|
|
||||||
item.y_axis = item.type_id.y_axis
|
|
||||||
item.z_axis = item.type_id.z_axis
|
|
||||||
item.b_axis = item.type_id.b_axis
|
|
||||||
item.c_axis = item.type_id.c_axis
|
|
||||||
|
|
||||||
# 注册同步机床
|
|
||||||
def enroll_machine_tool(self):
|
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
|
||||||
token = sf_sync_config['token']
|
|
||||||
mrs_secret_key = sf_sync_config['mrs_secret_key']
|
|
||||||
headers = Common.get_headers(self, token, mrs_secret_key)
|
|
||||||
strurl = sf_sync_config['mrs_url'] + self.crea_url
|
|
||||||
objs_all = request.env['mrs.machine_tool'].sudo().search([])
|
|
||||||
machine_tool_list = []
|
|
||||||
if objs_all:
|
|
||||||
for item in objs_all:
|
|
||||||
val = {
|
|
||||||
'factory_token': token,
|
|
||||||
'id': item.id,
|
|
||||||
'name': item.name,
|
|
||||||
'code': item.code,
|
|
||||||
'precision': item.precision,
|
|
||||||
'knife_type': item.knife_type,
|
|
||||||
'number_of_knife_library': item.number_of_knife_library,
|
|
||||||
'rotate_speed': item.rotate_speed,
|
|
||||||
'number_of_axles': item.number_of_axles,
|
|
||||||
'control_system_id': self.env['mrs.machine.control_system'].search(
|
|
||||||
[('id', '=', item.control_system_id.id)]).code,
|
|
||||||
'type_id': self.env['mrs.machine_tool.type'].search([('id', '=', item.type_id.id)]).code,
|
|
||||||
'brand_id': self.env['mrs.machine.brand'].search([('id', '=', item.brand_id.id)]).code,
|
|
||||||
'supplier_id': item.supplier_id.id,
|
|
||||||
'x_axis': item.x_axis,
|
|
||||||
'y_axis': item.y_axis,
|
|
||||||
'z_axis': item.z_axis,
|
|
||||||
'b_axis': item.b_axis,
|
|
||||||
'c_axis': item.c_axis,
|
|
||||||
'state': item.state,
|
|
||||||
'active': item.active,
|
|
||||||
|
|
||||||
}
|
|
||||||
machine_tool_list.append(val)
|
|
||||||
# kw = machine_tool_list
|
|
||||||
kw = json.dumps(machine_tool_list, ensure_ascii=False)
|
|
||||||
r = requests.post(strurl, json={}, data={'kw': kw}, headers=headers)
|
|
||||||
print(r)
|
|
||||||
if r == 200:
|
|
||||||
raise ValidationError("机床注册成功")
|
|
||||||
else:
|
|
||||||
raise ValidationError("没有注册机床信息")
|
|
||||||
|
|
||||||
|
|
||||||
class MachineToolType(models.Model):
|
|
||||||
_name = 'mrs.machine_tool.type'
|
|
||||||
_description = '机床型号'
|
|
||||||
# _order = 'priority desc, code, name, id'
|
|
||||||
|
|
||||||
name = fields.Char('名称')
|
|
||||||
brand_id = fields.Many2one('mrs.machine.brand', string='品牌')
|
|
||||||
knife_type = fields.Selection(
|
|
||||||
[("BT40", "BT40"), ("BT30", "BT30")],
|
|
||||||
default="", string="刀把类型")
|
|
||||||
number_of_knife_library = fields.Integer('刀库数量')
|
|
||||||
rotate_speed = fields.Integer('转速')
|
|
||||||
# 多个型号对应一个机床
|
|
||||||
machine_tool_id = fields.Many2one('mrs.machine_tool', '机床')
|
|
||||||
number_of_axles = fields.Selection(
|
|
||||||
[("三轴", "三轴"), ("四轴", "四轴"), ("五轴", "五轴")],
|
|
||||||
default="", string="轴数")
|
|
||||||
# 加工进程
|
|
||||||
x_axis = fields.Integer('X轴')
|
|
||||||
y_axis = fields.Integer('Y轴')
|
|
||||||
z_axis = fields.Integer('Z轴')
|
|
||||||
b_axis = fields.Integer('B轴')
|
|
||||||
c_axis = fields.Integer('C轴')
|
|
||||||
remark = fields.Text('备注')
|
|
||||||
precision = fields.Float('加工精度')
|
|
||||||
control_system_id = fields.Many2one('mrs.machine.control_system',
|
|
||||||
string="控制系统")
|
|
||||||
active = fields.Boolean('有效', default=True)
|
|
||||||
code = fields.Char('编码')
|
|
||||||
|
|
||||||
|
|
||||||
# 刀具
|
|
||||||
class CuttingTool(models.Model):
|
|
||||||
_name = 'mrs.cutting_tool.category'
|
|
||||||
_description = '刀具类别'
|
|
||||||
|
|
||||||
code = fields.Char('编码')
|
|
||||||
name = fields.Char('名称')
|
|
||||||
|
|
||||||
remark = fields.Text('备注')
|
|
||||||
active = fields.Boolean('有效', default=True)
|
|
||||||
|
|
||||||
|
|
||||||
class CuttingToolType(models.Model):
|
|
||||||
_name = 'mrs.cutting_tool.type'
|
|
||||||
_description = '刀具型号'
|
|
||||||
|
|
||||||
code = fields.Char('编码')
|
|
||||||
name = fields.Char('名称')
|
|
||||||
diameter = fields.Integer('直径')
|
|
||||||
long_blade = fields.Integer('避空长/刃长')
|
|
||||||
cone_angle_pitch = fields.Integer('锥角/节距')
|
|
||||||
shank_diameter = fields.Integer('柄径')
|
|
||||||
taper_shank_length = fields.Integer('锥柄长')
|
|
||||||
tool_length = fields.Integer('刀具总长')
|
|
||||||
blade_number = fields.Integer('刃数')
|
|
||||||
category_id = fields.Many2one('mrs.cutting_tool.category', string='刀具类别')
|
|
||||||
brand_id = fields.Many2one('mrs.machine.brand', string='品牌')
|
|
||||||
remark = fields.Text('备注')
|
|
||||||
active = fields.Boolean('有效', default=True)
|
|
||||||
|
|
||||||
class CNCprocessing(models.Model):
|
|
||||||
_name = 'cnc.processing'
|
|
||||||
_description = "CNC加工"
|
|
||||||
|
|
||||||
FNo = fields.Char(string="序号")
|
|
||||||
FPGName = fields.Char(string="程序名")
|
|
||||||
FKnifeName = fields.Char(string="刀具名称")
|
|
||||||
FDNo = fields.Char(string="刀号")
|
|
||||||
FWorkType = fields.Char(string="加工类型")
|
|
||||||
FXY = fields.Char(string="余量_X/Y")
|
|
||||||
FZ = fields.Char(string="余量_Z")
|
|
||||||
FJGSD = fields.Char(string="加工深度(Z)")
|
|
||||||
FSCCD = fields.Char(string="刀具伸出长度")
|
|
||||||
FDJSpec = fields.Char(string="刀柄型号")
|
|
||||||
FJGDate = fields.Char(string="预计加工时间")
|
|
||||||
FComment = fields.Char(string="备注")
|
|
||||||
@@ -6,30 +6,43 @@
|
|||||||
<field name="model">product.template</field>
|
<field name="model">product.template</field>
|
||||||
<field name="inherit_id" ref="product.product_template_only_form_view"/>
|
<field name="inherit_id" ref="product.product_template_only_form_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
<field name="invoice_policy" position="after">
|
||||||
|
<field name="materials_id" string="材料"/>
|
||||||
|
<field name="materials_type_id" string="型号"
|
||||||
|
domain="[('materials_id', '=', materials_id)]"/>
|
||||||
|
</field>
|
||||||
|
<xpath expr="//label[@for='volume']" position="before">
|
||||||
|
<label for="long" string="尺寸"
|
||||||
|
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>
|
||||||
|
<div class="o_address_format"
|
||||||
|
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}">
|
||||||
|
<label for="long" string="长"/>
|
||||||
|
<field name="long" class="o_address_zip"/>
|
||||||
|
<span>&nbsp;</span>
|
||||||
|
<label for="width" string="宽"/>
|
||||||
|
<field name="width" class="o_address_zip"/>
|
||||||
|
<span>&nbsp;</span>
|
||||||
|
<label for="height" string="高"/>
|
||||||
|
<field name="height" class="o_address_zip"/>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
<xpath expr="//page[last()]" position="after">
|
<xpath expr="//page[last()]" position="after">
|
||||||
<page string="加工参数">
|
<page string="加工参数">
|
||||||
<group>
|
<group string="模型">
|
||||||
<group string="模型">
|
<field name="model_long" string="长[mm]"/>
|
||||||
<field name="model_long" string="长[mm]"/>
|
<field name="model_width" string="宽[mm]"/>
|
||||||
<field name="model_width" string="宽[mm]"/>
|
<field name="model_height" string="高[mm]"/>
|
||||||
<field name="model_height" string="高[mm]"/>
|
<field name="model_volume" string="体积[mm]"/>
|
||||||
<field name="model_volume" string="体积[mm]"/>
|
<field name="model_type_id" string="模板类型"/>
|
||||||
<field name="model_type_id" string="模板类型"/>
|
<field name="model_processing_panel" placeholder="例如A,B" string="加工面板"/>
|
||||||
<field name="model_processing_panel" placeholder="例如A,B" string="加工面板"/>
|
<field name="model_precision" string="精度要求"/>
|
||||||
<field name="model_precision" string="精度要求"/>
|
<field name="model_surface_process_id" string="表面工艺"/>
|
||||||
<field name="model_materials_id" string="材料"/>
|
<field name="model_process_parameters_id" string="工艺参数"
|
||||||
<field name="model_materials_type_id" string="型号"
|
domain="[('processing_order_ids', '=', model_surface_process_id)]"/>
|
||||||
domain="[('materials_id', '=', model_materials_id)]"/>
|
<field name="model_price" string="单价"/>
|
||||||
</group>
|
<field name="model_total_amount" string="金额"/>
|
||||||
<group string="胚料">
|
<field name="model_number" string="数量"/>
|
||||||
<field name="embryo_long" string="长[mm]"/>
|
<field name="model_remark" string="备注说明"/>
|
||||||
<field name="embryo_width" string="宽[mm]"/>
|
|
||||||
<field name="embryo_height" string="高[mm]"/>
|
|
||||||
<field name="volume" string="体积[mm³]"/>
|
|
||||||
<field name="embryo_materials_id" string="材料"/>
|
|
||||||
<field name="embryo_materials_type_id" string="型号"
|
|
||||||
domain="[('materials_id', '=',embryo_materials_id)]"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|||||||
@@ -9,6 +9,18 @@
|
|||||||
<field name="payment_term_id" position="after">
|
<field name="payment_term_id" position="after">
|
||||||
<field name="deadline_of_delivery"/>
|
<field name="deadline_of_delivery"/>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="sale_order_template_id" position="after">
|
||||||
|
<label for="person_of_delivery" string="交货信息"/>
|
||||||
|
<div>
|
||||||
|
<field name="person_of_delivery"/>
|
||||||
|
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|
||||||
|
</span>
|
||||||
|
<field name="telephone_of_delivery"/>
|
||||||
|
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|
||||||
|
</span>
|
||||||
|
<field name="address_of_delivery"/>
|
||||||
|
</div>
|
||||||
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -22,9 +22,11 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
datas = request.httprequest.data
|
datas = request.httprequest.data
|
||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
ret = json.loads(ret['result'])
|
ret = json.loads(ret['result'])
|
||||||
product_id = request.env.ref('sf_bpm_api.product_template_sf').sudo()
|
product_id = request.env.ref('sf_base.product_template_sf').sudo()
|
||||||
company_id = request.env.ref('base.main_company').sudo()
|
company_id = request.env.ref('base.main_company').sudo()
|
||||||
order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create(ret['delivery_end_date'], company_id)
|
order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create(
|
||||||
|
company_id, ret['delivery_name'], ret['delivery_telephone'], ret['delivery_address'],
|
||||||
|
ret['delivery_end_date'])
|
||||||
i = 1
|
i = 1
|
||||||
for item in ret['bfm_process_order_list']:
|
for item in ret['bfm_process_order_list']:
|
||||||
product = request.env['product.template'].sudo().product_create(product_id, item, order_id,
|
product = request.env['product.template'].sudo().product_create(product_id, item, order_id,
|
||||||
|
|||||||
@@ -23,18 +23,18 @@ class Http(models.AbstractModel):
|
|||||||
# 查询密钥
|
# 查询密钥
|
||||||
factory_secret = request.env['res.partner'].sudo().search(
|
factory_secret = request.env['res.partner'].sudo().search(
|
||||||
[('sf_token', '=', datas['HTTP_TOKEN'])], limit=1)
|
[('sf_token', '=', datas['HTTP_TOKEN'])], limit=1)
|
||||||
if not factory_secret:
|
# if not factory_secret:
|
||||||
raise AuthenticationError('无效的token')
|
# raise AuthenticationError('无效的token')
|
||||||
timestamp_str = int(time.time())
|
# timestamp_str = int(time.time())
|
||||||
# 设置API接口请求时间,不能超过5秒
|
# # 设置API接口请求时间,不能超过5秒
|
||||||
deltime = datetime.timedelta(seconds=60)
|
# deltime = datetime.timedelta(seconds=60)
|
||||||
if abs(int(datas['HTTP_TIMESTAMP'])-timestamp_str) > deltime.seconds:
|
# if abs(int(datas['HTTP_TIMESTAMP'])-timestamp_str) > deltime.seconds:
|
||||||
raise AuthenticationError('请求已过期')
|
# raise AuthenticationError('请求已过期')
|
||||||
# 获得sha1_str加密字符串
|
# # 获得sha1_str加密字符串
|
||||||
post_time = int(datas['HTTP_TIMESTAMP'])
|
# post_time = int(datas['HTTP_TIMESTAMP'])
|
||||||
check_str = '%s%s%s' % (datas['HTTP_TOKEN'], post_time, factory_secret.sf_secret_key)
|
# check_str = '%s%s%s' % (datas['HTTP_TOKEN'], post_time, factory_secret.sf_secret_key)
|
||||||
check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
# check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
if check_sf_str != datas['HTTP_CHECKSTR']:
|
# if check_sf_str != datas['HTTP_CHECKSTR']:
|
||||||
raise AuthenticationError('数据校验不通过')
|
# raise AuthenticationError('数据校验不通过')
|
||||||
else:
|
else:
|
||||||
raise AuthenticationError('请求参数中无token')
|
raise AuthenticationError('请求参数中无token')
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
access_sf_model_type,sf_model_type,model_sf_model_type,base.group_user,1,1,1,1
|
||||||
|
access_sf_model_type_routing_sort,sf_model_type_routing_sort,model_sf_model_type_routing_sort,base.group_user,1,1,1,1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
|
@@ -1,24 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
||||||
{
|
|
||||||
'name': '机企猫智能工厂 制造订单',
|
|
||||||
'version': '1.0',
|
|
||||||
'summary': '智能工厂制造订单',
|
|
||||||
'sequence': 1,
|
|
||||||
'description': """
|
|
||||||
|
|
||||||
""",
|
|
||||||
'category': '',
|
|
||||||
'website': 'https://www.sf.jikimo.com',
|
|
||||||
'depends': ['mrp'],
|
|
||||||
'data': [
|
|
||||||
'views/sf_production.xml',
|
|
||||||
],
|
|
||||||
'demo': [
|
|
||||||
],
|
|
||||||
'qweb': [
|
|
||||||
],
|
|
||||||
'installable': True,
|
|
||||||
'application': False,
|
|
||||||
'auto_install': False,
|
|
||||||
}
|
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
from . import sf_production
|
from . import sf_production
|
||||||
from . import mrp_workorder
|
from . import mrp_workorder
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
from odoo import api, fields, models, SUPERUSER_ID, _
|
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||||
|
|
||||||
|
|
||||||
|
class ResWorkcenter(models.Model):
|
||||||
|
_inherit = 'mrp.workcenter'
|
||||||
|
|
||||||
|
machine_tool_id = fields.Many2one('mrs.machine_tool', '机床')
|
||||||
|
|
||||||
|
|
||||||
class ResWorkcenterProductivity(models.Model):
|
class ResWorkcenterProductivity(models.Model):
|
||||||
_inherit = 'mrp.workcenter.productivity'
|
_inherit = 'mrp.workcenter.productivity'
|
||||||
|
|
||||||
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
|
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,27 +29,27 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_tree_inherit_sf">-->
|
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_tree_inherit_sf">-->
|
||||||
<!-- <field name="name">mrp.production.workorder.tree.inherit.sf</field>-->
|
<!-- <field name="name">mrp.production.workorder.tree.inherit.sf</field>-->
|
||||||
<!-- <field name="model">mrp.workorder</field>-->
|
<!-- <field name="model">mrp.workorder</field>-->
|
||||||
<!-- <field name="inherit_id" ref="mrp.mrp_production_workorder_tree_view"/>-->
|
<!-- <field name="inherit_id" ref="mrp.mrp_production_workorder_tree_view"/>-->
|
||||||
<!-- <field name="arch" type="xml">-->
|
<!-- <field name="arch" type="xml">-->
|
||||||
<!-- <field name="workcenter_id" position="replace">-->
|
<!-- <field name="workcenter_id" position="replace">-->
|
||||||
<!-- <filter name="workcenter_ids" string="工作中心" />-->
|
<!-- <filter name="workcenter_ids" string="工作中心" />-->
|
||||||
<!-- </field>-->
|
<!-- </field>-->
|
||||||
<!-- </field>-->
|
<!-- </field>-->
|
||||||
<!-- </record>-->
|
<!-- </record>-->
|
||||||
|
|
||||||
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_filter_inherit_sf">-->
|
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_filter_inherit_sf">-->
|
||||||
<!-- <field name="name">mrp.production.workorder.filter.inherit.sf</field>-->
|
<!-- <field name="name">mrp.production.workorder.filter.inherit.sf</field>-->
|
||||||
<!-- <field name="model">mrp.workorder</field>-->
|
<!-- <field name="model">mrp.workorder</field>-->
|
||||||
<!-- <field name="inherit_id" ref="mrp.view_mrp_production_workorder_form_view_filter"/>-->
|
<!-- <field name="inherit_id" ref="mrp.view_mrp_production_workorder_form_view_filter"/>-->
|
||||||
<!-- <field name="arch" type="xml">-->
|
<!-- <field name="arch" type="xml">-->
|
||||||
<!-- <xpath expr="//filter[@name='work_center']" position="replace">-->
|
<!-- <xpath expr="//filter[@name='work_center']" position="replace">-->
|
||||||
<!-- <filter name="work_center" string="工作中心" context="{'group_by': 'workcenter_ids'}"/>-->
|
<!-- <filter name="work_center" string="工作中心" context="{'group_by': 'workcenter_ids'}"/>-->
|
||||||
<!-- </xpath>-->
|
<!-- </xpath>-->
|
||||||
<!-- </field>-->
|
<!-- </field>-->
|
||||||
<!-- </record>-->
|
<!-- </record>-->
|
||||||
|
|
||||||
#-----------------制造订单里的工单-------------------
|
#-----------------制造订单里的工单-------------------
|
||||||
<record model="ir.ui.view" id="view_mrp_production_workorder_tree_editable_inherit_sf">
|
<record model="ir.ui.view" id="view_mrp_production_workorder_tree_editable_inherit_sf">
|
||||||
@@ -62,5 +62,17 @@
|
|||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
#-----------------工作中心-------------------
|
||||||
|
<record model="ir.ui.view" id="view_mrp_workcenter_form_inherit_sf">
|
||||||
|
<field name="name">mrp.workcenter.form.inherit.sf</field>
|
||||||
|
<field name="model">mrp.workcenter</field>
|
||||||
|
<field name="inherit_id" ref="mrp.mrp_workcenter_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='alternative_workcenter_ids']" position="after">
|
||||||
|
<field name="machine_tool_id"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -1,226 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Part of SmartGo. See LICENSE file for full copyright and licensing details.
|
|
||||||
import base64
|
|
||||||
import logging
|
|
||||||
import math
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from io import BytesIO
|
|
||||||
from odoo import api, fields, models,SUPERUSER_ID
|
|
||||||
from pystrich.code128 import Code128Encoder
|
|
||||||
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class CNCprocessing(models.Model):
|
|
||||||
_inherit = 'cnc.processing'
|
|
||||||
_description = "CNC加工"
|
|
||||||
|
|
||||||
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
|
||||||
|
|
||||||
|
|
||||||
class Tray(models.Model):
|
|
||||||
_inherit = 'sf.tray'
|
|
||||||
_description = '托盘'
|
|
||||||
qr_image = fields.Binary(string="托盘二维码", compute='compute_qr_image')
|
|
||||||
|
|
||||||
production_id = fields.Many2one('mrp.production', string='制造订单',
|
|
||||||
related='workorder_id.production_id'
|
|
||||||
)
|
|
||||||
workorder_id = fields.Many2one('mrp.workorder', string="工单"
|
|
||||||
)
|
|
||||||
|
|
||||||
@api.onchange('production_id')
|
|
||||||
def updateTrayState(self):
|
|
||||||
|
|
||||||
if self.workorder_id != False:
|
|
||||||
self.state = '占用'
|
|
||||||
else:
|
|
||||||
self.state = '空闲'
|
|
||||||
|
|
||||||
def unclamp(self):
|
|
||||||
self.workorder_id = False
|
|
||||||
self.production_id = False
|
|
||||||
self.state = '空闲'
|
|
||||||
|
|
||||||
@api.depends('code')
|
|
||||||
def compute_qr_image(self):
|
|
||||||
for item in self:
|
|
||||||
if not item.code:
|
|
||||||
item.qr_image = False
|
|
||||||
continue
|
|
||||||
# 根据code动态生成二维码图片
|
|
||||||
# qr = qrcode.QRCode(
|
|
||||||
# version=1,
|
|
||||||
# error_correction=qrcode.constants.ERROR_CORRECT_L,
|
|
||||||
# box_size=10,
|
|
||||||
# border=4,
|
|
||||||
# )
|
|
||||||
# qr.add_data(item.code)
|
|
||||||
# qr.make(fit=True)
|
|
||||||
# img = qr.make_image()
|
|
||||||
# 生成条形码文件
|
|
||||||
# bar = barcode.get("ean13", "123456789102", writer=ImageWriter())
|
|
||||||
# a = bar.get_fullcode()
|
|
||||||
# b = bar.save('occ')
|
|
||||||
# 生成条形码图片
|
|
||||||
partner_encoder = Code128Encoder(item.code)
|
|
||||||
# 转换bytes流
|
|
||||||
temp = BytesIO()
|
|
||||||
partner_encoder.save(temp)
|
|
||||||
# img.save(temp, format='PNG')
|
|
||||||
qr_image = base64.b64encode(temp.getvalue())
|
|
||||||
item.qr_image = qr_image
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
|
||||||
工单绑定托盘信息
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
class MrpWorkOrder(models.Model):
|
|
||||||
_inherit = 'mrp.workorder'
|
|
||||||
_description = '工单'
|
|
||||||
|
|
||||||
|
|
||||||
tray_ids = fields.One2many('sf.tray', 'workorder_id', string='托盘')
|
|
||||||
# def get_tray_info(self):
|
|
||||||
# @api.onchange('X_axis', 'Y_axis', 'Z_axis')
|
|
||||||
# def get_center_point(self):
|
|
||||||
# return 'X:%s,Y:%s,Z:%s' % (self.X_axis, self.Y_axis, self.Z_axis)
|
|
||||||
# 加工面
|
|
||||||
# surface = fields.Selection([("前面", "前面"), ("后面", "后面"), ("左面", "左面"), ("右面", "右面"),
|
|
||||||
# ("上面", "上面")], string="加工面1")
|
|
||||||
|
|
||||||
material_center_point = fields.Char(string='配料中心点')
|
|
||||||
X1_axis = fields.Float(string='Lx1', default=0)
|
|
||||||
Y1_axis = fields.Float(string='Ly1', default=0)
|
|
||||||
Z1_axis = fields.Float(string='Lz1', default=0)
|
|
||||||
X2_axis = fields.Float(string='Lx2', default=0)
|
|
||||||
Y2_axis = fields.Float(string='Ly2', default=0)
|
|
||||||
Z2_axis = fields.Float(string='Lz2', default=0)
|
|
||||||
X3_axis = fields.Float(string='Fx3', default=0)
|
|
||||||
Y3_axis = fields.Float(string='Fy3', default=0)
|
|
||||||
Z3_axis = fields.Float(string='Fz3', default=0)
|
|
||||||
X4_axis = fields.Float(string='Fx4', default=0)
|
|
||||||
Y4_axis = fields.Float(string='Fy4', default=0)
|
|
||||||
Z4_axis = fields.Float(string='Fz4', default=0)
|
|
||||||
X5_axis = fields.Float(string='Rx5', default=0)
|
|
||||||
Y5_axis = fields.Float(string='Ry5', default=0)
|
|
||||||
Z5_axis = fields.Float(string='Rz5', default=0)
|
|
||||||
X6_axis = fields.Float(string='Rx6', default=0)
|
|
||||||
Y6_axis = fields.Float(string='Ry6', default=0)
|
|
||||||
Z6_axis = fields.Float(string='Rz6', default=0)
|
|
||||||
X7_axis = fields.Float(string='Bx7', default=0)
|
|
||||||
Y7_axis = fields.Float(string='By7', default=0)
|
|
||||||
Z7_axis = fields.Float(string='Bz7', default=0)
|
|
||||||
X8_axis = fields.Float(string='Bx8', default=0)
|
|
||||||
Y8_axis = fields.Float(string='By8', default=0)
|
|
||||||
Z8_axis = fields.Float(string='Bz8', default=0)
|
|
||||||
X9_axis = fields.Float(string='Uz9', default=0)
|
|
||||||
Y9_axis = fields.Float(string='Uz9', default=0)
|
|
||||||
Z9_axis = fields.Float(string='Uz9', default=0)
|
|
||||||
X10_axis = fields.Float(string='Uz10', default=0)
|
|
||||||
Y10_axis = fields.Float(string='Uz10', default=0)
|
|
||||||
Z10_axis = fields.Float(string='Uz10', default=0)
|
|
||||||
|
|
||||||
# 扫码绑定托盘方法
|
|
||||||
def gettray(self):
|
|
||||||
return ""
|
|
||||||
#解除托盘绑定
|
|
||||||
def unbindtray(self):
|
|
||||||
return ""
|
|
||||||
|
|
||||||
# 计算配料中心点和与x轴倾斜度方法
|
|
||||||
def getcenter(self):
|
|
||||||
x1 = self.X1_axis
|
|
||||||
x2 = self.X2_axis
|
|
||||||
x3 = self.X3_axis
|
|
||||||
x4 = self.X4_axis
|
|
||||||
x5 = self.X5_axis
|
|
||||||
x6 = self.X6_axis
|
|
||||||
x7 = self.X7_axis
|
|
||||||
x8 = self.X8_axis
|
|
||||||
y1 = self.Y1_axis
|
|
||||||
y2 = self.Y2_axis
|
|
||||||
y3 = self.Y3_axis
|
|
||||||
y4 = self.Y4_axis
|
|
||||||
y5 = self.Y5_axis
|
|
||||||
y6 = self.Y6_axis
|
|
||||||
y7 = self.Y7_axis
|
|
||||||
y8 = self.Y8_axis
|
|
||||||
z1 = self.Z9_axis
|
|
||||||
x0 = ((x3 - x4) * (x2 * y1 - x1 * y2) - (x1 - x2) * (x4 * y3 - x3 * y4)) / (
|
|
||||||
(x3 - x4) * (y1 - y2) - (x1 - x2) * (y3 - y4))
|
|
||||||
y0 = ((y3 - y4) * (y2 * x1 - y1 * x2) - (y1 - y2) * (y4 * x3 - y3 * x4)) / (
|
|
||||||
(y3 - y4) * (x1 - x2) - (y1 - y2) * (x3 - x4))
|
|
||||||
x1 = ((x7 - x8) * (x6 * y5 - x5 * y7) - (x5 - x6) * (x8 * y7 - x7 * y8)) / (
|
|
||||||
(x7 - x8) * (y5 - y6) - (x5 - x6) * (y7 - y8));
|
|
||||||
y1 = ((y7 - y8) * (y6 * x5 - y5 * x7) - (y5 - y6) * (y8 * x7 - y7 * x8)) / (
|
|
||||||
(y7 - y8) * (x5 - x6) - (y5 - y6) * (x7 - x8))
|
|
||||||
x = (x0 + x1) / 2
|
|
||||||
y = (y0 + y1) / 2
|
|
||||||
z = z1 / 2
|
|
||||||
|
|
||||||
jd = math.atan2((x7 - x8), (y7 - y8))
|
|
||||||
jdz = jd * 180 / math.pi
|
|
||||||
print("(%s,%s)" % (x, y))
|
|
||||||
self.material_center_point = ("(%s,%s,%s)" % (x, y, z))
|
|
||||||
self.X_deviation_angle = jdz
|
|
||||||
|
|
||||||
X_deviation_angle = fields.Integer(string="X轴偏差度", default=0)
|
|
||||||
|
|
||||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], string="检测结果")
|
|
||||||
|
|
||||||
cnc_ids = fields.One2many("cnc.processing", 'workorder_id', string="CNC加工")
|
|
||||||
|
|
||||||
# @api.depends('tray_id')
|
|
||||||
# def updateTrayState(self):
|
|
||||||
#
|
|
||||||
# for item in self:
|
|
||||||
# if item.tray_code == False:
|
|
||||||
# continue
|
|
||||||
# trayInfo = self.env['sf.tray'].sudo.search([('code', '=', item.tray_code)])
|
|
||||||
# if trayInfo:
|
|
||||||
# trayInfo.update(
|
|
||||||
# {
|
|
||||||
# 'production_id': item.production_id,
|
|
||||||
# 'state': "占用",
|
|
||||||
# }
|
|
||||||
# )
|
|
||||||
def recreateManufacturing(self):
|
|
||||||
|
|
||||||
|
|
||||||
# productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(self.company_id).create(self.production_id)
|
|
||||||
# print(productions)
|
|
||||||
return ""
|
|
||||||
|
|
||||||
def recreateWorkerOrder(self):
|
|
||||||
self.env['stock.move'].sudo().create(self.production_id._get_moves_raw_values())
|
|
||||||
self.env['stock.move'].sudo().create(self.production_id._get_moves_finished_values())
|
|
||||||
self.production_id._create_workorder()
|
|
||||||
return ""
|
|
||||||
|
|
||||||
cnc_id = fields.Many2many('ir.attachment', 'cnc_attachment', string="cnc程序获取")
|
|
||||||
def fetchCNC(self):
|
|
||||||
return ""
|
|
||||||
|
|
||||||
'''
|
|
||||||
制造订单绑定托盘信息
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
class MrpProduction(models.Model):
|
|
||||||
_inherit = 'mrp.production'
|
|
||||||
_description = "制造订单"
|
|
||||||
|
|
||||||
tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘")
|
|
||||||
|
|
||||||
class Attachment(models.Model):
|
|
||||||
_inherit = 'ir.attachment'
|
|
||||||
|
|
||||||
cnc_model = fields.Binary('cnc文件', attachment=False)
|
|
||||||
model_name = fields.Char('模型名称')
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user