智能工厂接口新增相关字段

This commit is contained in:
jinling.yang
2022-10-10 23:13:35 +08:00
parent 839de4c95f
commit e86a82c4b9
18 changed files with 155 additions and 95 deletions

3
sf_bpm_api/__init__.py Normal file
View File

@@ -0,0 +1,3 @@
# -*-coding:utf-8-*-
# from . import controllers
from . import models

View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': '机企猫智能工厂 API模块',
'version': '1.0',
'summary': '智能工厂API模块',
'sequence': 1,
'description': """
在本模块,接收业务平台订单
""",
'category': 'sf',
'website': 'https://www.sf.cs.jikimo.com',
'depends': ['sale', 'product'],
'data': [
'views/product_template_view.xml',
'views/sale_order_view.xml',
],
'demo': [
],
'qweb': [
],
'installable': True,
'application': False,
'auto_install': False,
}

View File

@@ -0,0 +1 @@
from .import controllers

View File

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
import json
import logging
from datetime import date, timedelta
from odoo import http
from odoo.http import request
class Sf_Bf_Connect(http.Controller):
@http.route('/api/bfm_process_order/list', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def get_bfm_process_order_list(self, **kw):
"""
获取业务平台传送来的订单
:param kw:
:return:
"""
result = json.loads('result')
order_line_ids = []
for item in result['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'])

View File

@@ -0,0 +1,4 @@
from . import sale_order
from . import product_template

View File

@@ -0,0 +1,35 @@
from odoo import models, fields
from odoo.exceptions import ValidationError
class ResProductTemplate(models.Model):
_inherit = 'product.template'
purchase_ok = fields.Boolean(default=False)
detailed_type = fields.Selection(default='product')
list_price = fields.Float(digits=(16, 3))
invoice_policy = fields.Selection(default='delivery')
long = fields.Float('长[mm]', digits=(16, 3))
width = fields.Float('宽[mm]', digits=(16, 3))
height = fields.Float('高[mm]', digits=(16, 3))
volume = fields.Float('体积[mm³]', digits=(16, 3))
precision = fields.Float('精度要求', digits=(16, 3))
materials_id = fields.Many2one('mrs.production.materials', string='材料')
# materials_type_id = fields.Many2one('mrs.materials.model', string='型号')
# surface_technics_id = fields.Many2one('mrs.production.process', string='表面工艺')
# technological_parameter_id = fields.Char('工艺参数')
unit_price = fields.Float('单价')
amount = fields.Integer('数量')
# 业务平台分配工厂时调用该方法创建产品,(调用该方法时用prototype)
def product_create(self, products):
self.env['product.template'].create({
'name': products['order_number'],
'length': products['length'],
'width': products['width'],
'height': products['height'],
'volume': products['volume'],
'materials_id': products['materials_id'],
'unit_price': products['unit_price'],
'amount': products['amount']
})

View File

@@ -0,0 +1,14 @@
from odoo import models, fields
from odoo.exceptions import ValidationError
class ReSaleOrder(models.Model):
_inherit = 'sale.order'
deadline_of_delivery = fields.Date('交货截止日期')
# 业务平台分配工厂时调用该方法先创建销售订单(调用该方法时用prototype)
def sale_order_create(self, order):
self.env['sale.order'].create({
'deadline_of_delivery': order['deadline_of_delivery']
})

View File

@@ -0,0 +1,5 @@
<odoo>
<data>
</data>
</odoo>

View File

@@ -0,0 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record model="ir.ui.view" id="view_product_template_form_inherit_sf">
<field name="name">product.template.form.inherit.sf</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<field name="uom_po_id" position="after">
<field name="long"/>
<field name="width"/>
<field name="height"/>
<field name="volume"/>
<field name="precision"/>
<field name="materials_id"/>
</field>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record model="ir.ui.view" id="view_sale_order_form_inherit_sf">
<field name="name">sale.order.form.inherit.sf</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="payment_term_id" position="after">
<field name="deadline_of_delivery"/>
</field>
</field>
</record>
</data>
</odoo>