diff --git a/sf_machine_connect/models/res_config_setting.py b/sf_machine_connect/models/res_config_setting.py
index 78d08003..16cc4d77 100644
--- a/sf_machine_connect/models/res_config_setting.py
+++ b/sf_machine_connect/models/res_config_setting.py
@@ -8,7 +8,6 @@ _logger = logging.getLogger(__name__)
class ResBFMConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
- lost_agent_id = fields.Char('22')
bfm_url = fields.Selection(
[("https://bfm.cs.jikimo.com", "开发环境(https://bfm.cs.jikimo.com)"),
("https://bfm.t.jikimo.com", "测试环境(https://bfm.t.jikimo.com)"),
diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index be35e436..4a0e6bb9 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -129,13 +129,16 @@ class MrpProduction(models.Model):
if production.state == 'progress':
if all(wo_state not in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'pending_cam'
- if production.state == 'pending_cam':
- if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')):
- production.state = 'done'
+ # if production.state == 'pending_cam':
+ # if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')):
+ # production.state = 'done'
if any(
(
- wo.test_results == '返工' and wo.state == 'done' and programming_state == '编程中') or wo.state == 'rework' or (
- wo.is_rework is True and wo.state == 'done') for wo in
+ wo.test_results == '返工' and wo.state == 'done' and production.programming_state == '已编程') or (
+ wo.state == 'rework' and production.programming_state == '编程中') or (
+ wo.is_rework is True and wo.state == 'done' and production.programming_state in ['编程中',
+ '已编程'])
+ for wo in
production.workorder_ids):
production.state = 'rework'
@@ -198,8 +201,8 @@ class MrpProduction(models.Model):
production.write({'programming_state': '已编程未下发' if item[
'programming_state'] == '已编程' else '编程中'})
else:
- self.write({'programming_state': '已编程未下发' if item[
- 'programming_state'] == '已编程' else '编程中'})
+ return item['programming_state']
+
else:
raise UserError(ret['message'])
except Exception as e:
@@ -760,8 +763,11 @@ class MrpProduction(models.Model):
# 返工
def button_rework(self):
- if self.programming_state != '已编程':
- self._cron_get_programming_state()
+ cloud_programming_state = None
+ if self.programming_state != '已编程' and self.reprogramming_num >= 1:
+ cloud_programming_state = self._cron_get_programming_state()
+ logging.info('cloud_programming_state:%s' % cloud_programming_state)
+ logging.info('programming_state:%s' % self.programming_state)
return {
'name': _('返工'),
'type': 'ir.actions.act_window',
@@ -771,8 +777,12 @@ class MrpProduction(models.Model):
'context': {
'default_production_id': self.id,
'default_product_id': self.product_id.id,
- 'default_programming_state': self.programming_state,
- 'default_is_reprogramming': True if self.programming_state in ['已编程'] else False
+ 'default_programming_state': self.programming_state if cloud_programming_state is not None else cloud_programming_state,
+ 'default_is_reprogramming': False if (cloud_programming_state in ['编程中',
+ '待编程'] and self.programming_state in [
+ '编程中'])
+ or (cloud_programming_state in [
+ '已编程'] and self.programming_state in ['已编程未下发']) else True
}
}
@@ -807,13 +817,7 @@ class MrpProduction(models.Model):
lambda m1: m1.state != 'rework' and m1.processing_panel == rework_workorder[0].processing_panel)
if not new_pancel_workorder.cnc_ids:
production.get_new_program(rework_workorder[0].processing_panel)
- rework_production = self.env['mrp.production'].search(
- [('state', '=', 'rework'), ('programming_no', '=', production.programming_no)])
- if rework_production:
- rework_production.workorder_ids.filtered(
- lambda m2: m2.state != 'rework' and m2.processing_panel == rework_workorder[
- 0].processing_panel and m2.routing_type == '装夹预调').write({'state': 'ready'})
- rework_production.write({'state': 'progress'})
+ production.write({'state': 'progress', 'programming_state': '已下发'})
# 从cloud获取重新编程过的最新程序
def get_new_program(self, processing_panel):
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index b6571a04..6da74cbc 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -827,6 +827,7 @@ class ResMrpWorkOrder(models.Model):
re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
('processing_panel', '=', workorder.processing_panel),
('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
+ logging.info('re_work:%s' % re_work.state)
if workorder.state not in ['cancel', 'progress', 'rework']:
logging.info('工序:%s' % workorder.routing_type)
logging.info('状态:%s' % workorder.state)
@@ -840,10 +841,14 @@ class ResMrpWorkOrder(models.Model):
# if re_work:
# workorder.state = 'rework'
if workorder.production_id.state == 'rework':
- if (workorder.routing_type == 'CNC加工' and re_work.state == 'done') or (
+ if (workorder.routing_type == 'CNC加工' and workorder.state == 'done') or (
workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '编程中' and re_work):
logging.info('面111:%s' % workorder.processing_panel)
workorder.state = 'waiting'
+ elif workorder.production_id.state == 'progress':
+ logging.info('面222:%s' % workorder.processing_panel)
+ if workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已下发' and re_work:
+ workorder.state = 'ready'
# else:
# if workorder.state not in ['cancel', 'rework']:
# workorder.state = 'rework'
@@ -998,6 +1003,7 @@ class ResMrpWorkOrder(models.Model):
'detailed_reason': record.detailed_reason,
'processing_panel': record.processing_panel,
'routing_type': record.routing_type,
+ 'handle_result': '待处理' if record.test_results == '返工' or record.is_rework is True else '',
'test_results': record.test_results,
'test_report': record.detection_report})]})
if record.routing_type == '解除装夹':
diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py
index f292d694..4d05de81 100644
--- a/sf_manufacturing/models/product_template.py
+++ b/sf_manufacturing/models/product_template.py
@@ -7,8 +7,8 @@ import os
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from odoo.modules import get_resource_path
-# from OCC.Extend.DataExchange import read_step_file
-# from OCC.Extend.DataExchange import write_stl_file
+from OCC.Extend.DataExchange import read_step_file
+from OCC.Extend.DataExchange import write_stl_file
class ResProductMo(models.Model):
diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml
index ee767897..9ee96732 100644
--- a/sf_manufacturing/views/mrp_production_addional_change.xml
+++ b/sf_manufacturing/views/mrp_production_addional_change.xml
@@ -120,9 +120,9 @@
+ attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程未下发')]}"/>
+ attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程')]}"/>
@@ -279,7 +279,7 @@
-
+
@@ -555,6 +555,7 @@
diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py
index 623aed9e..dade9a14 100644
--- a/sf_manufacturing/wizard/rework_wizard.py
+++ b/sf_manufacturing/wizard/rework_wizard.py
@@ -26,7 +26,8 @@ class ReworkWizard(models.TransientModel):
is_reprogramming = fields.Boolean(string='申请重新编程', default=False)
reprogramming_num = fields.Integer('重新编程次数', default=0)
programming_state = fields.Selection(
- [('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发')], string='编程状态')
+ [('待编程', '待编程'), ('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发')],
+ string='编程状态')
def confirm(self):
if self.routing_type in ['装夹预调', 'CNC加工']:
@@ -69,6 +70,8 @@ class ReworkWizard(models.TransientModel):
self.production_id.update_programming_state()
else:
self.production_id.do_update_program()
+ if self.production_id.state == 'progress':
+ self.production_id.write({'programming_state': '已编程'})
@api.onchange('production_id')
def onchange_processing_panel_id(self):
diff --git a/sf_manufacturing/wizard/rework_wizard_views.xml b/sf_manufacturing/wizard/rework_wizard_views.xml
index 883b22fb..b50cec1e 100644
--- a/sf_manufacturing/wizard/rework_wizard_views.xml
+++ b/sf_manufacturing/wizard/rework_wizard_views.xml
@@ -19,13 +19,14 @@
readonly="1"
style='color:red;'/>次,且当前编程状态为
+ attrs='{"invisible": [("routing_type","in",["装夹预调","CNC加工"])],"readonly": [("programming_state","in",["编程中","已编程未下发"])]}'/>