增加状态返回接口,增加调用京东接口
This commit is contained in:
@@ -34,6 +34,12 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
logging.info('get_bfm_process_or===================================:%s' % order_id.name)
|
logging.info('get_bfm_process_or===================================:%s' % order_id.name)
|
||||||
aa.default_code = kw['order_number']
|
aa.default_code = kw['order_number']
|
||||||
logging.info('get_bfm_process_order_listaaaaaaaaaaaaaaaaaaaaaaaaaaaa================:%s' % aa.default_code)
|
logging.info('get_bfm_process_order_listaaaaaaaaaaaaaaaaaaaaaaaaaaaa================:%s' % aa.default_code)
|
||||||
|
# # 给stock.picking的default_code字段赋值
|
||||||
|
# bb = request.env['stock.picking'].sudo().search([('origin', '=', order_id.name)])
|
||||||
|
# logging.info('get_bfm_process_or===================================:%s' % order_id.name)
|
||||||
|
# bb.default_code = kw['order_number']
|
||||||
|
# logging.info('get_bfm_process_order_listbbbbbbbbbbbbbbbbbbbbbbbbbbbb================:%s' % bb.default_code)
|
||||||
|
|
||||||
for item in bfm_process_order_list:
|
for item in 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,
|
||||||
kw['order_number'], i)
|
kw['order_number'], i)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from . import http
|
from . import http
|
||||||
from . import models
|
from . import models
|
||||||
from . import process_status
|
from . import process_status
|
||||||
|
from . import jd_eclp
|
||||||
|
|
||||||
|
|||||||
42
sf_bf_connect/models/jd_eclp.py
Normal file
42
sf_bf_connect/models/jd_eclp.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
from datetime import datetime
|
||||||
|
import jionlp as jio
|
||||||
|
import logging
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
import requests
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class JdEclp(models.Model):
|
||||||
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
|
def create_order(self):
|
||||||
|
sale_order_id = self.env['sale.order'].search([('name', '=', self.origin)])
|
||||||
|
raw_addres = self.address_of_delivery
|
||||||
|
json1 = {
|
||||||
|
'params': {
|
||||||
|
'orderNo': self.origin,
|
||||||
|
'senderNickName': self.,
|
||||||
|
'receiverName': self.person_of_delivery,
|
||||||
|
'receiverMobile': self.telephone_of_delivery,
|
||||||
|
'receiverProvinceName': jio.parse_location(raw_addres)['province'],
|
||||||
|
'receiverCityName': jio.parse_location(raw_addres)['city'],
|
||||||
|
'receiverCountyName': jio.parse_location(raw_addres)['county'],
|
||||||
|
'receiverTownName': jio.parse_location(raw_addres)['detail'],
|
||||||
|
'remark': self.,
|
||||||
|
'grossWeight': self.,
|
||||||
|
'grossVolume': self.,
|
||||||
|
'createTime': self.,
|
||||||
|
'createUser': self.,
|
||||||
|
'expressItemName': self.,
|
||||||
|
'pickupBeginTime': self.,
|
||||||
|
'deliveryType': self.,
|
||||||
|
'receiverCompany': self.,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
url1 = 'https://bfm.cs.jikimo.com/api/create/jd/order'
|
||||||
|
requests.post(url1, json=json1, data=None)
|
||||||
|
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@ import requests
|
|||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class StatusChange(models.Model):
|
class StatusChange(models.Model):
|
||||||
_inherit = 'sale.order'
|
_inherit = 'sale.order'
|
||||||
|
|
||||||
@@ -40,16 +41,16 @@ class StatusChange(models.Model):
|
|||||||
self.action_done()
|
self.action_done()
|
||||||
process_start_time = str(datetime.now())
|
process_start_time = str(datetime.now())
|
||||||
json1 = {
|
json1 = {
|
||||||
'params': {
|
'params': {
|
||||||
'model_name': 'jikimo.process.order',
|
'model_name': 'jikimo.process.order',
|
||||||
'field_name': 'name',
|
'field_name': 'name',
|
||||||
# 'default_code': 'PO-2022-1214-0022',
|
# 'default_code': 'PO-2022-1214-0022',
|
||||||
'default_code': self.default_code,
|
'default_code': self.default_code,
|
||||||
# 'default_code': self.name,
|
# 'default_code': self.name,
|
||||||
'state': '加工中',
|
'state': '加工中',
|
||||||
'process_start_time': process_start_time,
|
'process_start_time': process_start_time,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
url1 = 'https://bfm.cs.jikimo.com/api/get/state/get_order'
|
url1 = 'https://bfm.cs.jikimo.com/api/get/state/get_order'
|
||||||
requests.post(url1, json=json1, data=None)
|
requests.post(url1, json=json1, data=None)
|
||||||
logging.info('接口已经执行=============')
|
logging.info('接口已经执行=============')
|
||||||
@@ -108,3 +109,73 @@ class StatusChange(models.Model):
|
|||||||
else:
|
else:
|
||||||
return self._action_cancel()
|
return self._action_cancel()
|
||||||
|
|
||||||
|
|
||||||
|
class FinishStatusChange(models.Model):
|
||||||
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
|
# default_code = fields.Char(string='内部编码')
|
||||||
|
|
||||||
|
def button_validate(self):
|
||||||
|
# Clean-up the context key at validation to avoid forcing the creation of immediate
|
||||||
|
# transfers.
|
||||||
|
ctx = dict(self.env.context)
|
||||||
|
ctx.pop('default_immediate_transfer', None)
|
||||||
|
self = self.with_context(ctx)
|
||||||
|
|
||||||
|
# Sanity checks.
|
||||||
|
if not self.env.context.get('skip_sanity_check', False):
|
||||||
|
self._sanity_check()
|
||||||
|
|
||||||
|
self.message_subscribe([self.env.user.partner_id.id])
|
||||||
|
|
||||||
|
# Run the pre-validation wizards. Processing a pre-validation wizard should work on the
|
||||||
|
# moves and/or the context and never call `_action_done`.
|
||||||
|
if not self.env.context.get('button_validate_picking_ids'):
|
||||||
|
self = self.with_context(button_validate_picking_ids=self.ids)
|
||||||
|
res = self._pre_action_done_hook()
|
||||||
|
if res is not True:
|
||||||
|
return res
|
||||||
|
|
||||||
|
# Call `_action_done`.
|
||||||
|
pickings_not_to_backorder = self.filtered(lambda p: p.picking_type_id.create_backorder == 'never')
|
||||||
|
if self.env.context.get('picking_ids_not_to_backorder'):
|
||||||
|
pickings_not_to_backorder |= self.browse(self.env.context['picking_ids_not_to_backorder']).filtered(
|
||||||
|
lambda p: p.picking_type_id.create_backorder != 'always'
|
||||||
|
)
|
||||||
|
pickings_to_backorder = self - pickings_not_to_backorder
|
||||||
|
pickings_not_to_backorder.with_context(cancel_backorder=True)._action_done()
|
||||||
|
pickings_to_backorder.with_context(cancel_backorder=False)._action_done()
|
||||||
|
|
||||||
|
if self.user_has_groups('stock.group_reception_report') \
|
||||||
|
and self.picking_type_id.auto_show_reception_report:
|
||||||
|
lines = self.move_ids.filtered(lambda m: m.product_id.type == 'product' and m.state != 'cancel' and m.quantity_done and not m.move_dest_ids)
|
||||||
|
if lines:
|
||||||
|
# don't show reception report if all already assigned/nothing to assign
|
||||||
|
wh_location_ids = self.env['stock.location']._search([('id', 'child_of', self.picking_type_id.warehouse_id.view_location_id.id), ('usage', '!=', 'supplier')])
|
||||||
|
if self.env['stock.move'].search([
|
||||||
|
('state', 'in', ['confirmed', 'partially_available', 'waiting', 'assigned']),
|
||||||
|
('product_qty', '>', 0),
|
||||||
|
('location_id', 'in', wh_location_ids),
|
||||||
|
('move_orig_ids', '=', False),
|
||||||
|
('picking_id', 'not in', self.ids),
|
||||||
|
('product_id', 'in', lines.product_id.ids)], limit=1):
|
||||||
|
action = self.action_view_reception_report()
|
||||||
|
action['context'] = {'default_picking_ids': self.ids}
|
||||||
|
return action
|
||||||
|
|
||||||
|
out_start_time = str(datetime.now())
|
||||||
|
json2 = {
|
||||||
|
'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': out_start_time,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
url1 = 'https://bfm.cs.jikimo.com/api/get/state/get_order'
|
||||||
|
requests.post(url1, json=json2, data=None)
|
||||||
|
logging.info('接口已经执行=============')
|
||||||
|
return True
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import base64
|
import base64
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
import time
|
import time
|
||||||
@@ -261,6 +261,17 @@ class WorkCenterBarcode(models.Model):
|
|||||||
此函数用于将NC代码全部下发到机床
|
此函数用于将NC代码全部下发到机床
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
|
filepath = '/nc2machine'
|
||||||
|
del_list = os.listdir(filepath)
|
||||||
|
_logger.info("=====================================", del_list)
|
||||||
|
for f in del_list:
|
||||||
|
file_path = os.path.join(filepath, f)
|
||||||
|
if os.path.isfile(file_path):
|
||||||
|
os.remove(file_path)
|
||||||
|
except Exception as e:
|
||||||
|
_logger.info("=====================================", e)
|
||||||
|
raise UserError('程序删除失败,请重试')
|
||||||
# host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
|
# host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
|
||||||
host = self.workcenter_id.machine_tool_id.ftp_host
|
host = self.workcenter_id.machine_tool_id.ftp_host
|
||||||
port = self.workcenter_id.machine_tool_id.ftp_port
|
port = self.workcenter_id.machine_tool_id.ftp_port
|
||||||
|
|||||||
@@ -212,20 +212,29 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'production_id': self.production_id,
|
'production_id': self.production_id,
|
||||||
'state': '占用',
|
'state': '占用',
|
||||||
})
|
})
|
||||||
|
self.work_state = "已绑定"
|
||||||
|
orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
||||||
|
for a in orders:
|
||||||
|
a.tray_id = values
|
||||||
|
|
||||||
|
return values
|
||||||
|
|
||||||
|
# return {
|
||||||
|
# 'name': _('New Maintenance Request'),
|
||||||
|
# 'view_mode': 'form',
|
||||||
|
# 'res_model': 'maintenance.request',
|
||||||
|
# 'type': 'ir.actions.act_window',
|
||||||
|
# 'context': {
|
||||||
|
# 'default_company_id': self.company_id.id,
|
||||||
|
# 'default_production_id': self.id,
|
||||||
|
# },
|
||||||
|
# 'domain': [('production_id', '=', self.id)],
|
||||||
|
# }
|
||||||
else:
|
else:
|
||||||
raise UserError('该托盘编码已失效')
|
raise UserError('该托盘编码已失效')
|
||||||
else:
|
else:
|
||||||
return {
|
raise UserError('托盘码不能为空')
|
||||||
'name': _('New Maintenance Request'),
|
|
||||||
'view_mode': 'form',
|
|
||||||
'res_model': 'maintenance.request',
|
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
'context': {
|
|
||||||
'default_company_id': self.company_id.id,
|
|
||||||
'default_production_id': self.id,
|
|
||||||
},
|
|
||||||
'domain': [('production_id', '=', self.id)],
|
|
||||||
}
|
|
||||||
|
|
||||||
# 解除托盘绑定
|
# 解除托盘绑定
|
||||||
def unbindtray(self):
|
def unbindtray(self):
|
||||||
@@ -533,4 +542,15 @@ class SfWorkOrderBarcodes(models.Model):
|
|||||||
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
|
||||||
workorder = self.env['mrp.workorder'].browse(self.ids)
|
workorder = self.env['mrp.workorder'].browse(self.ids)
|
||||||
workorder.gettray_auto(barcode)
|
self.tray_id = workorder.gettray_auto(barcode)
|
||||||
|
|
||||||
|
# return {
|
||||||
|
# 'type': 'ir.actions.act_window',
|
||||||
|
# 'name': '工单',
|
||||||
|
# 'res_model': 'mrp.workorder',
|
||||||
|
# 'view_mode': 'form',
|
||||||
|
# 'context': {'active_id': self.id},
|
||||||
|
# # 'target': 'current',
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user