Accept Merge Request #1230: (feature/修复报废bug -> develop)

Merge Request: 修复报废bug

Created By: @杨金灵
Reviewed By: @马广威
Approved By: @马广威 
Accepted By: @杨金灵
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1230
This commit is contained in:
杨金灵
2024-08-21 14:47:23 +08:00
committed by Coding
3 changed files with 12 additions and 49 deletions

View File

@@ -808,7 +808,8 @@ class MrpProduction(models.Model):
'target': 'new', 'target': 'new',
'context': { 'context': {
'default_production_id': self.id, 'default_production_id': self.id,
'default_programming_state': cloud_programming['programming_state'], 'default_programming_state': '编程中' if cloud_programming[
'programming_state'] != '已下发' else '已下发',
'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False 'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False
} }
} }
@@ -986,15 +987,20 @@ class MrpProduction(models.Model):
move = self.env['stock.move'].search([('origin', '=', productions.name)], order='id desc') move = self.env['stock.move'].search([('origin', '=', productions.name)], order='id desc')
for mo in move: for mo in move:
print(mo.id) print(mo.id)
if mo.name in ['/', '']: if mo.procure_method == 'make_to_order' and mo.name != productions.name:
if mo.name == '/': if mo.name == '/':
domain = [('barcode', '=', 'WH-PC'), ('sequence_code', '=', 'PC')] domain = [('barcode', '=', 'WH-PC'), ('sequence_code', '=', 'PC')]
elif mo.name == '': elif mo.name == '':
domain = [('barcode', '=', 'WH-INTERNAL'), ('sequence_code', '=', 'INT')] domain = [('barcode', '=', 'WH-INTERNAL'), ('sequence_code', '=', 'INT')]
picking_type = self.env['stock.picking.type'].search(domain) picking_type = self.env['stock.picking.type'].search(domain)
mo.picking_type_id = picking_type.id mo.write({'picking_type_id': picking_type.id})
mo._assign_picking() mo._assign_picking()
mo.reference = mo.picking_id.name else:
if mo.reference != productions.name:
mo.reference = productions.name
if mo.production_id:
if mo.production_id != productions:
mo.production_id = False
productions.write({'programming_no': self.programming_no, 'is_remanufacture': True}) productions.write({'programming_no': self.programming_no, 'is_remanufacture': True})
productions.procurement_group_id.mrp_production_ids.move_dest_ids.write( productions.procurement_group_id.mrp_production_ids.move_dest_ids.write(
{'group_id': self.env['procurement.group'].search([('name', '=', sale_order.name)])}) {'group_id': self.env['procurement.group'].search([('name', '=', sale_order.name)])})
@@ -1066,46 +1072,6 @@ class MrpProduction(models.Model):
production_item) production_item)
else: else:
productions.programming_state = '编程中' productions.programming_state = '编程中'
for production in productions:
origin_production = production.move_dest_ids and production.move_dest_ids[
0].raw_material_production_id or False
orderpoint = production.orderpoint_id
if orderpoint and orderpoint.create_uid.id == SUPERUSER_ID and orderpoint.trigger == 'manual':
production.message_post(
body=_('This production order has been created from Replenishment Report.'),
message_type='comment',
subtype_xmlid='mail.mt_note')
elif orderpoint:
production.message_post_with_view(
'mail.message_origin_link',
values={'self': production, 'origin': orderpoint},
subtype_id=self.env.ref('mail.mt_note').id)
elif origin_production:
production.message_post_with_view(
'mail.message_origin_link',
values={'self': production, 'origin': origin_production},
subtype_id=self.env.ref('mail.mt_note').id)
'''
创建生产计划
'''
# 工单耗时
workorder_duration = 0
for workorder in productions.workorder_ids:
workorder_duration += workorder.duration_expected
if sale_order:
# sale_order.mrp_production_ids |= productions
self.env['sf.production.plan'].sudo().with_company(self.company_id).create({
'name': productions.name,
'order_deadline': sale_order.deadline_of_delivery,
'production_id': productions.id,
'date_planned_start': productions.date_planned_start,
'origin': productions.origin,
'product_qty': productions.product_qty,
'product_id': productions.product_id.id,
'state': 'draft',
})
return productions return productions
# 在之前的销售单上重新生成制造订单 # 在之前的销售单上重新生成制造订单

View File

@@ -1264,7 +1264,6 @@ class ResMrpWorkOrder(models.Model):
'is_trayed': False 'is_trayed': False
}) })
# 将FTP的检测报告文件下载到临时目录 # 将FTP的检测报告文件下载到临时目录
def download_reportfile_tmp(self, workorder, reportpath): def download_reportfile_tmp(self, workorder, reportpath):
logging.info('reportpath/ftp地址:%s' % reportpath) logging.info('reportpath/ftp地址:%s' % reportpath)
@@ -1659,7 +1658,6 @@ class WorkPieceDelivery(models.Model):
agv_scheduling_id = fields.Many2one('sf.agv.scheduling', 'AGV任务调度') agv_scheduling_id = fields.Many2one('sf.agv.scheduling', 'AGV任务调度')
@api.model @api.model
def create(self, vals): def create(self, vals):
if vals.get('route_id') and vals.get('type') is None: if vals.get('route_id') and vals.get('type') is None:
@@ -1749,7 +1747,6 @@ class WorkPieceDelivery(models.Model):
'default_confirm_button': '确认配送' 'default_confirm_button': '确认配送'
}} }}
# 验证agv站点是否可用 # 验证agv站点是否可用
def _check_avgsite_state(self): def _check_avgsite_state(self):
is_free = False is_free = False
@@ -1854,7 +1851,6 @@ class WorkPieceDelivery(models.Model):
obj.delivery_duration = 0.0 obj.delivery_duration = 0.0
class CMMprogram(models.Model): class CMMprogram(models.Model):
_name = 'sf.cmm.program' _name = 'sf.cmm.program'
_description = "CMM程序" _description = "CMM程序"

View File

@@ -178,7 +178,8 @@ class StockRule(models.Model):
# 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) logging.info(moves_values)
moves = self.env['stock.move'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(moves_values) moves = self.env['stock.move'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
moves_values)
logging.info(moves) 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()