diff --git a/jikimo_frontend/static/src/scss/custom_style.scss b/jikimo_frontend/static/src/scss/custom_style.scss
index b70cc749..7f11b5f5 100644
--- a/jikimo_frontend/static/src/scss/custom_style.scss
+++ b/jikimo_frontend/static/src/scss/custom_style.scss
@@ -503,4 +503,27 @@ div:has(.o_required_modifier) > label::before {
color: #fff;
background-color: #4A4F59;
border-color: #4A4F59;
+}
+
+// 功能刀具组装单 弹窗样式
+.o_horizontal_separator.mt-4.mb-3.text-uppercase.fw-bolder.small ~ div.col-lg-6 .o_inner_group.col-lg-6 {
+ width: 100%;
+}
+.o_horizontal_separator.mt-4.mb-3.text-uppercase.fw-bolder.small ~ div .o_inner_group .o_wrap_field.d-flex.d-sm-contents.flex-column{
+ display: flex!important;
+ flex-direction: row!important;
+ input {
+ border-bottom: 1px solid;
+ }
+}
+
+// 设置表格横向滚动
+.o_list_renderer.o_renderer {
+ max-width: 100%;
+ overflow-x: auto;
+}
+
+// 设置表单页面label文本不换行
+.o_form_view .o_group .o_wrap_label .o_form_label {
+ white-space: nowrap;
}
\ No newline at end of file
diff --git a/mrp_workorder/models/mrp_workorder.py b/mrp_workorder/models/mrp_workorder.py
index 81be5f2d..01363bb5 100644
--- a/mrp_workorder/models/mrp_workorder.py
+++ b/mrp_workorder/models/mrp_workorder.py
@@ -27,7 +27,7 @@ class MrpWorkcenter(models.Model):
class MrpProductionWorkcenterLine(models.Model):
_name = 'mrp.workorder'
- _inherit = ['mrp.workorder', 'barcodes.barcode_events_mixin']
+ _inherit = ['mrp.workorder', 'barcodes.barcode_events_mixin', 'mail.thread', 'mail.activity.mixin']
quality_point_ids = fields.Many2many('quality.point', compute='_compute_quality_point_ids', store=True)
quality_point_count = fields.Integer('Steps', compute='_compute_quality_point_count')
@@ -47,14 +47,17 @@ class MrpProductionWorkcenterLine(models.Model):
is_last_lot = fields.Boolean('Is Last lot', compute='_compute_is_last_lot')
is_first_started_wo = fields.Boolean('Is The first Work Order', compute='_compute_is_last_unfinished_wo')
- is_last_unfinished_wo = fields.Boolean('Is Last Work Order To Process', compute='_compute_is_last_unfinished_wo', store=False)
+ is_last_unfinished_wo = fields.Boolean('Is Last Work Order To Process', compute='_compute_is_last_unfinished_wo',
+ store=False)
lot_id = fields.Many2one(related='current_quality_check_id.lot_id', readonly=False)
move_id = fields.Many2one(related='current_quality_check_id.move_id', readonly=False)
move_line_id = fields.Many2one(related='current_quality_check_id.move_line_id', readonly=False)
move_line_ids = fields.One2many(related='move_id.move_line_ids')
- quality_state = fields.Selection(related='current_quality_check_id.quality_state', string="Quality State", readonly=False)
+ quality_state = fields.Selection(related='current_quality_check_id.quality_state', string="Quality State",
+ readonly=False)
qty_done = fields.Float(related='current_quality_check_id.qty_done', readonly=False)
- test_type_id = fields.Many2one('quality.point.test_type', 'Test Type', related='current_quality_check_id.test_type_id')
+ test_type_id = fields.Many2one('quality.point.test_type', 'Test Type',
+ related='current_quality_check_id.test_type_id')
test_type = fields.Char(related='test_type_id.technical_name')
user_id = fields.Many2one(related='current_quality_check_id.user_id', readonly=False)
worksheet_page = fields.Integer('Worksheet page')
@@ -65,7 +68,8 @@ class MrpProductionWorkcenterLine(models.Model):
def _compute_quality_point_ids(self):
for workorder in self:
quality_points = workorder.operation_id.quality_point_ids
- quality_points = quality_points.filtered(lambda qp: not qp.product_ids or workorder.production_id.product_id in qp.product_ids)
+ quality_points = quality_points.filtered(
+ lambda qp: not qp.product_ids or workorder.production_id.product_id in qp.product_ids)
workorder.quality_point_ids = quality_points
@api.depends('operation_id')
@@ -91,7 +95,8 @@ class MrpProductionWorkcenterLine(models.Model):
@api.depends('check_ids')
def _compute_finished_product_check_ids(self):
for wo in self:
- wo.finished_product_check_ids = wo.check_ids.filtered(lambda c: c.finished_product_sequence == wo.qty_produced)
+ wo.finished_product_check_ids = wo.check_ids.filtered(
+ lambda c: c.finished_product_sequence == wo.qty_produced)
def write(self, values):
res = super().write(values)
@@ -138,7 +143,8 @@ class MrpProductionWorkcenterLine(models.Model):
self.finished_lot_id = self.env['stock.lot'].create({
'product_id': self.product_id.id,
'company_id': self.company_id.id,
- 'name': self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) or self.env['ir.sequence'].next_by_code('stock.lot.serial'),
+ 'name': self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) or self.env[
+ 'ir.sequence'].next_by_code('stock.lot.serial'),
})
def _create_subsequent_checks(self):
@@ -152,7 +158,7 @@ class MrpProductionWorkcenterLine(models.Model):
"""
# Create another quality check if necessary
next_check = self.current_quality_check_id.next_check_id
- if next_check.component_id != self.current_quality_check_id.product_id or\
+ if next_check.component_id != self.current_quality_check_id.product_id or \
next_check.point_id != self.current_quality_check_id.point_id:
# TODO: manage reservation here
@@ -279,7 +285,8 @@ class MrpProductionWorkcenterLine(models.Model):
if self.current_quality_check_id:
team = self.current_quality_check_id.team_id
else:
- team = self.env['quality.alert.team'].search(['|', ('company_id', '=', self.company_id.id), ('company_id', '=', False)], limit=1)
+ team = self.env['quality.alert.team'].search(
+ ['|', ('company_id', '=', self.company_id.id), ('company_id', '=', False)], limit=1)
return {
'type': 'ir.actions.act_window',
'res_model': 'quality.check',
@@ -320,7 +327,8 @@ class MrpProductionWorkcenterLine(models.Model):
production = wo.production_id
move_raw_ids = wo.move_raw_ids.filtered(lambda m: m.state not in ('done', 'cancel'))
- move_finished_ids = wo.move_finished_ids.filtered(lambda m: m.state not in ('done', 'cancel') and m.product_id != wo.production_id.product_id)
+ move_finished_ids = wo.move_finished_ids.filtered(
+ lambda m: m.state not in ('done', 'cancel') and m.product_id != wo.production_id.product_id)
previous_check = self.env['quality.check']
for point in wo.quality_point_ids:
# Check if we need a quality control for this point
@@ -342,11 +350,13 @@ class MrpProductionWorkcenterLine(models.Model):
if point.test_type == 'register_byproducts':
moves = move_finished_ids.filtered(lambda m: m.product_id == point.component_id)
if not moves:
- moves = production.move_finished_ids.filtered(lambda m: not m.operation_id and m.product_id == point.component_id)
+ moves = production.move_finished_ids.filtered(
+ lambda m: not m.operation_id and m.product_id == point.component_id)
elif point.test_type == 'register_consumed_materials':
moves = move_raw_ids.filtered(lambda m: m.product_id == point.component_id)
if not moves:
- moves = production.move_raw_ids.filtered(lambda m: not m.operation_id and m.product_id == point.component_id)
+ moves = production.move_raw_ids.filtered(
+ lambda m: not m.operation_id and m.product_id == point.component_id)
else:
check = self.env['quality.check'].create(values)
previous_check.next_check_id = check
@@ -363,8 +373,10 @@ class MrpProductionWorkcenterLine(models.Model):
processed_move |= moves
# Generate quality checks associated with unreferenced components
- moves_without_check = ((move_raw_ids | move_finished_ids) - processed_move).filtered(lambda move: (move.has_tracking != 'none' and not move.raw_material_production_id.use_auto_consume_components_lots) or move.operation_id)
- quality_team_id = self.env['quality.alert.team'].search(['|', ('company_id', '=', wo.company_id.id), ('company_id', '=', False)], limit=1).id
+ moves_without_check = ((move_raw_ids | move_finished_ids) - processed_move).filtered(lambda move: (
+ move.has_tracking != 'none' and not move.raw_material_production_id.use_auto_consume_components_lots) or move.operation_id)
+ quality_team_id = self.env['quality.alert.team'].search(
+ ['|', ('company_id', '=', wo.company_id.id), ('company_id', '=', False)], limit=1).id
for move in moves_without_check:
values = {
'production_id': production.id,
@@ -412,7 +424,8 @@ class MrpProductionWorkcenterLine(models.Model):
backorder = False
# Trigger the backorder process if we produce less than expected
- if float_compare(self.qty_producing, self.qty_remaining, precision_rounding=self.product_uom_id.rounding) == -1 and self.is_first_started_wo:
+ if float_compare(self.qty_producing, self.qty_remaining,
+ precision_rounding=self.product_uom_id.rounding) == -1 and self.is_first_started_wo:
backorder = self.production_id._split_productions()[1:]
for workorder in backorder.workorder_ids:
if workorder.product_tracking == 'serial':
@@ -423,7 +436,8 @@ class MrpProductionWorkcenterLine(models.Model):
else:
if self.operation_id:
backorder = (self.production_id.procurement_group_id.mrp_production_ids - self.production_id).filtered(
- lambda p: p.workorder_ids.filtered(lambda wo: wo.operation_id == self.operation_id).state not in ('cancel', 'done')
+ lambda p: p.workorder_ids.filtered(lambda wo: wo.operation_id == self.operation_id).state not in (
+ 'cancel', 'done')
)[:1]
else:
index = list(self.production_id.workorder_ids).index(self)
@@ -442,7 +456,8 @@ class MrpProductionWorkcenterLine(models.Model):
wo.current_quality_check_id._update_component_quantity()
if not self.env.context.get('no_start_next'):
if self.operation_id:
- return backorder.workorder_ids.filtered(lambda wo: wo.operation_id == self.operation_id).open_tablet_view()
+ return backorder.workorder_ids.filtered(
+ lambda wo: wo.operation_id == self.operation_id).open_tablet_view()
else:
index = list(self.production_id.workorder_ids).index(self)
return backorder.workorder_ids[index].open_tablet_view()
@@ -466,7 +481,8 @@ class MrpProductionWorkcenterLine(models.Model):
def open_tablet_view(self):
self.ensure_one()
- if not self.is_user_working and self.working_state != 'blocked' and self.state in ('ready', 'waiting', 'progress', 'pending'):
+ if not self.is_user_working and self.working_state != 'blocked' and self.state in (
+ 'ready', 'waiting', 'progress', 'pending'):
self.button_start()
action = self.env["ir.actions.actions"]._for_xml_id("mrp_workorder.tablet_client_action")
action['target'] = 'fullscreen'
@@ -521,7 +537,8 @@ class MrpProductionWorkcenterLine(models.Model):
data = {
'mrp.workorder': self.read(self._get_fields_for_tablet(), load=False)[0],
'quality.check': self.check_ids._get_fields_for_tablet(sorted_check_list),
- 'operation': self.operation_id.read(self.operation_id._get_fields_for_tablet())[0] if self.operation_id else {},
+ 'operation': self.operation_id.read(self.operation_id._get_fields_for_tablet())[
+ 0] if self.operation_id else {},
'working_state': self.workcenter_id.working_state,
'views': {
'workorder': self.env.ref('mrp_workorder.mrp_workorder_view_form_tablet').id,
@@ -553,7 +570,8 @@ class MrpProductionWorkcenterLine(models.Model):
return {
'duration': self.duration,
- 'position': bisect_left(last30op, self.duration), # which position regarded other workorders ranked by duration
+ 'position': bisect_left(last30op, self.duration),
+ # which position regarded other workorders ranked by duration
'quality_score': score,
'show_rainbow': show_rainbow,
}
diff --git a/mrp_workorder/views/mrp_workorder_views.xml b/mrp_workorder/views/mrp_workorder_views.xml
index 37702c00..8c208f19 100644
--- a/mrp_workorder/views/mrp_workorder_views.xml
+++ b/mrp_workorder/views/mrp_workorder_views.xml
@@ -27,6 +27,13 @@
+
+
+
+
+
+
+
diff --git a/sf_base/static/src/scss/format_img.scss b/sf_base/static/src/scss/format_img.scss
index 279c5fff..982d3c50 100644
--- a/sf_base/static/src/scss/format_img.scss
+++ b/sf_base/static/src/scss/format_img.scss
@@ -1,7 +1,7 @@
.o_data_row .w-100 {
width: 40px !important;
height: 40px !important;
- display: block !important;
+ //display: block !important;
}
.o_list_renderer .o_list_table tbody > tr > td:not(.o_list_record_selector):not(.o_handle_cell):not(.o_list_button):not(.o_list_record_remove) {
diff --git a/sf_bf_connect/models/jd_eclp.py b/sf_bf_connect/models/jd_eclp.py
index 6d6a0e38..e381242a 100644
--- a/sf_bf_connect/models/jd_eclp.py
+++ b/sf_bf_connect/models/jd_eclp.py
@@ -67,9 +67,10 @@ class JdEclp(models.Model):
"""
判断是否为出库单
"""
- if self.name:
- is_check_out = self.name.split('/')
- self.check_out = is_check_out[1]
+ for record in self:
+ if record.name:
+ is_check_out = record.name.split('/')
+ record.check_out = is_check_out[1]
@api.depends('carrier_tracking_ref')
def query_bill_pdf(self):
diff --git a/sf_dlm_management/views/product_template_management_view.xml b/sf_dlm_management/views/product_template_management_view.xml
index dea0150d..accc23a0 100644
--- a/sf_dlm_management/views/product_template_management_view.xml
+++ b/sf_dlm_management/views/product_template_management_view.xml
@@ -10,6 +10,7 @@
+
+
@@ -47,10 +50,10 @@
-
-
@@ -95,6 +98,16 @@
+
+ {'readonly': ['|',('id','!=',False),('categ_type', '=',
+ '刀具')], 'required': True}
+
+
+
+
+
+
+
@@ -455,7 +468,8 @@
-
+
diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py
index b9027a9f..ddbf4048 100644
--- a/sf_manufacturing/controllers/controllers.py
+++ b/sf_manufacturing/controllers/controllers.py
@@ -215,6 +215,7 @@ class Manufacturing_Connect(http.Controller):
if workorder.state != 'progress':
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单未开始'}
return json.JSONEncoder().encode(res)
+ # workorder.write({'date_finished': datetime.now()})
workorder.button_finish()
# workorder.process_state = '待解除装夹'
# workorder.sudo().production_id.process_state = '待解除装夹'
diff --git a/sf_manufacturing/models/agv_setting.py b/sf_manufacturing/models/agv_setting.py
index 64af1d90..06f9edba 100644
--- a/sf_manufacturing/models/agv_setting.py
+++ b/sf_manufacturing/models/agv_setting.py
@@ -2,7 +2,8 @@
import requests
import logging
import time
-from odoo import fields, models
+from odoo import fields, models, api
+from odoo.exceptions import UserError
class AgvSetting(models.Model):
@@ -59,11 +60,17 @@ class AgvTaskRoute(models.Model):
('F01', '搬运'), ], string='任务类型', default="F01")
route_type = fields.Selection([
('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型')
- start_site_id = fields.Many2one('sf.agv.site', '起点接驳站位置编号')
- end_site_id = fields.Many2one('sf.agv.site', '终点接驳站位置编号')
+ start_site_id = fields.Many2one('sf.agv.site', '起点接驳站')
+ end_site_id = fields.Many2one('sf.agv.site', '终点接驳站')
destination_production_line_id = fields.Many2one('sf.production.line', '目的生产线')
active = fields.Boolean('有效', default=True)
+ @api.constrains('end_site_id')
+ def _check_end_site_id(self):
+ if self.end_site_id:
+ if self.end_site_id == self.start_site_id:
+ raise UserError("您选择的终点接驳站与起点接驳站重复,请重新选择")
+
class Center_controlInterfaceLog(models.Model):
_name = 'center_control.interface.log'
diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index 34e00aee..0f428d43 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -5,7 +5,7 @@ import re
import requests
from itertools import groupby
from odoo import api, fields, models, _
-from odoo.exceptions import UserError,ValidationError
+from odoo.exceptions import UserError, ValidationError
from odoo.addons.sf_base.commons.common import Common
from odoo.tools import float_compare, float_round, float_is_zero, format_datetime
@@ -53,13 +53,13 @@ class MrpProduction(models.Model):
active = fields.Boolean(string='已归档', default=True)
programming_no = fields.Char('编程单号')
work_state = fields.Char('业务状态')
- programming_state = fields.Char('编程状态')
+ programming_state = fields.Char('编程状态', tracking=True)
glb_file = fields.Binary("glb模型文件")
- production_line_id = fields.Many2one('sf.production.line', string='生产线')
+ production_line_id = fields.Many2one('sf.production.line', string='生产线', tracking=True)
plan_start_processing_time = fields.Datetime('计划开始加工时间')
production_line_state = fields.Selection(
[('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
- string='上/下产线', default='待上产线')
+ string='上/下产线', default='待上产线', tracking=True)
# 工序状态
# Todo 研究下用法
process_state = fields.Selection([
@@ -77,6 +77,7 @@ class MrpProduction(models.Model):
part_drawing = fields.Binary('零件图纸')
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
+ rework_production = fields.Many2one('mrp.production', string='返工的制造订单')
@api.depends(
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state',
@@ -154,8 +155,30 @@ class MrpProduction(models.Model):
for production in self:
production.maintenance_count = len(production.request_ids)
+ # 制造订单报废:编程单更新
+ def updateCNC(self):
+ try:
+ res = {'production_no': self.name, 'programming_no': self.programming_no,
+ 'order_no': self.origin}
+ logging.info('res=%s:' % res)
+ configsettings = self.env['res.config.settings'].get_values()
+ config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
+ url = '/api/intelligent_programming/update_intelligent_programmings'
+ config_url = configsettings['sf_url'] + url
+ res['token'] = configsettings['token']
+ ret = requests.post(config_url, json={}, data=res, headers=config_header)
+ ret = ret.json()
+ logging.info('updateCNC-ret:%s' % ret)
+ if ret['status'] == 1:
+ self.write({'work_state': '已编程'})
+ else:
+ raise UserError(ret['message'])
+ except Exception as e:
+ logging.info('updateCNC error:%s' % e)
+ raise UserError("更新程单失败,请联系管理员")
+
# cnc程序获取
- def fetchCNC(self, production_names):
+ def fetchCNC(self, production_names, scrap_production):
cnc = self.env['mrp.production'].search([('id', '=', self.id)])
quick_order = self.env['quick.easy.order'].search(
[('name', '=', cnc.product_id.default_code.rsplit('-', 1)[0])])
@@ -171,6 +194,8 @@ class MrpProduction(models.Model):
'production_no': production_names,
'machine_tool_code': '',
'product_name': cnc.product_id.name,
+ 'remanufacture_type': '' if not scrap_production else scrap_production.workorder_ids.filtered(
+ lambda b: b.routing_type == "CNC加工").test_results,
'model_code': cnc.product_id.model_code,
'material_code': self.env['sf.production.materials'].search(
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
@@ -312,10 +337,12 @@ class MrpProduction(models.Model):
[('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)],
limit=1, order='id asc')
if not production_programming.programming_no:
- production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]))
+ production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]),
+ scrap_production)
else:
production.write({'programming_no': production_programming.programming_no,
'programming_state': '编程中'})
+
# # 根据加工面板的面数及对应的工序模板生成工单
i = 0
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
@@ -406,20 +433,15 @@ class MrpProduction(models.Model):
# 工单排序
def _reset_work_order_sequence1(self, k):
- sequen = 0
for rec in self:
- current_sequence = 10
+ cnc_workorder = rec.workorder_ids.filtered(lambda wo: wo.name == "CNC加工")
+ cnc_back_workorder = rec.workorder_ids.filtered(lambda wo: wo.name == "CNC加工(返工)")
for work in rec.workorder_ids:
- work.sequence = current_sequence
- current_sequence += 10
- if work.name == '后置三元质量检测' and work.processing_panel == k:
- sequen = work.sequence
-
- for work in rec.workorder_ids:
- if work.name == '后置三元质量检测(返工)' and work.processing_panel == k:
- work.sequence = sequen + 2
- if work.name == 'CNC加工(返工)' and work.processing_panel == k:
- work.sequence = sequen + 1
+ if work.name == cnc_workorder.name and work.processing_panel == k:
+ cnc_back_workorder.write({'sequence': work.sequence + 1})
+ print(cnc_back_workorder.sequence)
+ elif work.routing_type not in ['装夹预调'] and work != cnc_back_workorder:
+ work.sequence += 1
# 在制造订单上新增工单
def _create_workorder1(self, k):
@@ -459,13 +481,7 @@ class MrpProduction(models.Model):
order='sequence asc'
)
i += 1
-
for route in routingworkcenter:
-
- # if route.routing_type == '后置三元质量检测':
- # workorders_values.append(
- # self.env['mrp.workorder'].json_workorder_str1(k, production, route)
- # )
if route.routing_type == 'CNC加工':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str1(k, production, route))
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 1751a9e3..1d65c0ae 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -102,7 +102,7 @@ class ResMrpWorkOrder(models.Model):
Z10_axis = fields.Float(default=0)
X_deviation_angle = fields.Integer(string="X轴偏差度", default=0)
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
- string="检测结果")
+ 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程序")
tray_code = fields.Char(string="托盘编码")
@@ -133,7 +133,7 @@ class ResMrpWorkOrder(models.Model):
return action
supplier_id = fields.Many2one('res.partner', string='外协供应商')
- equipment_id = fields.Many2one('maintenance.equipment', string='加工设备')
+ equipment_id = fields.Many2one('maintenance.equipment', string='加工设备', tracking=True)
is_ok = fields.Boolean(string='是否合格')
# 加工人
processing_user_id = fields.Many2one('res.users', string='加工人')
@@ -195,11 +195,16 @@ class ResMrpWorkOrder(models.Model):
rfid_code_old = fields.Char('RFID码(已解除)')
production_line_id = fields.Many2one('sf.production.line', related='production_id.production_line_id',
- string='生产线', store=True)
+ string='生产线', store=True, tracking=True)
production_line_state = fields.Selection(related='production_id.production_line_state',
- string='上/下产线', store=True)
+ string='上/下产线', store=True, tracking=True)
detection_report = fields.Binary('检测报告', readonly=True)
- is_remanufacture = fields.Boolean(string='是否重新生成制造订单', default=True)
+ is_remanufacture = fields.Boolean(string='重新生成制造订单', default=False)
+ is_fetchcnc = fields.Boolean(string='重新获取NC程序', default=False)
+ reason = fields.Selection(
+ [("programming", "编程"), ("clamping", "返工"), ("cutter", "刀具"), ("operate computer", "操机"),
+ ("technology", "工艺"), ("customer redrawing", "客户改图"), ("other", "其他"), ], string="原因", tracking=True)
+ detailed_reason = fields.Text('详细原因')
@api.onchange('rfid_code')
def _onchange(self):
@@ -672,18 +677,64 @@ class ResMrpWorkOrder(models.Model):
"""
重新生成制造订单或者重新生成工单
"""
- if self.test_results == '报废':
+ if self.test_results in ['返工', '报废']:
values = self.env['mrp.production'].create_production1_values(self.production_id)
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(
self.production_id.company_id).create(
values)
- self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
+ # self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
- productions._create_workorder()
+ productions._create_workorder(is_fetchcnc=self.is_fetchcnc, scrap_production=self.production_id)
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
(
p.move_dest_ids.procure_method != 'make_to_order' and
not p.move_raw_ids and not p.workorder_ids)).action_confirm()
+ for production_item in productions:
+ process_parameter_workorder = self.env['mrp.workorder'].search(
+ [('surface_technics_parameters_id', '!=', False), ('production_id', '=', production_item.id),
+ ('is_subcontract', '=', True)])
+ if process_parameter_workorder:
+ is_pick = False
+ consecutive_workorders = []
+ m = 0
+ sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
+ for i in range(len(sorted_workorders) - 1):
+ if m == 0:
+ is_pick = False
+ if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
+ sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
+ sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
+ if sorted_workorders[i] not in consecutive_workorders:
+ consecutive_workorders.append(sorted_workorders[i])
+ consecutive_workorders.append(sorted_workorders[i + 1])
+ m += 1
+ continue
+ else:
+ if m == len(consecutive_workorders) - 1 and m != 0:
+ self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
+ production_item)
+ if sorted_workorders[i] in consecutive_workorders:
+ is_pick = True
+ consecutive_workorders = []
+ m = 0
+ # 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
+ if is_pick is False:
+ self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
+ production_item)
+ if m == len(consecutive_workorders) - 1 and m != 0:
+ self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
+ production_item)
+ if sorted_workorders[i] in consecutive_workorders:
+ is_pick = True
+ consecutive_workorders = []
+ m = 0
+ if m == len(consecutive_workorders) - 1 and m != 0:
+ self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production_item)
+ if is_pick is False and m == 0:
+ if len(sorted_workorders) == 1:
+ self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production_item)
+ else:
+ self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production_item)
for production in productions:
origin_production = production.move_dest_ids and production.move_dest_ids[
@@ -704,13 +755,36 @@ class ResMrpWorkOrder(models.Model):
'mail.message_origin_link',
values={'self': production, 'origin': origin_production},
subtype_id=self.env.ref('mail.mt_note').id)
- if self.test_results == '返工':
- productions = self.production_id
- # self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
- # self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
- productions._create_workorder2(self.processing_panel)
- else:
- self.results = '合格'
+
+ '''
+ 创建生产计划
+ '''
+ # 工单耗时
+ workorder_duration = 0
+ for workorder in productions.workorder_ids:
+ workorder_duration += workorder.duration_expected
+
+ sale_order = self.env['sale.order'].sudo().search([('name', '=', productions.origin)])
+ if sale_order:
+ sale_order.mrp_production_ids |= productions
+ # sale_order.write({'schedule_status': 'to schedule'})
+ self.env['sf.production.plan'].sudo().with_company(self.production_id.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',
+ })
+ # if self.test_results == '返工':
+ # productions = self.production_id
+ # # self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
+ # # self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
+ # productions._create_workorder2(self.processing_panel)
+ # else:
+ # self.results = '合格'
def json_workorder_str1(self, k, production, route):
workorders_values_str = [0, '', {
@@ -720,7 +794,6 @@ class ResMrpWorkOrder(models.Model):
'name': '%s(返工)' % route.route_workcenter_id.name,
'processing_panel': k,
'routing_type': route.routing_type,
- 'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
route.routing_type,
production.product_id),
@@ -728,10 +801,37 @@ class ResMrpWorkOrder(models.Model):
'date_planned_finished': datetime.now() + timedelta(days=1),
'duration_expected': 60,
'duration': 0,
-
+ 'manual_quotation': production.workorder_ids.filtered(
+ lambda t: t.routing_type == 'CNC加工').manual_quotation,
+ 'rfid_code': production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').rfid_code,
+ 'cnc_ids': production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').cnc_ids,
+ 'cmm_ids': production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').cmm_ids,
}]
return workorders_values_str
+ # @api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state')
+ # def _compute_state(self):
+ # super(ResMrpWorkOrder, self)._compute_state()
+ # for item in self:
+ # print(item.name)
+ # print(item.state)
+ # print(item.is_remanufacture)
+ # scrap_workorder = self.env['mrp.workorder'].search(
+ # [('production_id', '=', item.production_id.id), ('routing_type', '=', 'CNC加工'),
+ # ('state', '=', 'done'), ('test_results', 'in', ['返工', '报废'])])
+ # print(scrap_workorder)
+ # # if item.routing_type == 'CNC加工' and item.state in ['done'] and item.test_results in ['返工', '报废']:
+ # if item.routing_type == '解除装夹':
+ # if scrap_workorder and item.state not in ['cancel']:
+ # item.state = 'cancel'
+ # elif item.routing_type == '表面工艺':
+ # if scrap_workorder:
+ # stock_move = self.env['stock.move'].search(
+ # [('origin', '=', item.production_id.name)])
+ # stock_move.write({'state': 'cancel'})
+ # item.picking_ids.write({'state': 'cancel'})
+ # item.state = 'cancel'
+
# 重写工单开始按钮方法
def button_start(self):
if self.routing_type == '装夹预调':
@@ -887,6 +987,7 @@ class ResMrpWorkOrder(models.Model):
raise UserError(
'请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
tem_date_planned_finished = record.date_planned_finished
+ tem_date_finished = record.date_finished
logging.info('routing_type:%s' % record.routing_type)
super().button_finish()
logging.info('date_planned_finished:%s' % record.date_planned_finished)
@@ -895,6 +996,15 @@ class ResMrpWorkOrder(models.Model):
record.write({
'date_planned_finished': tem_date_planned_finished # 保持原值
})
+ # if record.routing_type == 'CNC加工':
+ # record.write({
+ # 'date_finished': tem_date_finished # 保持原值
+ # })
+ # if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']:
+ # record.production_id.action_cancel()
+ # record.production_id.workorder_ids.write({'rfid_code': False, 'rfid_code_old': record.rfid_code})
+ # if record.is_remanufacture is True:
+ # record.recreateManufacturingOrWorkerOrder()
is_production_id = True
for workorder in record.production_id.workorder_ids:
if workorder.state != 'done':
@@ -1035,8 +1145,10 @@ class CNCprocessing(models.Model):
# 根据程序名和加工面匹配到ftp里对应的Nc程序名,可优化为根据cnc_processing.program_path进行匹配
def get_cnc_processing_file(self, serverdir, cnc_processing, program_path):
logging.info('serverdir:%s' % serverdir)
+ logging.info('cnc_processing:%s' % cnc_processing)
for root, dirs, files in os.walk(serverdir):
for f in files:
+ logging.info('splitext(f):%s' % os.path.splitext(f)[1])
if os.path.splitext(f)[1] == ".pdf":
full_path = os.path.join(serverdir, root, f)
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
@@ -1206,17 +1318,18 @@ class SfWorkOrderBarcodes(models.Model):
class WorkPieceDelivery(models.Model):
_name = "sf.workpiece.delivery"
+ _inherit = ['mail.thread', 'mail.activity.mixin']
_description = '工件配送'
- name = fields.Char('单据编号')
+ name = fields.Char('单据编码')
workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True)
workorder_state = fields.Selection(related='workorder_id.state', string='工单状态')
rfid_code = fields.Char(related='workorder_id.rfid_code', string='rfid码', store=True)
production_id = fields.Many2one('mrp.production', string='制造订单号', readonly=True)
- production_line_id = fields.Many2one('sf.production.line', string='目的生产线')
+ production_line_id = fields.Many2one('sf.production.line', string='目的生产线', tracking=True)
plan_start_processing_time = fields.Datetime('计划开始加工时间', readonly=True)
- route_id = fields.Many2one('sf.agv.task.route', '任务路线')
+ route_id = fields.Many2one('sf.agv.task.route', '任务路线', tracking=True)
feeder_station_start_id = fields.Many2one('sf.agv.site', '起点接驳站')
feeder_station_destination_id = fields.Many2one('sf.agv.site', '目的接驳站')
task_delivery_time = fields.Datetime('任务下发时间')
@@ -1225,26 +1338,41 @@ class WorkPieceDelivery(models.Model):
[('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型')
delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration')
status = fields.Selection(
- [('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发')
- is_cnc_program_down = fields.Boolean('程序是否下发', default=False)
+ [('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发',
+ tracking=True)
+ is_cnc_program_down = fields.Boolean('程序是否下发', default=False, tracking=True)
is_manual_work = fields.Boolean('人工操作', default=False)
active = fields.Boolean(string="有效", default=True)
@api.model
def create(self, vals):
- if vals.get('name', '/') == '/' or vals.get('name', '/') is False:
- vals['name'] = self.env['ir.sequence'].next_by_code('sf.workpiece.delivery') or '/'
- else:
+ if vals['route_id'] and vals.get('type') is None:
vals['type'] = '运送空料架'
+ else:
+ if vals.get('name', '/') == '/' or vals.get('name', '/') is False:
+ vals['name'] = self.env['ir.sequence'].next_by_code('sf.workpiece.delivery') or '/'
obj = super(WorkPieceDelivery, self).create(vals)
+ if obj.type == '运送空料架':
+ if obj.name is False:
+ obj.name = "运送空料架路线:%s-%s" % (
+ obj.feeder_station_start_id.name, obj.feeder_station_destination_id.name)
return obj
- @api.constrains('name')
- def _check_name(self):
+ @api.constrains('route_id')
+ def _check_route_id(self):
if self.type == '运送空料架':
- wd = self.sudo().search([('name', '=', self.name), ('id', '!=', self.id)])
- if wd:
- raise UserError("该名称已存在")
+ if self.route_id and self.name is False:
+ route = self.sudo().search(
+ [('route_id', '=', self.route_id.id), ('id', '!=', self.id), ('name', 'ilike', '运送空料架路线')])
+ if route:
+ raise UserError("该任务路线已存在,请重新选择")
+
+ # @api.constrains('name')
+ # def _check_name(self):
+ # if self.type == '运送空料架':
+ # wd = self.sudo().search([('name', '=', self.name), ('id', '!=', self.id)])
+ # if wd:
+ # raise UserError("该名称已存在")
def action_delivery_history(self):
return {
diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py
index 7d9bbac5..0753d556 100644
--- a/sf_manufacturing/models/product_template.py
+++ b/sf_manufacturing/models/product_template.py
@@ -50,8 +50,8 @@ class ResProductMo(models.Model):
cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', string='刀具物料')
cutting_tool_type = fields.Char(string="刀具物料类型", related='cutting_tool_material_id.name', store=True)
- cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='型号')
- specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='规格')
+ cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='型号名称')
+ specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='物料号')
cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='类型',
domain="[('cutting_tool_material_id.name', '=', cutting_tool_type)]")
@@ -104,6 +104,15 @@ class ResProductMo(models.Model):
compaction_way_id = fields.Many2one('maintenance.equipment.image',
'压紧方式', domain=[('type', '=', '压紧方式')])
+ name = fields.Char('产品名称', compute='_compute_tool_name', store=True, required=False)
+
+ @api.depends('cutting_tool_model_id', 'specification_id')
+ def _compute_tool_name(self):
+ for item in self:
+ if item.cutting_tool_model_id and item.specification_id:
+ name = '%s%s' % (item.cutting_tool_model_id.name, item.specification_id.name)
+ item.name = name
+
@api.onchange('cutting_tool_model_id')
def _onchange_cutting_tool_model_id(self):
for item in self:
@@ -530,6 +539,7 @@ class ResProductMo(models.Model):
# bfm下单
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
+ part_number = fields.Char(string='零件图号', readonly=True)
@api.constrains('tool_length')
def _check_tool_length_size(self):
@@ -626,6 +636,7 @@ class ResProductMo(models.Model):
'model_remark': item['remark'],
'default_code': '%s-%s' % (order_number, i),
'manual_quotation': item['manual_quotation'] or False,
+ 'part_number': item['part_number'] or '',
'active': True,
}
copy_product_id.sudo().write(vals)
@@ -721,6 +732,10 @@ class ResProductMo(models.Model):
logging.info('create-model_file:%s' % len(vals['model_file']))
self._sanitize_vals(vals)
templates = super(ResProductMo, self).create(vals_list)
+ # 产品名称唯一性校验
+ for item in templates:
+ if len(self.search([('name', '=', item.name)])) > 1:
+ raise ValidationError('产品名称【%s】已存在' % item.name)
if "create_product_product" not in self._context:
templates._create_variant_ids()
diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py
index 6874dd22..03ec8d0e 100644
--- a/sf_manufacturing/models/stock.py
+++ b/sf_manufacturing/models/stock.py
@@ -3,6 +3,7 @@ import base64
import qrcode
from collections import defaultdict, namedtuple
import logging
+import io
import json
from re import split as regex_split
from re import findall as regex_findall
@@ -207,7 +208,7 @@ class StockRule(models.Model):
'''
创建工单
'''
- productions._create_workorder()
+ productions._create_workorder(is_fetchcnc=False, scrap_production=False)
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
(
@@ -631,8 +632,8 @@ class ReStockMove(models.Model):
'reserved_uom_qty': 1.0,
'lot_id': purchase.picking_ids.move_line_ids.lot_id.id,
'company_id': self.company_id.id,
- 'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
- 'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,
+ # 'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
+ # 'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,
'state': 'assigned',
}
@@ -668,12 +669,14 @@ class ReStockMove(models.Model):
else:
view = self.env.ref('stock.view_stock_move_nosuggest_operations')
- if self.product_id.tracking == "serial" and self.state == "assigned":
- print(self.origin)
- if self.product_id.categ_id.name == '刀具':
- self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
- else:
- self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
+ if self.state == "assigned":
+ if self.product_id.tracking == "serial":
+ if self.product_id.categ_id.name == '刀具':
+ self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
+ else:
+ self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
+ elif self.product_id.tracking == "lot":
+ self._put_tool_lot(self.company_id, self.product_id, self.origin)
return {
'name': _('Detailed Operations'),
@@ -698,6 +701,35 @@ class ReStockMove(models.Model):
),
}
+ def _put_tool_lot(self, company, product, origin):
+ if product.tracking == "lot" and self.product_id.categ_id.name == '刀具':
+ if not self.move_line_nosuggest_ids:
+ lot_names = self.env['stock.lot'].generate_lot_names(
+ '%s-%s-%s' % ('%s-T-DJWL-%s' % (
+ product.cutting_tool_model_id.code.split('-')[0], product.cutting_tool_material_id.code),
+ datetime.now().strftime("%Y%m%d"), origin), 1)
+ move_lines_commands = self._generate_serial_move_line_commands_tool_lot(lot_names)
+ self.write({'move_line_nosuggest_ids': move_lines_commands})
+ for item in self.move_line_nosuggest_ids:
+ if item.lot_name:
+ item.lot_qr_code = self.compute_lot_qr_code(item.lot_name)
+
+ def compute_lot_qr_code(self, lot_name):
+ qr = qrcode.QRCode(
+ version=1,
+ error_correction=qrcode.constants.ERROR_CORRECT_L,
+ box_size=10,
+ border=4,
+ )
+ qr.add_data(lot_name)
+ qr.make(fit=True)
+ img = qr.make_image(fill_color="black", back_color="white")
+ buffer = io.BytesIO()
+ img.save(buffer, format="PNG")
+ binary_data = buffer.getvalue()
+ data = base64.b64encode(binary_data).decode() # 确保返回的是字符串形式的数据
+ return data
+
def _get_tool_next_serial(self, company, product, origin):
"""Return the next serial number to be attributed to the product."""
if product.tracking == "serial":
@@ -711,6 +743,67 @@ class ReStockMove(models.Model):
else:
return "%s-T-%s-%s-%03d" % (split_codes[0], origin, product.specification_id.name, 1)
+ def _generate_serial_move_line_commands_tool_lot(self, lot_names, origin_move_line=None):
+ """Return a list of commands to update the move lines (write on
+ existing ones or create new ones).
+ Called when user want to create and assign multiple serial numbers in
+ one time (using the button/wizard or copy-paste a list in the field).
+
+ :param lot_names: A list containing all serial number to assign.
+ :type lot_names: list
+ :param origin_move_line: A move line to duplicate the value from, default to None
+ :type origin_move_line: record of :class:`stock.move.line`
+ :return: A list of commands to create/update :class:`stock.move.line`
+ :rtype: list
+ """
+ self.ensure_one()
+
+ # Select the right move lines depending of the picking type configuration.
+ move_lines = self.env['stock.move.line']
+ if self.picking_type_id.show_reserved:
+ move_lines = self.move_line_ids.filtered(lambda ml: not ml.lot_id and not ml.lot_name)
+ else:
+ move_lines = self.move_line_nosuggest_ids.filtered(lambda ml: not ml.lot_id and not ml.lot_name)
+
+ loc_dest = origin_move_line and origin_move_line.location_dest_id
+ move_line_vals = {
+ 'picking_id': self.picking_id.id,
+ 'location_id': self.location_id.id,
+ 'product_id': self.product_id.id,
+ 'product_uom_id': self.product_id.uom_id.id,
+ 'qty_done': self.product_uom_qty,
+ }
+ if origin_move_line:
+ # `owner_id` and `package_id` are taken only in the case we create
+ # new move lines from an existing move line. Also, updates the
+ # `qty_done` because it could be usefull for products tracked by lot.
+ move_line_vals.update({
+ 'owner_id': origin_move_line.owner_id.id,
+ 'package_id': origin_move_line.package_id.id,
+ 'qty_done': origin_move_line.qty_done or 1,
+ })
+
+ move_lines_commands = []
+ qty_by_location = defaultdict(float)
+ for lot_name in lot_names:
+ # We write the lot name on an existing move line (if we have still one)...
+ if move_lines:
+ move_lines_commands.append((1, move_lines[0].id, {
+ 'lot_name': lot_name,
+ 'qty_done': 1,
+ }))
+ qty_by_location[move_lines[0].location_dest_id.id] += 1
+ move_lines = move_lines[1:]
+ # ... or create a new move line with the serial name.
+ else:
+ loc = loc_dest or self.location_dest_id._get_putaway_strategy(self.product_id, quantity=1,
+ packaging=self.product_packaging_id,
+ additional_qty=qty_by_location)
+ move_line_cmd = dict(move_line_vals, lot_name=lot_name, location_dest_id=loc.id)
+ move_lines_commands.append((0, 0, move_line_cmd))
+ qty_by_location[loc.id] += 1
+ return move_lines_commands
+
class ReStockQuant(models.Model):
_inherit = 'stock.quant'
diff --git a/sf_manufacturing/views/agv_setting_views.xml b/sf_manufacturing/views/agv_setting_views.xml
index 42662e2c..377bee74 100644
--- a/sf_manufacturing/views/agv_setting_views.xml
+++ b/sf_manufacturing/views/agv_setting_views.xml
@@ -7,9 +7,9 @@
sf.agv.site
-
-
-
+
+
+
@@ -34,12 +34,14 @@
sf.agv.task.route
-
+
-
-
+
+
-
+
@@ -73,7 +75,8 @@
center_control.interface.log
-
+
+
diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml
index c5616242..55dbbe33 100644
--- a/sf_manufacturing/views/mrp_production_addional_change.xml
+++ b/sf_manufacturing/views/mrp_production_addional_change.xml
@@ -87,7 +87,7 @@
-
+
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index bc1d4bfe..11219363 100644
--- a/sf_manufacturing/views/mrp_workorder_view.xml
+++ b/sf_manufacturing/views/mrp_workorder_view.xml
@@ -80,7 +80,7 @@
tree,form
-
+
current
[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]
@@ -214,7 +214,7 @@
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
-
@@ -477,8 +477,13 @@
-
-
+
+
+
+
+
+
+
@@ -573,7 +578,7 @@
-
+
@@ -604,7 +609,7 @@
工件配送
sf.workpiece.delivery
-
+
@@ -612,13 +617,13 @@
decoration-success="status == '已配送'"
decoration-warning="status == '待下发'"
decoration-danger="status == '待配送'"/>
+
-
@@ -629,13 +634,58 @@
+
+ 工件配送
+ sf.workpiece.delivery
+
+
+
+
+
工件配送
sf.workpiece.delivery
-
-
+
+
+
@@ -657,8 +707,10 @@
工件配送
sf.workpiece.delivery
- {'search_default_on_up':1}
- tree,search
+ {'search_default_filter_to_be_issued': 1,
+ 'search_default_filter_waiting_delivery': 1}
+
+ tree,form
[('type','in',['上产线','下产线']),('workorder_state','=','done'),('is_manual_work','=',false)]
@@ -671,23 +723,39 @@
sf.workpiece.delivery
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
空料架配送
sf.workpiece.delivery
@@ -710,6 +778,7 @@
sf.workpiece.delivery
+
diff --git a/sf_mrs_connect/models/ftp_operate.py b/sf_mrs_connect/models/ftp_operate.py
index 3a09a305..4cd5e3ba 100644
--- a/sf_mrs_connect/models/ftp_operate.py
+++ b/sf_mrs_connect/models/ftp_operate.py
@@ -32,6 +32,9 @@ class FtpController():
logging.error(f"Error checking file: {e}")
return False
+
+
+
# # 检测字符串的编码
# def detect_encoding(self, s):
# result = chardet.detect(s)
@@ -43,6 +46,8 @@ class FtpController():
os.makedirs(serverdir)
try:
logging.info("进入FTP目录 ")
+ self.ftp.pwd()
+ logging.info('当前目录:%s' % self.ftp.pwd())
logging.info('目录:%s' % target_dir)
target_dir1 = target_dir.split('/')
logging.info('目录1:%s' % target_dir1[1])
diff --git a/sf_mrs_connect/models/res_config_setting.py b/sf_mrs_connect/models/res_config_setting.py
index 035b10a0..159e8d48 100644
--- a/sf_mrs_connect/models/res_config_setting.py
+++ b/sf_mrs_connect/models/res_config_setting.py
@@ -26,6 +26,7 @@ class ResConfigSettings(models.TransientModel):
ftp_port = fields.Char(string='FTP端口')
ftp_user = fields.Char(string='FTP用户')
ftp_password = fields.Char(string='FTP密码')
+ enable_tool_presetter = fields.Boolean('是否启用刀具预调仪', default=True)
def sf_all_sync(self):
try:
@@ -108,6 +109,7 @@ class ResConfigSettings(models.TransientModel):
ftp_port = config.get_param('ftp_port', default='')
ftp_user = config.get_param('ftp_user', default='')
ftp_password = config.get_param('ftp_password', default='')
+ enable_tool_presetter = config.get_param('enable_tool_presetter', default='')
values.update(
token=token,
@@ -121,7 +123,8 @@ class ResConfigSettings(models.TransientModel):
ftp_host=ftp_host,
ftp_port=ftp_port,
ftp_user=ftp_user,
- ftp_password=ftp_password
+ ftp_password=ftp_password,
+ enable_tool_presetter=enable_tool_presetter
)
return values
@@ -140,3 +143,4 @@ class ResConfigSettings(models.TransientModel):
ir_config.set_param("ftp_port", self.ftp_port or "")
ir_config.set_param("ftp_user", self.ftp_user or "")
ir_config.set_param("ftp_password", self.ftp_password or "")
+ ir_config.set_param("enable_tool_presetter", self.enable_tool_presetter or False)
diff --git a/sf_mrs_connect/views/res_config_settings_views.xml b/sf_mrs_connect/views/res_config_settings_views.xml
index 2be92365..08e9560f 100644
--- a/sf_mrs_connect/views/res_config_settings_views.xml
+++ b/sf_mrs_connect/views/res_config_settings_views.xml
@@ -114,6 +114,21 @@
+
diff --git a/sf_plan/views/view.xml b/sf_plan/views/view.xml
index c240bed0..3b53efc2 100644
--- a/sf_plan/views/view.xml
+++ b/sf_plan/views/view.xml
@@ -135,12 +135,13 @@
-
-
-
-
+
+
+
+
+
diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py
index 259655ee..e3bf3002 100644
--- a/sf_sale/models/quick_easy_order.py
+++ b/sf_sale/models/quick_easy_order.py
@@ -19,6 +19,7 @@ from . import parser_and_calculate_work_time as pc
class QuickEasyOrder(models.Model):
_name = 'quick.easy.order'
+ _inherit = ['mail.thread', 'mail.activity.mixin']
_description = '简易下单'
_order = 'id desc'
@@ -35,13 +36,14 @@ class QuickEasyOrder(models.Model):
('0.03', '±0.03mm'),
('0.02', '±0.02mm'),
('0.01', '±0.01mm')], string='加工精度', default='0.10')
- material_id = fields.Many2one('sf.production.materials', '材料')
- material_model_id = fields.Many2one('sf.materials.model', '型号')
+ material_id = fields.Many2one('sf.production.materials', '材料', tracking=True)
+ material_model_id = fields.Many2one('sf.materials.model', '型号', tracking=True)
# process_id = fields.Many2one('sf.production.process', string='表面工艺')
- parameter_ids = fields.Many2many('sf.production.process.parameter', 'process_item_order_rel', string='可选参数')
- quantity = fields.Integer('数量', default=1)
- unit_price = fields.Float('单价')
- price = fields.Float('总价')
+ parameter_ids = fields.Many2many('sf.production.process.parameter', 'process_item_order_rel', string='可选参数',
+ tracking=True)
+ quantity = fields.Integer('数量', default=1, tracking=True)
+ unit_price = fields.Float('单价', tracking=True)
+ price = fields.Float('总价', tracking=True)
model_file = fields.Binary('glb模型文件')
upload_model_file = fields.Many2many('ir.attachment', 'upload_qf_model_file_attachment_ref', string='上传模型文件')
delivery_time = fields.Date('交货日期')
@@ -49,10 +51,10 @@ class QuickEasyOrder(models.Model):
state = fields.Selection([('草稿', '草稿'), ('待派单', '待派单'),
('待接单', '待接单'), ('加工中', '加工中'),
('物流中', '物流中'), ('已交付', '已交付')], string='订单状态', default='草稿',
- readonly=True)
+ readonly=True, tracking=True)
model_color_state = fields.Selection([
('success', '成功'),
- ('fail', '失败')], string='模型上色状态')
+ ('fail', '失败')], string='模型上色状态', tracking=True)
processing_time = fields.Integer('加工时长(min)')
sale_order_id = fields.Many2one('sale.order', '销售订单号')
@@ -94,8 +96,7 @@ class QuickEasyOrder(models.Model):
obj.state = '待接单'
return obj
-
- def model_analyze(self,model_attachment):
+ def model_analyze(self, model_attachment):
"""
step模型解析,上传模型时转为web可显示的格式
:return:
diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py
index dc4c588f..3ae65db3 100644
--- a/sf_sale/models/quick_easy_order_old.py
+++ b/sf_sale/models/quick_easy_order_old.py
@@ -16,6 +16,7 @@ from odoo.exceptions import ValidationError, UserError
class QuickEasyOrder(models.Model):
_name = 'quick.easy.order'
+ _inherit = ['mail.thread', 'mail.activity.mixin']
_description = '简易下单'
_order = 'id desc'
@@ -32,13 +33,15 @@ class QuickEasyOrder(models.Model):
('0.03', '±0.03mm'),
('0.02', '±0.02mm'),
('0.01', '±0.01mm')], string='加工精度', default='0.10')
- material_id = fields.Many2one('sf.production.materials', '材料')
- material_model_id = fields.Many2one('sf.materials.model', '型号', domain="[('materials_id', '=', material_id)]")
+ material_id = fields.Many2one('sf.production.materials', '材料', tracking=True)
+ material_model_id = fields.Many2one('sf.materials.model', '型号', domain="[('materials_id', '=', material_id)]",
+ tracking=True)
# process_id = fields.Many2one('sf.production.process', string='表面工艺')
- parameter_ids = fields.Many2many('sf.production.process.parameter', 'process_item_order_rel', string='可选参数')
- quantity = fields.Integer('数量', default=1)
- unit_price = fields.Float('单价')
- price = fields.Float('总价')
+ parameter_ids = fields.Many2many('sf.production.process.parameter', 'process_item_order_rel', string='可选参数',
+ tracking=True)
+ quantity = fields.Integer('数量', default=1, tracking=True)
+ unit_price = fields.Float('单价', tracking=True)
+ price = fields.Float('总价', tracking=True)
model_file = fields.Binary('glb模型文件')
upload_model_file = fields.Many2many('ir.attachment', 'upload_qf_model_file_attachment_ref', string='上传模型文件')
delivery_time = fields.Date('交货日期')
@@ -46,10 +49,10 @@ class QuickEasyOrder(models.Model):
state = fields.Selection([('草稿', '草稿'), ('待派单', '待派单'),
('待接单', '待接单'), ('加工中', '加工中'),
('物流中', '物流中'), ('已交付', '已交付')], string='订单状态', default='草稿',
- readonly=True)
+ readonly=True, tracking=True)
model_color_state = fields.Selection([
('success', '成功'),
- ('fail', '失败')], string='模型上色状态')
+ ('fail', '失败')], string='模型上色状态', tracking=True)
processing_time = fields.Integer('加工时长(min)')
sale_order_id = fields.Many2one('sale.order', '销售订单号')
diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py
index e168292b..9486f73c 100644
--- a/sf_sale/models/sale_order.py
+++ b/sf_sale/models/sale_order.py
@@ -233,12 +233,12 @@ class ResPartnerToSale(models.Model):
if obj:
raise UserError('该税ID已存在,请重新输入')
- @api.constrains('email')
- def _check_email(self):
- if self.customer_rank > 0:
- obj = self.sudo().search([('email', '=', self.email), ('id', '!=', self.id), ('active', '=', True)])
- if obj:
- raise UserError('该邮箱已存在,请重新输入')
+ # @api.constrains('email')
+ # def _check_email(self):
+ # if self.customer_rank > 0:
+ # obj = self.sudo().search([('email', '=', self.email), ('id', '!=', self.id), ('active', '=', True)])
+ # if obj:
+ # raise UserError('该邮箱已存在,请重新输入')
@api.model
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
diff --git a/sf_sale/views/quick_easy_order_view.xml b/sf_sale/views/quick_easy_order_view.xml
index 896d3704..b16a673f 100644
--- a/sf_sale/views/quick_easy_order_view.xml
+++ b/sf_sale/views/quick_easy_order_view.xml
@@ -84,6 +84,11 @@
+
+
+
+
+
diff --git a/sf_sale/views/res_partner_view.xml b/sf_sale/views/res_partner_view.xml
index cc8f49fb..a680bd7c 100644
--- a/sf_sale/views/res_partner_view.xml
+++ b/sf_sale/views/res_partner_view.xml
@@ -24,18 +24,18 @@
1
{'readonly': [('id','!=', False)]}
-
-
-
-
- {'required': [('phone', '=', False)],'readonly': [('id','!=', False)]}
-
-
-
- {'required': [('mobile', '=', False)],'readonly': [('id','!=', False)]}
-
-
+
+
+
+
+
+
+
+
+
+
+
+
{'readonly': [('id','!=', False)]}
@@ -56,10 +56,10 @@
-
- 1
- {'readonly': [('id','!=', False)]}
-
+
+
+
+
{'readonly': [('id','!=', False)]}
@@ -101,7 +101,7 @@
+ attrs="{'required' : [('supplier_rank','>', 0)]}"/>
{'readonly': [('id','!=', False)]}
@@ -195,10 +195,10 @@
{'invisible': [('customer_rank','=', 0)]}
-
-
-
+
+
+
+
diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml
index 0981ff59..647cf8ef 100644
--- a/sf_sale/views/sale_order_view.xml
+++ b/sf_sale/views/sale_order_view.xml
@@ -1,54 +1,6 @@
-
- sale.order.search.inherit.sf
- sale.order
- primary
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 报价
- ir.actions.act_window
- sale.order
-
- tree,kanban,form,calendar,pivot,graph,activity
-
- {'search_default_my_quotation': 1}
-
-
- Create a new quotation, the first step of a new sale!
-
-
- Once the quotation is confirmed by the customer, it becomes a sales order.
-
- You will be able to create an invoice and collect the payment.
-
-
-
-
-
-
-
-
-
-
-
sale.order.form.inherit.sf
sale.order
diff --git a/sf_tool_management/controllers/controllers.py b/sf_tool_management/controllers/controllers.py
index 4b68e3f8..baba93fc 100644
--- a/sf_tool_management/controllers/controllers.py
+++ b/sf_tool_management/controllers/controllers.py
@@ -126,4 +126,4 @@ class Manufacturing_Connect(http.Controller):
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('put_tool_preset_parameter_port error:%s' % e)
- return json.JSONEncoder().encode(res)
\ No newline at end of file
+ return json.JSONEncoder().encode(res)
diff --git a/sf_tool_management/data/tool_data.xml b/sf_tool_management/data/tool_data.xml
index 282f8c2a..4df37127 100644
--- a/sf_tool_management/data/tool_data.xml
+++ b/sf_tool_management/data/tool_data.xml
@@ -5,8 +5,8 @@
code
model._cron_tool_datasync_all()
- 1
- days
+ 12
+ hours
-1
\ No newline at end of file
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 11ea4ac4..bbcf9927 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -181,6 +181,7 @@ class MachineTableToolChangingApply(models.Model):
class CAMWorkOrderProgramKnifePlan(models.Model):
_name = 'sf.cam.work.order.program.knife.plan'
+ _inherit = ['mail.thread']
_description = 'CAM工单程序用刀计划'
name = fields.Char('工单任务编号')
@@ -228,7 +229,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
estimated_processing_time = fields.Char('预计加工时间')
plan_execute_status = fields.Selection([('0', '待下发'), ('1', '执行中'), ('2', '已完成')],
- string='计划执行状态', default='0', readonly=False)
+ string='计划执行状态', default='0', readonly=False, tracking=True)
sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True)
@@ -282,7 +283,8 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
'loading_task_source': '0',
'applicant': self.env.user.name,
- 'use_tool_time': self.need_knife_time,
+ 'use_tool_time': fields.Datetime.now() + timedelta(
+ hours=4) if not self.need_knife_time else self.need_knife_time,
'reason_for_applying': '工单用刀',
'sf_cam_work_order_program_knife_plan_id': self.id
@@ -362,6 +364,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
class FunctionalToolAssembly(models.Model):
_name = 'sf.functional.tool.assembly'
+ _inherit = ['mail.thread']
_description = '功能刀具组装'
_order = 'assemble_status, use_tool_time asc'
@@ -396,7 +399,7 @@ class FunctionalToolAssembly(models.Model):
applicant = fields.Char(string='申请人', readonly=True)
apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True)
assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态', default='0',
- readonly=True)
+ tracking=True, readonly=True)
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True)
whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True)
reason_for_applying = fields.Char(string='申请原因', readonly=True)
@@ -413,8 +416,9 @@ class FunctionalToolAssembly(models.Model):
return categories.browse(functional_tool_type_ids)
# 刀具物料信息
- # ==============整体式刀具型号============
- integral_freight_barcode = fields.Char('整体式刀具货位')
+ # ==============整体式刀具型号=============
+ integral_freight_barcode_id = fields.Many2one('sf.shelf.location', string='整体式刀具货位')
+ integral_lot_id = fields.Many2one('stock.lot', string='整体式刀具批次')
integral_product_id = fields.Many2one('product.product', string='整体式刀具名称',
compute='_compute_integral_product_id', store=True)
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
@@ -424,19 +428,15 @@ class FunctionalToolAssembly(models.Model):
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
related='integral_product_id.brand_id')
- @api.depends('integral_freight_barcode')
+ @api.depends('integral_lot_id')
def _compute_integral_product_id(self):
for item in self:
- if item.integral_freight_barcode:
- location = self.env['sf.shelf.location'].sudo().search(
- [('barcode', '=', item.integral_freight_barcode)])
- if location:
- item.integral_product_id = location.product_id.id
- else:
- item.integral_product_id = False
+ if item.integral_lot_id:
+ item.integral_product_id = item.integral_lot_id.product_id.id
# =================刀片型号=============
- blade_freight_barcode = fields.Char('刀片货位')
+ blade_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀片货位')
+ blade_lot_id = fields.Many2one('stock.lot', string='刀片批次')
blade_product_id = fields.Many2one('product.product', string='刀片名称', compute='_compute_blade_product_id',
store=True)
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
@@ -445,18 +445,15 @@ class FunctionalToolAssembly(models.Model):
related='blade_product_id.specification_id')
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id')
- @api.depends('blade_freight_barcode')
+ @api.depends('blade_lot_id')
def _compute_blade_product_id(self):
for item in self:
- if item.blade_freight_barcode:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.blade_freight_barcode)])
- if location:
- item.blade_product_id = location.product_id.id
- else:
- item.blade_product_id = False
+ if item.blade_lot_id:
+ item.blade_product_id = item.blade_lot_id.product_id.id
# ==============刀杆型号================
- bar_freight_barcode = fields.Char('刀杆货位')
+ bar_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀杆货位')
+ bar_lot_id = fields.Many2one('stock.lot', string='刀杆批次')
bar_product_id = fields.Many2one('product.product', string='刀杆名称', compute='_compute_bar_product_id',
store=True)
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
@@ -465,18 +462,15 @@ class FunctionalToolAssembly(models.Model):
related='bar_product_id.specification_id')
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id')
- @api.depends('bar_freight_barcode')
+ @api.depends('bar_lot_id')
def _compute_bar_product_id(self):
for item in self:
- if item.bar_freight_barcode:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.bar_freight_barcode)])
- if location:
- item.bar_product_id = location.product_id.id
- else:
- item.bar_product_id = False
+ if item.bar_lot_id:
+ item.bar_product_id = item.bar_lot_id.product_id.id
# =============刀盘型号================
- pad_freight_barcode = fields.Char('刀盘货位')
+ pad_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀盘货位')
+ pad_lot_id = fields.Many2one('stock.lot', string='刀盘批次')
pad_product_id = fields.Many2one('product.product', string='刀盘名称', compute='_compute_pad_product_id',
store=True)
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
@@ -485,15 +479,11 @@ class FunctionalToolAssembly(models.Model):
related='pad_product_id.specification_id')
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id')
- @api.depends('pad_freight_barcode')
+ @api.depends('pad_lot_id')
def _compute_pad_product_id(self):
for item in self:
- if item.pad_freight_barcode:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.pad_freight_barcode)])
- if location:
- item.pad_product_id = location.product_id.id
- else:
- item.pad_product_id = False
+ if item.pad_lot_id:
+ item.pad_product_id = item.pad_lot_id.product_id.id
# ==============刀柄型号==============
handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_handle_product_id', store=True)
@@ -517,7 +507,8 @@ class FunctionalToolAssembly(models.Model):
item.handle_freight_rfid = False
# ==============夹头型号==============
- chuck_freight_barcode = fields.Char('夹头货位')
+ chuck_freight_barcode_id = fields.Many2one('sf.shelf.location', string='夹头货位')
+ chuck_lot_id = fields.Many2one('stock.lot', string='夹头批次')
chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id',
store=True)
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
@@ -526,17 +517,18 @@ class FunctionalToolAssembly(models.Model):
related='chuck_product_id.specification_id')
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id')
- @api.depends('chuck_freight_barcode')
+ @api.depends('chuck_lot_id')
def _compute_chuck_product_id(self):
for item in self:
- if item.chuck_freight_barcode:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.chuck_freight_barcode)])
- if location:
- item.chuck_product_id = location.product_id.id
- else:
- item.chuck_product_id = False
+ if item.chuck_lot_id:
+ item.chuck_product_id = item.chuck_lot_id.product_id.id
# ==================待删除字段==================
+ integral_freight_barcode = fields.Char('整体式刀具货位')
+ blade_freight_barcode = fields.Char('刀片货位')
+ bar_freight_barcode = fields.Char('刀杆货位')
+ pad_freight_barcode = fields.Char('刀盘货位')
+ chuck_freight_barcode = fields.Char('夹头货位')
blade_name = fields.Char('')
integral_name = fields.Char('')
blade_code_id = fields.Many2one('stock.lot', '刀片序列号')
@@ -679,7 +671,7 @@ class FunctionalToolAssembly(models.Model):
class FunctionalToolDismantle(models.Model):
_name = 'sf.functional.tool.dismantle'
- _inherit = ["barcodes.barcode_events_mixin"]
+ _inherit = ["barcodes.barcode_events_mixin", 'mail.thread']
_description = '功能刀具拆解'
def on_barcode_scanned(self, barcode):
@@ -740,6 +732,22 @@ class FunctionalToolDismantle(models.Model):
raise ValidationError('该功能刀具因为%s拆解,无需录入库位' % self.dismantle_cause)
name = fields.Char('名称', related='functional_tool_id.name')
+ code = fields.Char('拆解单号', default=lambda self: self._get_code(), readonly=True)
+
+ def _get_code(self):
+ """
+ 自动生成拆解单编码
+ """
+ new_time = str(fields.Date.today())
+ datetime = new_time[2:4] + new_time[5:7] + new_time[-2:]
+ functional_tool_dismantle = self.env['sf.functional.tool.dismantle'].sudo().search(
+ [('code', 'ilike', datetime)], limit=1, order="id desc")
+ if not functional_tool_dismantle:
+ num = "%03d" % 1
+ else:
+ m = int(functional_tool_dismantle.code[-3:]) + 1
+ num = "%03d" % m
+ return 'GNDJ-CJD-%s-%s' % (datetime, num)
functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True,
domain=[('functional_tool_status', '!=', '已拆除')])
@@ -753,7 +761,7 @@ class FunctionalToolDismantle(models.Model):
dismantle_cause = fields.Selection(
[('寿命到期报废', '寿命到期报废'), ('崩刀报废', '崩刀报废'), ('更换为其他刀具', '更换为其他刀具'),
- ('刀具需磨削', '刀具需磨削')], string='拆解原因', required=True)
+ ('刀具需磨削', '刀具需磨削')], string='拆解原因', required=True, tracking=True)
dismantle_data = fields.Datetime('拆解日期', readonly=True)
dismantle_person = fields.Char('拆解人', readonly=True)
image = fields.Binary('图片', readonly=True)
@@ -761,7 +769,7 @@ class FunctionalToolDismantle(models.Model):
scrap_id = fields.Char('报废单号', readonly=True)
grinding_id = fields.Char('磨削单号', readonly=True)
- state = fields.Selection([('待拆解', '待拆解'), ('已拆解', '已拆解')], default='待拆解')
+ state = fields.Selection([('待拆解', '待拆解'), ('已拆解', '已拆解')], default='待拆解', tracking=True)
active = fields.Boolean('有效', default=True)
# 刀柄
@@ -771,7 +779,9 @@ class FunctionalToolDismantle(models.Model):
related='handle_product_id.cutting_tool_model_id')
handle_brand_id = fields.Many2one('sf.machine.brand', string='刀柄品牌', related='handle_product_id.brand_id')
handle_rfid = fields.Char(string='刀柄Rfid', compute='_compute_functional_tool_num', store=True)
- scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False)
+ handle_lot_id = fields.Many2one('stock.lot', string='刀柄序列号', compute='_compute_functional_tool_num',
+ store=True)
+ scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False, tracking=True)
# 整体式
integral_product_id = fields.Many2one('product.product', string='整体式刀具',
@@ -780,6 +790,8 @@ class FunctionalToolDismantle(models.Model):
related='integral_product_id.cutting_tool_model_id')
integral_brand_id = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
related='integral_product_id.brand_id')
+ integral_lot_id = fields.Many2one('stock.lot', string='整体式刀具批次', compute='_compute_functional_tool_num',
+ store=True)
integral_freight_id = fields.Many2one('sf.shelf.location', '整体式刀具目标货位',
domain="[('product_id', 'in', (integral_product_id, False))]")
@@ -789,6 +801,7 @@ class FunctionalToolDismantle(models.Model):
blade_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
related='blade_product_id.cutting_tool_model_id')
blade_brand_id = fields.Many2one('sf.machine.brand', string='刀片品牌', related='blade_product_id.brand_id')
+ blade_lot_id = fields.Many2one('stock.lot', string='刀片批次', compute='_compute_functional_tool_num', store=True)
blade_freight_id = fields.Many2one('sf.shelf.location', '刀片目标货位',
domain="[('product_id', 'in', (blade_product_id, False))]")
@@ -798,6 +811,7 @@ class FunctionalToolDismantle(models.Model):
bar_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
related='bar_product_id.cutting_tool_model_id')
bar_brand_id = fields.Many2one('sf.machine.brand', string='刀杆品牌', related='bar_product_id.brand_id')
+ bar_lot_id = fields.Many2one('stock.lot', string='刀杆批次', compute='_compute_functional_tool_num', store=True)
bar_freight_id = fields.Many2one('sf.shelf.location', '刀杆目标货位',
domain="[('product_id', 'in', (bar_product_id, False))]")
@@ -807,6 +821,7 @@ class FunctionalToolDismantle(models.Model):
pad_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
related='pad_product_id.cutting_tool_model_id')
pad_brand_id = fields.Many2one('sf.machine.brand', string='刀盘品牌', related='pad_product_id.brand_id')
+ pad_lot_id = fields.Many2one('stock.lot', string='刀盘批次', compute='_compute_functional_tool_num', store=True)
pad_freight_id = fields.Many2one('sf.shelf.location', '刀盘目标货位',
domain="[('product_id', 'in', (pad_product_id, False))]")
@@ -816,6 +831,7 @@ class FunctionalToolDismantle(models.Model):
chuck_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
related='chuck_product_id.cutting_tool_model_id')
chuck_brand_id = fields.Many2one('sf.machine.brand', string='夹头品牌', related='chuck_product_id.brand_id')
+ chuck_lot_id = fields.Many2one('stock.lot', string='夹头批次', compute='_compute_functional_tool_num', store=True)
chuck_freight_id = fields.Many2one('sf.shelf.location', '夹头目标货位',
domain="[('product_id', 'in', (chuck_product_id, False))]")
@@ -839,12 +855,20 @@ class FunctionalToolDismantle(models.Model):
item.rfid = item.functional_tool_id.rfid
item.handle_rfid = item.functional_tool_id.rfid
+ # 产品
item.handle_product_id = item.functional_tool_id.functional_tool_name_id.handle_product_id.id
item.integral_product_id = item.functional_tool_id.functional_tool_name_id.integral_product_id.id
item.blade_product_id = item.functional_tool_id.functional_tool_name_id.blade_product_id.id
item.bar_product_id = item.functional_tool_id.functional_tool_name_id.bar_product_id.id
item.pad_product_id = item.functional_tool_id.functional_tool_name_id.pad_product_id.id
item.chuck_product_id = item.functional_tool_id.functional_tool_name_id.chuck_product_id.id
+ # 批次/序列号
+ item.handle_lot_id = item.functional_tool_id.functional_tool_name_id.handle_code_id.id
+ item.integral_lot_id = item.functional_tool_id.functional_tool_name_id.integral_lot_id.id
+ item.blade_lot_id = item.functional_tool_id.functional_tool_name_id.blade_lot_id.id
+ item.bar_lot_id = item.functional_tool_id.functional_tool_name_id.bar_lot_id.id
+ item.pad_lot_id = item.functional_tool_id.functional_tool_name_id.pad_lot_id.id
+ item.chuck_lot_id = item.functional_tool_id.functional_tool_name_id.chuck_lot_id.id
else:
item.tool_groups_id = False
item.tool_type_id = False
@@ -860,14 +884,45 @@ class FunctionalToolDismantle(models.Model):
item.pad_product_id = False
item.chuck_product_id = False
+ item.handle_lot_id = False
+ item.integral_lot_id = False
+ item.blade_lot_id = False
+ item.bar_lot_id = False
+ item.pad_lot_id = False
+ item.chuck_lot_id = False
+
+ def location_duplicate_check(self):
+ """
+ 目标货位去重校验
+ """
+ if self.blade_freight_id:
+ if self.bar_freight_id:
+ if self.blade_freight_id == self.bar_freight_id:
+ raise ValidationError('【刀片】和【刀杆】的目标货位重复,请重新选择!')
+ elif self.pad_freight_id:
+ if self.blade_freight_id == self.pad_freight_id:
+ raise ValidationError('【刀片】和【刀盘】的目标货位重复,请重新选择!')
+ if self.chuck_freight_id:
+ if self.chuck_freight_id == self.integral_freight_id:
+ raise ValidationError('【夹头】和【整体式刀具】的目标货位重复,请重新选择!')
+ if self.chuck_freight_id == self.blade_freight_id:
+ raise ValidationError('【夹头】和【刀片】的目标货位重复,请重新选择!')
+ if self.chuck_freight_id == self.bar_freight_id:
+ raise ValidationError('【夹头】和【刀杆】的目标货位重复,请重新选择!')
+ if self.chuck_freight_id == self.pad_freight_id:
+ raise ValidationError('【夹头】和【刀盘】的目标货位重复,请重新选择!')
+
def confirmation_disassembly(self):
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
+ code = self.code
if self.functional_tool_id.functional_tool_status == '已拆除':
raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
# 对拆解的功能刀具进行校验,只有在刀具房的功能刀具才能拆解
if self.functional_tool_id.tool_room_num == 0:
raise ValidationError('Rfid为【%s】的功能刀具当前位置为【%s】,不能进行拆解!' % (
self.rfid, self.functional_tool_id.current_location))
+ # 目标重复校验
+ self.location_duplicate_check()
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
# =================刀柄是否[报废]拆解=======
@@ -879,53 +934,62 @@ class FunctionalToolDismantle(models.Model):
functional_tool_assembly = self.functional_tool_id.functional_tool_name_id
if self.scrap_boolean:
# 刀柄报废 入库到Scrap
- lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, '功能刀具拆解',
+ lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, code,
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
else:
# 刀柄不报废 入库到刀具房
- lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, '功能刀具拆解',
+ lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, code,
functional_tool_assembly, functional_tool_assembly.tool_groups_id)
# ==============功能刀具[报废]拆解================
if self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
# 除刀柄外物料报废 入库到Scrap
if self.integral_product_id:
- self.integral_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
+ self.integral_product_id.dismantle_stock_moves(False, self.integral_lot_id, location,
+ location_dest_scrap, code)
elif self.blade_product_id:
- self.blade_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
+ self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location, location_dest_scrap,
+ code)
if self.bar_product_id:
- self.bar_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
+ self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location, location_dest_scrap,
+ code)
elif self.pad_product_id:
- self.pad_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
+ self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location, location_dest_scrap,
+ code)
if self.chuck_product_id:
- self.chuck_product_id.dismantle_stock_moves(False, location, location_dest_scrap)
+ self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location, location_dest_scrap,
+ code)
# ===========功能刀具[磨削]拆解==============
- elif self.dismantle_cause in ['刀具需磨削']:
- location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
- # 除刀柄外物料拆解 入库到具体库位
- if self.integral_product_id:
- self.integral_product_id.dismantle_stock_moves(False, location, location_dest)
- elif self.blade_product_id:
- self.blade_product_id.dismantle_stock_moves(False, location, location_dest)
- if self.bar_product_id:
- self.bar_product_id.dismantle_stock_moves(False, location, location_dest)
- elif self.pad_product_id:
- self.pad_product_id.dismantle_stock_moves(False, location, location_dest)
- if self.chuck_product_id:
- self.chuck_product_id.dismantle_stock_moves(False, location, location_dest)
- # ==============功能刀具[更换]拆解==============
- elif self.dismantle_cause in ['更换为其他刀具']:
- # 除刀柄外物料拆解 入库到具体库位
+ # elif self.dismantle_cause in ['刀具需磨削']:
+ # location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
+ # # 除刀柄外物料拆解 入库到具体库位
+ # if self.integral_product_id:
+ # self.integral_product_id.dismantle_stock_moves(False, location, location_dest)
+ # elif self.blade_product_id:
+ # self.blade_product_id.dismantle_stock_moves(False, location, location_dest)
+ # if self.bar_product_id:
+ # self.bar_product_id.dismantle_stock_moves(False, location, location_dest)
+ # elif self.pad_product_id:
+ # self.pad_product_id.dismantle_stock_moves(False, location, location_dest)
+ # if self.chuck_product_id:
+ # self.chuck_product_id.dismantle_stock_moves(False, location, location_dest)
+ # ==============功能刀具[更换,磨削]拆解==============
+ elif self.dismantle_cause in ['更换为其他刀具', '刀具需磨削']:
+ # 除刀柄外物料拆解 入库到具体货位
if self.integral_freight_id:
- self.integral_product_id.dismantle_stock_moves(self.integral_freight_id.barcode, location,
- location_dest)
+ self.integral_product_id.dismantle_stock_moves(self.integral_freight_id, self.integral_lot_id, location,
+ location_dest, code)
elif self.blade_freight_id:
- self.blade_product_id.dismantle_stock_moves(self.blade_freight_id.barcode, location, location_dest)
+ self.blade_product_id.dismantle_stock_moves(self.blade_freight_id, self.blade_lot_id, location,
+ location_dest, code)
if self.bar_freight_id:
- self.bar_product_id.dismantle_stock_moves(self.bar_freight_id.barcode, location, location_dest)
+ self.bar_product_id.dismantle_stock_moves(self.bar_freight_id, self.bar_lot_id, location,
+ location_dest, code)
elif self.pad_freight_id:
- self.pad_product_id.dismantle_stock_moves(self.pad_freight_id.barcode, location, location_dest)
+ self.pad_product_id.dismantle_stock_moves(self.pad_freight_id, self.pad_lot_id, location,
+ location_dest, code)
if self.chuck_freight_id:
- self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id.barcode, location, location_dest)
+ self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id, self.chuck_lot_id, location,
+ location_dest, code)
# ===============删除功能刀具的Rfid字段的值, 赋值给Rfid(已拆解)字段=====
self.functional_tool_id.write({
'rfid_dismantle': self.functional_tool_id.rfid,
@@ -946,26 +1010,22 @@ class FunctionalToolDismantle(models.Model):
class ProductProduct(models.Model):
_inherit = 'product.product'
- def dismantle_stock_moves(self, shelf_location_barcode, location_id, location_dest_id):
+ def dismantle_stock_moves(self, shelf_location_id, lot_id, location_id, location_dest_id, code):
# 创建功能刀具拆解单产品库存移动记录
stock_move_id = self.env['stock.move'].sudo().create({
- 'name': '功能刀具拆解',
+ 'name': code,
'product_id': self.id,
'location_id': location_id.id,
'location_dest_id': location_dest_id.id,
'product_uom_qty': 1.00,
'state': 'done'
})
- if shelf_location_barcode:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)])
- location.product_num = location.product_num + 1
- else:
- location = self.env['sf.shelf.location']
# 创建移动历史记录
stock_move_line_id = self.env['stock.move.line'].sudo().create({
'product_id': self.id,
+ 'lot_id': lot_id.id,
'move_id': stock_move_id.id,
- 'current_location_id': location.id,
+ 'destination_location_id': shelf_location_id.id,
'install_tool_time': fields.Datetime.now(),
'qty_done': 1.0,
'state': 'done',
diff --git a/sf_tool_management/models/fixture_enroll.py b/sf_tool_management/models/fixture_enroll.py
index 24e4e9f5..f4d2a8cd 100644
--- a/sf_tool_management/models/fixture_enroll.py
+++ b/sf_tool_management/models/fixture_enroll.py
@@ -1,6 +1,7 @@
import json
import base64
import requests
+import logging
from odoo import models, api
from odoo.addons.sf_base.commons.common import Common
from odoo.exceptions import UserError
@@ -10,30 +11,36 @@ class StockLot(models.Model):
_inherit = 'stock.lot'
_description = '夹具物料序列号注册'
- def enroll_fixture_material_stock(self):
+ def sync_enroll_fixture_material_stock_all(self):
+ logging.info("调用 sync_enroll_fixture_material_stock_all 同步接口")
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
sf_secret_key = sf_sync_config['sf_secret_key']
headers = Common.get_headers(self, token, sf_secret_key)
str_url = sf_sync_config['sf_url'] + "/api/fixture_material_stock/create"
- objs_all = self.env['stock.lot'].search([('id', '=', self.id)])
+ product_ids = self.env['product.product'].sudo().search([('categ_type', '=', '夹具')]).ids
+ objs_all = self.env['stock.lot'].search([('rfid', '!=', False), ('product_id', 'in', product_ids)])
fixture_material_stock_list = []
- if objs_all:
- for item in objs_all:
- val = {
- 'name': item.name,
- 'tool_material_status': item.tool_material_status,
- 'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name,
- 'fixture_material_search_id': item.fixture_material_search_id.id,
- }
- fixture_material_stock_list.append(val)
- kw = json.dumps(fixture_material_stock_list, ensure_ascii=False)
- r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
- ret = r.json()
- if ret.get('code') == 200:
- return '夹具物料序列号注册成功'
- else:
- raise UserError("没有注册夹具物料序列号信息")
+ try:
+ if objs_all:
+ for item in objs_all:
+ val = {
+ 'name': item.name,
+ 'tool_material_status': item.tool_material_status,
+ 'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name,
+ 'fixture_material_search_id': item.fixture_material_search_id.id,
+ }
+ fixture_material_stock_list.append(val)
+ kw = json.dumps(fixture_material_stock_list, ensure_ascii=False)
+ r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
+ ret = r.json()
+ if ret.get('code') == 200:
+ logging.info("夹具物料序列号每日同步成功")
+ return '夹具物料序列号注册成功'
+ else:
+ logging.info("没有注册夹具物料序列号信息")
+ except Exception as e:
+ logging.info("夹具物料序列号同步失败:%s" % e)
class FixtureMaterialSearch(models.Model):
@@ -42,41 +49,46 @@ class FixtureMaterialSearch(models.Model):
crea_url = "/api/fixture_material/create"
- def enroll_fixture_material(self):
+ def sync_enroll_fixture_material_all(self):
+ logging.info("调用 sync_enroll_fixture_material_all 同步接口")
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
sf_secret_key = sf_sync_config['sf_secret_key']
headers = Common.get_headers(self, token, sf_secret_key)
str_url = sf_sync_config['sf_url'] + self.crea_url
- objs_all = self.search([('id', '=', self.id)])
+ objs_all = self.search([])
fixture_material_list = []
- if objs_all:
- for obj in objs_all:
- val = {
- 'name': obj.name,
- 'id': obj.id,
- 'fixture_material_code': obj.fixture_material_id.code,
- 'fixture_model_code': obj.fixture_model_id.code,
- 'specification_name': obj.specification_fixture_id.name,
- 'image': '' if not obj.image else base64.b64encode(obj.image).decode('utf-8'),
- 'number': obj.number,
- 'usable_num': obj.usable_num,
- 'have_been_used_num': obj.have_been_used_num,
- 'scrap_num': obj.scrap_num
- }
- fixture_material_list.append(val)
- kw = json.dumps(fixture_material_list, ensure_ascii=False)
- r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
- ret = r.json()
- if ret.get('code') == 200:
- return '夹具物料注册成功'
- else:
- raise UserError("没有注册夹具物料信息")
+ try:
+ if objs_all:
+ for obj in objs_all:
+ val = {
+ 'name': obj.name,
+ 'id': obj.id,
+ 'fixture_material_code': obj.fixture_material_id.code,
+ 'fixture_model_code': obj.fixture_model_id.code,
+ 'specification_name': obj.specification_fixture_id.name,
+ 'image': '' if not obj.image else base64.b64encode(obj.image).decode('utf-8'),
+ 'number': obj.number,
+ 'usable_num': obj.usable_num,
+ 'have_been_used_num': obj.have_been_used_num,
+ 'scrap_num': obj.scrap_num
+ }
+ fixture_material_list.append(val)
+ kw = json.dumps(fixture_material_list, ensure_ascii=False)
+ r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
+ ret = r.json()
+ if ret.get('code') == 200:
+ logging.info("夹具物料每日同步成功")
+ return '夹具物料注册成功'
+ else:
+ logging.info("没有注册夹具物料信息")
+ except Exception as e:
+ logging.info("夹具物料同步失败:%s" % e)
- @api.model_create_multi
- def create(self, vals_list):
- records = super(FixtureMaterialSearch, self).create(vals_list)
- for record in records:
- if record:
- record.enroll_fixture_material()
- return records
+ # @api.model_create_multi
+ # def create(self, vals_list):
+ # records = super(FixtureMaterialSearch, self).create(vals_list)
+ # for record in records:
+ # if record:
+ # record.enroll_fixture_material()
+ # return records
diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py
index de8106c4..34f26ff6 100644
--- a/sf_tool_management/models/functional_tool.py
+++ b/sf_tool_management/models/functional_tool.py
@@ -14,14 +14,15 @@ class FunctionalCuttingToolEntity(models.Model):
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具组装单', readonly=True)
- tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
+ tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id',
+ store=True)
code = fields.Char('编码')
rfid = fields.Char('Rfid', readonly=True)
rfid_dismantle = fields.Char('Rfid(已拆解)', readonly=True)
name = fields.Char('名称')
tool_name_id = fields.Many2one('sf.tool.inventory', '功能刀具名称')
sf_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号')
- barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
+ barcode_id = fields.Many2one('stock.lot', string='序列号', readonly=True)
sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型',
group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True)
@@ -49,8 +50,6 @@ class FunctionalCuttingToolEntity(models.Model):
string='位置', compute='_compute_current_location_id', store=True)
image = fields.Binary('图片', readonly=True)
- active = fields.Boolean(string='已归档', default=True)
-
safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools',
string='功能刀具安全库存', readonly=True)
@@ -391,6 +390,7 @@ class StockMoveLine(models.Model):
class RealTimeDistributionOfFunctionalTools(models.Model):
_name = 'sf.real.time.distribution.of.functional.tools'
+ _inherit = ['mail.thread']
_description = '功能刀具安全库存'
name = fields.Char('名称', readonly=True, compute='_compute_name', store=True)
@@ -408,7 +408,7 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
max_stock_num = fields.Integer('最高库存量')
batch_replenishment_num = fields.Integer('批次补货量', readonly=True, compute='_compute_batch_replenishment_num',
store=True)
- unit = fields.Char('单位')
+ unit = fields.Char('单位', default="件")
image = fields.Binary('图片', readonly=False)
coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False)
diff --git a/sf_tool_management/models/functional_tool_enroll.py b/sf_tool_management/models/functional_tool_enroll.py
index 73b20a30..25c31710 100644
--- a/sf_tool_management/models/functional_tool_enroll.py
+++ b/sf_tool_management/models/functional_tool_enroll.py
@@ -33,23 +33,26 @@ def get_suitable_coolant_names(item):
class ToolDatasync(models.Model):
_name = 'sf.tool.datasync'
- _description = '定时同步所有刀具'
+ _description = '定时同步所有刀具、夹具'
def _cron_tool_datasync_all(self):
try:
self.env['stock.lot'].sudo().sync_enroll_tool_material_stock_all()
- logging.info("刀具物料序列号每日同步成功")
+
+ self.env['stock.lot'].sudo().sync_enroll_fixture_material_stock_all()
+
self.env['sf.tool.material.search'].sudo().sync_enroll_tool_material_all()
- logging.info("刀具物料每日同步成功")
+
+ self.env['sf.fixture.material.search'].sudo().sync_enroll_fixture_material_all()
+
self.env['sf.functional.cutting.tool.entity'].sudo().esync_enroll_functional_tool_entity_all()
- logging.info("功能刀具列表每日同步成功")
- self.env['sf.functional.tool.warning'].sudo().sync_enroll_functional_tool_warning_all()
- logging.info("功能刀具预警每日同步成功")
- self.env['stock.move.line'].sudo().sync_enroll_functional_tool_move_all()
- logging.info("功能刀具出入库记录每日同步成功")
- self.env[
- 'sf.real.time.distribution.of.functional.tools'].sudo().sync_enroll_functional_tool_real_time_distribution_all()
- logging.info("功能刀具安全库存每日同步成功")
+ logging.info("已全部同步完成!!!")
+ # self.env['sf.functional.tool.warning'].sudo().sync_enroll_functional_tool_warning_all()
+ # logging.info("功能刀具预警每日同步成功")
+ # self.env['stock.move.line'].sudo().sync_enroll_functional_tool_move_all()
+ # logging.info("功能刀具出入库记录每日同步成功")
+ # self.env['sf.real.time.distribution.of.functional.tools'].sudo().sync_enroll_functional_tool_real_time_distribution_all()
+ # logging.info("功能刀具安全库存每日同步成功")
except Exception as e:
logging.info("捕获错误信息:%s" % e)
raise ValidationError("数据错误导致同步失败,请联系管理员")
@@ -59,24 +62,25 @@ class StockLot(models.Model):
_inherit = 'stock.lot'
_description = '刀具物料序列号注册'
- def enroll_tool_material_stock(self):
- logging.info('调用刀具物料序列号注册接口: enroll_tool_material_stock()')
- sf_sync_config = self.env['res.config.settings'].get_values()
- token = sf_sync_config['token']
- sf_secret_key = sf_sync_config['sf_secret_key']
- headers = Common.get_headers(self, token, sf_secret_key)
- str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
- objs_all = self.env['stock.lot'].search([('id', '=', self.id), ('active', 'in', [True, False])])
- self._get_sync_stock_lot(objs_all, str_url, token, headers)
+ # def enroll_tool_material_stock(self):
+ # logging.info('调用刀具物料序列号注册接口: enroll_tool_material_stock()')
+ # sf_sync_config = self.env['res.config.settings'].get_values()
+ # token = sf_sync_config['token']
+ # sf_secret_key = sf_sync_config['sf_secret_key']
+ # headers = Common.get_headers(self, token, sf_secret_key)
+ # str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
+ # objs_all = self.env['stock.lot'].search([('id', '=', self.id), ('active', 'in', [True, False])])
+ # self._get_sync_stock_lot(objs_all, str_url, token, headers)
def sync_enroll_tool_material_stock_all(self):
- logging.info('调用刀具物料序列号注册接口: sync_enroll_tool_material_stock_all()')
+ logging.info('调用 sync_enroll_tool_material_stock_all 同步接口')
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
sf_secret_key = sf_sync_config['sf_secret_key']
headers = Common.get_headers(self, token, sf_secret_key)
str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
- objs_all = self.env['stock.lot'].search([('rfid', '!=', False)])
+ product_ids = self.env['product.product'].sudo().search([('categ_type', '=', '刀具')]).ids
+ objs_all = self.env['stock.lot'].search([('product_id', 'in', product_ids)])
self._get_sync_stock_lot(objs_all, str_url, token, headers)
def _get_sync_stock_lot(self, objs_all, str_url, token, headers):
@@ -86,6 +90,7 @@ class StockLot(models.Model):
for item in objs_all:
val = {
'name': item.name,
+ 'qty': item.product_qty,
'tool_material_status': item.tool_material_status,
'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name,
'tool_material_search_id': item.tool_material_search_id.id,
@@ -95,12 +100,13 @@ class StockLot(models.Model):
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
ret = r.json()
if ret.get('code') == 200:
- return '刀具物料序列号注册成功'
+ logging.info("刀具物料序列号每日同步成功")
+ return '刀具(夹具)物料序列号注册成功'
else:
- logging.info("没有注册刀具物料序列号信息")
+ logging.info("没有刀具物料序列号信息")
except Exception as e:
- logging.info("捕获错误信息:%s" % e)
-
+ logging.info("刀具物料序列号同步失败:%s" % e)
+
class ToolMaterial(models.Model):
_inherit = 'sf.tool.material.search'
@@ -108,18 +114,18 @@ class ToolMaterial(models.Model):
crea_url = '/api/tool_material/create'
- def enroll_tool_material(self):
- logging.info('调用刀具物料注册接口: enroll_tool_material()')
- sf_sync_config = self.env['res.config.settings'].get_values()
- token = sf_sync_config['token']
- sf_secret_key = sf_sync_config['sf_secret_key']
- headers = Common.get_headers(self, token, sf_secret_key)
- str_url = sf_sync_config['sf_url'] + self.crea_url
- objs_all = self.search([('id', '=', self.id)])
- self._get_sync_tool_material_search(objs_all, str_url, token, headers)
+ # def enroll_tool_material(self):
+ # logging.info('调用刀具物料注册接口: enroll_tool_material()')
+ # sf_sync_config = self.env['res.config.settings'].get_values()
+ # token = sf_sync_config['token']
+ # sf_secret_key = sf_sync_config['sf_secret_key']
+ # headers = Common.get_headers(self, token, sf_secret_key)
+ # str_url = sf_sync_config['sf_url'] + self.crea_url
+ # objs_all = self.search([('id', '=', self.id)])
+ # self._get_sync_tool_material_search(objs_all, str_url, token, headers)
def sync_enroll_tool_material_all(self):
- logging.info('调用刀具物料注册接口: sync_enroll_tool_material_all()')
+ logging.info('调用 sync_enroll_tool_material_all 同步接口')
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
sf_secret_key = sf_sync_config['sf_secret_key']
@@ -150,11 +156,12 @@ class ToolMaterial(models.Model):
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
ret = r.json()
if ret.get('code') == 200:
+ logging.info("刀具物料每日同步成功")
return '刀具物料注册成功'
else:
logging.info('没有注册刀具物料信息')
except Exception as e:
- logging.info("捕获错误信息:%s" % e)
+ logging.info("刀具物料同步失败:%s" % e)
class FunctionalCuttingToolEntity(models.Model):
@@ -164,18 +171,18 @@ class FunctionalCuttingToolEntity(models.Model):
crea_url = "/api/functional_tool_entity/create"
# 注册同步功能刀具列表
- def enroll_functional_tool_entity(self):
- logging.info('调用功能刀具列表注册接口: enroll_functional_tool_entity()')
- sf_sync_config = self.env['res.config.settings'].get_values()
- token = sf_sync_config['token']
- sf_secret_key = sf_sync_config['sf_secret_key']
- headers = Common.get_headers(self, token, sf_secret_key)
- str_url = sf_sync_config['sf_url'] + self.crea_url
- objs_all = self.env['sf.functional.cutting.tool.entity'].search([('id', '=', self.id)])
- self._get_sync_functional_cutting_tool_entity(objs_all, str_url, token, headers)
+ # def enroll_functional_tool_entity(self):
+ # logging.info('调用功能刀具列表注册接口: enroll_functional_tool_entity()')
+ # sf_sync_config = self.env['res.config.settings'].get_values()
+ # token = sf_sync_config['token']
+ # sf_secret_key = sf_sync_config['sf_secret_key']
+ # headers = Common.get_headers(self, token, sf_secret_key)
+ # str_url = sf_sync_config['sf_url'] + self.crea_url
+ # objs_all = self.env['sf.functional.cutting.tool.entity'].search([('id', '=', self.id)])
+ # self._get_sync_functional_cutting_tool_entity(objs_all, str_url, token, headers)
def esync_enroll_functional_tool_entity_all(self):
- logging.info('调用功能刀具列表注册接口: esync_enroll_functional_tool_entity_all()')
+ logging.info('调用 esync_enroll_functional_tool_entity_all 同步接口')
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
sf_secret_key = sf_sync_config['sf_secret_key']
@@ -202,6 +209,7 @@ class FunctionalCuttingToolEntity(models.Model):
'coarse_middle_thin': item.coarse_middle_thin,
'new_former': item.new_former,
'tool_loading_length': item.tool_loading_length,
+ 'handle_length': item.handle_length,
'functional_tool_length': item.functional_tool_length,
'effective_length': item.effective_length,
'max_lifetime_value': item.max_lifetime_value,
@@ -234,11 +242,12 @@ class FunctionalCuttingToolEntity(models.Model):
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
ret = r.json()
if ret.get('code') == 200:
+ logging.info("功能刀具列表每日同步成功")
return "功能刀具注册成功"
else:
logging.info('没有注册功能刀具信息')
except Exception as e:
- logging.info("捕获错误信息:%s" % e)
+ logging.info("功能刀具同步失败:%s" % e)
class FunctionalToolWarning(models.Model):
diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py
index e26eab2b..af8833fb 100644
--- a/sf_tool_management/models/tool_material_search.py
+++ b/sf_tool_management/models/tool_material_search.py
@@ -46,6 +46,8 @@ class ToolMaterial(models.Model):
record.scrap_num = scrap_num
record.number = usable_num + have_been_used_num + scrap_num
+
+
@api.model
def _read_group_cutting_tool_material_id(self, categories, domain, order):
cutting_tool_material_id = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml
index 8d07bc70..283eb2cc 100644
--- a/sf_tool_management/views/functional_tool_views.xml
+++ b/sf_tool_management/views/functional_tool_views.xml
@@ -6,7 +6,7 @@
sf.functional.cutting.tool.entity.list.tree
sf.functional.cutting.tool.entity
-
+
@@ -19,13 +19,14 @@
-
-
-
+
+
+
+
@@ -115,7 +116,7 @@
options="{'no_create': True, 'no_quick_create': True}"/>
-
+
@@ -196,16 +197,30 @@
+
+
+
+
+
+
+
-
-
+
+
+
+
+
@@ -301,11 +316,10 @@
-
-
+
@@ -314,6 +328,8 @@
+
+
@@ -415,6 +431,10 @@
+
+
+
+
@@ -425,21 +445,20 @@
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index b3e93238..31fe53c9 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -376,6 +376,10 @@
+
+
+
+
@@ -430,17 +434,17 @@
-
+
-
+
-
-
+
+
@@ -464,8 +468,8 @@
@@ -677,30 +693,29 @@
-
+
+
-
-
-
-
-
-
-
+
+
-
-
-
-
+
+
+
+
+
+
+
@@ -722,6 +737,7 @@
sf.functional.tool.dismantle
+
@@ -749,13 +765,14 @@
-
+
+
@@ -786,91 +803,98 @@
+
+
+
-
-
-
-
+
+
-
-
-
+
+
-
-
-
-
+
+
-
-
-
+
+
-
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -880,6 +904,7 @@
+
diff --git a/sf_tool_management/views/tool_material_search.xml b/sf_tool_management/views/tool_material_search.xml
index eb7a2418..8a740676 100644
--- a/sf_tool_management/views/tool_material_search.xml
+++ b/sf_tool_management/views/tool_material_search.xml
@@ -62,6 +62,7 @@
+
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index 3ff8b5db..6aec47e9 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -233,7 +233,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 功能刀具组装信息
# ===============整体式刀具型号=================
- integral_freight_barcode = fields.Char('整体式刀具货位')
+ integral_freight_barcode_id = fields.Many2one('sf.shelf.location', string='整体式刀具货位',
+ domain="[('product_id.cutting_tool_material_id.name', '=', '整体式刀具'),('product_num', '>', 0)]")
+ integral_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='整体式刀具批次',
+ domain="[('shelf_location_id', '=', integral_freight_barcode_id)]")
integral_product_id = fields.Many2one('product.product', string='整体式刀具名称',
compute='_compute_integral_product_id', store=True)
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
@@ -243,28 +246,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
related='integral_product_id.brand_id')
- @api.depends('integral_freight_barcode')
+ @api.onchange('integral_freight_barcode_id')
+ def _onchange_integral_freight_barcode_id(self):
+ for item in self:
+ item.integral_freight_lot_id = False
+
+ @api.depends('integral_freight_lot_id')
def _compute_integral_product_id(self):
- if self.integral_freight_barcode:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)])
- if location:
- if not location.product_id:
- raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
- else:
- material_name_id = location.product_id.cutting_tool_material_id
- if material_name_id and material_name_id.name == '整体式刀具':
- if location.product_num == 0:
- raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
- self.integral_product_id = location.product_id.id
- else:
- raise ValidationError(
- '编码为【%s】的货位存放的产品为【%s】,不是整体式刀具,请重新选择!' % (
- location.barcode, location.product_id.name))
- else:
- raise ValidationError('编码为【%s】的货位不存在!' % self.integral_freight_barcode)
+ if self.integral_freight_lot_id:
+ self.integral_product_id = self.integral_freight_lot_id.lot_id.product_id.id
+ else:
+ self.integral_product_id = False
# ===============刀片型号====================
- blade_freight_barcode = fields.Char('刀片货位')
+ blade_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀片货位',
+ domain="[('product_id.cutting_tool_material_id.name', '=', '刀片'),('product_num', '>', 0)]")
+ blade_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀片批次',
+ domain="[('shelf_location_id', '=', blade_freight_barcode_id)]")
blade_product_id = fields.Many2one('product.product', string='刀片名称', compute='_compute_blade_product_id',
store=True)
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
@@ -273,28 +271,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
related='blade_product_id.specification_id')
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id')
- @api.depends('blade_freight_barcode')
+ @api.onchange('blade_freight_barcode_id')
+ def _onchange_blade_freight_barcode_id(self):
+ for item in self:
+ item.blade_freight_lot_id = False
+
+ @api.depends('blade_freight_lot_id')
def _compute_blade_product_id(self):
- if self.blade_freight_barcode:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)])
- if location:
- if not location.product_id:
- raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
- else:
- material_name_id = location.product_id.cutting_tool_material_id
- if material_name_id and material_name_id.name == '刀片':
- if location.product_num == 0:
- raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
- self.blade_product_id = location.product_id.id
- else:
- raise ValidationError(
- '编码为【%s】的货位存放的产品为【%s】,不是刀片,请重新选择!' % (
- location.barcode, location.product_id.name))
- else:
- raise ValidationError('编码为【%s】的货位不存在!' % self.blade_freight_barcode)
+ if self.blade_freight_lot_id:
+ self.blade_product_id = self.blade_freight_lot_id.lot_id.product_id.id
+ else:
+ self.blade_product_id = False
# ====================刀杆型号==================
- bar_freight_barcode = fields.Char('刀杆货位')
+ bar_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀杆货位',
+ domain="[('product_id.cutting_tool_material_id.name', '=', '刀杆'),('product_num', '>', 0)]")
+ bar_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀杆批次',
+ domain="[('shelf_location_id', '=', bar_freight_barcode_id)]")
bar_product_id = fields.Many2one('product.product', string='刀杆名称', compute='_compute_bar_product_id',
store=True)
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
@@ -303,28 +296,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
related='bar_product_id.specification_id')
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id')
- @api.depends('bar_freight_barcode')
+ @api.onchange('bar_freight_barcode_id')
+ def _onchange_bar_freight_barcode_id(self):
+ for item in self:
+ item.bar_freight_lot_id = False
+
+ @api.depends('bar_freight_lot_id')
def _compute_bar_product_id(self):
- if self.bar_freight_barcode:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)])
- if location:
- if not location.product_id:
- raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
- else:
- material_name_id = location.product_id.cutting_tool_material_id
- if material_name_id and material_name_id.name == '刀杆':
- if location.product_num == 0:
- raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
- self.bar_product_id = location.product_id.id
- else:
- raise ValidationError(
- '编码为【%s】的货位存放的产品为【%s】,不是刀杆,请重新选择!' % (
- location.barcode, location.product_id.name))
- else:
- raise ValidationError('编码为【%s】的货位不存在!' % self.bar_freight_barcode)
+ if self.bar_freight_lot_id:
+ self.bar_product_id = self.bar_freight_lot_id.lot_id.product_id.id
+ else:
+ self.bar_product_id = False
# ===============刀盘型号===================
- pad_freight_barcode = fields.Char('刀盘货位')
+ pad_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀盘货位',
+ domain="[('product_id.cutting_tool_material_id.name', '=', '刀盘'),('product_num', '>', 0)]")
+ pad_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀盘批次',
+ domain="[('shelf_location_id', '=', pad_freight_barcode_id)]")
pad_product_id = fields.Many2one('product.product', string='刀盘名称', compute='_compute_pad_product_id',
store=True)
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
@@ -333,25 +321,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
related='pad_product_id.specification_id')
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id')
- @api.depends('pad_freight_barcode')
+ @api.onchange('pad_freight_barcode_id')
+ def _onchange_pad_freight_barcode_id(self):
+ for item in self:
+ item.pad_freight_lot_id = False
+
+ @api.depends('pad_freight_lot_id')
def _compute_pad_product_id(self):
- if self.pad_freight_barcode:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)])
- if location:
- if not location.product_id:
- raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
- else:
- material_name_id = location.product_id.cutting_tool_material_id
- if material_name_id and material_name_id.name == '刀盘':
- if location.product_num == 0:
- raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
- self.pad_product_id = location.product_id.id
- else:
- raise ValidationError(
- '编码为【%s】的货位存放的产品为【%s】,不是刀盘,请重新选择!' % (
- location.barcode, location.product_id.name))
- else:
- raise ValidationError('编码为【%s】的货位不存在!' % self.pad_freight_barcode)
+ if self.pad_freight_lot_id:
+ self.pad_product_id = self.pad_freight_lot_id.lot_id.product_id.id
+ else:
+ self.pad_product_id = False
# ================刀柄型号===============
handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_rfid')
@@ -374,7 +354,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
self.pad_product_id = False
# =================夹头型号==============
- chuck_freight_barcode = fields.Char('夹头货位')
+ chuck_freight_barcode_id = fields.Many2one('sf.shelf.location', string='夹头货位',
+ domain="[('product_id.cutting_tool_material_id.name', '=', '夹头'),('product_num', '>', 0)]")
+ chuck_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='夹头批次',
+ domain="[('shelf_location_id', '=', chuck_freight_barcode_id)]")
chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id',
store=True)
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
@@ -383,25 +366,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
related='chuck_product_id.specification_id')
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id')
- @api.depends('chuck_freight_barcode')
+ @api.onchange('chuck_freight_barcode_id')
+ def _onchange_chuck_freight_barcode_id(self):
+ for item in self:
+ item.chuck_freight_lot_id = False
+
+ @api.depends('chuck_freight_lot_id')
def _compute_chuck_product_id(self):
- if self.chuck_freight_barcode:
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)])
- if location:
- if not location.product_id:
- raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
- else:
- material_name_id = location.product_id.cutting_tool_material_id
- if material_name_id and material_name_id.name == '夹头':
- if location.product_num == 0:
- raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
- self.chuck_product_id = location.product_id.id
- else:
- raise ValidationError(
- '编码为【%s】的货位存放的产品为【%s】,不是夹头,请重新选择!' % (
- location.barcode, location.product_id.name))
- else:
- raise ValidationError('编码为【%s】的货位不存在!' % self.chuck_freight_barcode)
+ if self.chuck_freight_lot_id:
+ self.chuck_product_id = self.chuck_freight_lot_id.lot_id.product_id.id
+ else:
+ self.chuck_product_id = False
# ========================================
def on_barcode_scanned(self, barcode):
@@ -423,23 +398,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
if location:
material_name = location.product_id.cutting_tool_material_id.name
if material_name == '夹头':
- record.chuck_freight_barcode = barcode
+ record.chuck_freight_barcode_id = location.id
elif material_name == '整体式刀具':
- record.integral_freight_barcode = barcode
- record.blade_freight_barcode = ''
- record.bar_freight_barcode = ''
- record.pad_freight_barcode = ''
+ record.integral_freight_barcode_id = location.id
+ record.blade_freight_barcode_id = False
+ record.bar_freight_barcode_id = False
+ record.pad_freight_barcode_id = False
elif material_name == '刀片':
- record.blade_freight_barcode = barcode
- record.integral_freight_barcode = ''
+ record.blade_freight_barcode_id = location.id
+ record.integral_freight_barcode_id = False
elif material_name == '刀杆':
- record.bar_freight_barcode = barcode
- record.integral_freight_barcode = ''
- record.pad_freight_barcode = ''
+ record.bar_freight_barcode_id = location.id
+ record.integral_freight_barcode_id = False
+ record.pad_freight_barcode_id = False
elif material_name == '刀盘':
- record.pad_freight_barcode = barcode
- record.integral_freight_barcode = ''
- record.bar_freight_barcode = ''
+ record.pad_freight_barcode_id = location.id
+ record.integral_freight_barcode_id = False
+ record.bar_freight_barcode_id = False
else:
raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
else:
@@ -490,6 +465,15 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
compute='_compute_after_assembly_max_lifetime_value')
obtain_measurement_status = fields.Boolean('是否获取测量值', default=False)
+ enable_tool_presetter = fields.Boolean('是否启用刀具预调仪', default=lambda self: self.get_enable_tool_presetter())
+
+ def get_enable_tool_presetter(self):
+ """
+ 获取是否启用刀具预调仪数据
+ """
+ sf_sync_config = self.env['res.config.settings'].get_values()
+ enable_tool_presetter = sf_sync_config['enable_tool_presetter']
+ return enable_tool_presetter
@api.depends('after_assembly_tool_loading_length', 'after_assembly_handle_length')
def _compute_after_assembly_functional_tool_length(self):
@@ -553,32 +537,21 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False)
# res_partner_id = fields.Many2one('res.partner', '智能工厂', domain="[('is_factory', '=', True)]")
- @api.depends('after_assembly_functional_tool_type_id', 'integral_specification_id', 'bar_specification_id',
- 'pad_specification_id', 'handle_specification_id', 'after_assembly_tool_loading_length')
+ @api.depends('after_assembly_functional_tool_type_id', 'cutting_tool_cutterhandle_model_id',
+ 'after_assembly_functional_tool_diameter', 'after_assembly_tool_loading_length',
+ 'after_assembly_knife_tip_r_angle', 'after_assembly_functional_tool_length',
+ 'after_assembly_handle_length')
def _compute_code(self):
for obj in self:
- str_1 = 'GNDJ-%s' % obj.after_assembly_functional_tool_type_id.code
- str_2 = ''
- if obj.handle_specification_id:
- if obj.integral_specification_id:
- str_2 = '%s-D%sL%sB%sH%s-' % (
- str_1, obj.integral_specification_id.blade_diameter, obj.after_assembly_tool_loading_length,
- obj.integral_specification_id.blade_length, obj.handle_specification_id.total_length)
- elif obj.bar_specification_id:
- str_2 = '%s-D%sL%sB%sH%s-' % (
- str_1, obj.bar_specification_id.cutter_arbor_diameter, obj.after_assembly_tool_loading_length,
- obj.bar_specification_id.blade_length, obj.handle_specification_id.total_length)
- elif obj.pad_specification_id:
- str_2 = '%s-D%sL%sB%sH%s-' % (
- str_1, obj.pad_specification_id.cutter_head_diameter, obj.after_assembly_tool_loading_length,
- obj.pad_specification_id.cut_depth_max, obj.handle_specification_id.total_length,
- )
- else:
- obj.code = str_2
- return True
- obj.code = str_2 + str(self._get_code(str_2))
+ if obj.cutting_tool_cutterhandle_model_id:
+ code = obj.cutting_tool_cutterhandle_model_id.code.split('-', 1)[0]
+ str_1 = '%s-GNDJ-%s-D%sL%sR%sB%sH%s' % (
+ code, obj.after_assembly_functional_tool_type_id.code, obj.after_assembly_functional_tool_diameter,
+ obj.after_assembly_tool_loading_length, obj.after_assembly_knife_tip_r_angle,
+ round(obj.after_assembly_functional_tool_length, 3), obj.after_assembly_handle_length)
+ obj.code = '%s-%s' % (str_1, self._get_code(str_1))
else:
- obj.code = str_2
+ obj.code = ''
def _get_code(self, str_2):
functional_tool_assembly = self.env['sf.functional.cutting.tool.entity'].sudo().search(
@@ -601,7 +574,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
else:
obj.after_assembly_functional_tool_name = ''
- @api.onchange('integral_freight_barcode')
+ @api.onchange('integral_freight_barcode_id')
def _onchange_after_assembly_functional_tool_diameter(self):
for obj in self:
if obj.integral_product_id:
@@ -609,7 +582,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
else:
obj.after_assembly_functional_tool_diameter = 0
- @api.onchange('blade_freight_barcode')
+ @api.onchange('blade_freight_barcode_id')
def _onchange_after_assembly_knife_tip_r_angle(self):
for obj in self:
if obj.blade_product_id:
@@ -644,25 +617,32 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 创建组装入库单
# 创建功能刀具批次/序列号记录
stock_lot = product_id.create_assemble_warehouse_receipt(self.id, functional_tool_assembly, self)
+ # 封装功能刀具数据,用于更新组装单信息
+ desc_1 = self.get_desc_1(stock_lot)
+ # 封装功能刀具数据,用于创建功能刀具记录
+ desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly)
# 创建刀具组装入库单
self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly, self)
# 刀具物料出库
if self.handle_code_id:
product_id.tool_material_stock_moves(self.handle_code_id, self.assembly_order_code)
if self.integral_product_id:
- self.integral_product_id.material_stock_moves(self.integral_freight_barcode, self.assembly_order_code)
+ self.integral_product_id.material_stock_moves(self.integral_freight_barcode_id,
+ self.integral_freight_lot_id, self.assembly_order_code)
if self.blade_product_id:
- self.blade_product_id.material_stock_moves(self.blade_freight_barcode, self.assembly_order_code)
+ self.blade_product_id.material_stock_moves(self.blade_freight_barcode_id,
+ self.blade_freight_lot_id, self.assembly_order_code)
if self.bar_product_id:
- self.bar_product_id.material_stock_moves(self.bar_freight_barcode, self.assembly_order_code)
+ self.bar_product_id.material_stock_moves(self.bar_freight_barcode_id,
+ self.bar_freight_lot_id, self.assembly_order_code)
if self.pad_product_id:
- self.pad_product_id.material_stock_moves(self.pad_freight_barcode, self.assembly_order_code)
+ self.pad_product_id.material_stock_moves(self.pad_freight_barcode_id,
+ self.pad_freight_lot_id, self.assembly_order_code)
if self.chuck_product_id:
- self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode, self.assembly_order_code)
+ self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode_id,
+ self.chuck_freight_lot_id, self.assembly_order_code)
# ============================创建功能刀具列表、安全库存记录===============================
- # 封装功能刀具数据
- desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly)
# 创建功能刀具列表记录
record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2)
# 创建安全库存信息
@@ -671,8 +651,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
}, record_1)
# =====================修改功能刀具组装单、机床换刀申请、CAM工单程序用刀计划的状态==============
- # 封装功能刀具数据
- desc_1 = self.get_desc_1(stock_lot)
# 修改功能刀具组装单信息
functional_tool_assembly.write(desc_1)
if functional_tool_assembly.sf_machine_table_tool_changing_apply_id:
@@ -729,12 +707,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'code': self.code,
'rfid': self.rfid,
'tool_groups_id': self.after_tool_groups_id.id,
- 'integral_freight_barcode': self.integral_freight_barcode,
- 'blade_freight_barcode': self.blade_freight_barcode,
- 'bar_freight_barcode': self.bar_freight_barcode,
- 'pad_freight_barcode': self.pad_freight_barcode,
'handle_code_id': self.handle_code_id.id,
- 'chuck_freight_barcode': self.chuck_freight_barcode,
+ 'integral_freight_barcode_id': self.integral_freight_barcode_id.id,
+ 'integral_lot_id': self.integral_freight_lot_id.lot_id.id,
+ 'blade_freight_barcode_id': self.blade_freight_barcode_id.id,
+ 'blade_lot_id': self.blade_freight_lot_id.lot_id.id,
+ 'bar_freight_barcode_id': self.bar_freight_barcode_id.id,
+ 'bar_lot_id': self.bar_freight_lot_id.lot_id.id,
+ 'pad_freight_barcode_id': self.pad_freight_barcode_id.id,
+ 'pad_lot_id': self.pad_freight_lot_id.lot_id.id,
+ 'chuck_freight_barcode_id': self.chuck_freight_barcode_id.id,
+ 'chuck_lot_id': self.chuck_freight_lot_id.lot_id.id,
'after_assembly_functional_tool_name': self.after_assembly_functional_tool_name,
'after_assembly_functional_tool_type_id': self.after_assembly_functional_tool_type_id.id,
@@ -815,6 +798,7 @@ class StockPicking(models.Model):
'picking_type_id': picking_type_id.id,
'location_id': picking_type_id.default_location_src_id.id,
'location_dest_id': picking_type_id.default_location_dest_id.id,
+ 'origin': obj.assembly_order_code
})
# 创建作业详情对象记录,并绑定到刀具组装入库单
self.env['stock.move.line'].create({
@@ -865,7 +849,7 @@ class ProductProduct(models.Model):
logging.info('没有搜索到功能刀具产品:%s' % product_id)
raise ValidationError('没有找到按唯一序列号追溯的功能刀具产品信息!')
stock_lot = self.env['stock.lot'].create({
- 'name': self.get_stock_lot_name(tool_assembly_order_id),
+ 'name': self.get_stock_lot_name(obj),
'product_id': product_id[0].id,
'company_id': self.env.company.id
})
@@ -878,25 +862,21 @@ class ProductProduct(models.Model):
return stock_lot
- def get_stock_lot_name(self, tool_assembly_order_id):
+ def get_stock_lot_name(self, obj):
"""
生成功能刀具序列号
"""
- tool_assembly_order = self.env['sf.functional.tool.assembly.order'].search(
- [('id', '=', tool_assembly_order_id)])
- code = 'JKM-T-' + str(tool_assembly_order.after_assembly_functional_tool_type_id.code) + '-' + str(
- tool_assembly_order.after_assembly_functional_tool_diameter) + '-'
+ company = obj.cutting_tool_cutterhandle_model_id.code.split('-', 1)[0]
new_time = datetime.strptime(str(fields.Date.today()), "%Y-%m-%d").strftime("%Y%m%d")
- code += str(new_time) + '-'
+ code = '%s-GNDJ-%s-%s' % (company, obj.after_assembly_functional_tool_type_id.code, new_time)
stock_lot_id = self.env['stock.lot'].sudo().search(
- [('name', 'like', new_time), ('product_id.categ_type', '=', '功能刀具'),
- ('product_id.tracking', '=', 'serial')], limit=1, order="id desc")
+ [('name', 'like', code)], limit=1, order="id desc")
if not stock_lot_id:
num = "%03d" % 1
else:
m = int(stock_lot_id.name[-3:]) + 1
num = "%03d" % m
- return code + str(num)
+ return '%s-%s' % (code, num)
def tool_material_stock_moves(self, tool_material, assembly_order_code):
"""
@@ -909,7 +889,7 @@ class ProductProduct(models.Model):
tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, assembly_order_code, False,
False)
- def material_stock_moves(self, shelf_location_barcode, assembly_order_code):
+ def material_stock_moves(self, shelf_location_barcode_id, lot_id, assembly_order_code):
# 创建库存移动记录
stock_move_id = self.env['stock.move'].sudo().create({
'name': assembly_order_code,
@@ -920,21 +900,16 @@ class ProductProduct(models.Model):
'state': 'done'
})
- location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)])
# 创建移动历史记录
stock_move_line_id = self.env['stock.move.line'].sudo().create({
'product_id': self.id,
'move_id': stock_move_id.id,
- 'current_location_id': location.id,
+ 'lot_id': lot_id.lot_id.id,
+ 'current_location_id': shelf_location_barcode_id.id,
'install_tool_time': fields.Datetime.now(),
'qty_done': 1.0,
'state': 'done',
})
- if location.product_num > 0:
- location.product_num = location.product_num - 1
- else:
- raise ValidationError(
- '【%s】货位的【%s】产品库存数量为零,请采购入库后再重新组装!' % (location.barcode, location.product_id.name))
return stock_move_id, stock_move_line_id
diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml
index 955bb998..b6e15586 100644
--- a/sf_tool_management/wizard/wizard_view.xml
+++ b/sf_tool_management/wizard/wizard_view.xml
@@ -229,13 +229,18 @@
+ attrs="{'invisible': ['|','|',('blade_freight_barcode_id', '!=', False),('bar_freight_barcode_id', '!=', False),('pad_freight_barcode_id', '!=', False)]}">
-
+
+
+
+
@@ -249,13 +254,18 @@
-
+
-
+
+
+
+
@@ -270,13 +280,18 @@
+ attrs="{'invisible': ['|',('integral_freight_barcode_id', '!=', False),('pad_freight_barcode_id', '!=', False)]}">
-
+
+
+
+
@@ -291,13 +306,18 @@
+ attrs="{'invisible': ['|',('integral_freight_barcode_id', '!=', False),('bar_freight_barcode_id', '!=', False)]}">
-
+
+
+
+
@@ -317,7 +337,12 @@
-
+
+
+
+
@@ -343,12 +368,14 @@
-
@@ -367,12 +394,16 @@
attrs="{'invisible': [('after_assembly_new_former','=','0')]}"/>
+
+ attrs="{'readonly': [('enable_tool_presetter', '=', True)]}"
+ class="custom_required"/>
+ attrs="{'readonly': [('enable_tool_presetter', '=', True)]}"
+ class="custom_required"/>
+ attrs="{'readonly': [('enable_tool_presetter', '=', True)]}"
+ class="custom_required"/>
diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py
index 1a7ba1e0..62a7836b 100644
--- a/sf_warehouse/models/model.py
+++ b/sf_warehouse/models/model.py
@@ -452,8 +452,9 @@ class ShelfLocation(models.Model):
# product_id = fields.Many2one('product.template', string='产品')
product_id = fields.Many2one('product.product', string='产品', compute='_compute_product_id', store=True)
product_sn_id = fields.Many2one('stock.lot', string='产品序列号')
+ product_sn_ids = fields.One2many('sf.shelf.location.lot', 'shelf_location_id', string='产品批次号')
# 产品数量
- product_num = fields.Integer('数量')
+ product_num = fields.Integer('总数量', compute='_compute_number', store=True)
@api.depends('product_num')
def _compute_product_num(self):
@@ -463,6 +464,15 @@ class ShelfLocation(models.Model):
elif record.product_num == 0:
record.location_status = '空闲'
+ @api.depends('product_sn_ids.qty')
+ def _compute_number(self):
+ for item in self:
+ if item.product_sn_ids:
+ qty = 0
+ for product_sn_id in item.product_sn_ids:
+ qty += product_sn_id.qty
+ item.product_num = qty
+
# 修改货位状态为禁用
def action_location_status_disable(self):
self.location_status = '禁用'
@@ -471,7 +481,7 @@ class ShelfLocation(models.Model):
def action_location_status_enable(self):
self.location_status = '空闲'
- @api.depends('product_sn_id')
+ @api.depends('product_sn_id', 'product_sn_ids')
def _compute_product_id(self):
"""
根据产品序列号,获取产品
@@ -484,7 +494,8 @@ class ShelfLocation(models.Model):
record.sudo().product_num = 1
except Exception as e:
print('eeeeeee占用', e)
-
+ elif record.product_sn_ids:
+ return True
else:
try:
record.sudo().product_id = False
@@ -525,7 +536,24 @@ class ShelfLocation(models.Model):
return records
-class Sf_stock_move_line(models.Model):
+class SfShelfLocationLot(models.Model):
+ _name = 'sf.shelf.location.lot'
+ _description = '批次数量'
+
+ name = fields.Char('名称', related='lot_id.name')
+ shelf_location_id = fields.Many2one('sf.shelf.location', string="货位")
+ lot_id = fields.Many2one('stock.lot', string='批次号')
+ qty = fields.Integer('数量')
+ qty_num = fields.Integer('变更数量')
+
+ @api.onchange('qty_num')
+ def _onchange_qty_num(self):
+ for item in self:
+ if item.qty_num > item.qty:
+ raise ValidationError('变更数量不能比库存数量大!!!')
+
+
+class SfStockMoveLine(models.Model):
_name = 'stock.move.line'
_inherit = ['stock.move.line', 'printing.utils']
@@ -825,15 +853,20 @@ class Sf_stock_move_line(models.Model):
obj = self.env['sf.shelf.location'].search([('name', '=',
self.destination_location_id.name)])
if record.lot_id:
- shelf_location_obj = self.env['sf.shelf.location'].search(
- [('product_sn_id', '=', record.lot_id.id)])
- if shelf_location_obj:
- shelf_location_obj.product_sn_id = False
- if obj:
- obj.product_sn_id = record.lot_id.id
- else:
- if obj:
- obj.product_sn_id = record.lot_id.id
+ if record.product_id.tracking == 'serial':
+ shelf_location_obj = self.env['sf.shelf.location'].search(
+ [('product_sn_id', '=', record.lot_id.id)])
+ if shelf_location_obj:
+ shelf_location_obj.product_sn_id = False
+ if obj:
+ obj.product_sn_id = record.lot_id.id
+ else:
+ if obj:
+ obj.product_sn_id = record.lot_id.id
+ elif record.product_id.tracking == 'lot':
+ self.put_shelf_location(record)
+ if not obj.product_id:
+ obj.product_id = record.product_id.id
else:
if obj:
obj.product_id = record.product_id.id
@@ -853,20 +886,83 @@ class Sf_stock_move_line(models.Model):
raise ValidationError(
'【%s】货位已经被占用,请重新选择!!!' % item.destination_location_id.barcode)
+ def put_shelf_location(self, vals):
+ """
+ 对货位的批量数据进行数量计算
+ """
+ for record in vals:
+ if record.lot_id and record.product_id.tracking == 'lot':
+ if record.current_location_id:
+ location_lot = self.env['sf.shelf.location.lot'].sudo().search(
+ [('shelf_location_id', '=', record.current_location_id.id), ('lot_id', '=', record.lot_id.id)])
+ if location_lot:
+ location_lot.qty -= record.qty_done
+ if location_lot.qty == 0:
+ location_lot.unlink()
+ elif location_lot.qty < 0:
+ raise ValidationError('【%s】货位【%s】批次的【%s】产品数量不足!' % (
+ record.current_location_id.barcode, record.lot_id.name, record.product_id.name))
+ else:
+ raise ValidationError('【%s】货位不存在【%s】批次的【%s】产品' % (
+ record.current_location_id.barcode, record.lot_id.name, record.product_id.name))
+ if record.destination_location_id:
+ location_lot = self.env['sf.shelf.location.lot'].sudo().search(
+ [('shelf_location_id', '=', record.destination_location_id.id),
+ ('lot_id', '=', record.lot_id.id)])
+ if location_lot:
+ location_lot.qty += record.qty_done
+ else:
+ self.env['sf.shelf.location.lot'].sudo().create({
+ 'shelf_location_id': record.destination_location_id.id,
+ 'lot_id': record.lot_id.id,
+ 'qty': record.qty_done
+ })
+ if not record.destination_location_id.product_id:
+ record.destination_location_id.product_id = record.product_id.id
+
+ @api.model_create_multi
+ def create(self, vals_list):
+
+ records = super(SfStockMoveLine, self).create(vals_list)
+ self.put_shelf_location(records)
+ return records
+
class SfStockPicking(models.Model):
_inherit = 'stock.picking'
check_in = fields.Char(string='查询是否为入库单', compute='_check_is_in')
+ def batch_stock_move(self):
+ """
+ 批量调拨,非就绪状态的会被忽略,完成后有通知提示
+ """
+ for record in self:
+ if record.state != 'assigned':
+ continue
+ record.action_set_quantities_to_reservation()
+ record.button_validate()
+
+ notification_message = '批量调拨完成!请注意,状态非就绪的单据会被忽略'
+ return {
+ 'effect': {
+ 'fadeout': 'fast',
+ 'message': notification_message,
+ 'img_url': '/web/image/%s/%s/image_1024' % (
+ self.create_uid._name, self.create_uid.id) if 0 else '/web/static/img/smile.svg',
+ 'type': 'rainbow_man',
+ }
+ }
+
@api.depends('name')
def _check_is_in(self):
"""
判断是否为出库单
"""
- if self.name:
- is_check_in = self.name.split('/')
- self.check_in = is_check_in[1]
+ for record in self:
+ if record.name:
+ is_check_in = record.name.split('/')
+ record.check_in = is_check_in[1]
def button_validate(self):
"""
@@ -894,6 +990,9 @@ class SfStockPicking(models.Model):
if move and move.product_id.cutting_tool_material_id.name == '刀柄' or '托盘' in (
move.product_id.fixture_material_id.name or ''):
for item in move.move_line_nosuggest_ids:
+ if item.rfid:
+ if self.env['stock.lot'].search([('rfid', '=', item.rfid)]):
+ raise ValidationError('该Rfid【%s】在系统中已经存在,请重新录入!' % item.rfid)
if item.location_dest_id.name == '进货':
if not item.rfid:
raise ValidationError('你需要提供%s的Rfid' % move.product_id.name)
diff --git a/sf_warehouse/models/sync_common.py b/sf_warehouse/models/sync_common.py
index 28f82313..3df97423 100644
--- a/sf_warehouse/models/sync_common.py
+++ b/sf_warehouse/models/sync_common.py
@@ -20,7 +20,7 @@ class MrsShelfLocationDataSync(models.Model):
paired_data = list(zip(my_data, their_data))
return paired_data
- shelf_1_obj = self.env['sf.shelf'].search([('name', '=', '一号线边刀架')], limit=1)
+ shelf_1_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-一号线边刀架')], limit=1)
tool_location_objs_1 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_1_obj.id)], order='id')
location_codes_1 = [location.barcode for location in tool_location_objs_1]
@@ -32,7 +32,7 @@ class MrsShelfLocationDataSync(models.Model):
aligned_data_1 = align_data(location_codes_1, their_data_1)
# 2
- shelf_2_obj = self.env['sf.shelf'].search([('name', '=', '二号线边刀架')], limit=1)
+ shelf_2_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-二号线边刀架')], limit=1)
tool_location_objs_2 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_2_obj.id)], order='id')
location_codes_2 = [location.barcode for location in tool_location_objs_2]
@@ -44,7 +44,7 @@ class MrsShelfLocationDataSync(models.Model):
aligned_data_2 = align_data(location_codes_2, their_data_2)
# 4
- shelf_4_obj = self.env['sf.shelf'].search([('name', '=', '一号线边料架')], limit=1)
+ shelf_4_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-一号线边料架')], limit=1)
tool_location_objs_4 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_4_obj.id)], order='id')
location_codes_4 = [location.barcode for location in tool_location_objs_4]
@@ -56,7 +56,7 @@ class MrsShelfLocationDataSync(models.Model):
aligned_data_4 = align_data(location_codes_4, their_data_4)
# 3
- shelf_3_obj = self.env['sf.shelf'].search([('name', '=', '一号线边料架')], limit=1)
+ shelf_3_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-二号线边料架')], limit=1)
tool_location_objs_3 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_3_obj.id)], order='id')
location_codes_3 = [location.barcode for location in tool_location_objs_3]
@@ -68,7 +68,7 @@ class MrsShelfLocationDataSync(models.Model):
aligned_data_3 = align_data(location_codes_3, their_data_3)
# 5
- shelf_5_obj = self.env['sf.shelf'].search([('name', '=', '一号线边料架')], limit=1)
+ shelf_5_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-三号线边料架')], limit=1)
tool_location_objs_5 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_5_obj.id)], order='id')
location_codes_5 = [location.barcode for location in tool_location_objs_5]
diff --git a/sf_warehouse/security/ir.model.access.csv b/sf_warehouse/security/ir.model.access.csv
index f981d477..88514fd3 100644
--- a/sf_warehouse/security/ir.model.access.csv
+++ b/sf_warehouse/security/ir.model.access.csv
@@ -1,7 +1,9 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sf_shelf_location_group_sf_stock_user_group_sf_stock_user,sf.shelf.location,model_sf_shelf_location,sf_base.group_sf_stock_user,1,0,0,0
+access_sf_shelf_location_lot_group_sf_stock_user_group_sf_stock_user,sf.shelf.location.lot,model_sf_shelf_location_lot,sf_base.group_sf_stock_user,1,0,0,0
access_sf_shelf_location_group_sf_stock_manager,sf.shelf.location,model_sf_shelf_location,sf_base.group_sf_stock_manager,1,1,1,0
+access_sf_shelf_location_lot_group_sf_stock_manager,sf.shelf.location.lot,model_sf_shelf_location_lot,sf_base.group_sf_stock_manager,1,1,1,0
access_sf_shelf_group_sf_stock_user_group_sf_stock_user,sf.shelf.group.sf.stock.user,model_sf_shelf,sf_base.group_sf_stock_user,1,0,0,0
access_sf_shelf_group_sf_stock_manager,sf.shelf.group.sf.stock.manager,model_sf_shelf,sf_base.group_sf_stock_manager,1,1,1,0
@@ -101,6 +103,7 @@ access_stock_replenish_option_group_sf_stock_user,stock.replenishment.option,sto
access_mrp_production_group_sf_stock_user,mrp.production,mrp.model_mrp_production,sf_base.group_sf_stock_user,1,1,1,0
access_sf_shelf_location_group_plan_dispatch,sf.shelf.location,model_sf_shelf_location,sf_base.group_plan_dispatch,1,0,0,0
+access_sf_shelf_location_lot_group_plan_dispatch,sf.shelf.location.lot,model_sf_shelf_location_lot,sf_base.group_plan_dispatch,1,0,0,0
access_stock_move,stock.move,stock.model_stock_move,sf_base.group_plan_dispatch,1,1,1,0
access_stock_picking_group_plan_dispatch,stock.picking,stock.model_stock_picking,sf_base.group_plan_dispatch,1,0,0,0
access_stock_lot_group_plan_dispatch,stock.lot,stock.model_stock_lot,sf_base.group_plan_dispatch,1,0,0,0
@@ -142,6 +145,9 @@ access_sf_shelf_location_wizard_group_sf_stock_manager,sf_shelf_location_wizard_
access_sf_shelf_location_group_sf_tool_user,sf.shelf.location.group_sf_tool_user,model_sf_shelf_location,sf_base.group_sf_tool_user,1,1,0,0
access_sf_shelf_group_user,sf.shelf.location.group_user,model_sf_shelf_location,base.group_user,1,1,0,0
+access_sf_shelf_location_lot_group_sf_tool_user,sf.shelf.location.lot.group_sf_tool_user,model_sf_shelf_location_lot,sf_base.group_sf_tool_user,1,1,0,0
+access_sf_shelf_lot_group_user,sf.shelf.location.lot.group_user,model_sf_shelf_location_lot,base.group_user,1,1,0,0
+
access_ir_model_group_sf_stock_user,ir_model_group_sf_stock_user,base.model_ir_model,sf_base.group_sf_stock_user,1,1,0,0
access_mrp_workorder_group_sf_stock_user,mrp_workorder_group_sf_stock_user,mrp.model_mrp_workorder,sf_base.group_sf_stock_user,1,0,0,0
diff --git a/sf_warehouse/views/change_stock_move_views.xml b/sf_warehouse/views/change_stock_move_views.xml
index 677f1887..a77b916c 100644
--- a/sf_warehouse/views/change_stock_move_views.xml
+++ b/sf_warehouse/views/change_stock_move_views.xml
@@ -149,6 +149,9 @@
+
+
+
diff --git a/sf_warehouse/views/shelf_location.xml b/sf_warehouse/views/shelf_location.xml
index a284f288..418f7d5c 100644
--- a/sf_warehouse/views/shelf_location.xml
+++ b/sf_warehouse/views/shelf_location.xml
@@ -133,9 +133,11 @@
type="action"
context="{'default_name':name,
'default_current_name':name,
+ 'default_current_product_sn_ids':product_sn_ids,
+ 'default_lot_id':product_sn_id,
'default_current_shelf_id':shelf_id,
'default_current_location_id':location_id,
- 'default_current_barcode':barcode,
+ 'default_current_barcode_id':id,
'default_current_product_id':product_id,
}"
class="btn-primary" attrs="{'invisible':[('location_status','!=','占用')]}"/>
@@ -169,8 +171,16 @@
-
+
+
+
+
+
+
+
diff --git a/sf_warehouse/wizard/wizard.py b/sf_warehouse/wizard/wizard.py
index db64fe07..62ed5771 100644
--- a/sf_warehouse/wizard/wizard.py
+++ b/sf_warehouse/wizard/wizard.py
@@ -8,17 +8,23 @@ class ShelfLocationWizard(models.TransientModel):
name = fields.Char('')
- current_location_id = fields.Many2one('stock.location', string='所属库区', readonly=True)
+ lot_id = fields.Many2one('stock.lot', string="序列号", readonly=True)
+ current_location_id = fields.Many2one('stock.location', string='所属库区', readonly=True)
current_shelf_id = fields.Many2one('sf.shelf', string='当前货架', readonly=True)
- current_barcode = fields.Char('当前货位编码', readonly=True)
+ current_barcode_id = fields.Many2one('sf.shelf.location', string='当前货位编码', readonly=True)
current_name = fields.Char('当前货位名称', readonly=True)
current_product_id = fields.Many2one('product.product', string='产品', readonly=True)
+ current_product_sn_ids = fields.Many2many('sf.shelf.location.lot', 'shelf_location_wizard', string='产品批次号',
+ readonly=True)
+ destination_location_id = fields.Many2one('stock.location', string='目标库区', compute='_compute_destination_name')
destination_shelf_id = fields.Many2one('sf.shelf', string='目标货架', compute='_compute_destination_name')
destination_barcode_id = fields.Many2one('sf.shelf.location', string='目标货位编码', required=True,
- domain="")
+ domain="[('product_id', 'in', (False, current_product_id))]")
destination_name = fields.Char('目标货位名称', compute='_compute_destination_name')
+ destination_product_sn_ids = fields.Many2many('sf.shelf.location.lot', 'shelf_location_wizard', string='批次号',
+ domain="[('shelf_location_id', '=', current_barcode_id)]")
def return_domain(self):
val = [('location_status', '=', '空闲')]
@@ -32,9 +38,11 @@ class ShelfLocationWizard(models.TransientModel):
def _compute_destination_name(self):
if self.destination_barcode_id:
self.destination_name = self.destination_barcode_id.name
+ self.destination_location_id = self.destination_barcode_id.location_id.id
self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
else:
self.destination_name = ''
+ self.destination_location_id = False
self.destination_shelf_id = False
#
@@ -43,22 +51,46 @@ class ShelfLocationWizard(models.TransientModel):
# if self.destination_barcode_id:
# self.destination_shelf_id = self.destination_barcode_id.shelf_id.id
- def confirm_the_change(self):
- shelf_location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.current_barcode)])
- # 变更货位
- if self.destination_barcode_id and shelf_location:
- if self.destination_barcode_id.product_id and self.destination_barcode_id.product_id == shelf_location.product_id and not self.destination_barcode_id.product_sn_id:
- self.destination_barcode_id.product_num += shelf_location.product_num
- else:
- self.destination_barcode_id.product_sn_id = shelf_location.product_sn_id.id
- self.destination_barcode_id.product_id = shelf_location.product_id.id
- self.destination_barcode_id.product_num = shelf_location.product_num
+ def create_stock_moves(self, lot_id, num):
+ # 创建产品货位变更的库存移动记录
+ stock_move_id = self.env['stock.move'].sudo().create({
+ 'name': 'HWBG/%s' % self.id,
+ 'product_id': self.current_product_id.id,
+ 'location_id': self.current_location_id.id,
+ 'location_dest_id': self.destination_location_id.id,
+ 'product_uom_qty': num,
+ 'state': 'done'
+ })
+ # 创建移动历史记录
+ stock_move_line_id = self.env['stock.move.line'].sudo().create({
+ 'product_id': self.current_product_id.id,
+ 'lot_id': lot_id.id,
+ 'move_id': stock_move_id.id,
+ 'current_location_id': self.current_barcode_id.id,
+ 'destination_location_id': self.destination_barcode_id.id,
+ 'install_tool_time': fields.Datetime.now(),
+ 'qty_done': num,
+ 'state': 'done'
+ })
- shelf_location.product_sn_id = False
- shelf_location.product_id = False
- shelf_location.product_num = 0
+ return stock_move_id, stock_move_line_id
+
+ def confirm_the_change(self):
+ if self.destination_barcode_id:
+ if self.lot_id:
+ self.current_barcode_id.product_sn_id = False
+ self.destination_barcode_id.product_sn_id = self.lot_id.id
+ self.create_stock_moves(self.lot_id, 1)
+ elif self.current_product_sn_ids:
+ for current_product_sn_id in self.current_product_sn_ids:
+ self.create_stock_moves(current_product_sn_id.lot_id, current_product_sn_id.qty_num)
+ current_product_sn_id.write({
+ 'qty_num': 0
+ })
+ else:
+ raise ValidationError('没有需要变更的批次/序列号!')
else:
- raise ValidationError('目标货位出错,请联系管理员!')
+ raise ValidationError('请选择目标货位编码!')
# 关闭弹出窗口
return {'type': 'ir.actions.act_window_close'}
diff --git a/sf_warehouse/wizard/wizard_view.xml b/sf_warehouse/wizard/wizard_view.xml
index 1bb95e15..d77a813c 100644
--- a/sf_warehouse/wizard/wizard_view.xml
+++ b/sf_warehouse/wizard/wizard_view.xml
@@ -6,27 +6,45 @@