Accept Merge Request #142: (feature/优化进度反馈 -> develop)
Merge Request: 京东物流对接sf端基本完成 Created By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/142?initial=true
This commit is contained in:
@@ -12,7 +12,9 @@
|
|||||||
'website': 'https://www.sf.cs.jikimo.com',
|
'website': 'https://www.sf.cs.jikimo.com',
|
||||||
'depends': ['sf_base', 'sf_sale', 'sf_dlm'],
|
'depends': ['sf_base', 'sf_sale', 'sf_dlm'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/res_partner_view.xml'
|
'views/res_partner_view.xml',
|
||||||
|
'views/view.xml',
|
||||||
|
'report/bill_report.xml',
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -114,3 +120,30 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
res['status'] = -1
|
res['status'] = -1
|
||||||
res['message'] = '工厂创建销售订单和产品失败,请联系管理员'
|
res['message'] = '工厂创建销售订单和产品失败,请联系管理员'
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
|
|
||||||
|
class jdElcp(http.Controller):
|
||||||
|
|
||||||
|
@http.route('/api/jd_create/order', type='http', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def get_jd_order(self, **kw):
|
||||||
|
"""
|
||||||
|
回调函数:拿到京东返回的下单数据
|
||||||
|
"""
|
||||||
|
logging.info('get_jd_order================:%s', kw)
|
||||||
|
# aa = request.env['stock.picking'].sudo().search([('origin', '=', kw['orderNo'])])
|
||||||
|
# aa.carrier_tracking_ref = kw['wbNo']
|
||||||
|
# logging.info('get_jd_order================:%s' %
|
||||||
|
# aa.carrier_tracking_ref)
|
||||||
|
|
||||||
|
@http.route('/api/jd_create/bill', type='http', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def get_jd_bill(self, **kw):
|
||||||
|
"""
|
||||||
|
回调函数:拿到京东返回的快递面单
|
||||||
|
"""
|
||||||
|
logging.info('get_jd_bill================:%s', kw)
|
||||||
|
aa = request.env['stock.picking'].sudo().search([('origin', '=', kw['orderNo'])])
|
||||||
|
aa.bill_url = kw['bill']
|
||||||
|
logging.info('get_jd_bill================:%s' %
|
||||||
|
aa.bill_url)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
132
sf_bf_connect/models/jd_eclp.py
Normal file
132
sf_bf_connect/models/jd_eclp.py
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
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
|
||||||
|
import base64
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class JdEclp(models.Model):
|
||||||
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
|
senderNickName = fields.Char(string='寄件工厂简称', required=True, default='MW')
|
||||||
|
receiverName = fields.Char(string='收件人姓名', compute='_truck_info')
|
||||||
|
receiverMobile = fields.Char(string='收件人电话', compute='_truck_info')
|
||||||
|
receiverProvinceName = fields.Char(string='收件人省', compute='_truck_info')
|
||||||
|
receiverCityName = fields.Char(string='收件人市', compute='_truck_info')
|
||||||
|
receiverCountyName = fields.Char(string='收件人县', compute='_truck_info')
|
||||||
|
receiverTownName = fields.Char(string='收件人详细地址', compute='_truck_info')
|
||||||
|
receiverCompany = fields.Char(string='收货人公司', required=True)
|
||||||
|
remark = fields.Char(string='物流面单备注', default='无')
|
||||||
|
grossWeight = fields.Char(string='总重量', required=True, default=0)
|
||||||
|
grossVolume = fields.Char(string='总体积', default=0)
|
||||||
|
expressItemName = fields.Char(string='货物名称', required=True, default='非标工件')
|
||||||
|
pickupBeginTime = fields.Char(string='期望取件时间')
|
||||||
|
deliveryType = fields.Selection([('6', '特快零担'), ('25', '特快重货')], string='运输类型', default='25')
|
||||||
|
# bill = fields.Char(string='物流面单')
|
||||||
|
|
||||||
|
bill = fields.Many2one('ir.attachment', string='物流面单', compute='query_bill_pdf')
|
||||||
|
# bill_show = fields.Binary(string='物流面单展示', readonly=True, related='self.bill.datas')
|
||||||
|
bill_show = fields.Binary(string='物流面单展示', readonly=True)
|
||||||
|
|
||||||
|
@api.depends('carrier_tracking_ref')
|
||||||
|
def query_bill_pdf(self):
|
||||||
|
self.bill = self.env['ir.attachment'].sudo().search([('name', '=', self.carrier_tracking_ref)])
|
||||||
|
|
||||||
|
|
||||||
|
@api.depends('origin')
|
||||||
|
def _truck_info(self):
|
||||||
|
sale_order_id = self.env['sale.order'].search([('name', '=', self.origin)])
|
||||||
|
raw_addres = sale_order_id.address_of_delivery
|
||||||
|
self.receiverName = sale_order_id.person_of_delivery
|
||||||
|
self.receiverMobile = sale_order_id.telephone_of_delivery
|
||||||
|
self.receiverProvinceName = jio.parse_location(raw_addres)['province']
|
||||||
|
self.receiverCityName = jio.parse_location(raw_addres)['city']
|
||||||
|
self.receiverCountyName = jio.parse_location(raw_addres)['county']
|
||||||
|
self.receiverTownName = jio.parse_location(raw_addres)['detail']
|
||||||
|
# self.receiverMobile = sale_order_id.telephone_of_delivery
|
||||||
|
|
||||||
|
def create_order(self):
|
||||||
|
# sale_order_id = self.env['sale.order'].search([('name', '=', self.origin)])
|
||||||
|
|
||||||
|
# if self.carrier_id == '京东物流':
|
||||||
|
createTime = str(datetime.now())
|
||||||
|
json1 = {
|
||||||
|
'params': {
|
||||||
|
'orderNo': self.origin,
|
||||||
|
'senderNickName': self.senderNickName,
|
||||||
|
'receiverName': self.receiverName,
|
||||||
|
'receiverMobile': self.receiverMobile,
|
||||||
|
'receiverProvinceName': self.receiverProvinceName,
|
||||||
|
'receiverCityName': self.receiverCityName,
|
||||||
|
'receiverCountyName': self.receiverCountyName,
|
||||||
|
'receiverTownName': self.receiverTownName,
|
||||||
|
'remark': self.remark,
|
||||||
|
'grossWeight': self.grossWeight,
|
||||||
|
'grossVolume': self.grossVolume,
|
||||||
|
'createTime': createTime,
|
||||||
|
# 'createUser': self.user_id,
|
||||||
|
'expressItemName': self.expressItemName,
|
||||||
|
'pickupBeginTime': self.pickupBeginTime,
|
||||||
|
'deliveryType': self.deliveryType,
|
||||||
|
'receiverCompany': self.receiverCompany,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_logger.info('准备调接口1')
|
||||||
|
url1 = 'https://bfm.cs.jikimo.com/api/create/jd/order'
|
||||||
|
requests.post(url1, json=json1, data=None)
|
||||||
|
_logger.info('调用成功1')
|
||||||
|
_logger.info('准备调接口2')
|
||||||
|
json2 = {
|
||||||
|
'params': {
|
||||||
|
'orderNo': self.origin,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
url2 = 'https://bfm.cs.jikimo.com/api/get/jd/no'
|
||||||
|
response = requests.post(url2, json=json2, data=None)
|
||||||
|
# _logger.info('调用成功2', response.json()['result']['wbNo'])
|
||||||
|
self.carrier_tracking_ref = response.json()['result']['wbNo']
|
||||||
|
|
||||||
|
|
||||||
|
# else:
|
||||||
|
# raise UserError("选择京东物流才能下单呦")
|
||||||
|
|
||||||
|
def get_bill(self):
|
||||||
|
|
||||||
|
json1 = {
|
||||||
|
'params': {
|
||||||
|
'no': self.origin,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
url1 = 'https://bfm.cs.jikimo.com/api/create/jd/bill'
|
||||||
|
response = requests.post(url1, json=json1, data=None)
|
||||||
|
# _logger.info('调用成功2', response.json())
|
||||||
|
|
||||||
|
# _logger.info('调用成功2', response.text)
|
||||||
|
bill_url_str = response.json()['result']['jingdong_eclp_co_generateBdWayBillFile_responce']['result']['content']
|
||||||
|
bill_url = 'http:' + bill_url_str
|
||||||
|
data = base64.b64encode(requests.get(bill_url).content)
|
||||||
|
# self.bill = ''
|
||||||
|
self.bill_show = data
|
||||||
|
_logger.info('调用成功2')
|
||||||
|
attachment = self.env['ir.attachment'].sudo().create({
|
||||||
|
'datas': data,
|
||||||
|
'type': 'binary',
|
||||||
|
'description': '快递面单',
|
||||||
|
'name': self.carrier_tracking_ref,
|
||||||
|
# 'res_id': invoice.id,
|
||||||
|
# 'res_model': 'stock.picking',
|
||||||
|
'public': True,
|
||||||
|
'mimetype': 'application/pdf',
|
||||||
|
# 'model_name': 'stock.picking',
|
||||||
|
})
|
||||||
|
_logger.info(attachment)
|
||||||
|
# _logger.info(attachment.datas)
|
||||||
|
# _logger.info(attachment.datas_fname)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|||||||
84
sf_bf_connect/report/bill_report.xml
Normal file
84
sf_bf_connect/report/bill_report.xml
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<!-- 托盘码打印尺寸-->
|
||||||
|
<!-- <record id="sf_tray1" model="report.paperformat">-->
|
||||||
|
<!-- <field name="name">Dymo Label Sheet</field>-->
|
||||||
|
<!-- <field name="default" eval="True"/>-->
|
||||||
|
<!-- <field name="format">custom</field>-->
|
||||||
|
<!-- <field name="page_height">100</field>-->
|
||||||
|
<!-- <field name="page_width">60</field>-->
|
||||||
|
<!-- <field name="orientation">Landscape</field>-->
|
||||||
|
<!-- <field name="margin_top">0</field>-->
|
||||||
|
<!-- <field name="margin_bottom">0</field>-->
|
||||||
|
<!-- <field name="margin_left">0</field>-->
|
||||||
|
<!-- <field name="margin_right">0</field>-->
|
||||||
|
<!-- <field name="disable_shrinking" eval="True"/>-->
|
||||||
|
<!-- <field name="dpi">96</field>-->
|
||||||
|
<!-- </record>-->
|
||||||
|
|
||||||
|
<record model="ir.actions.report" id="stock_picking_report">
|
||||||
|
<field name="name">面单打印</field>
|
||||||
|
<field name="model">stock.picking</field>
|
||||||
|
<field name="report_type">qweb-pdf</field>
|
||||||
|
<field name="report_name">sf_bf_connect.bill_report_template</field>
|
||||||
|
<field name="print_report_name">(object.carrier_tracking_ref)</field>
|
||||||
|
<field name="binding_model_id" ref="stock.model_stock_picking"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- 托盘码打印动作-->
|
||||||
|
<!-- <record id="label_sf_tray_code" model="ir.actions.report">-->
|
||||||
|
<!-- <field name="name">打印条形码</field>-->
|
||||||
|
<!-- <field name="model">sf.tray</field>-->
|
||||||
|
<!-- <field name="report_type">qweb-pdf</field>-->
|
||||||
|
<!-- <field name="report_name">sf_manufacturing.sf_tray_template</field>-->
|
||||||
|
<!-- <field name="report_file">sf_manufacturing.sf_tray_template</field>-->
|
||||||
|
<!-- <field name="binding_model_id" ref="model_sf_tray"/>-->
|
||||||
|
<!-- <field name="binding_type">report</field>-->
|
||||||
|
<!-- <field name="paperformat_id" ref="sf_manufacturing.sf_tray1"/>-->
|
||||||
|
|
||||||
|
<!-- </record>-->
|
||||||
|
<!-- 托盘码打印模板-->
|
||||||
|
<template id="bill_report_template">
|
||||||
|
<t t-call="web.html_container">
|
||||||
|
<t t-call="web.external_layout">
|
||||||
|
|
||||||
|
<t t-foreach="docs" t-as="o">
|
||||||
|
<div class="page">
|
||||||
|
<!-- <div t-field="o.bill_show"-->
|
||||||
|
<!-- t-options="{'widget': 'barcode', 'width': 600, 'height': 100, 'img_style': 'width:350px;height:60px'}"/>-->
|
||||||
|
<div t-field="o.bill_show"/>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</t>
|
||||||
|
</t>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- <!– 产品信息打印动作–>-->
|
||||||
|
<!-- <record id="label_sf_tray_code1" model="ir.actions.report">-->
|
||||||
|
<!-- <field name="name">打印产品信息</field>-->
|
||||||
|
<!-- <field name="model">mrp.workorder</field>-->
|
||||||
|
<!-- <field name="report_type">qweb-pdf</field>-->
|
||||||
|
<!-- <field name="report_name">sf_manufacturing.sf_tray_template1</field>-->
|
||||||
|
<!-- <field name="report_file">sf_manufacturing.sf_tray_template1</field>-->
|
||||||
|
<!-- <field name="binding_model_id" ref="model_mrp_workorder"/>-->
|
||||||
|
<!-- <field name="binding_type">report</field>-->
|
||||||
|
<!-- <field name="paperformat_id" ref="sf_manufacturing.sf_tray1"/>-->
|
||||||
|
<!-- </record>-->
|
||||||
|
|
||||||
|
<!-- <!– 产品信息打印模板–>-->
|
||||||
|
<!-- <template id="sf_tray_template1">-->
|
||||||
|
<!-- <t t-call="web.html_container">-->
|
||||||
|
<!-- <t t-call="web.external_layout">-->
|
||||||
|
<!-- <t t-foreach="docs" t-as="o">-->
|
||||||
|
<!-- <div class="page">-->
|
||||||
|
<!-- <div t-field="o.production_id.name"-->
|
||||||
|
<!-- t-options="{'widget': 'barcode', 'width': 600, 'height': 100, 'img_style': 'width:350px;height:60px'}"/>-->
|
||||||
|
<!-- <div t-field="o.production_id" style="text-align: center"/>-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<!-- </t>-->
|
||||||
|
<!-- </t>-->
|
||||||
|
<!-- </t>-->
|
||||||
|
<!-- </template>-->
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
50
sf_bf_connect/views/view.xml
Normal file
50
sf_bf_connect/views/view.xml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="tracking_view" model="ir.ui.view">
|
||||||
|
<field name="name">tracking</field>
|
||||||
|
<field name="model">stock.picking</field>
|
||||||
|
<field name="inherit_id" ref="delivery.view_picking_withcarrier_out_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//group//field[@name='carrier_id']" position="after">
|
||||||
|
<field name="senderNickName"/>
|
||||||
|
<field name="expressItemName"/>
|
||||||
|
<field name="deliveryType"/>
|
||||||
|
<field name="receiverName"/>
|
||||||
|
<field name="receiverMobile"/>
|
||||||
|
<field name="receiverProvinceName"/>
|
||||||
|
<field name="receiverCityName"/>
|
||||||
|
<field name="receiverCountyName"/>
|
||||||
|
<field name="receiverTownName"/>
|
||||||
|
<field name="receiverCompany"/>
|
||||||
|
<field name="remark"/>
|
||||||
|
<field name="grossWeight"/>
|
||||||
|
<field name="grossVolume"/>
|
||||||
|
<field name="pickupBeginTime"/>
|
||||||
|
<field name="bill"/>
|
||||||
|
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//group//field[@name='group_id']" position="after">
|
||||||
|
<field name="bill_show" widget="pdf_viewer"/>
|
||||||
|
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//group[@name='other_infos']" position="after">
|
||||||
|
<!-- <group>-->
|
||||||
|
<div>
|
||||||
|
<button string="京东物流下单" name="create_order" type="object" confirm="是否确认物流下单" class="btn-primary"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- </group>-->
|
||||||
|
<!-- <group>-->
|
||||||
|
<div>
|
||||||
|
<button string="获取物流面单" name="get_bill" type="object" confirm="是否获取物流面单" class="btn-primary"/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- </group>-->
|
||||||
|
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@@ -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
|
||||||
@@ -207,7 +207,7 @@ class WorkCenterBarcode(models.Model):
|
|||||||
machine_tool_name = fields.Char(string='机床名称', default='未知机床', compute='_run_info', readonly=True)
|
machine_tool_name = fields.Char(string='机床名称', default='未知机床', compute='_run_info', readonly=True)
|
||||||
machine_tool_type_id = fields.Char(string='机床型号', default='未知型号', compute='_run_info', readonly=True)
|
machine_tool_type_id = fields.Char(string='机床型号', default='未知型号', compute='_run_info', readonly=True)
|
||||||
machine_tool_status = fields.Boolean(string='在线状态', compute='_run_info', readonly=True)
|
machine_tool_status = fields.Boolean(string='在线状态', compute='_run_info', readonly=True)
|
||||||
machine_tool_run_status = fields.Selection([('0', '关机中'), ('1', '加工中'), ('2', '加工中'), ('3', '等待中')],
|
machine_tool_run_status = fields.Selection([('0', '关机中'), ('1', '加工中'), ('2', '加工中'), ('3', '加工中')],
|
||||||
string='运行状态', compute='_run_info', readonly=True, default='0')
|
string='运行状态', compute='_run_info', readonly=True, default='0')
|
||||||
machine_tool_timestamp = fields.Datetime('时间戳', compute='_run_info', readonly=True)
|
machine_tool_timestamp = fields.Datetime('时间戳', compute='_run_info', readonly=True)
|
||||||
machine_tool_time_on = fields.Char('总在线时长', compute='_run_info', readonly=True)
|
machine_tool_time_on = fields.Char('总在线时长', compute='_run_info', readonly=True)
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -217,20 +217,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):
|
||||||
@@ -532,4 +541,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