Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化表面工艺
# Conflicts: # sf_manufacturing/models/mrp_production.py # sf_manufacturing/models/mrp_workorder.py
This commit is contained in:
@@ -29,41 +29,42 @@ class MrpProduction(models.Model):
|
||||
detection_result_ids = fields.One2many('sf.detection.result', 'production_id', '检测报告')
|
||||
tool_state = fields.Selection([('0', '正常'), ('1', '缺刀'), ('2', '无效刀')], string='功能刀具状态', default='0',
|
||||
store=True, compute='_compute_tool_state')
|
||||
tool_state_remark = fields.Text(string='功能刀具状态备注(缺刀)', readonly=True)
|
||||
tool_state_remark = fields.Text(string='功能刀具状态备注(缺刀)', compute='_compute_tool_state_remark', store=True)
|
||||
tool_state_remark2 = fields.Text(string='功能刀具状态备注(无效刀)', readonly=True)
|
||||
|
||||
@api.depends('workorder_ids.tool_state_remark')
|
||||
def _compute_tool_state_remark(self):
|
||||
for item in self:
|
||||
if item.workorder_ids:
|
||||
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ['rework', 'done', 'cancel'])
|
||||
if workorder_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
work_ids = workorder_ids.filtered(lambda a: a.tool_state == '1')
|
||||
tool_state_remark = ''
|
||||
for work_id in work_ids:
|
||||
if tool_state_remark == '':
|
||||
tool_state_remark = f'{work_id.tool_state_remark}'
|
||||
else:
|
||||
tool_state_remark = f"{tool_state_remark}\n{work_id.tool_state_remark}"
|
||||
item.tool_state_remark = tool_state_remark
|
||||
else:
|
||||
item.tool_state_remark = False
|
||||
|
||||
@api.depends('workorder_ids.tool_state')
|
||||
def _compute_tool_state(self):
|
||||
# if self.workorder_ids:
|
||||
for item in self:
|
||||
if item.workorder_ids:
|
||||
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工'))
|
||||
tool_state = item.tool_state
|
||||
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ['rework', 'done', 'cancel'])
|
||||
if workorder_ids.filtered(lambda a: a.tool_state == '2'):
|
||||
item.tool_state = '2'
|
||||
elif workorder_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
tool_state_remark = ''
|
||||
data = {}
|
||||
# 获取所有缺刀工单加工面对应缺的刀
|
||||
for work in workorder_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
if work.processing_panel not in list(data.keys()):
|
||||
data.update({work.processing_panel: []})
|
||||
for cnc in work.cnc_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
if cnc.cutting_tool_name not in data[work.processing_panel]:
|
||||
data[work.processing_panel].append(cnc.cutting_tool_name)
|
||||
# 按格式生成缺刀提示信息
|
||||
for key in data:
|
||||
if data.get(key) and not data.get(key):
|
||||
if tool_state_remark != '':
|
||||
tool_state_remark = f'{tool_state_remark}\n{key}缺刀:{data.get(key)}'
|
||||
else:
|
||||
tool_state_remark = f'{key}缺刀:{data.get(key)}'
|
||||
item.tool_state = '1'
|
||||
item.tool_state_remark = tool_state_remark
|
||||
item.tool_state_remark2 = ''
|
||||
else:
|
||||
item.tool_state = '0'
|
||||
item.tool_state_remark = ''
|
||||
item.tool_state_remark2 = ''
|
||||
if tool_state == '2' and item.tool_state != '2':
|
||||
item.detection_result_ids.filtered(
|
||||
lambda a: a.detailed_reason == '无效功能刀具' and a.handle_result == '待处理').write(
|
||||
{'handle_result': '已处理'})
|
||||
|
||||
# state = fields.Selection(selection_add=[
|
||||
# ('pending_scheduling', '待排程'),
|
||||
@@ -237,7 +238,6 @@ class MrpProduction(models.Model):
|
||||
ret = requests.post(config_url, json=res, data=None, headers=config_header)
|
||||
ret = ret.json()
|
||||
result = json.loads(ret['result'])
|
||||
logging.info('cron_get_programming_state-ret:%s' % result)
|
||||
if result['status'] == 1:
|
||||
for item in result['programming_list']:
|
||||
if not self:
|
||||
@@ -245,7 +245,6 @@ class MrpProduction(models.Model):
|
||||
if rp.programming_no == item['programming_no']:
|
||||
rp.write({'programming_state': '已编程未下发' if item[
|
||||
'programming_state'] == '已编程' else '编程中'})
|
||||
logging.info('rp:%s' % rp.name)
|
||||
|
||||
else:
|
||||
return item
|
||||
@@ -794,8 +793,6 @@ class MrpProduction(models.Model):
|
||||
cloud_programming = None
|
||||
if self.programming_state in ['已编程']:
|
||||
cloud_programming = self._cron_get_programming_state()
|
||||
logging.info('cloud_programming_state:%s' % cloud_programming['programming_state'])
|
||||
logging.info('programming_state:%s' % self.programming_state)
|
||||
return {
|
||||
'name': _('返工'),
|
||||
'type': 'ir.actions.act_window',
|
||||
@@ -814,17 +811,17 @@ class MrpProduction(models.Model):
|
||||
def do_update_program(self):
|
||||
program_production = self
|
||||
if len(program_production) >= 1:
|
||||
same_product_id = None
|
||||
is_not_same_product = 0
|
||||
# same_product_id = None
|
||||
# is_not_same_product = 0
|
||||
for item in program_production:
|
||||
if same_product_id is None:
|
||||
same_product_id = item.product_id
|
||||
if item.product_id != same_product_id:
|
||||
is_not_same_product += 1
|
||||
# if same_product_id is None:
|
||||
# same_product_id = item.product_id
|
||||
# if item.product_id != same_product_id:
|
||||
# is_not_same_product += 1
|
||||
if item.state != "rework" and item.programming_state != "已编程未下发":
|
||||
raise UserError("请选择状态为返工且已编程未下发的制造订单")
|
||||
if is_not_same_product >= 1:
|
||||
raise UserError("您选择的记录中含有其他产品的制造订单,请选择同一产品的制造订单")
|
||||
# if is_not_same_product >= 1:
|
||||
# raise UserError("您选择的记录中含有其他产品的制造订单,请选择同一产品的制造订单")
|
||||
grouped_program_ids = {k: list(g) for k, g in groupby(program_production, key=lambda x: x.programming_no)}
|
||||
program_to_production_names = {}
|
||||
for programming_no, program_production in grouped_program_ids.items():
|
||||
@@ -904,8 +901,10 @@ class MrpProduction(models.Model):
|
||||
if pre_workorder:
|
||||
pre_workorder.write(
|
||||
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
|
||||
logging.info('更新程序完成:%s' % production.name)
|
||||
# if production.state == 'rework' and production.programming_state == '已编程未下发':
|
||||
# production.write(
|
||||
# {'state': 'progress', 'programming_state': '已编程', 'is_rework': False})
|
||||
# logging.info('返工含有已编程未下发的程序更新完成:%s' % production.name)
|
||||
|
||||
else:
|
||||
raise UserError(result['message'])
|
||||
@@ -1084,18 +1083,3 @@ class sf_processing_panel(models.Model):
|
||||
|
||||
name = fields.Char('加工面')
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
# @api.model
|
||||
# def name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
|
||||
# if self.env.user.has_group('sf_base.group_sf_order_user'):
|
||||
# if self._context.get('product_id'):
|
||||
# product = self.env['product.product'].search([('id', '=', self._context.get('product_id'))])
|
||||
# if product:
|
||||
# panel = self.env['sf.processing.panel'].search([('name', 'ilike', 'ZM')])
|
||||
# if panel:
|
||||
# ids = [t.id for t in panel]
|
||||
# domain = [('id', 'in', ids)]
|
||||
# else:
|
||||
# domain = [('id', '=', False)]
|
||||
# return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
|
||||
# return super()._name_search(name, args, operator, limit, name_get_uid)
|
||||
|
||||
Reference in New Issue
Block a user