修改接口授权后,没有赋予用户的bug,导致无法获取公司,增加替换sf销售订单行产品名称的模块
This commit is contained in:
2
jikimo_test_generate_product_name/__init__.py
Normal file
2
jikimo_test_generate_product_name/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from . import models
|
||||||
18
jikimo_test_generate_product_name/__manifest__.py
Normal file
18
jikimo_test_generate_product_name/__manifest__.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
{
|
||||||
|
'name': 'Jikimo_test_generate_product_name',
|
||||||
|
'version': '',
|
||||||
|
'summary': """ Jikimo_test_generate_product_name Summary """,
|
||||||
|
'author': '',
|
||||||
|
'website': '',
|
||||||
|
'category': '',
|
||||||
|
'depends': ['sf_manufacturing'],
|
||||||
|
'data': [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'application': True,
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': False,
|
||||||
|
'license': 'LGPL-3',
|
||||||
|
}
|
||||||
2
jikimo_test_generate_product_name/models/__init__.py
Normal file
2
jikimo_test_generate_product_name/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from . import product_template
|
||||||
21
jikimo_test_generate_product_name/models/product_template.py
Normal file
21
jikimo_test_generate_product_name/models/product_template.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from odoo import models
|
||||||
|
|
||||||
|
|
||||||
|
class ProductTemplate(models.Model):
|
||||||
|
_inherit = 'product.template'
|
||||||
|
|
||||||
|
def generate_product_name(self, order_id, item, i):
|
||||||
|
"""生成成品名称"""
|
||||||
|
# 3D文件名(去掉后缀,截取前40个字符)+“-”+模型ID
|
||||||
|
product_name = '%s-%s' % ('.'.join(item['model_name'].split('.')[:-1])[:40], item['model_id'])
|
||||||
|
return product_name
|
||||||
|
|
||||||
|
def generate_embryo_name(self, order_id, item, materials_id, materials_type_id, embryo_redundancy_id, i):
|
||||||
|
"""生成坯料名称"""
|
||||||
|
embryo_name = '%s-%s-%s [%s %s-%s * %s * %s]' % ('R',
|
||||||
|
order_id.name, i, materials_id.name, materials_type_id.name,
|
||||||
|
self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
||||||
|
self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
||||||
|
self.format_float(item['model_height'] + embryo_redundancy_id.height))
|
||||||
|
return embryo_name
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
import logging
|
import logging
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import hashlib
|
import hashlib
|
||||||
from odoo import models
|
from odoo import models, SUPERUSER_ID
|
||||||
from odoo.http import request
|
from odoo.http import request
|
||||||
|
|
||||||
__author__ = 'jinling.yang'
|
__author__ = 'jinling.yang'
|
||||||
@@ -48,5 +48,7 @@ class Http(models.AbstractModel):
|
|||||||
_logger.info('sf_secret_key:%s' % factory_secret.sf_secret_key)
|
_logger.info('sf_secret_key:%s' % factory_secret.sf_secret_key)
|
||||||
if check_sf_str != datas['HTTP_CHECKSTR']:
|
if check_sf_str != datas['HTTP_CHECKSTR']:
|
||||||
raise AuthenticationError('数据校验不通过')
|
raise AuthenticationError('数据校验不通过')
|
||||||
|
# 设置管理员用户
|
||||||
|
request.update_env(user=SUPERUSER_ID)
|
||||||
else:
|
else:
|
||||||
raise AuthenticationError('请求参数中无token')
|
raise AuthenticationError('请求参数中无token')
|
||||||
|
|||||||
@@ -890,8 +890,9 @@ class ResProductMo(models.Model):
|
|||||||
embryo_redundancy_id = item.get('embryo_redundancy')
|
embryo_redundancy_id = item.get('embryo_redundancy')
|
||||||
if not embryo_redundancy_id:
|
if not embryo_redundancy_id:
|
||||||
raise UserError('请先配置模型类型内的坯料冗余')
|
raise UserError('请先配置模型类型内的坯料冗余')
|
||||||
|
product_name = self.generate_product_name(order_id, item, i)
|
||||||
vals = {
|
vals = {
|
||||||
'name': '%s-%s-%s' % ('P', order_id.name, i),
|
'name': product_name,
|
||||||
'model_long': self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
'model_long': self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
||||||
'model_width': self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
'model_width': self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
||||||
'model_height': self.format_float(item['model_height'] + embryo_redundancy_id.height),
|
'model_height': self.format_float(item['model_height'] + embryo_redundancy_id.height),
|
||||||
@@ -1012,12 +1013,9 @@ class ResProductMo(models.Model):
|
|||||||
if not embryo_redundancy_id:
|
if not embryo_redundancy_id:
|
||||||
raise UserError('请先配置模型类型内的坯料冗余')
|
raise UserError('请先配置模型类型内的坯料冗余')
|
||||||
logging.info('no_bom_copy_product_supplier-vals:%s' % supplier)
|
logging.info('no_bom_copy_product_supplier-vals:%s' % supplier)
|
||||||
|
embryo_name = self.generate_embryo_name(order_id, item, materials_id, materials_type_id, embryo_redundancy_id, i)
|
||||||
vals = {
|
vals = {
|
||||||
'name': '%s-%s-%s [%s %s-%s * %s * %s]' % ('R',
|
'name': embryo_name,
|
||||||
order_id.name, i, materials_id.name, materials_type_id.name,
|
|
||||||
self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
|
||||||
self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
|
||||||
self.format_float(item['model_height'] + embryo_redundancy_id.height)),
|
|
||||||
'length': self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
'length': self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
||||||
'width': self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
'width': self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
||||||
'height': self.format_float(item['model_height'] + embryo_redundancy_id.height),
|
'height': self.format_float(item['model_height'] + embryo_redundancy_id.height),
|
||||||
@@ -1119,7 +1117,19 @@ class ResProductMo(models.Model):
|
|||||||
|
|
||||||
# 增加产品表面积
|
# 增加产品表面积
|
||||||
|
|
||||||
|
def generate_product_name(self, order_id, item, i):
|
||||||
|
"""生成成品名称"""
|
||||||
|
product_name = '%s-%s-%s' % ('P', order_id.name, i),
|
||||||
|
return product_name
|
||||||
|
|
||||||
|
def generate_embryo_name(self, order_id, item, materials_id, materials_type_id, embryo_redundancy_id, i):
|
||||||
|
"""生成坯料名称"""
|
||||||
|
embryo_name = '%s-%s-%s [%s %s-%s * %s * %s]' % ('R',
|
||||||
|
order_id.name, i, materials_id.name, materials_type_id.name,
|
||||||
|
self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
||||||
|
self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
||||||
|
self.format_float(item['model_height'] + embryo_redundancy_id.height))
|
||||||
|
return embryo_name
|
||||||
|
|
||||||
class ResProductFixture(models.Model):
|
class ResProductFixture(models.Model):
|
||||||
_inherit = 'product.template'
|
_inherit = 'product.template'
|
||||||
|
|||||||
Reference in New Issue
Block a user