Merge branch 'feature/修改产品等信息' into develop

# Conflicts:
#	sf_base/models/product_template.py
#	sf_route_workcenter/models/workcenter.py
This commit is contained in:
jinling.yang
2022-11-20 20:11:21 +08:00
14 changed files with 128 additions and 102 deletions

View File

@@ -3,13 +3,16 @@
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 datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from odoo.addons.sf_base.commons.common import Common
_logger = logging.getLogger(__name__)
@@ -19,6 +22,26 @@ class CNCprocessing(models.Model):
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']),
('processing_panel', '=', obj['processing_panel']),
('routing_type', '=', 'CNC加工')])
self.env['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'],
# 'FJGDate': obj['']
})
class Tray(models.Model):
_inherit = 'sf.tray'
@@ -83,11 +106,6 @@ class MrpWorkOrder(models.Model):
_inherit = 'mrp.workorder'
_description = '工单'
def button_start(self):
if self.state == 'waiting':
self.ensure_one()
@@ -133,7 +151,9 @@ class MrpWorkOrder(models.Model):
if self.date_planned_finished and self.date_planned_finished < start_date:
vals['date_planned_finished'] = start_date
return self.write(vals)
else:raise ValidationError(_('请先完成上一步工单'))
else:
raise ValidationError(_('请先完成上一步工单'))
# def get_tray_info(self):
# @api.onchange('X_axis', 'Y_axis', 'Z_axis')
# def get_center_point(self):
@@ -290,8 +310,31 @@ class MrpWorkOrder(models.Model):
else:
return True
# cnc程序获取
def fetchCNC(self):
return ""
res = [{'model_code': self.product_id.barcode, 'production_no': self.production_id.name,
'machine_tool_code': self.workcenter_id.machine_tool_id.code,
'material_code': self.env['mrs.production.materials'].search(
[('id', '=', self.product_id.materials_id.id)]).materials_no,
'material_type_code': self.env['mrs.materials.model'].search(
[('id', '=', self.product_id.materials_type_id.id)]).materials_no,
'embryo_long': self.product_id.bom_ids.bom_line_ids.product_id.long,
'embryo_height': self.product_id.bom_ids.bom_line_ids.product_id.height,
'embryo_width': self.product_id.bom_ids.bom_line_ids.product_id.width
# 'factory_code': self.env.user.company_id.partner_id.
}]
configsettings = self.env['res.config.settings'].get_values()
config_header = Common.get_headers(self, configsettings['token'], configsettings['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)
ret = ret.json()
result = json.loads(ret['result'])
if result['status'] == 1:
return self.write({'state': 'progress'})
def json_workorder_str1(self, k, production, route):
workorders_values_str = [0, '', {
'product_uom_id': production.product_uom_id.id,
@@ -340,14 +383,13 @@ class MrpProduction(models.Model):
'user_id': production.user_id.id}
return production_values_str
def _reset_work_order_sequence1(self,k):
def _reset_work_order_sequence1(self, k):
for rec in self:
current_sequence = 1
for work in rec.workorder_ids:
work.sequence = current_sequence
current_sequence += 1
def _create_workorder1(self, k):
for production in self:
if not production.bom_id or not production.product_id:
@@ -389,11 +431,10 @@ class MrpProduction(models.Model):
i += 1
for route in routingworkcenter:
if route.routing_type == '后置三元质量检测':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str1(k, production, route)
)
)
if route.routing_type == 'CNC加工':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str1(k, production, route))
@@ -406,6 +447,3 @@ class MrpProduction(models.Model):
res = self._create_workorder1(k)
self._reset_work_order_sequence1(k)
return res