Merge branch 'develop' into feature/sf看板样式统一
# Conflicts: # jikimo_frontend/static/src/scss/custom_style.scss
This commit is contained in:
@@ -2,8 +2,8 @@ from . import model_type
|
||||
from . import product_template
|
||||
from . import mrp_production
|
||||
from . import mrp_workorder
|
||||
from . import mrp_workcenter
|
||||
from . import mrp_maintenance
|
||||
from . import mrp_workcenter
|
||||
from . import mrp_routing_workcenter
|
||||
from . import stock
|
||||
from . import res_user
|
||||
|
||||
@@ -6,8 +6,8 @@ from dateutil.relativedelta import relativedelta
|
||||
|
||||
class MaintenanceEquipment(models.Model):
|
||||
_inherit = "maintenance.equipment"
|
||||
_check_company_auto = True
|
||||
|
||||
production_line_id = fields.Many2one('sf.production.line', string='生产线')
|
||||
expected_mtbf = fields.Integer(string='Expected MTBF', help='Expected Mean Time Between Failure')
|
||||
mtbf = fields.Integer(compute='_compute_maintenance_request', string='MTBF',
|
||||
help='Mean Time Between Failure, computed based on done corrective maintenances.')
|
||||
@@ -16,8 +16,6 @@ class MaintenanceEquipment(models.Model):
|
||||
string='Estimated time before next failure (in days)',
|
||||
help='Computed as Latest Failure Date + MTBF')
|
||||
latest_failure_date = fields.Date(compute='_compute_maintenance_request', string='Latest Failure Date')
|
||||
workcenter_id = fields.Many2one(
|
||||
'mrp.workcenter', string='Work Center', check_company=True)
|
||||
|
||||
@api.depends('effective_date', 'maintenance_ids.stage_id', 'maintenance_ids.close_date',
|
||||
'maintenance_ids.request_date')
|
||||
@@ -64,3 +62,8 @@ class MaintenanceRequest(models.Model):
|
||||
'mrp.workorder', string='Work Order', check_company=True)
|
||||
production_company_id = fields.Many2one(string='Production Company', related='production_id.company_id')
|
||||
company_id = fields.Many2one(domain="[('id', '=?', production_company_id)]")
|
||||
|
||||
class SfMaintenanceLogs(models.Model):
|
||||
_inherit = 'sf.maintenance.logs'
|
||||
|
||||
production_line_id = fields.Many2one('sf.production.line', string='生产线', related='maintenance_equipment_id.production_line_id', store=True)
|
||||
|
||||
@@ -9,13 +9,10 @@ class ResWorkcenter(models.Model):
|
||||
|
||||
# 生产线显示
|
||||
production_line_show = fields.Char(string='生产线名称')
|
||||
machine_tool_id = fields.Many2one('sf.machine_tool', string='机床')
|
||||
production_line_id = fields.Many2one('sf.production.line', string='生产线')
|
||||
equipment_id = fields.Many2one(
|
||||
'maintenance.equipment', string="设备",
|
||||
check_company=True)
|
||||
|
||||
|
||||
)
|
||||
production_line_id = fields.Many2one('sf.production.line', string='生产线', related='equipment_id.production_line_id', store=True)
|
||||
|
||||
is_process_outsourcing = fields.Boolean('工艺外协')
|
||||
users_ids = fields.Many2many("res.users", 'users_workcenter')
|
||||
@@ -25,13 +22,13 @@ class ResWorkcenter(models.Model):
|
||||
|
||||
equipment_status = fields.Selection(
|
||||
[("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")],
|
||||
string="设备状态", compute='_compute_equipment_id')
|
||||
string="设备状态", related='equipment_id.state')
|
||||
|
||||
@api.depends('equipment_id')
|
||||
def _compute_equipment_id(self):
|
||||
for record in self:
|
||||
if record:
|
||||
record.equipment_status = record.equipment_id.state
|
||||
# @api.depends('equipment_id')
|
||||
# def _compute_equipment_id(self):
|
||||
# for record in self:
|
||||
# if record:
|
||||
# record.equipment_status = record.equipment_id.state
|
||||
|
||||
equipment_image = fields.Binary('设备图片', related='equipment_id.machine_tool_picture')
|
||||
|
||||
@@ -40,23 +37,23 @@ class ResWorkcenter(models.Model):
|
||||
outsourcing_workcenter = self.env['mrp.workcenter'].search([('is_process_outsourcing', '=', True)])
|
||||
return outsourcing_workcenter.id
|
||||
|
||||
@api.onchange('machine_tool_id')
|
||||
def update_machine_tool_is_binding(self):
|
||||
machine_tool = self.env["sf.machine_tool"].search([('is_binding', '=', True)])
|
||||
if machine_tool:
|
||||
for item in machine_tool:
|
||||
workcenter_machine_tool = self.env["mrp.workcenter"].search([('machine_tool_id', '=', item.id)])
|
||||
if workcenter_machine_tool:
|
||||
if self.machine_tool_id.id:
|
||||
if workcenter_machine_tool.id != self.machine_tool_id.id:
|
||||
self.machine_tool_id.is_binding = True
|
||||
else:
|
||||
self.machine_tool_id.is_binding = True
|
||||
else:
|
||||
self.machine_tool_id.is_binding = True
|
||||
item.is_binding = False
|
||||
else:
|
||||
self.machine_tool_id.is_binding = True
|
||||
# @api.onchange('machine_tool_id')
|
||||
# def update_machine_tool_is_binding(self):
|
||||
# machine_tool = self.env["sf.machine_tool"].search([('is_binding', '=', True)])
|
||||
# if machine_tool:
|
||||
# for item in machine_tool:
|
||||
# workcenter_machine_tool = self.env["mrp.workcenter"].search([('machine_tool_id', '=', item.id)])
|
||||
# if workcenter_machine_tool:
|
||||
# if self.machine_tool_id.id:
|
||||
# if workcenter_machine_tool.id != self.machine_tool_id.id:
|
||||
# self.machine_tool_id.is_binding = True
|
||||
# else:
|
||||
# self.machine_tool_id.is_binding = True
|
||||
# else:
|
||||
# self.machine_tool_id.is_binding = True
|
||||
# item.is_binding = False
|
||||
# else:
|
||||
# self.machine_tool_id.is_binding = True
|
||||
|
||||
def action_work_order(self):
|
||||
if not self.env.context.get('desktop_list_view', False):
|
||||
|
||||
@@ -835,3 +835,43 @@ class ResMrpBomMo(models.Model):
|
||||
raw_bom = self.env['product.product'].search(
|
||||
[('categ_id.type', '=', '原材料'), ('materials_type_id', '=', product.materials_type_id.id)])
|
||||
return raw_bom
|
||||
|
||||
|
||||
class SfMaintenanceEquipmentAndProductTemplate(models.Model):
|
||||
_inherit = 'maintenance.equipment'
|
||||
_description = '设备'
|
||||
product_template_ids = fields.One2many('maintenance.equipment.tool', 'equipment_id', string='机床刀位')
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
vals = []
|
||||
for value in vals_list:
|
||||
res = super(SfMaintenanceEquipmentAndProductTemplate, self).create(value)
|
||||
number = value.get('number_of_knife_library')
|
||||
for i in range(1, number + 1):
|
||||
self.env['maintenance.equipment.tool'].create({
|
||||
'equipment_id': res.id,
|
||||
'code': 'T' + str(i)
|
||||
})
|
||||
vals.append(res)
|
||||
return vals[0]
|
||||
|
||||
|
||||
class SfMaintenanceEquipmentTool(models.Model):
|
||||
_name = 'maintenance.equipment.tool'
|
||||
_description = '机床刀位'
|
||||
|
||||
equipment_id = fields.Many2one('maintenance.equipment', string='设备')
|
||||
product_template_id = fields.Many2one('product.template', string='功能刀具名称', domain="[('categ_type', '=', '刀具')]")
|
||||
image_1920 = fields.Binary('图片', related='product_template_id.image_1920')
|
||||
categ_type = fields.Char(string='功能刀具类型')
|
||||
diameter = fields.Char('直径')
|
||||
precision = fields.Char('粗\中\精')
|
||||
tool_code = fields.Char('功能刀具编码')
|
||||
hilt_name = fields.Char('刀柄名称')
|
||||
hilt_code = fields.Char('刀柄编码')
|
||||
life_value_max = fields.Char('最大寿命值')
|
||||
alarm_value = fields.Char('报警值')
|
||||
used_value = fields.Char('已使用值')
|
||||
code = fields.Char('机床刀位号')
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ class ProductionLine(models.Model):
|
||||
return num
|
||||
|
||||
mrp_workcenter_ids = fields.One2many('mrp.workcenter', 'production_line_id', '工作中心')
|
||||
mrp_manufacturing_ids = fields.One2many('maintenance.equipment', 'production_line_id', '设备')
|
||||
name = fields.Char('生产线', size=20, required=True)
|
||||
code = fields.Char('编码', default=_get_code, readonly=True)
|
||||
remark = fields.Char('备注')
|
||||
|
||||
Reference in New Issue
Block a user