Merge commit 'd24ade9e55501e74591717f8938ac35f5089eca2' into develop
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'views/mrs_base_view.xml',
|
'views/mrs_base_view.xml',
|
||||||
'views/mrs_common_view.xml',
|
'views/mrs_common_view.xml',
|
||||||
# 'views/menu_view.xml'
|
'views/menu_view.xml'
|
||||||
|
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
# -*-coding:utf-8-*-
|
# -*-coding:utf-8-*-
|
||||||
# from . import controllers
|
from . import controllers
|
||||||
from . import models
|
from . import models
|
||||||
|
|||||||
@@ -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='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
@http.route('/api/bfm_process_order/list', type='json', 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):
|
||||||
"""
|
"""
|
||||||
@@ -16,17 +16,10 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
:param kw:
|
:param kw:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
result = json.loads('result')
|
datas = request.httprequest.data
|
||||||
|
ret = json.loads(datas)
|
||||||
|
ret = json.loads(ret['result'])
|
||||||
|
request.env['sale.order'].sudo().sale_order_create(ret['delivery_end_date'])
|
||||||
order_line_ids = []
|
order_line_ids = []
|
||||||
for item in result['bfm_process_order_list']:
|
# for item in ret['bfm_process_order_list']:
|
||||||
order_line_ids.append({
|
|
||||||
"long": item['model_length'],
|
|
||||||
"width": item['model_width'],
|
|
||||||
"height": item['model_height'],
|
|
||||||
"volume": item['model_volume'],
|
|
||||||
"materials_id": item['texture_id'],
|
|
||||||
"unit_price": item['unit_price']
|
|
||||||
# "barcode": item['barcode']
|
|
||||||
})
|
|
||||||
self.env['sale.order'].sudo().sale_order_create(result['result'])
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
from . import sale_order
|
from . import sale_order
|
||||||
from . import product_template
|
from . import product_template
|
||||||
|
from . import http
|
||||||
|
from . import models
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
43
sf_bpm_api/models/http.py
Normal file
43
sf_bpm_api/models/http.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import base64
|
||||||
|
import datetime
|
||||||
|
import time
|
||||||
|
import hashlib
|
||||||
|
from odoo import fields, models, api
|
||||||
|
from odoo.http import request, AuthenticationError
|
||||||
|
import redis
|
||||||
|
|
||||||
|
__author__ = 'jinling.yang'
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Http(models.AbstractModel):
|
||||||
|
_inherit = 'ir.http'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _auth_method_sf_token(cls):
|
||||||
|
# 从headers.environ中获取对方传过来的token,timestamp,加密的校验字符串
|
||||||
|
datas = request.httprequest.headers.environ
|
||||||
|
if 'HTTP_TOKEN' in datas:
|
||||||
|
_logger.info('token:%s' % datas['HTTP_TOKEN'])
|
||||||
|
# 查询密钥
|
||||||
|
factory_secret = request.env['res.partner'].sudo().search(
|
||||||
|
[('sf_token', '=', datas['HTTP_TOKEN'])], limit=1)
|
||||||
|
if not factory_secret:
|
||||||
|
raise AuthenticationError('无效的token')
|
||||||
|
timestamp_str = int(time.time())
|
||||||
|
# 设置API接口请求时间,不能超过5秒
|
||||||
|
deltime = datetime.timedelta(seconds=60)
|
||||||
|
if abs(int(datas['HTTP_TIMESTAMP'])-timestamp_str) > deltime.seconds:
|
||||||
|
raise AuthenticationError('请求已过期')
|
||||||
|
# 获得sha1_str加密字符串
|
||||||
|
post_time = int(datas['HTTP_TIMESTAMP'])
|
||||||
|
check_str = '%s%s%s' % (datas['HTTP_TOKEN'], post_time, factory_secret.sf_secret_key)
|
||||||
|
check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
if check_sf_str != datas['HTTP_CHECKSTR']:
|
||||||
|
raise AuthenticationError('数据校验不通过')
|
||||||
|
else:
|
||||||
|
raise AuthenticationError('请求参数中无token')
|
||||||
28
sf_bpm_api/models/models.py
Normal file
28
sf_bpm_api/models/models.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import logging
|
||||||
|
import uuid
|
||||||
|
import string
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
from odoo import fields, models, api
|
||||||
|
|
||||||
|
__author__ = 'jinling.yang'
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ResPartner(models.Model):
|
||||||
|
_inherit = 'res.partner'
|
||||||
|
|
||||||
|
# 获取token,token自动生成且唯一
|
||||||
|
def get_token(self):
|
||||||
|
return uuid.uuid1()
|
||||||
|
|
||||||
|
# 获取密钥(大小字母+数字随机)
|
||||||
|
def get_secret(self):
|
||||||
|
ran_str = ''.join(random.sample(string.ascii_letters + string.digits, 16))
|
||||||
|
return ran_str
|
||||||
|
|
||||||
|
sf_token = fields.Char(u'Token', default=get_token)
|
||||||
|
sf_secret_key = fields.Char(u'密钥', default=get_secret)
|
||||||
@@ -9,11 +9,11 @@ class ResProductTemplate(models.Model):
|
|||||||
detailed_type = fields.Selection(default='product')
|
detailed_type = fields.Selection(default='product')
|
||||||
list_price = fields.Float(digits=(16, 3))
|
list_price = fields.Float(digits=(16, 3))
|
||||||
invoice_policy = fields.Selection(default='delivery')
|
invoice_policy = fields.Selection(default='delivery')
|
||||||
long = fields.Float('长[mm]', digits=(16, 3))
|
model_long = fields.Float('长[mm]', digits=(16, 3))
|
||||||
width = fields.Float('宽[mm]', digits=(16, 3))
|
model_width = fields.Float('宽[mm]', digits=(16, 3))
|
||||||
height = fields.Float('高[mm]', digits=(16, 3))
|
model_height = fields.Float('高[mm]', digits=(16, 3))
|
||||||
volume = fields.Float('体积[mm³]', digits=(16, 3))
|
model_volume = fields.Float('体积[mm³]', digits=(16, 3))
|
||||||
precision = fields.Float('精度要求', digits=(16, 3))
|
model_precision = fields.Float('精度要求', digits=(16, 3))
|
||||||
materials_id = fields.Many2one('mrs.production.materials', string='材料')
|
materials_id = fields.Many2one('mrs.production.materials', string='材料')
|
||||||
# materials_type_id = fields.Many2one('mrs.materials.model', string='型号')
|
# materials_type_id = fields.Many2one('mrs.materials.model', string='型号')
|
||||||
# surface_technics_id = fields.Many2one('mrs.production.process', string='表面工艺')
|
# surface_technics_id = fields.Many2one('mrs.production.process', string='表面工艺')
|
||||||
@@ -21,15 +21,16 @@ class ResProductTemplate(models.Model):
|
|||||||
unit_price = fields.Float('单价')
|
unit_price = fields.Float('单价')
|
||||||
amount = fields.Integer('数量')
|
amount = fields.Integer('数量')
|
||||||
|
|
||||||
# 业务平台分配工厂时调用该方法创建产品,(调用该方法时用prototype)
|
# 业务平台分配工厂时调用该方法创建产品
|
||||||
def product_create(self, products):
|
def product_create(self, products):
|
||||||
self.env['product.template'].create({
|
self.env['product.template'].create({
|
||||||
'name': products['order_number'],
|
'name': products['order_number'],
|
||||||
'length': products['length'],
|
'model_long': products['length'],
|
||||||
'width': products['width'],
|
'model_width': products['width'],
|
||||||
'height': products['height'],
|
'model_height': products['height'],
|
||||||
'volume': products['volume'],
|
'model_volume': products['volume'],
|
||||||
'materials_id': products['materials_id'],
|
'materials_id': products['materials_id'],
|
||||||
'unit_price': products['unit_price'],
|
'unit_price': products['unit_price'],
|
||||||
'amount': products['amount']
|
'amount': products['amount'],
|
||||||
|
'barcode':products['barcode'],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from odoo import models, fields
|
from odoo import models, fields
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
class ReSaleOrder(models.Model):
|
class ReSaleOrder(models.Model):
|
||||||
@@ -7,8 +8,13 @@ class ReSaleOrder(models.Model):
|
|||||||
|
|
||||||
deadline_of_delivery = fields.Date('交货截止日期')
|
deadline_of_delivery = fields.Date('交货截止日期')
|
||||||
|
|
||||||
# 业务平台分配工厂时调用该方法先创建销售订单(调用该方法时用prototype)
|
# 业务平台分配工厂时调用该方法先创建销售订单
|
||||||
def sale_order_create(self, order):
|
def sale_order_create(self, deadline_of_delivery):
|
||||||
self.env['sale.order'].create({
|
now = datetime.datetime.now()
|
||||||
'deadline_of_delivery': order['deadline_of_delivery']
|
self.env['sale.order'].sudo().create({
|
||||||
|
'company_id': 1,
|
||||||
|
'date_order': now,
|
||||||
|
'name': '12',
|
||||||
|
'partner_id': 1,
|
||||||
|
'deadline_of_delivery': deadline_of_delivery
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,14 +6,22 @@
|
|||||||
<field name="model">product.template</field>
|
<field name="model">product.template</field>
|
||||||
<field name="inherit_id" ref="product.product_template_only_form_view"/>
|
<field name="inherit_id" ref="product.product_template_only_form_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="uom_po_id" position="after">
|
<xpath expr="//page[last()]" position="after">
|
||||||
<field name="long"/>
|
<page string="CNC加工">
|
||||||
<field name="width"/>
|
<group string="模型">
|
||||||
<field name="height"/>
|
<group>
|
||||||
<field name="volume"/>
|
<field name="model_long" />
|
||||||
<field name="precision"/>
|
<field name="model_width" />
|
||||||
<field name="materials_id"/>
|
<field name="model_height" />
|
||||||
</field>
|
<field name="model_volume" />
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="model_precision"/>
|
||||||
|
<field name="materials_id"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
Reference in New Issue
Block a user