修复报废
This commit is contained in:
@@ -620,12 +620,12 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
# if is_free is True:
|
# if is_free is True:
|
||||||
# delivery_workpiece._delivery_avg()
|
# delivery_workpiece._delivery_avg()
|
||||||
# logging.info('agv下发下产线任务下发完成')
|
# logging.info('agv下发下产线任务下发完成')
|
||||||
# if ret['IsComplete'] is True:
|
if ret['IsComplete'] is True:
|
||||||
# # 向AGV任务调度下发下产线任务
|
# 向AGV任务调度下发下产线任务
|
||||||
# workorders = request.env['mrp.workorder'].browse(workorder_ids)
|
workorders = request.env['mrp.workorder'].browse(workorder_ids)
|
||||||
# request.env['sf.agv.scheduling'].add_scheduling(ret['DeviceId'], '下产线', workorders)
|
request.env['sf.agv.scheduling'].add_scheduling(ret['DeviceId'], '下产线', workorders)
|
||||||
# else:
|
else:
|
||||||
# res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'}
|
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'}
|
||||||
except RepeatTaskException as e:
|
except RepeatTaskException as e:
|
||||||
logging.info('AGVToProduct error:%s' % e)
|
logging.info('AGVToProduct error:%s' % e)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -142,13 +142,13 @@ class MrpProduction(models.Model):
|
|||||||
|
|
||||||
def action_view_remanufacture_productions(self):
|
def action_view_remanufacture_productions(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
mrp_production_ids = self.env['mrp.production'].search(
|
mrp_production = self.env['mrp.production'].search(
|
||||||
[('id', '=', self.remanufacture_production_id.id)])
|
[('id', '=', self.remanufacture_production_id.id)])
|
||||||
action = {
|
action = {
|
||||||
'res_model': 'mrp.production',
|
'res_model': 'mrp.production',
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
'res_id': mrp_production_ids[0],
|
'res_id': mrp_production.id,
|
||||||
}
|
}
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
|||||||
@@ -1154,8 +1154,8 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
def button_finish(self):
|
def button_finish(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.routing_type == '装夹预调':
|
if record.routing_type == '装夹预调':
|
||||||
if not record.material_center_point or record.X_deviation_angle <= 0:
|
# if not record.material_center_point or record.X_deviation_angle <= 0:
|
||||||
raise UserError("请对前置三元检测定位参数进行计算定位")
|
# raise UserError("请对前置三元检测定位参数进行计算定位")
|
||||||
if not record.rfid_code and record.is_rework is False:
|
if not record.rfid_code and record.is_rework is False:
|
||||||
raise UserError("请扫RFID码进行绑定")
|
raise UserError("请扫RFID码进行绑定")
|
||||||
record.process_state = '待加工'
|
record.process_state = '待加工'
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError
|
|||||||
from odoo.modules import get_resource_path
|
from odoo.modules import get_resource_path
|
||||||
|
|
||||||
|
|
||||||
# from OCC.Extend.DataExchange import read_step_file
|
from OCC.Extend.DataExchange import read_step_file
|
||||||
# from OCC.Extend.DataExchange import write_stl_file
|
from OCC.Extend.DataExchange import write_stl_file
|
||||||
|
|
||||||
|
|
||||||
class ResProductMo(models.Model):
|
class ResProductMo(models.Model):
|
||||||
|
|||||||
@@ -151,8 +151,6 @@ class StockRule(models.Model):
|
|||||||
list2.append(item)
|
list2.append(item)
|
||||||
|
|
||||||
for procurement, rule in list2:
|
for procurement, rule in list2:
|
||||||
logging.info(rule)
|
|
||||||
logging.info(rule.procure_method)
|
|
||||||
procure_method = rule.procure_method
|
procure_method = rule.procure_method
|
||||||
if rule.procure_method == 'mts_else_mto':
|
if rule.procure_method == 'mts_else_mto':
|
||||||
qty_needed = procurement.product_uom._compute_quantity(procurement.product_qty,
|
qty_needed = procurement.product_uom._compute_quantity(procurement.product_qty,
|
||||||
@@ -178,10 +176,8 @@ class StockRule(models.Model):
|
|||||||
for company_id, moves_values in moves_values_by_company.items():
|
for company_id, moves_values in moves_values_by_company.items():
|
||||||
# create the move as SUPERUSER because the current user may not have the rights to do it (mto product
|
# create the move as SUPERUSER because the current user may not have the rights to do it (mto product
|
||||||
# launched by a sale for example)
|
# launched by a sale for example)
|
||||||
logging.info(moves_values)
|
|
||||||
moves = self.env['stock.move'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
|
moves = self.env['stock.move'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
|
||||||
moves_values)
|
moves_values)
|
||||||
logging.info(moves)
|
|
||||||
# Since action_confirm launch following procurement_group we should activate it.
|
# Since action_confirm launch following procurement_group we should activate it.
|
||||||
moves._action_confirm()
|
moves._action_confirm()
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -127,7 +127,7 @@
|
|||||||
confirm="是否确认更新程序"
|
confirm="是否确认更新程序"
|
||||||
attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程未下发')]}"/>
|
attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程未下发')]}"/>
|
||||||
<button name="button_rework" string="返工" type="object" groups="sf_base.group_sf_mrp_user"
|
<button name="button_rework" string="返工" type="object" groups="sf_base.group_sf_mrp_user"
|
||||||
attrs="{'invisible': ['|',('state', '!=', 'rework') ,('programming_state', '!=', '已编程')]}"/>
|
attrs="{'invisible': ['|','|',('state', '!=', 'rework') ,('programming_state', '!=', '已编程'),('is_rework', '=', True)]}"/>
|
||||||
<button name="button_scrap_new" string="报废" type="object"
|
<button name="button_scrap_new" string="报废" type="object"
|
||||||
groups="sf_base.group_sf_mrp_user"
|
groups="sf_base.group_sf_mrp_user"
|
||||||
attrs="{'invisible': ['|',('is_scrap', '=', False),('state','=','cancel')]}"/>
|
attrs="{'invisible': ['|',('is_scrap', '=', False),('state','=','cancel')]}"/>
|
||||||
@@ -201,18 +201,18 @@
|
|||||||
data-hotkey="l"/>
|
data-hotkey="l"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
<!-- <xpath expr="//header//button[@name='action_view_mo_delivery']" position="after">-->
|
<xpath expr="//button[@name='action_view_mo_delivery']" position="before">
|
||||||
<!-- <button class="oe_stat_button" name="action_view_remanufacture_productions" type="object"-->
|
<button class="oe_stat_button" name="action_view_remanufacture_productions" type="object"
|
||||||
<!-- icon="fa-wrench" attrs="{'invisible': [('remanufacture_count', '=', 0)]}"-->
|
icon="fa-wrench" attrs="{'invisible': [('remanufacture_count', '=', 0)]}"
|
||||||
<!-- groups="mrp.group_mrp_user">-->
|
groups="mrp.group_mrp_user">
|
||||||
<!-- <div class="o_field_widget o_stat_info">-->
|
<div class="o_field_widget o_stat_info">
|
||||||
<!-- <span class="o_stat_value">-->
|
<span class="o_stat_value">
|
||||||
<!-- <field name="remanufacture_count"/>-->
|
<field name="remanufacture_count"/>
|
||||||
<!-- </span>-->
|
</span>
|
||||||
<!-- <span class="o_stat_text">新的制造</span>-->
|
<span class="o_stat_text">新的制造</span>
|
||||||
<!-- </div>-->
|
</div>
|
||||||
<!-- </button>-->
|
</button>
|
||||||
<!-- </xpath>-->
|
</xpath>
|
||||||
|
|
||||||
<xpath expr="//header//button[@name='action_toggle_is_locked']" position="replace">
|
<xpath expr="//header//button[@name='action_toggle_is_locked']" position="replace">
|
||||||
<button name="action_toggle_is_locked"
|
<button name="action_toggle_is_locked"
|
||||||
|
|||||||
@@ -27,20 +27,21 @@ class ProductionWizard(models.TransientModel):
|
|||||||
self.is_reprogramming = False
|
self.is_reprogramming = False
|
||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.programming_state != '已下发':
|
|
||||||
self.programming_state = '编程中'
|
|
||||||
self.production_id.action_cancel()
|
|
||||||
self.production_id.detection_result_ids.write({'handle_result': '已处理'})
|
self.production_id.detection_result_ids.write({'handle_result': '已处理'})
|
||||||
self.production_id.write({'state': 'cancel', 'scrap_ids': [(0, 0, {
|
self.production_id.write({'state': 'cancel', 'scrap_ids': [(0, 0, {
|
||||||
'name': self.env['ir.sequence'].next_by_code('stock.scrap') or _('New'),
|
'name': self.env['ir.sequence'].next_by_code('stock.scrap') or _('New'),
|
||||||
'product_id': self.production_id.product_id.id,
|
'product_id': self.production_id.product_id.id,
|
||||||
'scrap_qty': 1,
|
'scrap_qty': 1,
|
||||||
'lot_id': self.production_id.move_line_raw_ids.lot_id.id,
|
'origin': self.production_id.origin,
|
||||||
|
'date_done': fields.datetime.now(),
|
||||||
|
'lot_id': self.env['stock.move.line'].search(
|
||||||
|
[('move_id', '=', self.production_id.move_raw_ids[0].id)]).lot_id.id,
|
||||||
'location_id': self.production_id.move_raw_ids.filtered(lambda x: x.state not in (
|
'location_id': self.production_id.move_raw_ids.filtered(lambda x: x.state not in (
|
||||||
'done',
|
'done',
|
||||||
'cancel')) and self.production_id.location_src_id.id or self.production_id.location_dest_id.id,
|
'cancel')) and self.production_id.location_src_id.id or self.production_id.location_dest_id.id,
|
||||||
'scrap_location_id': self.env['stock.scrap']._get_default_scrap_location_id(),
|
'scrap_location_id': self.env['stock.scrap']._get_default_scrap_location_id(),
|
||||||
'state': 'done'})]})
|
'state': 'done'})]})
|
||||||
|
self.production_id.action_cancel()
|
||||||
if self.is_remanufacture is True:
|
if self.is_remanufacture is True:
|
||||||
ret = {'programming_list': [], 'is_reprogramming': self.is_reprogramming}
|
ret = {'programming_list': [], 'is_reprogramming': self.is_reprogramming}
|
||||||
if self.is_reprogramming is True:
|
if self.is_reprogramming is True:
|
||||||
|
|||||||
@@ -29,21 +29,21 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
[('programming_no', '=', ret['programming_no'])])
|
[('programming_no', '=', ret['programming_no'])])
|
||||||
if productions:
|
if productions:
|
||||||
# # 拉取所有加工面的程序文件
|
# # 拉取所有加工面的程序文件
|
||||||
# for r in ret['processing_panel'].split(','):
|
for r in ret['processing_panel'].split(','):
|
||||||
# program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
||||||
# if os.path.exists(program_path_tmp_r):
|
if os.path.exists(program_path_tmp_r):
|
||||||
# files_r = os.listdir(program_path_tmp_r)
|
files_r = os.listdir(program_path_tmp_r)
|
||||||
# if files_r:
|
if files_r:
|
||||||
# for file_name in files_r:
|
for file_name in files_r:
|
||||||
# file_path = os.path.join(program_path_tmp_r, file_name)
|
file_path = os.path.join(program_path_tmp_r, file_name)
|
||||||
# os.remove(file_path)
|
os.remove(file_path)
|
||||||
# download_state = request.env['sf.cnc.processing'].with_user(
|
download_state = request.env['sf.cnc.processing'].with_user(
|
||||||
# request.env.ref("base.user_admin")).download_file_tmp(
|
request.env.ref("base.user_admin")).download_file_tmp(
|
||||||
# ret['folder_name'], r)
|
ret['folder_name'], r)
|
||||||
# if download_state is False:
|
if download_state is False:
|
||||||
# res['status'] = -2
|
res['status'] = -2
|
||||||
# res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||||
# return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
for production in productions:
|
for production in productions:
|
||||||
if not production.workorder_ids:
|
if not production.workorder_ids:
|
||||||
production.product_id.model_processing_panel = ret['processing_panel']
|
production.product_id.model_processing_panel = ret['processing_panel']
|
||||||
@@ -82,32 +82,32 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
# if pre_workorder:
|
# if pre_workorder:
|
||||||
# pre_workorder.write(
|
# pre_workorder.write(
|
||||||
# {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
# {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||||
# for panel in ret['processing_panel'].split(','):
|
for panel in ret['processing_panel'].split(','):
|
||||||
# # 查询状态为进行中且工序类型为CNC加工的工单
|
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||||
# cnc_workorder = productions.workorder_ids.filtered(
|
cnc_workorder = productions.workorder_ids.filtered(
|
||||||
# lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done',
|
lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done',
|
||||||
# 'cancel'] and ac.processing_panel == panel)
|
'cancel'] and ac.processing_panel == panel)
|
||||||
# if cnc_workorder:
|
if cnc_workorder:
|
||||||
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
||||||
# panel)
|
# panel)
|
||||||
# program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
||||||
# logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
|
logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
|
||||||
# files_panel = os.listdir(program_path_tmp_panel)
|
files_panel = os.listdir(program_path_tmp_panel)
|
||||||
# if files_panel:
|
if files_panel:
|
||||||
# for file in files_panel:
|
for file in files_panel:
|
||||||
# file_extension = os.path.splitext(file)[1]
|
file_extension = os.path.splitext(file)[1]
|
||||||
# logging.info('file_extension:%s' % file_extension)
|
logging.info('file_extension:%s' % file_extension)
|
||||||
# if file_extension.lower() == '.pdf':
|
if file_extension.lower() == '.pdf':
|
||||||
# panel_file_path = os.path.join(program_path_tmp_panel, file)
|
panel_file_path = os.path.join(program_path_tmp_panel, file)
|
||||||
# logging.info('panel_file_path:%s' % panel_file_path)
|
logging.info('panel_file_path:%s' % panel_file_path)
|
||||||
# cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||||
# pre_workorder = productions.workorder_ids.filtered(
|
pre_workorder = productions.workorder_ids.filtered(
|
||||||
# lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done',
|
lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done',
|
||||||
# 'cancel'] and ap.processing_panel == panel)
|
'cancel'] and ap.processing_panel == panel)
|
||||||
# if pre_workorder:
|
if pre_workorder:
|
||||||
# pre_workorder.write(
|
pre_workorder.write(
|
||||||
# {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||||
# productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
# cnc_program_ids = [item.id for item in productions]
|
# cnc_program_ids = [item.id for item in productions]
|
||||||
# workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
# workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||||
# [('production_id', 'in', cnc_program_ids)])
|
# [('production_id', 'in', cnc_program_ids)])
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ from datetime import datetime
|
|||||||
import requests
|
import requests
|
||||||
from odoo import http
|
from odoo import http
|
||||||
from odoo.http import request
|
from odoo.http import request
|
||||||
# from OCC.Extend.DataExchange import read_step_file
|
from OCC.Extend.DataExchange import read_step_file
|
||||||
# from OCC.Extend.DataExchange import write_stl_file
|
from OCC.Extend.DataExchange import write_stl_file
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
from odoo.modules import get_resource_path
|
from odoo.modules import get_resource_path
|
||||||
from odoo.exceptions import ValidationError, UserError
|
from odoo.exceptions import ValidationError, UserError
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import os
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from stl import mesh
|
from stl import mesh
|
||||||
# from OCC.Core.GProp import GProp_GProps
|
# from OCC.Core.GProp import GProp_GProps
|
||||||
# from OCC.Extend.DataExchange import read_step_file
|
from OCC.Extend.DataExchange import read_step_file
|
||||||
# from OCC.Extend.DataExchange import write_stl_file
|
from OCC.Extend.DataExchange import write_stl_file
|
||||||
from odoo.addons.sf_base.commons.common import Common
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
from odoo.modules import get_resource_path
|
from odoo.modules import get_resource_path
|
||||||
|
|||||||
Reference in New Issue
Block a user