Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造功能优化
This commit is contained in:
@@ -51,11 +51,11 @@ class JikimoWorkorderException(models.Model):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_message(self, message_queue_ids):
|
def _get_message(self, message_queue_ids):
|
||||||
contents = super(JikimoWorkorderException, self)._get_message(message_queue_ids)
|
contents, _ = super(JikimoWorkorderException, self)._get_message(message_queue_ids)
|
||||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||||
action_id = self.env.ref('mrp.mrp_production_action').id
|
action_id = self.env.ref('mrp.mrp_production_action').id
|
||||||
for index, content in enumerate(contents):
|
for index, content in enumerate(contents):
|
||||||
exception_id = self.env['jikimo.workorder.exception'].browse(message_queue_ids[index].res_id)
|
exception_id = self.env['jikimo.workorder.exception'].browse(message_queue_ids[index].res_id)
|
||||||
url = url + '/web#id=%s&view_type=form&action=%s' % (exception_id.workorder_id.production_id.id, action_id)
|
url = url + '/web#id=%s&view_type=form&action=%s' % (exception_id.workorder_id.production_id.id, action_id)
|
||||||
contents[index] = content.replace('{{url}}', url)
|
contents[index] = content.replace('{{url}}', url)
|
||||||
return contents
|
return contents, message_queue_ids
|
||||||
|
|||||||
@@ -803,45 +803,45 @@ class MrpProduction(models.Model):
|
|||||||
workorder.move_subcontract_workorder_ids.picking_id.write({'state': 'cancel'})
|
workorder.move_subcontract_workorder_ids.picking_id.write({'state': 'cancel'})
|
||||||
consecutive_workorders = []
|
consecutive_workorders = []
|
||||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
||||||
for i, workorder in enumerate(sorted_workorders):
|
# for i, workorder in enumerate(sorted_workorders):
|
||||||
# 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
|
# # 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
|
||||||
if i == 0:
|
# if i == 0:
|
||||||
consecutive_workorders.append(workorder)
|
# consecutive_workorders.append(workorder)
|
||||||
elif workorder.sequence == sorted_workorders[
|
# elif workorder.sequence == sorted_workorders[
|
||||||
i - 1].sequence + 1 and workorder.supplier_id.id == sorted_workorders[i - 1].supplier_id.id:
|
# i - 1].sequence + 1 and workorder.supplier_id.id == sorted_workorders[i - 1].supplier_id.id:
|
||||||
consecutive_workorders.append(workorder)
|
# consecutive_workorders.append(workorder)
|
||||||
else:
|
# else:
|
||||||
# 处理连续组,如果它不为空
|
# # 处理连续组,如果它不为空
|
||||||
if consecutive_workorders:
|
# if consecutive_workorders:
|
||||||
proc_workorders.append(consecutive_workorders)
|
# proc_workorders.append(consecutive_workorders)
|
||||||
# 创建外协出入库单和采购订单
|
# # 创建外协出入库单和采购订单
|
||||||
# self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production, sorted_workorders)
|
# # self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production, sorted_workorders)
|
||||||
# self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
# # self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
||||||
# product_id_to_production_names)
|
# # product_id_to_production_names)
|
||||||
if i < len(sorted_workorders) - 1:
|
# if i < len(sorted_workorders) - 1:
|
||||||
# 重置连续组,并添加当前工作订单
|
# # 重置连续组,并添加当前工作订单
|
||||||
consecutive_workorders = [workorder]
|
# consecutive_workorders = [workorder]
|
||||||
else:
|
# else:
|
||||||
# 判断最后一笔:
|
# # 判断最后一笔:
|
||||||
if workorder.sequence == sorted_workorders[
|
# if workorder.sequence == sorted_workorders[
|
||||||
i - 1].sequence and workorder.supplier_id.id == sorted_workorders[
|
# i - 1].sequence and workorder.supplier_id.id == sorted_workorders[
|
||||||
i - 1].supplier_id.id:
|
# i - 1].supplier_id.id:
|
||||||
consecutive_workorders = [workorder]
|
# consecutive_workorders = [workorder]
|
||||||
else:
|
# else:
|
||||||
proc_workorders.append([workorder])
|
# proc_workorders.append([workorder])
|
||||||
# 立即创建外协出入库单和采购订单
|
# # 立即创建外协出入库单和采购订单
|
||||||
# self.env['stock.picking'].create_outcontract_picking(workorder, production)
|
# # self.env['stock.picking'].create_outcontract_picking(workorder, production)
|
||||||
# self.env['purchase.order'].get_purchase_order(workorder, production,
|
# # self.env['purchase.order'].get_purchase_order(workorder, production,
|
||||||
# product_id_to_production_names)
|
# # product_id_to_production_names)
|
||||||
consecutive_workorders = []
|
# consecutive_workorders = []
|
||||||
|
#
|
||||||
# 处理最后一个组,即使它可能只有一个工作订单
|
# # 处理最后一个组,即使它可能只有一个工作订单
|
||||||
if consecutive_workorders:
|
# if consecutive_workorders:
|
||||||
proc_workorders.append(consecutive_workorders)
|
# proc_workorders.append(consecutive_workorders)
|
||||||
# self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
# self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
||||||
# self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
# self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
||||||
# product_id_to_production_names)
|
# product_id_to_production_names)
|
||||||
for workorders in reversed(proc_workorders):
|
for workorders in reversed(sorted_workorders):
|
||||||
self.env['stock.picking'].create_outcontract_picking(workorders, production, sorted_workorders)
|
self.env['stock.picking'].create_outcontract_picking(workorders, production, sorted_workorders)
|
||||||
self.env['purchase.order'].get_purchase_order(workorders, production, product_id_to_production_names)
|
self.env['purchase.order'].get_purchase_order(workorders, production, product_id_to_production_names)
|
||||||
|
|
||||||
|
|||||||
@@ -677,9 +677,8 @@ class StockPicking(models.Model):
|
|||||||
move_dest_id = item.move_raw_ids[0].id
|
move_dest_id = item.move_raw_ids[0].id
|
||||||
else:
|
else:
|
||||||
# 从sorted_workorders中找到上一工单的move
|
# 从sorted_workorders中找到上一工单的move
|
||||||
if sorted_workorders.index(workorder) > 0:
|
if len(sorted_workorders) > 1:
|
||||||
move_dest_id = \
|
move_dest_id = sorted_workorders[sorted_workorders.index(workorder)+1].move_subcontract_workorder_ids[1].id
|
||||||
sorted_workorders[sorted_workorders.index(workorder) - 1].move_subcontract_workorder_ids[1].id
|
|
||||||
new_picking = True
|
new_picking = True
|
||||||
outcontract_picking_type_in = self.env.ref(
|
outcontract_picking_type_in = self.env.ref(
|
||||||
'sf_manufacturing.outcontract_picking_in').id,
|
'sf_manufacturing.outcontract_picking_in').id,
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ class SFMessageMaintenanceLogs(models.Model):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_message(self, message_queue_ids):
|
def _get_message(self, message_queue_ids):
|
||||||
contents = super(SFMessageMaintenanceLogs, self)._get_message(message_queue_ids)
|
contents, _ = super(SFMessageMaintenanceLogs, self)._get_message(message_queue_ids)
|
||||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||||
action_id = self.env.ref('sf_maintenance.action_maintenance_logs').id
|
action_id = self.env.ref('sf_maintenance.action_maintenance_logs').id
|
||||||
for index, content in enumerate(contents):
|
for index, content in enumerate(contents):
|
||||||
maintenance_logs_id = self.env['sf.maintenance.logs'].browse(message_queue_ids[index].res_id)
|
maintenance_logs_id = self.env['sf.maintenance.logs'].browse(message_queue_ids[index].res_id)
|
||||||
url = url + '/web#id=%s&view_type=form&action=%s' % (maintenance_logs_id.id, action_id)
|
url = url + '/web#id=%s&view_type=form&action=%s' % (maintenance_logs_id.id, action_id)
|
||||||
contents[index] = content.replace('{{url}}', url)
|
contents[index] = content.replace('{{url}}', url)
|
||||||
return contents
|
return contents, message_queue_ids
|
||||||
@@ -81,7 +81,7 @@ class SFMessageMrpProduction(models.Model):
|
|||||||
action_id)
|
action_id)
|
||||||
contents.extend(technology_to_confirmed_contents)
|
contents.extend(technology_to_confirmed_contents)
|
||||||
logging.info('生产完工入库提醒: %s' % contents)
|
logging.info('生产完工入库提醒: %s' % contents)
|
||||||
return contents
|
return contents, message_queue_ids
|
||||||
|
|
||||||
def get_production_info(self, content, product_ids, state, action_id):
|
def get_production_info(self, content, product_ids, state, action_id):
|
||||||
contents = []
|
contents = []
|
||||||
|
|||||||
@@ -13,8 +13,15 @@ class SFMessagePlan(models.Model):
|
|||||||
if message_queue_id.message_template_id.name == '工单已下发通知':
|
if message_queue_id.message_template_id.name == '工单已下发通知':
|
||||||
content = message_queue_id.message_template_id.content
|
content = message_queue_id.message_template_id.content
|
||||||
product_product = self.env['product.product'].sudo().search([('id', '=', int(message_queue_id.res_id))])
|
product_product = self.env['product.product'].sudo().search([('id', '=', int(message_queue_id.res_id))])
|
||||||
production_num = self.env['mrp.production'].sudo().search_count(
|
mrp_production_list = self.env['mrp.production'].sudo().search(
|
||||||
[('product_id', '=', product_product.id)])
|
[('product_id', '=', product_product.id)])
|
||||||
|
production_num = 0
|
||||||
|
for mrp_production_info in mrp_production_list:
|
||||||
|
routing_type = '人工线下加工' if mrp_production_info.production_type == '人工线下加工' else '装夹预调'
|
||||||
|
mrp_production_ready = mrp_production_info.workorder_ids.filtered(
|
||||||
|
lambda w: w.routing_type == routing_type and w.state == 'ready')
|
||||||
|
if mrp_production_ready:
|
||||||
|
production_num += 1
|
||||||
if production_num >= 1:
|
if production_num >= 1:
|
||||||
url = self.get_request_url()
|
url = self.get_request_url()
|
||||||
content = content.replace('{{product_id}}', product_product.name).replace(
|
content = content.replace('{{product_id}}', product_product.name).replace(
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class SFMessagePurchase(models.Model):
|
|||||||
.replace('{{url}}', url_with_id)
|
.replace('{{url}}', url_with_id)
|
||||||
.replace('{{num}}', str(production_num)))
|
.replace('{{num}}', str(production_num)))
|
||||||
contents.append(new_content)
|
contents.append(new_content)
|
||||||
return contents
|
return contents, message_queue_ids
|
||||||
|
|
||||||
def request_url(self, id):
|
def request_url(self, id):
|
||||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||||
|
|||||||
@@ -33,4 +33,4 @@ class SFMessageQualityCncTest(models.Model):
|
|||||||
content_template = content.replace('{{judge_num}}', str(i))
|
content_template = content.replace('{{judge_num}}', str(i))
|
||||||
content_template = content_template.replace('{{url}}', url_with_id)
|
content_template = content_template.replace('{{url}}', url_with_id)
|
||||||
contents.append(content_template)
|
contents.append(content_template)
|
||||||
return contents
|
return contents, message_queue_ids
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class SFMessageSale(models.Model):
|
|||||||
i = 0
|
i = 0
|
||||||
for item in message_queue_ids:
|
for item in message_queue_ids:
|
||||||
if item.message_template_id.bussiness_node_id.name in ('待接单', '待确认供货方式'):
|
if item.message_template_id.bussiness_node_id.name in ('待接单', '待确认供货方式'):
|
||||||
content = super(SFMessageSale, self)._get_message(item)
|
content, _ = super(SFMessageSale, self)._get_message(item)
|
||||||
action_id = self.env.ref('sale.action_quotations_with_onboarding').id \
|
action_id = self.env.ref('sale.action_quotations_with_onboarding').id \
|
||||||
if item.message_template_id.bussiness_node_id.name == '待接单' \
|
if item.message_template_id.bussiness_node_id.name == '待接单' \
|
||||||
else self.env.ref('sale.action_orders').id
|
else self.env.ref('sale.action_orders').id
|
||||||
@@ -66,7 +66,7 @@ class SFMessageSale(models.Model):
|
|||||||
content = content[0].replace('{{url}}', url_with_id)
|
content = content[0].replace('{{url}}', url_with_id)
|
||||||
contents.append(content)
|
contents.append(content)
|
||||||
elif item.message_template_id.bussiness_node_id.name == '确认接单':
|
elif item.message_template_id.bussiness_node_id.name == '确认接单':
|
||||||
content = super(SFMessageSale, self)._get_message(item)
|
content, _ = super(SFMessageSale, self)._get_message(item)
|
||||||
sale_order_line = self.env['sale.order.line'].sudo().search([('order_id', '=', int(item.res_id))])
|
sale_order_line = self.env['sale.order.line'].sudo().search([('order_id', '=', int(item.res_id))])
|
||||||
product = sale_order_line[0].product_id.name if len(sale_order_line) == 1 else '%s...' % \
|
product = sale_order_line[0].product_id.name if len(sale_order_line) == 1 else '%s...' % \
|
||||||
sale_order_line[
|
sale_order_line[
|
||||||
@@ -103,7 +103,7 @@ class SFMessageSale(models.Model):
|
|||||||
elif bussiness_node == '销售订单已逾期':
|
elif bussiness_node == '销售订单已逾期':
|
||||||
content = content_template.replace('{{overdue_num}}', str(i))
|
content = content_template.replace('{{overdue_num}}', str(i))
|
||||||
contents.append(content)
|
contents.append(content)
|
||||||
return contents
|
return contents, message_queue_ids
|
||||||
|
|
||||||
# # 销售订单逾期预警和已逾期
|
# # 销售订单逾期预警和已逾期
|
||||||
def _overdue_or_warning_func(self):
|
def _overdue_or_warning_func(self):
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ class SFMessageStockPicking(models.Model):
|
|||||||
content = message_queue_id.message_template_id.content
|
content = message_queue_id.message_template_id.content
|
||||||
stock_picking_line = self.env['stock.picking'].sudo().search(
|
stock_picking_line = self.env['stock.picking'].sudo().search(
|
||||||
[('id', '=', int(message_queue_id.res_id))])
|
[('id', '=', int(message_queue_id.res_id))])
|
||||||
if stock_picking_line.state == 'assigned':
|
|
||||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
action_id = self.env.ref('stock.action_picking_tree_ready').id
|
action_id = self.env.ref('stock.action_picking_tree_ready').id
|
||||||
menu_id = self.env.ref('stock.menu_stock_root').id
|
menu_id = self.env.ref('stock.menu_stock_root').id
|
||||||
@@ -84,7 +83,7 @@ class SFMessageStockPicking(models.Model):
|
|||||||
content = self.deal_stock_picking_sfp(message_queue_id)
|
content = self.deal_stock_picking_sfp(message_queue_id)
|
||||||
if content:
|
if content:
|
||||||
contents.append(content)
|
contents.append(content)
|
||||||
return contents
|
return contents, message_queue_ids
|
||||||
|
|
||||||
def get_special_url(self, id, tmplate_name, special_name, model_id):
|
def get_special_url(self, id, tmplate_name, special_name, model_id):
|
||||||
menu_id = 0
|
menu_id = 0
|
||||||
|
|||||||
@@ -18,13 +18,18 @@ class SFMessageWork(models.Model):
|
|||||||
def _compute_state(self):
|
def _compute_state(self):
|
||||||
super(SFMessageWork, self)._compute_state()
|
super(SFMessageWork, self)._compute_state()
|
||||||
for workorder in self:
|
for workorder in self:
|
||||||
|
min_sequence_wk = None
|
||||||
work_ids = workorder.production_id.workorder_ids.filtered(lambda w: w.routing_type == '装夹预调')
|
work_ids = workorder.production_id.workorder_ids.filtered(lambda w: w.routing_type == '装夹预调')
|
||||||
if work_ids:
|
if work_ids:
|
||||||
min_sequence_wk = work_ids.sorted(key=lambda w: w.sequence)[0]
|
min_sequence_wk = work_ids.sorted(key=lambda w: w.sequence)[0]
|
||||||
if workorder.state == 'ready' and workorder.routing_type == '装夹预调' and workorder.id == min_sequence_wk.id:
|
if (
|
||||||
message_template = self.env["jikimo.message.template"].sudo().search([("name", "=", '工单已下发通知')], limit=1)
|
workorder.state == 'ready' and workorder.routing_type == '装夹预调' and workorder.id == min_sequence_wk.id) or (
|
||||||
|
workorder.state == 'ready' and workorder.routing_type == '人工线下加工'):
|
||||||
|
message_template = self.env["jikimo.message.template"].sudo().search(
|
||||||
|
[("name", "=", '工单已下发通知')], limit=1)
|
||||||
jikimo_message_queue = self.env['jikimo.message.queue'].sudo().search(
|
jikimo_message_queue = self.env['jikimo.message.queue'].sudo().search(
|
||||||
[('res_id', '=', workorder.production_id.product_id.id), ("message_status", "in", ("pending", "sent")),
|
[('res_id', '=', workorder.production_id.product_id.id),
|
||||||
|
("message_status", "in", ("pending", "sent")),
|
||||||
('message_template_id', '=', message_template.id)])
|
('message_template_id', '=', message_template.id)])
|
||||||
if not jikimo_message_queue:
|
if not jikimo_message_queue:
|
||||||
workorder.production_id.product_id.add_queue('工单已下发通知')
|
workorder.production_id.product_id.add_queue('工单已下发通知')
|
||||||
@@ -86,7 +91,7 @@ class SFMessageWork(models.Model):
|
|||||||
elif bussiness_node in template_names['已逾期']:
|
elif bussiness_node in template_names['已逾期']:
|
||||||
content = content_template.replace('{{overdue_num}}', str(i))
|
content = content_template.replace('{{overdue_num}}', str(i))
|
||||||
contents.append(content)
|
contents.append(content)
|
||||||
return contents
|
return contents, message_queue_ids
|
||||||
|
|
||||||
def _overdue_or_warning_func(self):
|
def _overdue_or_warning_func(self):
|
||||||
workorders = self.env['mrp.workorder'].search(
|
workorders = self.env['mrp.workorder'].search(
|
||||||
|
|||||||
@@ -6678,7 +6678,7 @@ msgstr "账单状态"
|
|||||||
#: model_terms:ir.ui.view,arch_db:account.account_journal_dashboard_kanban_view
|
#: model_terms:ir.ui.view,arch_db:account.account_journal_dashboard_kanban_view
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Bills"
|
msgid "Bills"
|
||||||
msgstr "账单"
|
msgstr "发票账单"
|
||||||
|
|
||||||
#. module: account
|
#. module: account
|
||||||
#: model_terms:ir.ui.view,arch_db:account.account_journal_dashboard_kanban_view
|
#: model_terms:ir.ui.view,arch_db:account.account_journal_dashboard_kanban_view
|
||||||
@@ -23023,7 +23023,7 @@ msgstr "支付:支付收据"
|
|||||||
#: model_terms:ir.ui.view,arch_db:account.view_account_payment_search
|
#: model_terms:ir.ui.view,arch_db:account.view_account_payment_search
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Payments"
|
msgid "Payments"
|
||||||
msgstr "支付"
|
msgstr "付款单"
|
||||||
|
|
||||||
#. module: account
|
#. module: account
|
||||||
#: model_terms:ir.actions.act_window,help:account.action_account_payments
|
#: model_terms:ir.actions.act_window,help:account.action_account_payments
|
||||||
|
|||||||
Reference in New Issue
Block a user