Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造功能优化
This commit is contained in:
@@ -433,6 +433,7 @@ class MrpProduction(models.Model):
|
||||
def technology_confirm(self):
|
||||
process_parameters = []
|
||||
account_moves = []
|
||||
purchase_orders = []
|
||||
parameters_not = []
|
||||
# 获取原有的工单对应的工序
|
||||
origin_designs = self.workorder_ids.technology_design_id
|
||||
@@ -444,8 +445,10 @@ class MrpProduction(models.Model):
|
||||
purchase = workorder._get_surface_technics_purchase_ids()
|
||||
account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids.ids)])
|
||||
if account.state not in ['cancel', False]:
|
||||
if purchase.name not in account_moves:
|
||||
account_moves.append(purchase.name)
|
||||
if account.name not in account_moves:
|
||||
account_moves.append(account.name)
|
||||
if purchase.state not in ['cancel','draft', False]:
|
||||
purchase_orders.append(purchase.name)
|
||||
special_design = self.technology_design_ids.filtered(
|
||||
lambda a: a.routing_tag == 'special' and a.is_auto is False)
|
||||
for special in special_design:
|
||||
@@ -459,7 +462,9 @@ class MrpProduction(models.Model):
|
||||
process_parameters.append(special.process_parameters_id.display_name)
|
||||
|
||||
if account_moves:
|
||||
raise UserError(_("请联系工厂生产经理对会计凭证为%s生成的账单进行取消", ", ".join([move.name for move in account_moves])))
|
||||
raise UserError(_("请联系工厂生产经理对该(%s)账单进行取消", ", ".join(account_moves)))
|
||||
if purchase_orders:
|
||||
raise UserError(_("请联系工厂生产经理对该(%s)采购订单进行取消", ", ".join(purchase_orders)))
|
||||
if parameters_not:
|
||||
raise UserError(_("【工艺设计】-【工序】为%s未选择参数,请选择", ", ".join(parameters_not)))
|
||||
if process_parameters:
|
||||
@@ -692,7 +697,13 @@ class MrpProduction(models.Model):
|
||||
'user': cnc.env.user.name,
|
||||
'programme_way': programme_way,
|
||||
'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
|
||||
cnc.product_id.model_file).decode('utf-8')
|
||||
cnc.product_id.model_file).decode('utf-8'),
|
||||
'part_name': cnc.product_id.part_name,
|
||||
'part_number': cnc.product_id.part_number,
|
||||
'machining_drawings': base64.b64encode(cnc.product_id.machining_drawings).decode(
|
||||
'utf-8') if cnc.product_id.machining_drawings else '',
|
||||
'machining_drawings_name': cnc.product_id.machining_drawings_name,
|
||||
'machining_drawings_mimetype': cnc.product_id.machining_drawings_mimetype,
|
||||
}
|
||||
# 打印出除了 model_file 之外的所有键值对
|
||||
for key, value in res.items():
|
||||
@@ -839,7 +850,7 @@ class MrpProduction(models.Model):
|
||||
if process_parameter_workorder:
|
||||
# 将这些特殊表面工艺工单的采购单与调拨单置为失效
|
||||
for workorder in process_parameter_workorder:
|
||||
workorder._get_surface_technics_purchase_ids().write({'state': 'cancel'})
|
||||
# workorder._get_surface_technics_purchase_ids().write({'state': 'cancel'})
|
||||
workorder.move_subcontract_workorder_ids.write({'state': 'cancel'})
|
||||
workorder.move_subcontract_workorder_ids.picking_id.write({'state': 'cancel'})
|
||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
||||
@@ -1520,7 +1531,10 @@ class MrpProduction(models.Model):
|
||||
"""
|
||||
重载创建制造订单的方法,单个制造订单,同一成品只创建一个采购组,用于后续单据的创建
|
||||
"""
|
||||
group_id = self.env["procurement.group"].create({'name':vals_list[0].get('origin')}).id
|
||||
group_id = False
|
||||
first_origin = next((obj['origin'] for obj in vals_list if 'origin' in obj), None)
|
||||
if first_origin:
|
||||
group_id = self.env["procurement.group"].create({'name':first_origin}).id
|
||||
for vals in vals_list:
|
||||
if not vals.get('name', False) or vals['name'] == _('New'):
|
||||
picking_type_id = vals.get('picking_type_id')
|
||||
@@ -1528,7 +1542,7 @@ class MrpProduction(models.Model):
|
||||
picking_type_id = self._get_default_picking_type_id(vals.get('company_id', self.env.company.id))
|
||||
vals['picking_type_id'] = picking_type_id
|
||||
vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id()
|
||||
if not vals.get('procurement_group_id'):
|
||||
if not vals.get('procurement_group_id') and group_id:
|
||||
vals['procurement_group_id'] = group_id
|
||||
return super(MrpProduction, self).create(vals_list)
|
||||
|
||||
@@ -1692,6 +1706,7 @@ class sf_programming_record(models.Model):
|
||||
class sf_detection_result(models.Model):
|
||||
_name = 'sf.detection.result'
|
||||
_description = "检测结果"
|
||||
_order = 'handle_result_date desc, id asc'
|
||||
|
||||
production_id = fields.Many2one('mrp.production')
|
||||
processing_panel = fields.Char('加工面')
|
||||
@@ -1709,6 +1724,8 @@ class sf_detection_result(models.Model):
|
||||
test_report = fields.Binary('检测报告', readonly=True)
|
||||
handle_result = fields.Selection([("待处理", "待处理"), ("已处理", "已处理")], default='', string="处理结果",
|
||||
tracking=True)
|
||||
handle_result_date = fields.Datetime('处理时间')
|
||||
handle_result_user = fields.Many2one('res.users', '处理人')
|
||||
|
||||
# 查看检测报告
|
||||
def button_look_test_report(self):
|
||||
@@ -1719,6 +1736,12 @@ class sf_detection_result(models.Model):
|
||||
'views': [(self.env.ref('sf_manufacturing.sf_test_report_form').id, 'form')],
|
||||
'target': 'new'
|
||||
}
|
||||
|
||||
def write(self, vals):
|
||||
if vals.get('handle_result') and vals.get('handle_result') == '已处理':
|
||||
vals['handle_result_date'] = fields.Datetime.now()
|
||||
vals['handle_result_user'] = self.env.user.id
|
||||
return super(sf_detection_result, self).write(vals)
|
||||
|
||||
|
||||
class sf_processing_panel(models.Model):
|
||||
|
||||
Reference in New Issue
Block a user