修复报废没有生成调拨单
This commit is contained in:
@@ -1189,7 +1189,8 @@ class MrpProduction(models.Model):
|
||||
'res_model': 'sf.production.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_production_id': self.id,
|
||||
'default_mrp_production_id': self.id,
|
||||
'is_remanufacture_flag': True,
|
||||
'default_reprogramming_num': cloud_programming['reprogramming_num'],
|
||||
'default_programming_states': cloud_programming['programming_state'],
|
||||
'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False
|
||||
@@ -1348,10 +1349,6 @@ class MrpProduction(models.Model):
|
||||
if self.is_scrap is True:
|
||||
procurement_requests = []
|
||||
sale_order = self.env['sale.order'].sudo().search([('name', '=', self.origin)])
|
||||
values = self.env['mrp.production'].create_production1_values(self)
|
||||
# productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(
|
||||
# self.company_id).create(
|
||||
# values)
|
||||
# 查询出库移动记录
|
||||
out_picking = self.env['stock.picking'].search(
|
||||
[('origin', '=', sale_order.name), ('name', 'ilike', 'WH/OUT/')])
|
||||
@@ -1375,31 +1372,14 @@ class MrpProduction(models.Model):
|
||||
productions = self.env['mrp.production'].sudo().search(
|
||||
[('origin', '=', self.origin)], order='id desc', limit=1)
|
||||
productions.write({'programming_no': self.programming_no, 'is_remanufacture': True})
|
||||
move = self.env['stock.move'].search([('origin', '=', productions.name)], order='id desc')
|
||||
for mo in move:
|
||||
domain = []
|
||||
if mo.location_id.barcode == 'PL' and mo.rule_id.picking_type_id.sequence_code == 'PC':
|
||||
domain = [('barcode', '=', 'WH-PC'), ('sequence_code', '=', 'PC')]
|
||||
elif mo.location_id.barcode == 'WH-INPUT' and mo.rule_id.picking_type_id.sequence_code == 'INT':
|
||||
domain = [('barcode', '=', 'WH-INTERNAL'), ('sequence_code', '=', 'INT')]
|
||||
if domain:
|
||||
picking_type = self.env['stock.picking.type'].search(domain)
|
||||
mo.write({'picking_type_id': picking_type.id})
|
||||
mo._assign_picking()
|
||||
else:
|
||||
if mo.reference != productions.name:
|
||||
mo.reference = productions.name
|
||||
if mo.production_id:
|
||||
if mo.production_id != productions:
|
||||
mo.production_id = False
|
||||
mo_move = self.env['stock.move'].search(
|
||||
[('origin', '=', sale_order.name), ('reference', 'ilike', 'WH/MO/')])
|
||||
if mo_move:
|
||||
sfp_move = self.env['stock.move'].search(
|
||||
[('origin', '=', sale_order.name), ('reference', 'ilike', 'WH/SFP/')], limit=1)
|
||||
mo_move.write({'reference': sfp_move.reference, 'partner_id': sfp_move.partner_id.id,
|
||||
'picking_id': sfp_move.picking_id.id, 'picking_type_id': sfp_move.picking_type_id.id,
|
||||
'production_id': False})
|
||||
# mo_move = self.env['stock.move'].search(
|
||||
# [('origin', '=', sale_order.name), ('reference', 'ilike', 'WH/MO/')])
|
||||
# if mo_move:
|
||||
# sfp_move = self.env['stock.move'].search(
|
||||
# [('origin', '=', sale_order.name), ('reference', 'ilike', 'WH/SFP/')], limit=1)
|
||||
# mo_move.write({'reference': sfp_move.reference, 'partner_id': sfp_move.partner_id.id,
|
||||
# 'picking_id': sfp_move.picking_id.id, 'picking_type_id': sfp_move.picking_type_id.id,
|
||||
# 'production_id': False})
|
||||
# productions.procurement_group_id.mrp_production_ids.move_dest_ids.write(
|
||||
# {'group_id': self.env['procurement.group'].search([('name', '=', sale_order.name)])})
|
||||
stock_picking_remanufacture = self.env['stock.picking'].search([('origin', '=', productions.name)])
|
||||
|
||||
@@ -129,7 +129,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
Y10_axis = fields.Float(default=0)
|
||||
Z10_axis = fields.Float(default=0)
|
||||
X_deviation_angle = fields.Integer(string="X轴偏差度", default=0)
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工")], default='合格',
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
|
||||
string="检测结果", tracking=True)
|
||||
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工程序")
|
||||
cmm_ids = fields.One2many("sf.cmm.program", 'workorder_id', string="CMM程序")
|
||||
|
||||
@@ -1031,12 +1031,7 @@ class ReStockMove(models.Model):
|
||||
"""
|
||||
res = super(ReStockMove, self)._get_new_picking_values()
|
||||
## 制造订单报废生成的新制造订单不走合并
|
||||
production_remanufacture = None
|
||||
if 'origin' in res:
|
||||
if self.picking_type_id.name in ['生产发料', '内部调拨']:
|
||||
production_remanufacture = self.env['mrp.production'].search(
|
||||
[('name', '=', res['origin']), ('is_remanufacture', '=', True)])
|
||||
if not production_remanufacture:
|
||||
if not self.env.context.get('is_remanufacture_flag'):
|
||||
if self[0].origin and self.picking_type_id.name in ['生产发料', '内部调拨']:
|
||||
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
||||
productions = self.env['mrp.production'].search(
|
||||
|
||||
@@ -12,7 +12,7 @@ class ProductionWizard(models.TransientModel):
|
||||
_name = 'sf.production.wizard'
|
||||
_description = '制造订单向导'
|
||||
|
||||
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||
mrp_production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||
reprogramming_num = fields.Integer('重新编程次数', default=0)
|
||||
is_reprogramming = fields.Boolean(string='申请重新编程', default=False)
|
||||
is_remanufacture = fields.Boolean(string='重新生成制造订单', default=True)
|
||||
@@ -27,24 +27,24 @@ class ProductionWizard(models.TransientModel):
|
||||
self.is_reprogramming = False
|
||||
|
||||
def confirm(self):
|
||||
self.production_id.detection_result_ids.write({'handle_result': '已处理'})
|
||||
self.production_id.write({'state': 'cancel', 'scrap_ids': [(0, 0, {
|
||||
self.mrp_production_id.detection_result_ids.write({'handle_result': '已处理'})
|
||||
self.mrp_production_id.write({'state': 'cancel', 'scrap_ids': [(0, 0, {
|
||||
'name': self.env['ir.sequence'].next_by_code('stock.scrap') or _('New'),
|
||||
'product_id': self.production_id.product_id.id,
|
||||
'product_id': self.mrp_production_id.product_id.id,
|
||||
'scrap_qty': 1,
|
||||
'origin': self.production_id.origin,
|
||||
'origin': self.mrp_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 (
|
||||
[('move_id', '=', self.mrp_production_id.move_raw_ids[0].id)]).lot_id.id,
|
||||
'location_id': self.mrp_production_id.move_raw_ids.filtered(lambda x: x.state not in (
|
||||
'done',
|
||||
'cancel')) and self.production_id.location_src_id.id or self.production_id.location_dest_id.id,
|
||||
'cancel')) and self.mrp_production_id.location_src_id.id or self.mrp_production_id.location_dest_id.id,
|
||||
'scrap_location_id': self.env['stock.scrap']._get_default_scrap_location_id(),
|
||||
'state': 'done'})]})
|
||||
self.production_id.action_cancel()
|
||||
self.mrp_production_id.action_cancel()
|
||||
if self.is_remanufacture is True:
|
||||
ret = {'programming_list': [], 'is_reprogramming': self.is_reprogramming}
|
||||
if self.is_reprogramming is True:
|
||||
self.production_id.update_programming_state()
|
||||
new_production = self.production_id.recreateManufacturing(ret)
|
||||
self.production_id.write({'remanufacture_production_id': new_production.id})
|
||||
self.mrp_production_id.update_programming_state()
|
||||
new_production = self.mrp_production_id.recreateManufacturing(ret)
|
||||
self.mrp_production_id.write({'remanufacture_production_id': new_production.id})
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<field name="production_id" invisible="1"/>
|
||||
<field name="mrp_production_id" invisible="1"/>
|
||||
<field name="programming_states" invisible="1"/>
|
||||
<div>
|
||||
重新生成制造订单
|
||||
|
||||
@@ -25,7 +25,7 @@ class SfQualityCncTest(models.Model):
|
||||
('pass', '合格'),
|
||||
('fail', '不合格')], string='判定结果')
|
||||
number = fields.Integer('数量', default=1)
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工")], string="检测结果")
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], string="检测结果")
|
||||
reason = fields.Selection(
|
||||
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"),
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因")
|
||||
|
||||
Reference in New Issue
Block a user