1.优化sf的产品页面展示:新增服务产品的工艺参数字段,当产品类别为服务时,该字段出现出现,材料和型号隐藏;加工参数里的表面工艺参数字段的值显示为表面工艺+可选参数
2.修复sf的表面工艺工单及完成后的询价单
This commit is contained in:
@@ -136,7 +136,7 @@ class MrpProduction(models.Model):
|
||||
route_workcenter_arr = []
|
||||
for item in production.product_id.product_model_type_id.surface_technics_routing_tmpl_ids:
|
||||
surface_technics_arr.append(item.route_workcenter_id.surface_technics_id.id)
|
||||
route_workcenter_arr.append(item.route_workcenter_id)
|
||||
route_workcenter_arr.append(item.route_workcenter_id.id)
|
||||
if surface_technics_arr:
|
||||
production_process = self.env['sf.production.process.category'].search(
|
||||
[('production_process_ids.id', 'in', surface_technics_arr)],
|
||||
@@ -146,16 +146,18 @@ class MrpProduction(models.Model):
|
||||
for p in production_process:
|
||||
for pitem in p.production_process_ids:
|
||||
if pitem.id in surface_technics_arr:
|
||||
process_parameter = self.env['sf.production.process.parameter'].search(
|
||||
[('id', '=', pitem.id)])
|
||||
for ritem in route_workcenter_arr:
|
||||
route_production_process = self.env['mrp.routing.workcenter'].search(
|
||||
[('surface_technics_id', '=', pitem.id), ('id', '=', ritem)])
|
||||
if route_production_process:
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder']._json_workorder_surface_process_str(
|
||||
production, route_production_process,
|
||||
process_parameter))
|
||||
for param in production.product_id.model_process_parameters_ids:
|
||||
process_parameter = self.env['sf.production.process.parameter'].search(
|
||||
[('process_id.id', '=', pitem.id), ('id', '=', param.id)])
|
||||
if process_parameter:
|
||||
for ritem in route_workcenter_arr:
|
||||
route_production_process = self.env['mrp.routing.workcenter'].search(
|
||||
[('surface_technics_id', '=', pitem.id), ('id', '=', ritem)])
|
||||
if route_production_process:
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder']._json_workorder_surface_process_str(
|
||||
production, route_production_process,
|
||||
process_parameter))
|
||||
elif production.product_id.categ_id.type == '胚料':
|
||||
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
|
||||
[('embryo_model_type_id', '=', production.product_id.embryo_model_type_id.id)],
|
||||
|
||||
@@ -60,7 +60,7 @@ class ResMrpRoutingWorkcenter(models.Model):
|
||||
order by count(*),workcenter_id asc limit 1 """, [tuple(workcenter_ids)])
|
||||
res = self.env.cr.fetchone()
|
||||
if res:
|
||||
workcenter_id = self.env.cr.dictfetchall()[0].get('workcenter_id')
|
||||
workcenter_id = res[0]
|
||||
else:
|
||||
workcenter_id = workcenter_ids[0]
|
||||
return workcenter_id
|
||||
|
||||
@@ -91,6 +91,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工")
|
||||
tray_code = fields.Char(string="托盘")
|
||||
glb_file = fields.Binary("glb模型文件")
|
||||
is_subcontract = fields.Boolean(string='是否外协')
|
||||
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
||||
|
||||
# 计算配料中心点和与x轴倾斜度方法
|
||||
def getcenter(self):
|
||||
@@ -163,10 +165,12 @@ class ResMrpWorkOrder(models.Model):
|
||||
'product_uom_id': production.product_uom_id.id,
|
||||
'qty_producing': 0,
|
||||
'operation_id': False,
|
||||
'name': route.name,
|
||||
'name': '%s-%s' % (route.name, process_parameter.name),
|
||||
'processing_panel': '',
|
||||
'routing_type': '表面工艺',
|
||||
'surface_technics_parameters_id': process_parameter.id,
|
||||
'work_state': '',
|
||||
'is_subcontract': True if process_parameter.gain_way == '外协' else False,
|
||||
'workcenter_id': self.env[
|
||||
'mrp.workcenter'].get_process_outsourcing_workcenter() if process_parameter.gain_way == '外协' else
|
||||
self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
|
||||
@@ -465,6 +469,51 @@ class ResMrpWorkOrder(models.Model):
|
||||
else:
|
||||
raise UserError(_('请先完成上一步工单'))
|
||||
|
||||
def button_finish(self):
|
||||
end_date = datetime.now()
|
||||
for workorder in self:
|
||||
if workorder.state in ('done', 'cancel'):
|
||||
continue
|
||||
workorder.end_all()
|
||||
vals = {
|
||||
'qty_produced': workorder.qty_produced or workorder.qty_producing or workorder.qty_production,
|
||||
'state': 'done',
|
||||
'date_finished': end_date,
|
||||
'date_planned_finished': end_date,
|
||||
'costs_hour': workorder.workcenter_id.costs_hour
|
||||
}
|
||||
if not workorder.date_start:
|
||||
vals['date_start'] = end_date
|
||||
if not workorder.date_planned_start or end_date < workorder.date_planned_start:
|
||||
vals['date_planned_start'] = end_date
|
||||
workorder.with_context(bypass_duration_calculation=True).write(vals)
|
||||
self.env.cr.commit()
|
||||
finish_workorder_count = self.env['mrp.workorder'].search_count(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
('is_subcontract', '=', True)])
|
||||
subcontract_workorder_count = self.env['mrp.workorder'].search_count(
|
||||
[('production_id', '=', workorder.production_id.id), ('is_subcontract', '=', True),
|
||||
('state', '=', 'done')])
|
||||
if len(finish_workorder_count) == len(subcontract_workorder_count):
|
||||
subcontract_workorder = self.env['mrp.workorder'].search(
|
||||
[('production_id', '=', workorder.production_id.id), ('is_subcontract', '=', True),
|
||||
('state', '=', 'done')])
|
||||
for item in subcontract_workorder:
|
||||
order_line_ids = []
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id),
|
||||
('categ_type', '=', '服务'), ('detailed_type', '=', 'service')])
|
||||
order_line_ids.append((0, 0, {
|
||||
'product_id': server_product.id,
|
||||
'product_qty': 1,
|
||||
'product_uom': server_product.uom_id.id
|
||||
}))
|
||||
self.env['purchase.order'].create({
|
||||
'partner_id': server_product.seller_ids[0].id,
|
||||
'state': 'draft',
|
||||
'order_line': order_line_ids,
|
||||
})
|
||||
|
||||
|
||||
class CNCprocessing(models.Model):
|
||||
_name = 'sf.cnc.processing'
|
||||
@@ -569,6 +618,25 @@ class CNCprocessing(models.Model):
|
||||
else:
|
||||
return False
|
||||
|
||||
# end_date = datetime.now()
|
||||
# for workorder in self:
|
||||
# if workorder.state in ('done', 'cancel'):
|
||||
# continue
|
||||
# workorder.end_all()
|
||||
# vals = {
|
||||
# 'qty_produced': workorder.qty_produced or workorder.qty_producing or workorder.qty_production,
|
||||
# 'state': 'done',
|
||||
# 'date_finished': end_date,
|
||||
# 'date_planned_finished': end_date,
|
||||
# 'costs_hour': workorder.workcenter_id.costs_hour
|
||||
# }
|
||||
# if not workorder.date_start:
|
||||
# vals['date_start'] = end_date
|
||||
# if not workorder.date_planned_start or end_date < workorder.date_planned_start:
|
||||
# vals['date_planned_start'] = end_date
|
||||
# workorder.with_context(bypass_duration_calculation=True).write(vals)
|
||||
return True
|
||||
|
||||
|
||||
class SfWorkOrderBarcodes(models.Model):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user