Accept Merge Request #76: (feature/轨迹跟踪 -> develop)
Merge Request: 物流前轨迹跟踪代码合并 Created By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/76
This commit is contained in:
@@ -8,7 +8,7 @@ from odoo.http import request
|
|||||||
|
|
||||||
class Sf_Bf_Connect(http.Controller):
|
class Sf_Bf_Connect(http.Controller):
|
||||||
|
|
||||||
@http.route('/api/bfm_process_order/list', type='http', auth='none', methods=['GET', 'POST'], csrf=False,
|
@http.route('/api/bfm_process_order/list', type='http', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def get_bfm_process_order_list(self, **kw):
|
def get_bfm_process_order_list(self, **kw):
|
||||||
"""
|
"""
|
||||||
@@ -19,6 +19,9 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
res = {'status': 1, 'factory_order_no': ''}
|
res = {'status': 1, 'factory_order_no': ''}
|
||||||
logging.info('get_bfm_process_order_list:%s' % kw)
|
logging.info('get_bfm_process_order_list:%s' % kw)
|
||||||
try:
|
try:
|
||||||
|
logging.info('get_bfm_process_order_list===================================:%s' % kw['order_number'])
|
||||||
|
# aa = request.env['sale.order'].sudo().get_default_code(kw['order_number'])
|
||||||
|
|
||||||
# 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'])
|
||||||
@@ -44,9 +47,7 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
# else:
|
# else:
|
||||||
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,
|
||||||
kw['order_number'], i)
|
kw['order_number'], i)
|
||||||
# order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
i += 1
|
||||||
logging.info('order_id:%s' % order_id)
|
|
||||||
logging.info('product:%s' % product)
|
|
||||||
bom_data = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).get_bom(product)
|
bom_data = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).get_bom(product)
|
||||||
logging.info('bom_data:%s' % bom_data)
|
logging.info('bom_data:%s' % bom_data)
|
||||||
if bom_data:
|
if bom_data:
|
||||||
@@ -102,8 +103,12 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
product_bom_purchase.with_user(request.env.ref("base.user_admin")).bom_create_line_has(
|
product_bom_purchase.with_user(request.env.ref("base.user_admin")).bom_create_line_has(
|
||||||
purchase_embryo)
|
purchase_embryo)
|
||||||
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
||||||
i += 1
|
|
||||||
res['factory_order_no'] = order_id.name
|
res['factory_order_no'] = order_id.name
|
||||||
|
aa = request.env['sale.order'].sudo().search([('name', '=', order_id.name)])
|
||||||
|
logging.info('get_bfm_process_or===================================:%s' % order_id.name)
|
||||||
|
aa.default_code = kw['order_number']
|
||||||
|
logging.info('get_bfm_process_order_listaaaaaaaaaaaaaaaaaaaaaaaaaaaa================:%s' % aa.default_code)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info('get_bfm_process_order_list error:%s' % e)
|
logging.info('get_bfm_process_order_list error:%s' % e)
|
||||||
res['status'] = -1
|
res['status'] = -1
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
from . import http
|
from . import http
|
||||||
from . import models
|
from . import models
|
||||||
|
from . import process_status
|
||||||
|
|
||||||
|
|||||||
110
sf_bf_connect/models/process_status.py
Normal file
110
sf_bf_connect/models/process_status.py
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
from datetime import datetime
|
||||||
|
import logging
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
import requests
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class StatusChange(models.Model):
|
||||||
|
_inherit = 'sale.order'
|
||||||
|
|
||||||
|
default_code = fields.Char(string='内部编码')
|
||||||
|
|
||||||
|
def action_confirm(self):
|
||||||
|
logging.info('函数已经执行=============')
|
||||||
|
if self._get_forbidden_state_confirm() & set(self.mapped('state')):
|
||||||
|
raise UserError(_(
|
||||||
|
"It is not allowed to confirm an order in the following states: %s",
|
||||||
|
", ".join(self._get_forbidden_state_confirm()),
|
||||||
|
))
|
||||||
|
logging.info('函数已经执行=============1')
|
||||||
|
for order in self:
|
||||||
|
if order.partner_id in order.message_partner_ids:
|
||||||
|
logging.info('函数已经执行=============2')
|
||||||
|
continue
|
||||||
|
order.message_subscribe([order.partner_id.id])
|
||||||
|
logging.info('函数已经执行=============3')
|
||||||
|
self.write(self._prepare_confirmation_values())
|
||||||
|
|
||||||
|
# Context key 'default_name' is sometimes propagated up to here.
|
||||||
|
# We don't need it and it creates issues in the creation of linked records.
|
||||||
|
context = self._context.copy()
|
||||||
|
context.pop('default_name', None)
|
||||||
|
logging.info('函数已经执行=============4')
|
||||||
|
|
||||||
|
self.with_context(context)._action_confirm()
|
||||||
|
if self.env.user.has_group('sale.group_auto_done_setting'):
|
||||||
|
logging.info('函数已经执行=============5')
|
||||||
|
self.action_done()
|
||||||
|
process_start_time = str(datetime.now())
|
||||||
|
json1 = {
|
||||||
|
'params': {
|
||||||
|
'model_name': 'jikimo.process.order',
|
||||||
|
'field_name': 'name',
|
||||||
|
# 'default_code': 'PO-2022-1214-0022',
|
||||||
|
'default_code': self.default_code,
|
||||||
|
# 'default_code': self.name,
|
||||||
|
'state': '加工中',
|
||||||
|
'process_start_time': process_start_time,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
url1 = 'https://bfm.cs.jikimo.com/api/get/state/get_order'
|
||||||
|
requests.post(url1, json=json1, data=None)
|
||||||
|
logging.info('接口已经执行=============')
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def action_cancel(self):
|
||||||
|
""" Cancel SO after showing the cancel wizard when needed. (cfr `_show_cancel_wizard`)
|
||||||
|
|
||||||
|
For post-cancel operations, please only override `_action_cancel`.
|
||||||
|
|
||||||
|
note: self.ensure_one() if the wizard is shown.
|
||||||
|
"""
|
||||||
|
logging.info('函数已经执行=============')
|
||||||
|
cancel_warning = self._show_cancel_wizard()
|
||||||
|
logging.info('函数已经执行=============2')
|
||||||
|
json1 = {
|
||||||
|
'params': {
|
||||||
|
'model_name': 'jikimo.process.order',
|
||||||
|
'field_name': 'name',
|
||||||
|
'default_code': self.default_code,
|
||||||
|
# 'default_code': self.name,
|
||||||
|
'state': '待派单',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
url1 = 'https://bfm.cs.jikimo.com/api/get/state/cancel_order'
|
||||||
|
requests.post(url1, json=json1, data=None)
|
||||||
|
if cancel_warning:
|
||||||
|
logging.info('函数已经执行=============3')
|
||||||
|
self.ensure_one()
|
||||||
|
logging.info('函数已经执行=============4')
|
||||||
|
template_id = self.env['ir.model.data']._xmlid_to_res_id(
|
||||||
|
'sale.mail_template_sale_cancellation', raise_if_not_found=False
|
||||||
|
)
|
||||||
|
lang = self.env.context.get('lang')
|
||||||
|
template = self.env['mail.template'].browse(template_id)
|
||||||
|
if template.lang:
|
||||||
|
lang = template._render_lang(self.ids)[self.id]
|
||||||
|
ctx = {
|
||||||
|
'default_use_template': bool(template_id),
|
||||||
|
'default_template_id': template_id,
|
||||||
|
'default_order_id': self.id,
|
||||||
|
'mark_so_as_canceled': True,
|
||||||
|
'default_email_layout_xmlid': "mail.mail_notification_layout_with_responsible_signature",
|
||||||
|
'model_description': self.with_context(lang=lang).type_name,
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'name': _('Cancel %s', self.type_name),
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_model': 'sale.order.cancel',
|
||||||
|
'view_id': self.env.ref('sale.sale_order_cancel_view_form').id,
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'context': ctx,
|
||||||
|
'target': 'new'
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return self._action_cancel()
|
||||||
|
|
||||||
@@ -4,6 +4,7 @@ import math
|
|||||||
import requests
|
import requests
|
||||||
import logging
|
import logging
|
||||||
import base64
|
import base64
|
||||||
|
import hashlib
|
||||||
# import subprocess
|
# import subprocess
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
@@ -36,20 +37,22 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
uid = self.env.uid
|
uid = self.env.uid
|
||||||
for workorder in self:
|
for workorder in self:
|
||||||
if workorder.users_ids:
|
if workorder.users_ids:
|
||||||
|
list_user_id=[]
|
||||||
for item in workorder.users_ids:
|
for item in workorder.users_ids:
|
||||||
if item.id == uid:
|
list_user_id.append(item.id)
|
||||||
workorder.user_permissions = True
|
if uid in list_user_id:
|
||||||
else:
|
workorder.user_permissions = True
|
||||||
workorder.user_permissions = False
|
else:
|
||||||
|
workorder.user_permissions = False
|
||||||
else:workorder.user_permissions=False
|
else:workorder.user_permissions=False
|
||||||
|
|
||||||
|
|
||||||
user_permissions = fields.Boolean('用户权限', compute='get_user_permissions')
|
user_permissions = fields.Boolean('用户权限', compute='get_user_permissions')
|
||||||
programming_no = fields.Char('编程单号')
|
programming_no = fields.Char('编程单号')
|
||||||
is_programming = fields.Boolean('是否编程', default=False)
|
work_state = fields.Char('业务状态')
|
||||||
|
programming_state = fields.Char('编程状态')
|
||||||
cnc_worksheet = fields.Binary(
|
cnc_worksheet = fields.Binary(
|
||||||
'工作指令', readonly=True)
|
'工作指令', readonly=True)
|
||||||
material_center_point = fields.Char(string='胚料中心点')
|
material_center_point = fields.Char(string='配料中心点')
|
||||||
X1_axis = fields.Float(default=0)
|
X1_axis = fields.Float(default=0)
|
||||||
Y1_axis = fields.Float(default=0)
|
Y1_axis = fields.Float(default=0)
|
||||||
Z1_axis = fields.Float(default=0)
|
Z1_axis = fields.Float(default=0)
|
||||||
@@ -136,6 +139,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'name': route.route_workcenter_id.name,
|
'name': route.route_workcenter_id.name,
|
||||||
'processing_panel': k,
|
'processing_panel': k,
|
||||||
'routing_type': route.routing_type,
|
'routing_type': route.routing_type,
|
||||||
|
'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
|
||||||
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids),
|
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids),
|
||||||
'date_planned_start': False,
|
'date_planned_start': False,
|
||||||
'date_planned_finished': False,
|
'date_planned_finished': False,
|
||||||
@@ -253,23 +257,34 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def fetchCNCing(self):
|
||||||
|
return None
|
||||||
|
|
||||||
# cnc程序获取
|
# cnc程序获取
|
||||||
def fetchCNC(self):
|
def fetchCNC(self):
|
||||||
cnc = self.env['mrp.workorder'].search(
|
cnc = self.env['mrp.workorder'].search(
|
||||||
[('routing_type', '=', 'CNC加工'), ('production_id', '=', self.production_id.id)], limit=1)
|
[('routing_type', '=', 'CNC加工'), ('production_id', '=', self.production_id.id)], limit=1)
|
||||||
res = {'model_code': cnc.product_id.barcode, 'production_no': self.production_id.name,
|
if cnc.product_id.upload_model_file:
|
||||||
|
attachment = cnc.product_id.upload_model_file[0]
|
||||||
|
base64_data = base64.b64encode(attachment.datas)
|
||||||
|
base64_datas = base64_data.decode('utf-8')
|
||||||
|
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||||
|
res = {'model_code': '' if not cnc.product_id.upload_model_file else model_code,
|
||||||
|
'production_no': self.production_id.name,
|
||||||
'machine_tool_code': cnc.workcenter_id.machine_tool_id.code,
|
'machine_tool_code': cnc.workcenter_id.machine_tool_id.code,
|
||||||
'material_code': cnc.env['sf.production.materials'].search(
|
'material_code': cnc.env['sf.production.materials'].search(
|
||||||
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
|
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
|
||||||
'material_type_code': cnc.env['sf.materials.model'].search(
|
'material_type_code': cnc.env['sf.materials.model'].search(
|
||||||
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
|
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
|
||||||
|
'machining_processing_panel': cnc.product_id.model_processing_panel,
|
||||||
'machining_precision': cnc.product_id.model_machining_precision,
|
'machining_precision': cnc.product_id.model_machining_precision,
|
||||||
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
|
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
|
||||||
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
|
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
|
||||||
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
|
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
|
||||||
'order_no': cnc.production_id.origin,
|
'order_no': cnc.production_id.origin,
|
||||||
'user': self.env.user.name,
|
'user': self.env.user.name,
|
||||||
'model_file': base64.b64encode(cnc.product_id.model_file).decode('utf-8')
|
'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
|
||||||
|
cnc.product_id.model_file).decode('utf-8')
|
||||||
}
|
}
|
||||||
logging.info('res:%s' % res)
|
logging.info('res:%s' % res)
|
||||||
configsettings = self.env['res.config.settings'].get_values()
|
configsettings = self.env['res.config.settings'].get_values()
|
||||||
@@ -279,9 +294,16 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# res_str = json.dumps(res)
|
# res_str = json.dumps(res)
|
||||||
ret = requests.post(config_url, json={}, data=res, headers=config_header)
|
ret = requests.post(config_url, json={}, data=res, headers=config_header)
|
||||||
ret = ret.json()
|
ret = ret.json()
|
||||||
result = json.loads(ret['result'])
|
if ret['status'] == 1:
|
||||||
if result['status'] == 1:
|
self.write({'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'})
|
||||||
return self.write({'programming_no': result['programming_no'], 'is_programming': True})
|
return {
|
||||||
|
'name': _("工单"),
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_model': 'mrp.workorder',
|
||||||
|
'res_id': self.id,
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'target': 'new'
|
||||||
|
}
|
||||||
|
|
||||||
def json_workorder_str1(self, k, production, route):
|
def json_workorder_str1(self, k, production, route):
|
||||||
workorders_values_str = [0, '', {
|
workorders_values_str = [0, '', {
|
||||||
@@ -291,6 +313,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'name': route.route_workcenter_id.name,
|
'name': route.route_workcenter_id.name,
|
||||||
'processing_panel': k,
|
'processing_panel': k,
|
||||||
'routing_type': route.routing_type,
|
'routing_type': route.routing_type,
|
||||||
|
'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
|
||||||
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids),
|
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids),
|
||||||
'date_planned_start': False,
|
'date_planned_start': False,
|
||||||
'date_planned_finished': False,
|
'date_planned_finished': False,
|
||||||
@@ -303,7 +326,6 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
def button_start(self):
|
def button_start(self):
|
||||||
if self.state == 'waiting' or self.state == 'ready':
|
if self.state == 'waiting' or self.state == 'ready':
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|
||||||
if any(not time.date_end for time in self.time_ids.filtered(lambda t: t.user_id.id == self.env.user.id)):
|
if any(not time.date_end for time in self.time_ids.filtered(lambda t: t.user_id.id == self.env.user.id)):
|
||||||
return True
|
return True
|
||||||
# As button_start is automatically called in the new view
|
# As button_start is automatically called in the new view
|
||||||
@@ -370,28 +392,39 @@ class CNCprocessing(models.Model):
|
|||||||
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
||||||
|
|
||||||
# mrs下发编程单创建CNC加工
|
# mrs下发编程单创建CNC加工
|
||||||
def cnc_processing_create(self, obj):
|
def cnc_processing_create(self, cncObj, production_order_no):
|
||||||
workorder = self.env['mrp.workorder'].search([('production_id.name', '=', obj['production_order_no']),
|
cnc_processing = self.env['mrp.workorder'].search([('production_id.name', '=', production_order_no),
|
||||||
('processing_panel', '=', obj['processing_panel']),
|
('routing_type', '=', '获取CNC加工程序'),
|
||||||
('routing_type', '=', 'CNC加工')])
|
('state', '=', 'progress')])
|
||||||
vals = {
|
# cnc.workorder_id.state = 'done'
|
||||||
'workorder_id': workorder.id,
|
if cnc_processing:
|
||||||
'sequence_number': obj['sequence_number'],
|
for obj in cncObj:
|
||||||
'program_name': obj['program_name'],
|
workorder = self.env['mrp.workorder'].search([('production_id.name', '=', production_order_no),
|
||||||
'cutting_tool_name': obj['cutting_tool_name'],
|
('processing_panel', '=', obj['processing_panel']),
|
||||||
'cutting_tool_no': obj['cutting_tool_no'],
|
('routing_type', '=', 'CNC加工')])
|
||||||
'processing_type': obj['processing_type'],
|
self.env['sf.cnc.processing'].create({
|
||||||
'margin_x_y': obj['margin_x_y'],
|
'workorder_id': workorder.id,
|
||||||
'margin_z': obj['margin_z'],
|
'sequence_number': obj['sequence_number'],
|
||||||
'depth_of_processing_z': obj['depth_of_processing_z'],
|
'program_name': obj['program_name'],
|
||||||
'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
|
'cutting_tool_name': obj['cutting_tool_name'],
|
||||||
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
'cutting_tool_no': obj['cutting_tool_no'],
|
||||||
'estimated_processing_time': obj['estimated_processing_time'],
|
'processing_type': obj['processing_type'],
|
||||||
'remark': obj['remark']
|
'margin_x_y': obj['margin_x_y'],
|
||||||
}
|
'margin_z': obj['margin_z'],
|
||||||
return self.env['sf.cnc.processing'].create(vals)
|
'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'],
|
||||||
|
'estimated_processing_time': obj['estimated_processing_time'],
|
||||||
|
'remark': obj['remark']
|
||||||
|
})
|
||||||
|
cnc_processing.state = 'done'
|
||||||
|
cnc_processing.work_state = '已编程'
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# 创建附件(nc文件)
|
||||||
|
|
||||||
# 创建附件(nc文件)
|
|
||||||
def attachment_create(self, name, data):
|
def attachment_create(self, name, data):
|
||||||
attachment = self.env['ir.attachment'].create({
|
attachment = self.env['ir.attachment'].create({
|
||||||
'datas': base64.b64encode(data),
|
'datas': base64.b64encode(data),
|
||||||
@@ -402,9 +435,9 @@ class CNCprocessing(models.Model):
|
|||||||
return attachment
|
return attachment
|
||||||
|
|
||||||
# 将FTP的nc文件下载到临时目录
|
# 将FTP的nc文件下载到临时目录
|
||||||
def download_file_tmp(self, model_code, processing_panel):
|
def download_file_tmp(self, production_no, processing_panel):
|
||||||
remotepath = os.path.join('/', model_code, 'return', processing_panel)
|
remotepath = os.path.join('/', production_no, 'return', processing_panel)
|
||||||
serverdir = os.path.join('/tmp', model_code, 'return', processing_panel)
|
serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
|
||||||
ftp = FtpController()
|
ftp = FtpController()
|
||||||
ftp.download_file_tree(remotepath, serverdir)
|
ftp.download_file_tree(remotepath, serverdir)
|
||||||
return serverdir
|
return serverdir
|
||||||
@@ -420,6 +453,20 @@ class CNCprocessing(models.Model):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# 将nc文件对应的excel清单转为pdf
|
||||||
|
# def to_pdf(self, excel_path, pdf_path):
|
||||||
|
# """
|
||||||
|
# 需要在linux中下载好libreoffice
|
||||||
|
# """
|
||||||
|
# logging.info('pdf_path:%s' % pdf_path)
|
||||||
|
# logging.info('pdf_path:%s' % excel_path)
|
||||||
|
# # 注意cmd中的libreoffice要和linux中安装的一致
|
||||||
|
# cmd = 'soffice --headless --convert-to pdf'.split() + [excel_path] + ['--outdir'] + [pdf_path]
|
||||||
|
# p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=1)
|
||||||
|
# # p.wait(timeout=30) # 停顿30秒等待转化
|
||||||
|
# # stdout, stderr = p.communicate()
|
||||||
|
# p.communicate()
|
||||||
|
|
||||||
|
|
||||||
class SfWorkOrderBarcodes(models.Model):
|
class SfWorkOrderBarcodes(models.Model):
|
||||||
"""
|
"""
|
||||||
@@ -430,6 +477,9 @@ class SfWorkOrderBarcodes(models.Model):
|
|||||||
|
|
||||||
def on_barcode_scanned(self, barcode):
|
def on_barcode_scanned(self, barcode):
|
||||||
tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
|
tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
|
||||||
self.tray_code = tray_code.code
|
# 在这里,用等号赋值只是一次性的,只是一种展示
|
||||||
|
# self.tray_code = tray_code.code
|
||||||
|
# 用write方法写入数据库是永久的
|
||||||
|
self.write({'tray_code': tray_code.code})
|
||||||
workorder = self.env['mrp.workorder'].browse(self.ids)
|
workorder = self.env['mrp.workorder'].browse(self.ids)
|
||||||
workorder.gettray_auto(barcode)
|
workorder.gettray_auto(barcode)
|
||||||
|
|||||||
Reference in New Issue
Block a user