').append(message),
+ buttons: [
+ { text: "确认", classes: 'btn-primary jikimo_button_confirm', close: true, click: () => actionCleanDataConfirm(parent, params) },
+ { text: "取消", close: true },
+ ],
+ });
+ dialog.open();
+
+
+ async function actionCleanDataConfirm(parent, params) {
+ rpc.query({
+ model: 'jikimo.data.clean.wizard',
+ method: 'action_clean_data',
+ args: [params.active_id],
+ kwargs: {
+ context: params.context,
+ }
+ }).then(res => {
+ parent.services.action.doAction({
+ 'type': 'ir.actions.client',
+ 'tag': 'display_notification',
+ 'target': 'new',
+ 'params': {
+ 'message': '数据清理成功!',
+ 'type': 'success',
+ 'sticky': false,
+ 'next': {'type': 'ir.actions.act_window_close'},
+ }
+ });
+ })
+
+ }
+ }
+
+ core.action_registry.add('action_clean_data_confirm', action_clean_data_confirm);
+ return action_clean_data_confirm;
+});
diff --git a/jikimo_test_assistant/wizards/__init__.py b/jikimo_test_assistant/wizards/__init__.py
new file mode 100644
index 00000000..2dadb00b
--- /dev/null
+++ b/jikimo_test_assistant/wizards/__init__.py
@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+from . import jikimo_data_clean_wizard
\ No newline at end of file
diff --git a/jikimo_test_assistant/wizards/jikimo_data_clean_wizard.py b/jikimo_test_assistant/wizards/jikimo_data_clean_wizard.py
new file mode 100644
index 00000000..f08b114e
--- /dev/null
+++ b/jikimo_test_assistant/wizards/jikimo_data_clean_wizard.py
@@ -0,0 +1,99 @@
+from odoo import models, fields, api
+from datetime import datetime
+
+import logging
+
+_logger = logging.getLogger(__name__)
+
+class JikimoDataCleanWizard(models.TransientModel):
+ _name = 'jikimo.data.clean.wizard'
+ _description = '业务数据清理'
+
+ date = fields.Date(string='截止日期', required=True, default=fields.Date.context_today)
+ model_ids = fields.Many2many('ir.model', string='业务模型', domain=[
+ ('model', 'in', [
+ 'sale.order', # 销售订单
+ 'purchase.order', # 采购订单
+ 'mrp.production', # 生产订单
+ 'stock.picking', # 库存调拨
+ 'account.move', # 会计凭证
+ ])
+ ])
+
+ def action_clean_data(self):
+ self.ensure_one()
+ model_list = self.model_ids.mapped('model')
+
+ # 销售订单清理(排除已交付,已锁定,已取消)
+ if 'sale.order' in model_list:
+ self.model_cancel('sale.order', except_states=['delivered', 'done', 'cancel'])
+
+ # 采购订单清理(排除采购订单,已锁定,已取消)
+ if 'purchase.order' in model_list:
+ self.model_cancel('purchase.order', except_states=['purchase', 'done', 'cancel'])
+
+ # 生产订单清理(排除返工,报废,完成,已取消)
+ if 'mrp.production' in model_list:
+ self.model_cancel('mrp.production', except_states=['rework', 'scrap', 'done', 'cancel'])
+
+ # 工单清理 (排除返工,完成,已取消)
+ if 'mrp.workorder' in model_list:
+ self.model_cancel('mrp.production', except_states=['rework', 'done', 'cancel'])
+
+ # 排程单清理 (排除已完成,已取消)
+ if 'mrp.workorder' in model_list:
+ self.model_cancel('mrp.production', except_states=['finished', 'cancel'])
+
+ # 工单库存移动 (排除完成,已取消)
+ if 'stock.move' in model_list:
+ self.model_cancel('stock.move')
+
+ # 库存调拨清理 (排除完成,已取消)
+ if 'stock.picking' in model_list:
+ self.model_cancel('stock.picking')
+
+ # 会计凭证清理 (排除已过账,已取消)
+ if 'account.move' in model_list:
+ self.model_cancel('account.move', except_states=['posted', 'cancel'])
+
+ return True
+
+ def model_cancel(self, model_name, state_field='state', to_state='cancel',except_states=('done', 'cancel')):
+ table = self.env[model_name]._table
+ if isinstance(except_states, list):
+ except_states = tuple(except_states)
+ sql = """
+ UPDATE
+ %s SET %s = '%s'
+ WHERE
+ create_date < '%s'
+ AND state NOT IN %s
+""" % (table, state_field, to_state, self.date.strftime('%Y-%m-%d'), except_states)
+ self.env.cr.execute(sql)
+ self.env.cr.commit()
+
+ @api.model
+ def get_confirm_message(self):
+ date_str = self.date.strftime('%Y-%m-%d') if self.date else ''
+ model_names = ', '.join([model.name for model in self.model_ids])
+ return {
+ 'date': date_str,
+ 'model_names': model_names
+ }
+
+ def action_clean_data_confirm(self):
+ model_names = self.model_ids.mapped('display_name')
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'action_clean_data_confirm',
+ 'params': {
+ 'model_names': model_names,
+ 'date': self.date,
+ 'active_id': self.id,
+ 'context': self.env.context
+ }
+ }
+
+
+
+
diff --git a/jikimo_test_assistant/wizards/jikimo_data_clean_wizard.xml b/jikimo_test_assistant/wizards/jikimo_data_clean_wizard.xml
new file mode 100644
index 00000000..d297bb3c
--- /dev/null
+++ b/jikimo_test_assistant/wizards/jikimo_data_clean_wizard.xml
@@ -0,0 +1,47 @@
+
+
+
+
+ jikimo.data.clean.wizard.form
+ jikimo.data.clean.wizard
+
+
+
+
+
+
+
+ 业务数据清理
+ jikimo.data.clean.wizard
+ form
+ new
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jikimo_workorder_exception/controllers/main.py b/jikimo_workorder_exception/controllers/main.py
index 03744ff9..cf208700 100644
--- a/jikimo_workorder_exception/controllers/main.py
+++ b/jikimo_workorder_exception/controllers/main.py
@@ -4,6 +4,7 @@ import json
import logging
from odoo.addons.sf_mrs_connect.controllers.controllers import Sf_Mrs_Connect
from odoo.addons.sf_manufacturing.controllers.controllers import Manufacturing_Connect
+from datetime import datetime
_logger = logging.getLogger(__name__)
@@ -30,6 +31,7 @@ class WorkorderExceptionConroller(http.Controller):
workorder = request.env['mrp.workorder'].sudo().search([
('rfid_code', '=', ret['RfidCode']),
('routing_type', '=', 'CNC加工'),
+ ('state', '!=', 'rework')
])
if not workorder:
res = {'Succeed': False, 'ErrorCode': 401, 'Error': '无效的工单'}
@@ -41,7 +43,10 @@ class WorkorderExceptionConroller(http.Controller):
'exception_code': ret.get('coding'),
'exception_content': ret.get('Error', '')
})
-
+ # 申请重新编程
+ workorder.production_id.update_programming_state(trigger_time=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
+ reprogramming_reason=ret.get('Error', ''))
+ workorder.production_id.write({'programming_state': '编程中', 'work_state': '编程中', 'is_rework': False})
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
_logger.info('workder_exception error:%s' % e)
diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py
index 3517766d..f4ccd085 100644
--- a/sf_base/models/tool_base_new.py
+++ b/sf_base/models/tool_base_new.py
@@ -187,7 +187,7 @@ class CuttingToolModel(models.Model):
def _get_ids(self, cutting_tool_type_code, factory_short_name):
cutting_tool_type_ids = []
for item in cutting_tool_type_code:
- cutting_tool_type = self.search([('code', '=', item.replace("JKM", factory_short_name))])
+ cutting_tool_type = self.search([('code', '=', item)])
if cutting_tool_type:
cutting_tool_type_ids.append(cutting_tool_type.id)
return [(6, 0, cutting_tool_type_ids)]
diff --git a/sf_base/static/js/updateTable.js b/sf_base/static/js/updateTable.js
index beec2c94..f76ff006 100644
--- a/sf_base/static/js/updateTable.js
+++ b/sf_base/static/js/updateTable.js
@@ -9,6 +9,7 @@ function getDomData() {
table.hide()
const thead = customTable.children('thead')
const tbody = customTable.children('tbody')
+ const tfooter = customTable.children('tfoot')
const tableData = []
const tbody_child = tbody.children()
@@ -16,30 +17,29 @@ function getDomData() {
for (let v = 0; v < tbody_child_len; v++) { // 将数据取出来到tableData里面
const data = tbody_child[v].innerText.split('\t')
- // console.log('dom data',data)
const [index, deep, name, Φ, value] = data
- tableData.push({index, deep, name, Φ, value})
+ tableData.push({ index, deep, name, Φ, value })
}
- const ΦList = [...new Set(tableData.map(_ => _.name))] // ΦList去重
+ const ΦList = [...new Set(tableData.map(_ => _.Φ))] // ΦList去重
const newTableData = {}
tableData.forEach(_ => {
- const key = _.deep + '|' + _.Φ
- !newTableData[key] ? newTableData[key] = {i: _.index} : '';
+ const key = _.deep + '|' + _.name
+ !newTableData[key] ? newTableData[key] = { i: _.index } : '';
if (_.Φ) { // 去除没有Φ的脏数据
newTableData[key]['Φ' + _.Φ] = _.value
newTableData[key]['Φ' + _.Φ + 'i'] = _.index
}
})
- // console.log('qwdh',tableData, ΦList, newTableData);
+ // console.log(tableData, ΦList, newTableData);
if (ΦList.filter(_ => _).length == 0) return;
- handleThead(thead, ΦList)
+ handleThead(thead, ΦList, tfooter)
- handleTbody(tbody, newTableData, ΦList, table)
+ handleTbody(tbody, newTableData, ΦList, table )
}
// 重新设置表头、
-function handleThead(thead, ΦList) {
+function handleThead(thead, ΦList, tfooter) {
const dom = thead.children().eq(0).children()
const len = dom.length
dom.eq(0).attr('rowspan', 2)
@@ -47,7 +47,11 @@ function handleThead(thead, ΦList) {
len == 5 ? dom.eq(2).attr('rowspan', 2) : ''
dom.eq(-2).attr('colspan', ΦList.length)
dom.eq(-1).remove()
-
+ if(tfooter && tfooter.length) {
+ tfooter.children().each(function () {
+ $(this).children().eq(-1).remove()
+ })
+ }
const tr = document.createElement('tr')
for (let v = 0; v < ΦList.length; v++) {
const th = document.createElement('th')
@@ -68,7 +72,6 @@ function handleTbody(tbody, newTableData, ΦList, table) {
// b = b.split('=')[1].split('%')[0]
// return a - b
// })
- // console.log('wqoqw ',ΦList)
data.forEach(_ => {
i++
const tr = $('
|
')
@@ -98,61 +101,6 @@ function handleTbody(tbody, newTableData, ΦList, table) {
// // }
tbody.append(tr)
})
- // $(document).click(function (e) {
- // if ($(e.target).attr('coustomTd')) {
- // const orginV = $('[coustomInput=1]').children('input').val()
- // $('[coustomInput=1]').parent().html(orginV)
- // const v = $(e.target).attr('val')
- // console.log($(e.target));
- // $(e.target).html('')
- // const input = $('
')
- // input.children('input').val(v)
- // $(e.target).append(input)
- // input.children('input').focus()
- // input.children('input').select()
- // } else if ($(e.target).attr('coustomInput')) {
- //
- // } else {
- // const orginV = $('[coustomInput=1]').children('input').val()
- // $('[coustomInput=1]').parent().html(orginV)
- // const v = $(e.target).attr('val')
- // }
- // })
- // $(document).off('change') // 防止重复绑定
-// $(document).on('change', '[coustomInput] input', function () {
-// $(this).parents('td').attr('val', $(this).val());
-// var eve1 = new Event('change');
-// var eve2 = new Event('input');
-// var eve3 = new Event('click');
-// const i = $(this).parents('td').attr('col');
-// let patchDom = table.find('tbody').children('tr').eq(i - 1);
-//
-// if (patchDom.length === 0) {
-// console.error('No such row found');
-// return;
-// }
-//
-// patchDom = patchDom.children().eq(-1);
-//
-// setTimeout(() => {
-// if (patchDom.length === 0) {
-// console.error('No such cell found');
-// return;
-// }
-// patchDom[0].dispatchEvent(eve3); // Simulate click event
-//
-// setTimeout(() => {
-// patchDom = patchDom.find('input');
-// if (patchDom.length === 0) {
-// console.error('No input found in the target cell');
-// return;
-// }
-// patchDom.val($(this).val());
-// patchDom[0].dispatchEvent(eve2);
-// patchDom[0].dispatchEvent(eve1);
-// }, 200);
-// }, 500);
-// });
}
diff --git a/sf_base/static/src/scss/format_img.scss b/sf_base/static/src/scss/format_img.scss
index fc6f02dc..940e3a68 100644
--- a/sf_base/static/src/scss/format_img.scss
+++ b/sf_base/static/src/scss/format_img.scss
@@ -24,4 +24,18 @@
.o_search_panel.account_root {
flex: unset !important;
+}
+
+.multi-line {
+ display: flex;
+ flex-wrap: nowrap;
+ > label.o_form_label {
+ width: 52px;
+ }
+ > span {
+ flex: 1;
+ }
+ > div {
+ flex: 2
+ }
}
\ No newline at end of file
diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml
index b2d53392..eda526b6 100644
--- a/sf_base/views/tool_views.xml
+++ b/sf_base/views/tool_views.xml
@@ -112,6 +112,8 @@
+
+
@@ -138,7 +140,7 @@
-