Accept Merge Request #666: (feature/制造代码优化 -> develop)
Merge Request: 测试优化后的代码扫描效果,优化代码 Created By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/666?initial=true
This commit is contained in:
@@ -1,22 +1,21 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import base64
|
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
import json
|
|
||||||
import hashlib
|
|
||||||
import time
|
import time
|
||||||
import requests
|
import json
|
||||||
from datetime import datetime, timedelta
|
import base64
|
||||||
from odoo.http import request
|
|
||||||
from odoo import fields, models, api, _
|
|
||||||
from odoo.exceptions import ValidationError
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
from odoo.addons.sf_machine_connect.models import py2opcua, ftp_operate
|
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
import logging
|
||||||
|
import hashlib
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
import requests
|
||||||
|
from odoo.http import request
|
||||||
|
from odoo import fields, models, api, _
|
||||||
|
from odoo.exceptions import UserError
|
||||||
from odoo.exceptions import MissingError
|
from odoo.exceptions import MissingError
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
from odoo.addons.sf_machine_connect.models import py2opcua, ftp_operate
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -514,7 +513,6 @@ class WorkCenterBarcode(models.Model):
|
|||||||
print('111111111111111111111')
|
print('111111111111111111111')
|
||||||
workorder_obj_target = self.env['mrp.workorder'].sudo().search([('tray_code', '=', barcode)])
|
workorder_obj_target = self.env['mrp.workorder'].sudo().search([('tray_code', '=', barcode)])
|
||||||
workorder_obj_current = self.env['mrp.workorder'].sudo().search([('id', '=', kwargs['current_id'])])
|
workorder_obj_current = self.env['mrp.workorder'].sudo().search([('id', '=', kwargs['current_id'])])
|
||||||
# workorder_cnc = self.env['mrp.workorder'].sudo().search(['&', ('production_id', '=', workorder_obj.production_id.id), ('name', '=', 'CNC加工')])
|
|
||||||
workorder_cnc = self.env['mrp.workorder'].sudo().search(
|
workorder_cnc = self.env['mrp.workorder'].sudo().search(
|
||||||
['&', ('production_id', '=', workorder_obj_target.production_id.id),
|
['&', ('production_id', '=', workorder_obj_target.production_id.id),
|
||||||
('name', '=', workorder_obj_current.name)])
|
('name', '=', workorder_obj_current.name)])
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ class FtpController:
|
|||||||
self.port = port
|
self.port = port
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
# _logger.info("===================ftppppp==================%s,%s,%s,%s" % self.host, self.port, self.username, self.password)
|
|
||||||
# 测试
|
# 测试
|
||||||
print("==============================================")
|
print("==============================================")
|
||||||
print(self.username, self.port, self.host, self.password)
|
print(self.username, self.port, self.host, self.password)
|
||||||
|
|||||||
@@ -33,4 +33,3 @@ class ResBFMConfigSettings(models.TransientModel):
|
|||||||
super(ResBFMConfigSettings, self).set_values()
|
super(ResBFMConfigSettings, self).set_values()
|
||||||
ir_config = self.env['ir.config_parameter'].sudo()
|
ir_config = self.env['ir.config_parameter'].sudo()
|
||||||
ir_config.set_param("bfm_url", self.bfm_url or "")
|
ir_config.set_param("bfm_url", self.bfm_url or "")
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,23 @@
|
|||||||
/** @odoo-module **/
|
/** @odoo-module **/
|
||||||
|
|
||||||
import { browser } from "@web/core/browser/browser";
|
import { browser } from "@web/core/browser/browser";
|
||||||
import { Dialog } from "@web/core/dialog/dialog";
|
|
||||||
import { _lt } from "@web/core/l10n/translation";
|
|
||||||
import { useChildRef, useOwnedDialogs, useService } from "@web/core/utils/hooks";
|
|
||||||
import { sprintf } from "@web/core/utils/strings";
|
|
||||||
import { isMobileOS } from "@web/core/browser/feature_detection";
|
|
||||||
import * as BarcodeScanner from "@web/webclient/barcode/barcode_scanner";
|
import * as BarcodeScanner from "@web/webclient/barcode/barcode_scanner";
|
||||||
const { useRef } = owl;
|
const { Component } = owl;
|
||||||
const {xml, Component} = owl;
|
|
||||||
import { standardFieldProps } from "@web/views/fields/standard_field_props";
|
import { standardFieldProps } from "@web/views/fields/standard_field_props";
|
||||||
import {registry} from "@web/core/registry";
|
import {registry} from "@web/core/registry";
|
||||||
import {useInputField} from "@web/views/fields/input_field_hook";
|
import {useInputField} from "@web/views/fields/input_field_hook";
|
||||||
|
|
||||||
export class CodeField extends Component {
|
export class CodeField extends Component {
|
||||||
setup() {
|
setup() {
|
||||||
console.log('CodeField created')
|
// console.log('CodeField created')
|
||||||
console.log('this',this)
|
// console.log('this',this)
|
||||||
console.log('this.props',this.props)
|
// console.log('this.props',this.props)
|
||||||
console.log('this.props.record',this.props.value)
|
// console.log('this.props.record',this.props.value)
|
||||||
useInputField({
|
useInputField({
|
||||||
getValue: () => this.props.value,
|
getValue: () => this.props.value,
|
||||||
refName: "scan_code",
|
refName: "scan_code",
|
||||||
});
|
});
|
||||||
console.log('我是setup1')
|
// console.log('我是setup1')
|
||||||
super.setup();
|
super.setup();
|
||||||
this.orm = this.env.services.orm;
|
this.orm = this.env.services.orm;
|
||||||
this.record = this.props.record;
|
this.record = this.props.record;
|
||||||
@@ -45,12 +39,12 @@ export class CodeField extends Component {
|
|||||||
async search(barcode) {
|
async search(barcode) {
|
||||||
// alert('我是search')
|
// alert('我是search')
|
||||||
const domain = [["code", "=", barcode]];
|
const domain = [["code", "=", barcode]];
|
||||||
console.log(domain)
|
// console.log(domain)
|
||||||
const fields = ["id", "code", "name", "state"];
|
const fields = ["id", "code", "name", "state"];
|
||||||
console.log(fields)
|
// console.log(fields)
|
||||||
const results = await this.orm.call("sf.tray", "search_read", [domain, fields]);
|
const results = await this.orm.call("sf.tray", "search_read", [domain, fields]);
|
||||||
const values = await this.orm.call("sf.tray", "search_read", [domain]);
|
const values = await this.orm.call("sf.tray", "search_read", [domain]);
|
||||||
console.log(results)
|
// console.log(results)
|
||||||
return results.map((result) => {
|
return results.map((result) => {
|
||||||
return {
|
return {
|
||||||
id: result.id,
|
id: result.id,
|
||||||
@@ -63,16 +57,16 @@ export class CodeField extends Component {
|
|||||||
}
|
}
|
||||||
async onBarcodeScanned(barcode) {
|
async onBarcodeScanned(barcode) {
|
||||||
const results = await this.search(barcode);
|
const results = await this.search(barcode);
|
||||||
console.log(results)
|
// console.log(results)
|
||||||
const records = results.filter((r) => !!r.id);
|
const records = results.filter((r) => !!r.id);
|
||||||
console.log(records)
|
// console.log(records)
|
||||||
if (records.length === 1) {
|
if (records.length === 1) {
|
||||||
if (records[0].state === '空闲') {
|
if (records[0].state === '空闲') {
|
||||||
console.log('currentModel',this)
|
// console.log('currentModel',this)
|
||||||
console.log('this.record.data',this.record.data)
|
// console.log('this.record.data',this.record.data)
|
||||||
console.log('this.record.data.id', this.record.data.id)
|
// console.log('this.record.data.id', this.record.data.id)
|
||||||
const workorder = await this.orm.call('mrp.workorder', 'read', [this.record.data.id]);
|
const workorder = await this.orm.call('mrp.workorder', 'read', [this.record.data.id]);
|
||||||
console.log('workorder', workorder[0])
|
// console.log('workorder', workorder[0])
|
||||||
const updatedRecord = await this.orm.call("sf.tray", "write", [
|
const updatedRecord = await this.orm.call("sf.tray", "write", [
|
||||||
[records[0].id],
|
[records[0].id],
|
||||||
{
|
{
|
||||||
@@ -81,31 +75,32 @@ export class CodeField extends Component {
|
|||||||
production_id: workorder[0].product_id[0],
|
production_id: workorder[0].product_id[0],
|
||||||
// workorder_id: workorder.id,
|
// workorder_id: workorder.id,
|
||||||
}]);
|
}]);
|
||||||
console.log(workorder[0].routing_type);
|
// console.log(workorder[0].routing_type);
|
||||||
console.log(workorder[0].production_id);
|
// console.log(workorder[0].production_id);
|
||||||
// const productionIDS = await this.orm.call('mrp.production', 'search', [[['id', '=', workorder[0].production_id[0]]]]);
|
// const productionIDS = await this.orm.call('mrp.production', 'search', [[['id', '=', workorder[0].production_id[0]]]]);
|
||||||
const productionIDS = await this.orm.call('mrp.workorder', 'search', [[["production_id", "=", workorder[0].production_id[0]]]]);
|
const productionIDS = await this.orm.call('mrp.workorder', 'search', [[["production_id", "=", workorder[0].production_id[0]]]]);
|
||||||
console.log('prooooooo', productionIDS);
|
// console.log('prooooooo', productionIDS);
|
||||||
console.log('values', records[0].values[0]);
|
// console.log('values', records[0].values[0]);
|
||||||
productionIDS.forEach(async (data) => {
|
productionIDS.forEach(async (data) => {
|
||||||
// 处理每一个数据
|
// 处理每一个数据
|
||||||
console.log(data);
|
// console.log(data);
|
||||||
const updatetrayRecord = await this.orm.call("mrp.workorder", "write", [
|
const updatetrayRecord = await this.orm.call("mrp.workorder", "write", [
|
||||||
[data],
|
[data],
|
||||||
{
|
{
|
||||||
tray_id: records[0].values[0].id,
|
tray_id: records[0].values[0].id,
|
||||||
// tray_id: false,
|
// tray_id: false,
|
||||||
}]);
|
}]);
|
||||||
console.log(updatetrayRecord)
|
// console.log(updatetrayRecord)
|
||||||
});
|
});
|
||||||
this.props.update(records[0].code);
|
this.props.update(records[0].code);
|
||||||
$('.o_form_button_save').click();
|
$('.o_form_button_save').click();
|
||||||
} else {
|
} else {
|
||||||
if (records[0].state === '占用') {
|
if (records[0].state === '占用') {
|
||||||
console.log('此托盘已占用,请检查')
|
// console.log('此托盘已占用,请检查')
|
||||||
alert('此托盘已占用,请检查')
|
alert('此托盘已占用,请检查')
|
||||||
} else {
|
} else {
|
||||||
console.log('此托盘已损坏,请登记')
|
// console.log('此托盘已损坏,请登记')
|
||||||
|
alert('此托盘已损坏,请登记')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,7 @@ const { Component, xml } = owl;
|
|||||||
|
|
||||||
export class BarcodeHandlerField extends Component {
|
export class BarcodeHandlerField extends Component {
|
||||||
setup() {
|
setup() {
|
||||||
console.log('99999999111');
|
|
||||||
this.actionService = useService("action")
|
this.actionService = useService("action")
|
||||||
console.log(this.actionService)
|
|
||||||
|
|
||||||
const barcode = useService("barcode");
|
const barcode = useService("barcode");
|
||||||
// this.rpc = useService("rpc");
|
// this.rpc = useService("rpc");
|
||||||
// useBus(barcode.bus, "barcode_scanned", this.onBarcodeScanned.bind(this));
|
// useBus(barcode.bus, "barcode_scanned", this.onBarcodeScanned.bind(this));
|
||||||
@@ -20,9 +17,6 @@ export class BarcodeHandlerField extends Component {
|
|||||||
async _rpc(params) {
|
async _rpc(params) {
|
||||||
// const { data } = await this.env.services.rpc('/web/dataset/call_kw', params);
|
// const { data } = await this.env.services.rpc('/web/dataset/call_kw', params);
|
||||||
const response = await this.env.services.rpc('/web/dataset/call_kw', params);
|
const response = await this.env.services.rpc('/web/dataset/call_kw', params);
|
||||||
console.log('response', response);
|
|
||||||
console.log('response.result', response.result);
|
|
||||||
|
|
||||||
// return response
|
// return response
|
||||||
const responseObject = JSON.parse(response)
|
const responseObject = JSON.parse(response)
|
||||||
return responseObject;
|
return responseObject;
|
||||||
@@ -33,8 +27,6 @@ export class BarcodeHandlerField extends Component {
|
|||||||
this.props.update(barcode);
|
this.props.update(barcode);
|
||||||
// const actionService = useService("action");
|
// const actionService = useService("action");
|
||||||
// const productId = 12345
|
// const productId = 12345
|
||||||
console.log('111222222222211111');
|
|
||||||
|
|
||||||
// 根据条形码获取相关数据,例如产品ID
|
// 根据条形码获取相关数据,例如产品ID
|
||||||
const response = await this._rpc({
|
const response = await this._rpc({
|
||||||
model: 'mrp.workorder',
|
model: 'mrp.workorder',
|
||||||
@@ -42,11 +34,10 @@ export class BarcodeHandlerField extends Component {
|
|||||||
args: [barcode],
|
args: [barcode],
|
||||||
kwargs:{},
|
kwargs:{},
|
||||||
});
|
});
|
||||||
// console.log(productId.result)
|
|
||||||
if (response.result) {
|
if (response.result) {
|
||||||
const action = response.result;
|
// const action = response.result;
|
||||||
console.log(action)
|
// console.log(action)
|
||||||
console.log('11111111111111111111111111111111111');
|
// console.log('11111111111111111111111111111111111');
|
||||||
// 通过产品ID执行操作并跳转到表单视图
|
// 通过产品ID执行操作并跳转到表单视图
|
||||||
// await this.actionService.doAction({
|
// await this.actionService.doAction({
|
||||||
// // type: 'ir.actions.act_window',
|
// // type: 'ir.actions.act_window',
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ import os
|
|||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
import time
|
import time
|
||||||
import requests
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import requests
|
||||||
from odoo import fields, models, api, _
|
from odoo import fields, models, api, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ class CustomKanbanController extends KanbanController {
|
|||||||
console.log('99999999111');
|
console.log('99999999111');
|
||||||
this.workOrders = await this.getAllWorkOrders();
|
this.workOrders = await this.getAllWorkOrders();
|
||||||
this.workOrdersNew = this.workOrders;
|
this.workOrdersNew = this.workOrders;
|
||||||
console.log('lines222222222', this.workOrders);
|
// console.log('lines222222222', this.workOrders);
|
||||||
|
//
|
||||||
console.log(typeof this.workOrders);
|
// console.log(typeof this.workOrders);
|
||||||
console.log(Array.isArray(this.workOrders));
|
// console.log(Array.isArray(this.workOrders));
|
||||||
|
//
|
||||||
console.log(this.workOrders.every(order => typeof order === 'object' && order.id !== undefined));
|
// console.log(this.workOrders.every(order => typeof order === 'object' && order.id !== undefined));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import base64
|
import base64
|
||||||
import json, requests
|
import json
|
||||||
from odoo import models, fields, api, _
|
import requests
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from odoo import models, fields, api, _
|
||||||
from odoo.exceptions import UserError, ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
|
|
||||||
|
|
||||||
@@ -41,22 +42,13 @@ class sf_production_plan(models.Model):
|
|||||||
actual_end_time = fields.Datetime(string='实际结束时间')
|
actual_end_time = fields.Datetime(string='实际结束时间')
|
||||||
shift = fields.Char(string='班次')
|
shift = fields.Char(string='班次')
|
||||||
|
|
||||||
# 序号、坯料编号、坯料名称、材质、数量、长度、宽度、厚度、直径、计划开始时间、计划结束时间、状态(已产出与待产出)、操作、创建人、创建时间、客户名称、订单号、行号、长度、宽度、厚度、直径、交货数量、交货日期
|
# 序号、坯料编号、坯料名称、材质、数量、长度、宽度、厚度、直径、计划开始时间、计划结束时间、状态(已产出与待产出)、操作、创建人、创建时间、
|
||||||
|
# 客户名称、订单号、行号、长度、宽度、厚度、直径、交货数量、交货日期
|
||||||
# sequence = fields.Integer(string='序号', required=True, copy=False, readonly=True, index=True,
|
# sequence = fields.Integer(string='序号', required=True, copy=False, readonly=True, index=True,
|
||||||
# default=lambda self: self.env['ir.sequence'].sudo().next_by_code('sf.pl.plan'))
|
# default=lambda self: self.env['ir.sequence'].sudo().next_by_code('sf.pl.plan'))
|
||||||
sequence = fields.Integer(string='序号', copy=False, readonly=True, index=True)
|
sequence = fields.Integer(string='序号', copy=False, readonly=True, index=True)
|
||||||
current_operation_name = fields.Char(string='当前工序名称', size=64, default='生产计划')
|
current_operation_name = fields.Char(string='当前工序名称', size=64, default='生产计划')
|
||||||
|
|
||||||
# state = fields.Selection([
|
|
||||||
# ('未排程', '未排程'), ('已排程', '已排程')], string='State', copy=False, index=True, readonly=True,
|
|
||||||
# store=True, tracking=True)
|
|
||||||
|
|
||||||
# orderpoint_id = fields.Many2one('stock.warehouse.orderpoint', compute='_compute_orderpoint_id')
|
|
||||||
# location_src_id = fields.Many2one('stock.location', 'Components Location', compute='_compute_orderpoint_id', active=False)
|
|
||||||
# location_dest_id = fields.Many2one('stock.location', 'Finished Products Location', compute='_compute_orderpoint_id')
|
|
||||||
# picking_type_id = fields.Many2one('stock.picking.type', 'Operation Type', compute='_compute_orderpoint_id')
|
|
||||||
# move_dest_ids = fields.One2many('stock.move', 'created_production_id', compute='_compute_orderpoint_id')
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def get_import_templates(self):
|
def get_import_templates(self):
|
||||||
"""returns the xlsx import template file"""
|
"""returns the xlsx import template file"""
|
||||||
@@ -135,112 +127,6 @@ class sf_production_plan(models.Model):
|
|||||||
|
|
||||||
return num
|
return num
|
||||||
|
|
||||||
# pl_no = fields.Char(string='坯料编号', required=True, default=_get_pl_no, readonly=True)
|
|
||||||
# pl_name = fields.Char(string='坯料名称', size=64, required=True)
|
|
||||||
# material = fields.Many2one('sf.production.materials', string='材质', required=True)
|
|
||||||
# quantity = fields.Float(string='数量', required=True)
|
|
||||||
# length = fields.Float(string='长度', required=True)
|
|
||||||
# width = fields.Float(string='宽度', required=True)
|
|
||||||
# thickness = fields.Float(string='厚度', required=True)
|
|
||||||
# diameter = fields.Float(string='直径', required=True)
|
|
||||||
# plan_start_time = fields.Datetime(string='计划开始时间')
|
|
||||||
# plan_end_time = fields.Datetime(string='计划结束时间')
|
|
||||||
# state = fields.Selection([
|
|
||||||
# ('draft', '待排程'),
|
|
||||||
# ('produce', '已排程'),
|
|
||||||
# ('done', '已产出'),
|
|
||||||
# ], string='状态', copy=False, index=True, default='draft')
|
|
||||||
# customer_name = fields.Char(string='客户名称', size=64)
|
|
||||||
# order_no = fields.Char(string='订单号', size=64)
|
|
||||||
# line_no = fields.Char(string='行号', size=64)
|
|
||||||
# delivery_length = fields.Float(string='交货长度')
|
|
||||||
# delivery_width = fields.Float(string='交货宽度')
|
|
||||||
# delivery_thickness = fields.Float(string='交货厚度')
|
|
||||||
# delivery_diameter = fields.Float(string='交货直径')
|
|
||||||
# delivery_quantity = fields.Float(string='交货数量')
|
|
||||||
# delivery_date = fields.Datetime(string='交货日期', related='plan_end_time', readonly=False, store=True)
|
|
||||||
|
|
||||||
# 当不设置计划结束时间时,增加计算计划结束时间的方法,根据采购周期加缓冲期两个值来算就可以了
|
|
||||||
# def do_production_schedule(self):
|
|
||||||
# """
|
|
||||||
# 排程方法
|
|
||||||
# """
|
|
||||||
# if not self.production_line_id:
|
|
||||||
# raise ValidationError("未选择生产线")
|
|
||||||
# else:
|
|
||||||
# aa = self.env['mrp.production'].sudo().search([('name', '=', self.name)])
|
|
||||||
# workorder_time = 0
|
|
||||||
# workorder_id_list = self.production_id.workorder_ids.ids
|
|
||||||
# print(workorder_id_list)
|
|
||||||
# print(type(self.production_id.workorder_ids))
|
|
||||||
# if self.production_id.workorder_ids:
|
|
||||||
# for item in self.production_id.workorder_ids:
|
|
||||||
# if item.name == 'CNC加工':
|
|
||||||
# item.date_planned_start = self.date_planned_start
|
|
||||||
# item.date_planned_finished = item.date_planned_start + timedelta(
|
|
||||||
# minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# [('name', '=', 'CNC加工')]).time_cycle)
|
|
||||||
# item.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# [('name', '=', 'CNC加工')]).time_cycle
|
|
||||||
# # print(item.id)
|
|
||||||
# sequence = workorder_id_list.index(item.id) - 1
|
|
||||||
# # print('sequence', sequence)
|
|
||||||
# # print('total', len(workorder_id_list))
|
|
||||||
# # 计算CNC加工之前工单的开始结束时间
|
|
||||||
# for i in range(sequence):
|
|
||||||
# current_workorder_id = (item.id - (i + 1))
|
|
||||||
# current_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
|
||||||
# [('id', '=', current_workorder_id)])
|
|
||||||
# old_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
|
||||||
# [('id', '=', (current_workorder_id + 1))])
|
|
||||||
# work_order = self.env['mrp.workorder'].sudo().search(
|
|
||||||
# [('production_id', '=', self.production_id.id), ('id', '=', current_workorder_id)])
|
|
||||||
# work_order.date_planned_finished = old_workorder_obj.date_planned_start
|
|
||||||
# work_order.date_planned_start = old_workorder_obj.date_planned_start - timedelta(
|
|
||||||
# minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# [('name', '=', current_workorder_obj.name)]).time_cycle)
|
|
||||||
# work_order.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# [('name', '=', current_workorder_obj.name)]).time_cycle
|
|
||||||
# # 计算CNC加工之后工单的开始结束时间
|
|
||||||
# for j in range(len(workorder_id_list) - sequence - 2):
|
|
||||||
# current_workorder_id = (item.id + (j + 1))
|
|
||||||
# current_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
|
||||||
# [('id', '=', current_workorder_id)])
|
|
||||||
# old_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
|
||||||
# [('id', '=', (current_workorder_id - 1))])
|
|
||||||
# work_order = self.env['mrp.workorder'].sudo().search(
|
|
||||||
# [('production_id', '=', self.production_id.id), ('id', '=', current_workorder_id)])
|
|
||||||
# try:
|
|
||||||
# work_order.date_planned_start = old_workorder_obj.date_planned_finished
|
|
||||||
# print('work_order.data_start', work_order.date_planned_start)
|
|
||||||
# work_order.date_planned_finished = old_workorder_obj.date_planned_finished + timedelta(
|
|
||||||
# minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# [('name', '=', current_workorder_obj.name)]).time_cycle)
|
|
||||||
# work_order.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
# [('name', '=', current_workorder_obj.name)]).time_cycle
|
|
||||||
# except ValueError as e:
|
|
||||||
# print('时间设置失败,请检查是否为工序分配工作中心,%s' % e)
|
|
||||||
#
|
|
||||||
# current_workorder = self.env['mrp.workorder'].sudo().search([('id', '=', item.id)])
|
|
||||||
# workorder_time += current_workorder.duration_expected
|
|
||||||
# print('workorder_time', workorder_time)
|
|
||||||
# self.date_planned_finished = self.date_planned_start + timedelta(minutes=workorder_time)
|
|
||||||
# self.state = 'done'
|
|
||||||
# self.production_id.schedule_state = '已排'
|
|
||||||
# # self.production_id.date_planned_start = self.date_planned_start
|
|
||||||
# # self.production_id.date_planned_finished = self.date_planned_finished
|
|
||||||
# else:
|
|
||||||
# raise ValidationError("未找到工单")
|
|
||||||
# # self.date_planned_finished = self.date_planned_start + timedelta(days=3)
|
|
||||||
# # self.state = 'done'
|
|
||||||
# return {
|
|
||||||
# 'name': '排程甘特图',
|
|
||||||
# 'type': 'ir.actions.act_window',
|
|
||||||
# 'res_model': 'sf.production.plan', # 要跳转的模型名称
|
|
||||||
# 'view_mode': 'gantt,tree,form', # 要显示的视图类型,可以是'form', 'tree', 'kanban', 'graph', 'calendar', 'pivot'等
|
|
||||||
# 'target': 'current', # 跳转的目标窗口,可以是'current'或'new'
|
|
||||||
# }
|
|
||||||
|
|
||||||
def do_production_schedule(self):
|
def do_production_schedule(self):
|
||||||
"""
|
"""
|
||||||
排程方法
|
排程方法
|
||||||
@@ -261,7 +147,8 @@ class sf_production_plan(models.Model):
|
|||||||
[('name', '=', 'CNC加工')]).time_cycle
|
[('name', '=', 'CNC加工')]).time_cycle
|
||||||
self.calculate_plan_time_before(item, workorder_id_list)
|
self.calculate_plan_time_before(item, workorder_id_list)
|
||||||
self.calculate_plan_time_after(item, workorder_id_list)
|
self.calculate_plan_time_after(item, workorder_id_list)
|
||||||
self.date_planned_start, self.date_planned_finished = item.date_planned_start, item.date_planned_finished
|
self.date_planned_start, self.date_planned_finished = \
|
||||||
|
item.date_planned_start, item.date_planned_finished
|
||||||
self.state = 'done'
|
self.state = 'done'
|
||||||
self.production_id.schedule_state = '已排'
|
self.production_id.schedule_state = '已排'
|
||||||
# self.production_id.date_planned_start = self.date_planned_start
|
# self.production_id.date_planned_start = self.date_planned_start
|
||||||
@@ -274,7 +161,8 @@ class sf_production_plan(models.Model):
|
|||||||
'name': '排程甘特图',
|
'name': '排程甘特图',
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'res_model': 'sf.production.plan', # 要跳转的模型名称
|
'res_model': 'sf.production.plan', # 要跳转的模型名称
|
||||||
'view_mode': 'gantt,tree,form', # 要显示的视图类型,可以是'form', 'tree', 'kanban', 'graph', 'calendar', 'pivot'等
|
# 要显示的视图类型,可以是'form', 'tree', 'kanban', 'graph', 'calendar', 'pivot'等
|
||||||
|
'view_mode': 'gantt,tree,form',
|
||||||
'target': 'current', # 跳转的目标窗口,可以是'current'或'new'
|
'target': 'current', # 跳转的目标窗口,可以是'current'或'new'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +236,6 @@ class sf_production_plan(models.Model):
|
|||||||
'bfm_process_order_list': []}
|
'bfm_process_order_list': []}
|
||||||
aa = self.env['ir.attachment'].search([('id', '=', 631)])
|
aa = self.env['ir.attachment'].search([('id', '=', 631)])
|
||||||
temp = self.env['product.template'].search([('id', '=', 47)])
|
temp = self.env['product.template'].search([('id', '=', 47)])
|
||||||
item = aa.datas.decode('utf-8')
|
|
||||||
val = {
|
val = {
|
||||||
'model_long': 3,
|
'model_long': 3,
|
||||||
'model_width': 1,
|
'model_width': 1,
|
||||||
|
|||||||
@@ -24,10 +24,9 @@
|
|||||||
|
|
||||||
'web.assets_qweb': [
|
'web.assets_qweb': [
|
||||||
],
|
],
|
||||||
'web.assets_backend':[
|
'web.assets_backend': [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
'license': 'LGPL-3',
|
'license': 'LGPL-3',
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
|||||||
Reference in New Issue
Block a user