1、新增夹具物料搜索模型,完成tree视图和form视图;2、新增夹具物料序列号、夹具物料搜索模型注册到cloud的接口,优化刀具物料序列号注册接口及流程;3、删除刀具物料搜索模型的无关字段;

This commit is contained in:
yuxianghui
2024-03-20 16:34:11 +08:00
parent 952e663b31
commit a07563e166
10 changed files with 278 additions and 339 deletions

View File

@@ -34,14 +34,12 @@ class StockLot(models.Model):
_inherit = 'stock.lot'
_description = '刀具物料序列号注册'
crea_url = "/api/tool_material_stock/create"
def enroll_tool_material_stock(self):
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
sf_secret_key = sf_sync_config['sf_secret_key']
headers = Common.get_headers(self, token, sf_secret_key)
str_url = sf_sync_config['sf_url'] + self.crea_url
str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
objs_all = self.env['stock.lot'].search([('id', '=', self.id)])
tool_material_stock_list = []
if objs_all:
@@ -61,15 +59,6 @@ class StockLot(models.Model):
else:
raise UserError("没有注册刀具物料序列号信息")
@api.model_create_multi
def create(self, vals_list):
records = super(StockLot, self).create(vals_list)
for record in records:
if record.product_id.categ_id.name == '刀具':
record.tool_material_status = '未入库'
record.enroll_tool_material_stock()
return records
class ToolMaterial(models.Model):
_inherit = 'sf.tool.material.search'
@@ -87,10 +76,6 @@ class ToolMaterial(models.Model):
tool_material_list = []
if objs_all:
for item in objs_all:
barcode_names = []
for barcode_id in item.barcode_ids:
if barcode_id.name:
barcode_names.append(barcode_id.name)
val = {
'name': item.name,
'id': item.id,
@@ -101,9 +86,7 @@ class ToolMaterial(models.Model):
'number': item.number,
'usable_num': item.usable_num,
'have_been_used_num': item.have_been_used_num,
'scrap_num': item.scrap_num,
'barcode_names': str(barcode_names),
'active': item.active
'scrap_num': item.scrap_num
}
tool_material_list.append(val)
kw = json.dumps(tool_material_list, ensure_ascii=False)