Accept Merge Request #993: (feature/优化模型上色路径 -> develop)

Merge Request: 修复快速订单和预调工单

Created By: @杨金灵
Reviewed By: @马广威
Approved By: @马广威 
Accepted By: @杨金灵
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/993
This commit is contained in:
杨金灵
2024-05-08 14:29:05 +08:00
committed by Coding
5 changed files with 27 additions and 11 deletions

View File

@@ -37,7 +37,7 @@ class ResMrpBomMo(models.Model):
'product_qty': 1,
'product_uom_id': 1
}
return self.env['mrp.bom.line'].create(vals)
return self.env['mrp.bom.line'].sudo().create(vals)
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
def bom_create(self, product, bom_type, product_type):
@@ -64,7 +64,7 @@ class ResMrpBomMo(models.Model):
qty = 1
if round(embryo.volume * raw_bom_line.materials_type_id.density / 1000000) > 1:
qty = round(embryo.volume * raw_bom_line.materials_type_id.density / 1000000)
bom_line = self.env['mrp.bom.line'].create({
bom_line = self.env['mrp.bom.line'].sudo().create({
'bom_id': self.id,
'product_id': raw_bom_line.id,
'product_tmpl_id': raw_bom_line.product_tmpl_id.id,

View File

@@ -56,8 +56,9 @@ class MrpProduction(models.Model):
glb_file = fields.Binary("glb模型文件")
production_line_id = fields.Many2one('sf.production.line', string='生产线')
plan_start_processing_time = fields.Datetime('计划开始加工时间')
production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
string='/下产线', default='待上产线')
production_line_state = fields.Selection(
[('待上产线', '待上产线'), ('已上产线', '上产线'), ('已下产线', '已下产线')],
string='上/下产线', default='待上产线')
# 工序状态
# Todo 研究下用法
process_state = fields.Selection([
@@ -114,7 +115,7 @@ class MrpProduction(models.Model):
# production.state = 'pending_processing'
production.state = 'pending_cam'
if production.state == 'progress' and production.schedule_state == '已排' and production.process_state == '待加工':
# if production.state == 'pending_cam' and production.process_state == '待加工':
# if production.state == 'pending_cam' and production.process_state == '待加工':
production.state = 'pending_processing'
elif production.state == 'progress' and production.process_state == '待解除装夹':
production.state = 'pending_era_cam'
@@ -262,10 +263,14 @@ class MrpProduction(models.Model):
# 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心;
def _create_workorder3(self):
programming_no = None
product_id_new = None
for production in self:
if not production.bom_id or not production.product_id:
continue
workorders_values = []
if product_id_new is None:
product_id_new = production.product_id
product_qty = production.product_uom_id._compute_quantity(production.product_qty,
production.bom_id.product_uom_id)
@@ -290,7 +295,14 @@ class MrpProduction(models.Model):
'state': 'pending',
}]
if production.product_id.categ_id.type == '成品':
production.fetchCNC()
if programming_no is None:
production.fetchCNC()
programming_no = production.programming_no
else:
if production.product_id == product_id_new:
if not production.programming_no:
production.write({'programming_no': programming_no, 'programming_state': '编程中'})
# 根据加工面板的面数及对应的工序模板生成工单
i = 0
processing_panel_len = len(production.product_id.model_processing_panel.split(','))

View File

@@ -736,14 +736,17 @@ class ResMrpWorkOrder(models.Model):
if self.routing_type == '装夹预调' and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name:
self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name
if self.routing_type == '装夹预调':
if not self.cnc_ids:
cnc_workorder = self.search(
[('production_id', '=', self.production_id.id), ('routing_type', '=', 'CNC加工')],
limit=1, order='id asc')
if not cnc_workorder:
raise UserError(_('该制造订单还未下发CNC程序请稍后再试'))
else:
for item in self.cnc_ids:
for item in cnc_workorder.cnc_ids:
functional_cutting_tool = self.env['sf.functional.cutting.tool.entity'].search(
[('tool_name_id.name', '=', item.cutting_tool_name)])
if not functional_cutting_tool:
raise UserError(_('该制造订单的CNC程序为%s没有对应的功能刀具%s' % item.cutting_tool_name))
raise UserError(_('该制造订单的CNC程序为%s没有对应的功能刀具' % item.cutting_tool_name))
if self.routing_type == '解除装夹':
'''
记录开始时间

View File

@@ -612,6 +612,7 @@
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
<field name="is_cnc_program_down" readonly="1"/>
<!-- <field name="rfid_code"/>-->
<field name="task_delivery_time" readonly="1"/>
<field name="task_completion_time" readonly="1"/>
<field name="delivery_duration" widget="float_time"/>

View File

@@ -85,9 +85,9 @@ class ReSaleOrder(models.Model):
self.check_status = 'pending'
def get_customer(self):
partner_tag = self.env['res.partner.category'].search([('name', '=', '业务平台')], limit=1, order='id asc')
partner_tag = self.env['res.partner.category'].sudo().search([('name', '=', '业务平台')], limit=1, order='id asc')
if not partner_tag:
partner_tag = self.env['res.partner.category'].create({'name': '平台客户'})
partner_tag = self.env['res.partner.category'].sudo().create({'name': '平台客户'})
customer = self.env['res.partner'].search([('name', '=', '业务平台')], limit=1, order='id asc')
if customer:
if not customer.vat: