Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/修复质检接口

This commit is contained in:
jinling.yang
2024-02-29 10:35:38 +08:00
5 changed files with 61 additions and 28 deletions

View File

@@ -13,7 +13,7 @@ class SfMaintenanceEquipmentCategory(models.Model):
_description = '设备类别' _description = '设备类别'
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'),
('检测设备', '检测设备')], string='类型', default='机床') ('检测设备', '检测设备'), ('其他', '其他')], string='类型', default='机床')
equipment_type_code = fields.Char('简写') equipment_type_code = fields.Char('简写')
@@ -104,18 +104,18 @@ class SfMaintenanceEquipment(models.Model):
tool_diameter_max = fields.Char('刀具刀径max(mm)') tool_diameter_max = fields.Char('刀具刀径max(mm)')
tool_diameter_min = fields.Char('刀具刀径min(mm)') tool_diameter_min = fields.Char('刀具刀径min(mm)')
def get_no(self): # def get_no(self):
partner = self.env['maintenance.equipment'].sudo().search( # partner = self.env['maintenance.equipment'].sudo().search(
[('MTcode', '!=', '')], # [('MTcode', '!=', '')],
limit=1, # limit=1,
order="id desc") # order="id desc")
if not partner: # if not partner:
num = "%04d" % 1 # num = "%04d" % 1
#
else: # else:
m = int(partner.MTcode) + 1 # m = int(partner.MTcode) + 1
num = "%04d" % m # num = "%04d" % m
return num # return num
equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards', equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards',
@@ -145,7 +145,7 @@ class SfMaintenanceEquipment(models.Model):
else: else:
record.equipment_maintenance_standards_ids = False record.equipment_maintenance_standards_ids = False
MTcode = fields.Char("机台编码", default=get_no) MTcode = fields.Char("机台编码")
created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user) created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user)
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'),
('检测设备', '检测设备')], compute='_compute_category_id') ('检测设备', '检测设备')], compute='_compute_category_id')
@@ -230,7 +230,15 @@ class SfMaintenanceEquipment(models.Model):
equipment = super(SfMaintenanceEquipment, self).create(vals) equipment = super(SfMaintenanceEquipment, self).create(vals)
if equipment.category_id: if equipment.category_id:
equipment.name = equipment.MTcode + '#' + equipment.category_id.name equipment.name = "%s%s" % (equipment.MTcode, equipment.category_id.name)
if equipment.category_id.equipment_type == '机床':
equipment_id = self.env['maintenance.equipment.oee'].search([('equipment_id', '=', equipment.id)])
if not equipment_id:
self.env['maintenance.equipment.oee'].sudo().create({
'equipment_id': equipment.id,
'name': equipment.name,
})
# 在创建设备之后执行一些自定义逻辑 # 在创建设备之后执行一些自定义逻辑
# ... # ...
@@ -567,7 +575,6 @@ class SfMaintenanceEquipment(models.Model):
'T_tool_time': item.T_tool_time, 'T_tool_time': item.T_tool_time,
'C_tool_time': item.C_tool_time, 'C_tool_time': item.C_tool_time,
'jiancheng': item.category_id.equipment_type_code, 'jiancheng': item.category_id.equipment_type_code,
'function_type': item.function_type,
} }
machine_tool_list.append(val) machine_tool_list.append(val)
# kw = machine_tool_list # kw = machine_tool_list

View File

@@ -36,8 +36,7 @@
type="action" type="action"
class="oe_stat_button" class="oe_stat_button"
context="{'search_default_equipment_id': [active_id]}" context="{'search_default_equipment_id': [active_id]}"
icon="fa-exchange" icon="fa-exchange">
attrs="{'invisible': [('state_zc', '!=', '已注册')]}">
<field string="设备oee" name="equipment_oee_ids" widget="statinfo"/> <field string="设备oee" name="equipment_oee_ids" widget="statinfo"/>
</button> </button>

View File

@@ -22,10 +22,19 @@ class ResMrpRoutingWorkcenter(models.Model):
bom_id = fields.Many2one('mrp.bom', required=False) bom_id = fields.Many2one('mrp.bom', required=False)
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺") surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
def generate_code(self): def get_no(self):
return self.env['ir.sequence'].next_by_code('mrp.routing.workcenter') international_standards = self.search(
[('code', '!=', ''), ('active', 'in', [True, False])],
limit=1,
order="id desc")
if not international_standards:
num = "%03d" % 1
else:
m = int(international_standards.code) + 1
num = "%03d" % m
return num
code = fields.Char('编码', default=generate_code) code = fields.Char('编码', default=get_no)
# 获得当前登陆者公司 # 获得当前登陆者公司
def get_company_id(self): def get_company_id(self):

View File

@@ -859,7 +859,7 @@ class SfMaintenanceEquipmentAndProductTemplate(models.Model):
for i in range(1, number + 1): for i in range(1, number + 1):
self.env['maintenance.equipment.tool'].create({ self.env['maintenance.equipment.tool'].create({
'equipment_id': res.id, 'equipment_id': res.id,
'code': 'T' + str(i) 'code': "T%02d" % i
}) })
vals.append(res) vals.append(res)
return vals[0] return vals[0]

View File

@@ -14,6 +14,7 @@ from odoo.addons.stock.models.stock_rule import ProcurementException
from odoo.addons.sf_base.commons.common import Common from odoo.addons.sf_base.commons.common import Common
from odoo.exceptions import UserError from odoo.exceptions import UserError
from io import BytesIO from io import BytesIO
from odoo.exceptions import ValidationError
class StockRule(models.Model): class StockRule(models.Model):
@@ -250,6 +251,22 @@ class ProductionLot(models.Model):
)) ))
return lot_names return lot_names
def get_tool_generate_lot_names1(self, company, product):
"""
采购时生成刀具物料序列号
"""
now = datetime.now().strftime("%Y%m%d")
last_serial = self.env['stock.lot'].search(
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'like', now)],
limit=1, order='id DESC')
if product.cutting_tool_model_id:
if not last_serial:
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1)
else:
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, int(last_serial.name[-3:]) + 1)
else:
raise ValidationError('该刀具物料产品的型号字段为空,请补充完整!!!')
@api.model @api.model
def _get_next_serial(self, company, product): def _get_next_serial(self, company, product):
"""Return the next serial number to be attributed to the product.""" """Return the next serial number to be attributed to the product."""
@@ -258,12 +275,13 @@ class ProductionLot(models.Model):
[('company_id', '=', company.id), ('product_id', '=', product.id)], [('company_id', '=', company.id), ('product_id', '=', product.id)],
limit=1, order='id DESC') limit=1, order='id DESC')
if last_serial: if last_serial:
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name, 2)[ if product.categ_id.name == '刀具':
1] return self.env['stock.lot'].get_tool_generate_lot_names1(company, product)
now = datetime.now().strftime("%Y-%m-%d") else:
# formatted_date = now.strftime("%Y-%m-%d") return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name, 2)[1]
now = datetime.now().strftime("%Y%m%d")
if product.cutting_tool_model_id: if product.cutting_tool_model_id:
return "%s-%s-%03d" % (product.cutting_tool_model_id.code, now, 1) return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1)
return "%s-%03d" % (product.name, 1) return "%s-%03d" % (product.name, 1)
qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code') qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code')