Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into develop
# Conflicts: # sf_manufacturing/models/mrp_workorder.py
This commit is contained in:
@@ -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]', compute='_compute_model_volume', store=True)
|
||||
model_machining_precision = fields.Selection([
|
||||
('±0.10mm', '±0.10mm'),
|
||||
('±0.05mm', '±0.05mm'),
|
||||
@@ -22,9 +22,9 @@ class ResProductTemplate(models.Model):
|
||||
model_process_parameters_id = fields.Many2one('sf.processing.technology', string='工艺参数')
|
||||
model_price = fields.Float('模型单价', digits=(16, 3))
|
||||
model_remark = fields.Char('模型备注说明')
|
||||
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')
|
||||
long = fields.Float('长[mm]', digits=(16, 3))
|
||||
width = fields.Float('宽[mm]', digits=(16, 3))
|
||||
height = fields.Float('高[mm]', digits=(16, 3))
|
||||
materials_id = fields.Many2one('sf.production.materials', string='材料')
|
||||
materials_type_id = fields.Many2one('sf.materials.model', string='材料型号')
|
||||
volume = fields.Float(compute='_compute_volume', store=True)
|
||||
@@ -34,6 +34,10 @@ class ResProductTemplate(models.Model):
|
||||
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()
|
||||
@@ -70,17 +74,20 @@ class ResProductTemplate(models.Model):
|
||||
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
|
||||
[('id', '=', self.model_type_id.id), ('embryo_tolerance', '=', True)])
|
||||
if model_type:
|
||||
self.model_long = self.model_long + 1
|
||||
self.model_width = self.model_width + 1
|
||||
self.model_height = self.model_width + 1
|
||||
# for item in self:
|
||||
# print(item.model_long)
|
||||
# print(item.model_width)
|
||||
# print(item.model_height)
|
||||
# item.model_long = item.model_long + 1
|
||||
# item.model_width = item.model_width + 1
|
||||
# item.model_height = item.model_width + 1
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
class ResMrpBom(models.Model):
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
<field name="model_width" string="宽[mm]"/>
|
||||
<field name="model_height" string="高[mm]"/>
|
||||
<field name="model_volume" string="体积[mm]"/>
|
||||
<field name="model_type_id" string="模板类型"/>
|
||||
<field name="model_processing_panel" placeholder="例如A,B" string="加工面板"/>
|
||||
<field name="model_type_id" string="模型类型"/>
|
||||
<field name="model_processing_panel" placeholder="例如R,U" string="加工面板"/>
|
||||
<field name="model_machining_precision" />
|
||||
<field name="model_surface_process_id" string="表面工艺"/>
|
||||
<field name="model_process_parameters_id" string="工艺参数"
|
||||
|
||||
@@ -6,7 +6,7 @@ class ModelType(models.Model):
|
||||
_description = '模型类型'
|
||||
|
||||
name = fields.Char('名称')
|
||||
embryo_tolerance = fields.Integer('胚料的容余量')
|
||||
embryo_tolerance = fields.Boolean('胚料的容余量', default=False)
|
||||
routing_tmpl_ids = fields.One2many('sf.model.type.routing.sort', 'model_type_id', '工序模板')
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,13 @@ import logging
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||
<<<<<<< HEAD
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
=======
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo.exceptions import UserError
|
||||
>>>>>>> b2d1e9ce8c5d8965ed09c3fbd6de543708223487
|
||||
|
||||
|
||||
class ResMrpWorkOrder(models.Model):
|
||||
@@ -97,6 +102,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
print("(%.2f,%.2f)" % (x, y))
|
||||
self.material_center_point = ("(%.2f,%.2f,%.2f)" % (x, y, z))
|
||||
self.X_deviation_angle = jdz
|
||||
return self.material_center_point
|
||||
|
||||
def json_workorder_str(self, k, production, route):
|
||||
workorders_values_str = [0, '', {
|
||||
@@ -139,9 +145,9 @@ class ResMrpWorkOrder(models.Model):
|
||||
values = self.env['sf.tray'].search([("code", "=", self.tray_code)])
|
||||
if values:
|
||||
if values.state == "占用":
|
||||
raise ValidationError('该托盘已占用')
|
||||
raise UserError('该托盘已占用')
|
||||
if values.state == "报损":
|
||||
raise ValidationError('该托盘已损坏')
|
||||
raise UserError('该托盘已损坏')
|
||||
else:
|
||||
values.update({
|
||||
'workorder_id': self,
|
||||
@@ -149,7 +155,26 @@ class ResMrpWorkOrder(models.Model):
|
||||
'state': '占用',
|
||||
})
|
||||
else:
|
||||
raise ValidationError('该托盘编码已失效')
|
||||
raise UserError('该托盘编码已失效')
|
||||
else:
|
||||
return ""
|
||||
|
||||
def gettray_auto(self, barcode):
|
||||
if barcode != False:
|
||||
values = self.env['sf.tray'].search([("code", "=", barcode)])
|
||||
if values:
|
||||
if values.state == "占用":
|
||||
raise UserError('该托盘已占用')
|
||||
if values.state == "报损":
|
||||
raise UserError('该托盘已损坏')
|
||||
else:
|
||||
values.update({
|
||||
'workorder_id': self,
|
||||
'production_id': self.production_id,
|
||||
'state': '占用',
|
||||
})
|
||||
else:
|
||||
raise UserError('该托盘编码已失效')
|
||||
else:
|
||||
return ""
|
||||
|
||||
@@ -206,7 +231,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
|
||||
# cnc程序获取
|
||||
def fetchCNC(self):
|
||||
cnc = self.env['mrp.workorder'].search([('routing_type', '=', 'CNC加工')], limit=1)
|
||||
cnc = self.env['mrp.workorder'].search(
|
||||
[('routing_type', '=', 'CNC加工'), ('production_id', '=', self.production_id.id)], limit=1)
|
||||
res = {'model_code': cnc.product_id.barcode, 'production_no': self.production_id.name,
|
||||
'machine_tool_code': cnc.workcenter_id.machine_tool_id.code,
|
||||
'material_code': cnc.env['sf.production.materials'].search(
|
||||
@@ -302,36 +328,52 @@ class CNCprocessing(models.Model):
|
||||
_description = "CNC加工"
|
||||
|
||||
cnc_id = fields.Many2one('ir.attachment')
|
||||
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.Datetime(string="预计加工时间")
|
||||
FComment = fields.Char(string="备注")
|
||||
sequence_number = fields.Char('序号')
|
||||
program_name = fields.Char('程序名')
|
||||
cutting_tool_name = fields.Char('刀具名称')
|
||||
cutting_tool_no = fields.Char('刀号')
|
||||
processing_type = fields.Char('加工类型')
|
||||
margin_x_y = fields.Char('余量_X/Y')
|
||||
margin_z = fields.Char('余量_Z')
|
||||
depth_of_processing_z = fields.Char('加工深度(Z)')
|
||||
cutting_tool_extension_length = fields.Char('刀具伸出长度')
|
||||
cutting_tool_handle_type = fields.Char('刀柄型号')
|
||||
estimated_processing_time = fields.Char('预计加工时间')
|
||||
remark = fields.Text('备注')
|
||||
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
||||
|
||||
# mrs下发编程单创建CNC加工
|
||||
def CNCprocessing_create(self, obj):
|
||||
workorder = self.env['mrp.workorder'].search([('production_id', '=', obj['manufacturing_order_no']),
|
||||
workorder = self.env['mrp.workorder'].search([('production_id.name', '=', obj['manufacturing_order_no']),
|
||||
('processing_panel', '=', obj['processing_panel']),
|
||||
('routing_type', '=', 'CNC加工')])
|
||||
self.env['sf.cnc.processing'].create({
|
||||
'workorder_id': workorder.id,
|
||||
'FNo': obj['sequence_number'],
|
||||
'FPGName': obj['program_name'],
|
||||
'FKnifeName': obj['cutting_tool_name'],
|
||||
'FDNo': obj['cutting_tool_no'],
|
||||
'FWorkType': obj['processing_type'],
|
||||
'FXY': obj['margin_x_y'],
|
||||
'FZ': obj['margin_z'],
|
||||
'FJGSD': obj['depth_of_processing_z'],
|
||||
'FSCCD': obj['cutting_tool_extension_length'],
|
||||
'FDJSpec': obj['cutting_tool_handle_type'],
|
||||
'sequence_number': obj['sequence_number'],
|
||||
'program_name': obj['program_name'],
|
||||
'cutting_tool_name': obj['cutting_tool_name'],
|
||||
'cutting_tool_no': obj['cutting_tool_no'],
|
||||
'processing_type': obj['processing_type'],
|
||||
'margin_x_y': obj['margin_x_y'],
|
||||
'margin_z': obj['margin_z'],
|
||||
'depth_of_processing_z': obj['depth_of_processing_z'],
|
||||
'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
|
||||
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
||||
'remark': obj['remark']
|
||||
# 'FJGDate': obj['']
|
||||
})
|
||||
|
||||
class SfWorkOrderBarcodes(models.Model):
|
||||
"""
|
||||
智能工厂工单处扫码绑定托盘
|
||||
"""
|
||||
_name = "mrp.workorder"
|
||||
_inherit = ["mrp.workorder", "barcodes.barcode_events_mixin"]
|
||||
|
||||
def on_barcode_scanned(self, barcode):
|
||||
|
||||
tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
|
||||
self.tray_code = tray_code.code
|
||||
|
||||
workorder = self.env['mrp.workorder'].browse(self.ids)
|
||||
workorder.gettray_auto(barcode)
|
||||
@@ -41,16 +41,16 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_mrp_production_workorder_form_inherit_sf">
|
||||
<field name="name">mrp.production.workorder.form.inherit.sf</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="production_id" position="after">
|
||||
<field name="processing_panel" readonly="1"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_form_inherit_sf">-->
|
||||
<!-- <field name="name">mrp.production.workorder.form.inherit.sf</field>-->
|
||||
<!-- <field name="model">mrp.workorder</field>-->
|
||||
<!-- <field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <field name="production_id" position="after">-->
|
||||
<!-- <field name="processing_panel" readonly="1"/>-->
|
||||
<!-- </field>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<record id="view_mrp_production_workorder_tray_form_inherit_sf" model="ir.ui.view">
|
||||
<field name="name">mrp.production.workorder.tray.form.inherit.sf</field>
|
||||
@@ -213,18 +213,18 @@
|
||||
<field name="cnc_ids" widget="one2many">
|
||||
<tree>
|
||||
<field name="cnc_id"/>
|
||||
<field name="FNo"/>
|
||||
<field name="FPGName"/>
|
||||
<field name="FKnifeName"/>
|
||||
<field name="FDNo"/>
|
||||
<field name="FWorkType"/>
|
||||
<field name="FXY"/>
|
||||
<field name="FZ"/>
|
||||
<field name="FJGSD"/>
|
||||
<field name="FSCCD"/>
|
||||
<field name="FDJSpec"/>
|
||||
<field name="FJGDate"/>
|
||||
<field name="FComment"/>
|
||||
<field name="sequence_number"/>
|
||||
<field name="program_name"/>
|
||||
<field name="cutting_tool_name"/>
|
||||
<field name="cutting_tool_no"/>
|
||||
<field name="processing_type"/>
|
||||
<field name="margin_x_y"/>
|
||||
<field name="margin_z"/>
|
||||
<field name="depth_of_processing_z"/>
|
||||
<field name="cutting_tool_extension_length"/>
|
||||
<field name="cutting_tool_handle_type"/>
|
||||
<field name="estimated_processing_time"/>
|
||||
<field name="remark"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user