diff --git a/jikimo_frontend/static/src/js/custom_form_status_indicator.js b/jikimo_frontend/static/src/js/custom_form_status_indicator.js
index 7db13b4b..100542b8 100644
--- a/jikimo_frontend/static/src/js/custom_form_status_indicator.js
+++ b/jikimo_frontend/static/src/js/custom_form_status_indicator.js
@@ -4,6 +4,7 @@ import {patch} from '@web/core/utils/patch';
// import { Dialog } from "@web/core/dialog/dialog";
import {_t} from "@web/core/l10n/translation";
import {FormStatusIndicator} from "@web/views/form/form_status_indicator/form_status_indicator";
+import {ListRenderer} from "@web/views/list/list_renderer";
import {Field} from "@web/views/fields/field";
@@ -45,6 +46,11 @@ const filedRequiredList = {
'date_planned_start': { multiple: false, noLabel: false },
'date_planned_finished': { multiple: false, noLabel: false },
}
+const tableRequiredList = [
+ 'product_template_id', 'product_uom_qty', 'price_unit','product_id','product_qty',
+ 'name', 'fault_type', 'maintenance_standards', 'Period'
+]
+
patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', {
// 你可以重写或者添加一些方法和属性
async _onDiscardChanges() {
@@ -110,7 +116,24 @@ patch(Field.prototype, 'jikimo_frontend.Field', {
}
}
})
-
+patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
+ setup(){
+ owl.onMounted(() => {
+ this.activeElement = this.uiService.activeElement;
+ this.setRequired()
+ })
+ return this._super(...arguments);
+ },
+ setRequired() {
+ this.allColumns.forEach(_ => {
+ if( tableRequiredList.indexOf(_.name) >= 0 ) {
+ const dom = $(`th[data-name=${_.name}]`)
+ let t = dom.html()
+ dom.html('*' + t)
+ }
+ })
+ }
+})
$(function () {
document.addEventListener('click', function () {
@@ -160,45 +183,13 @@ $(function () {
}, 500)
}
- function setRequired(dom = {label: [], table: []}) {
- let domTimer = null
- let timer_count = 0
- clearInterval(domTimer)
- domTimer = setInterval(() => {
- timer_count++
- const lint = $('.o_form_view_container')
- if (lint.length) {
- clearInterval(domTimer)
- const { table} = dom
-
- if (table.length) {
- table.forEach(_ => {
- const th = $(`th[data-name=${_}]`)
- const t = th.find('span').eq(0).text().replace('*','')
- th.find('span').eq(0).html('*' + t)
-
- })
-
- }
- }
- if (timer_count == 20) {
- clearInterval(domTimer)
- }
- }, 500)
- }
-
var currentUrl = location.href
- const customRequiredDom = {
- table: ['product_template_id', 'product_uom_qty', 'price_unit','product_id','product_qty', 'name', 'fault_type', 'maintenance_standards', 'Period']
- }
const listenerUrl = setInterval(() => {
const isChange = currentUrl != location.href
if (isChange) {
currentUrl = location.href
customRequired()
- setRequired(customRequiredDom)
}
}, 500)
customRequired()
- setRequired(customRequiredDom)
})
diff --git a/jikimo_frontend/static/src/scss/custom_style.scss b/jikimo_frontend/static/src/scss/custom_style.scss
index bc1be730..f7195534 100644
--- a/jikimo_frontend/static/src/scss/custom_style.scss
+++ b/jikimo_frontend/static/src/scss/custom_style.scss
@@ -467,3 +467,15 @@ div:has(.o_required_modifier) > label::before {
background: #71639e;
color: #fff
}
+
+// 修改时间输入框宽度
+.o_datepicker_input.o_input.datetimepicker-input {
+ width: 200px;
+}
+
+
+.o_form_view .o_form_editable .o_row > .o_field_widget, .o_form_view .o_form_editable .o_row > .o_field_widget.o_field_float_time {
+ width: auto !important;
+ flex: unset;
+}
+
diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py
index a3a9e172..f2010b4a 100644
--- a/sf_base/models/tool_base_new.py
+++ b/sf_base/models/tool_base_new.py
@@ -308,3 +308,28 @@ class ToolGroups(models.Model):
# records = super(ToolGroups, self).create(vals_list)
# self._register_tool_groups(records)
# return records
+
+
+class ToolInventory(models.Model):
+ _name = 'sf.tool.inventory'
+ _description = '功能刀具清单'
+
+ name = fields.Char('功能刀具名称', required=True)
+ type = fields.Char('类型')
+ functional_cutting_tool_model_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型')
+ prefix = fields.Char('前缀')
+ postfix = fields.Char('后缀')
+ diameter = fields.Float('直径(mm)')
+ angle = fields.Float('R角(mm)')
+ tool_length = fields.Float('刀具总长(mm)')
+ blade_length = fields.Float('避空长/刃长(mm)')
+ knife_head_name = fields.Char('刀头名称')
+ cutter_number = fields.Char('刀号')
+ blade_number = fields.Integer('刃数(个)')
+ extension = fields.Float('伸出长度(mm)')
+ work_material = fields.Selection([('钢', '钢'), ('铝', '铝')], string='加工材料')
+ life_span = fields.Float('寿命(h)')
+
+ tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组')
+
+ active = fields.Boolean('已归档', default=True)
diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv
index 2a3cd471..9d027bdb 100644
--- a/sf_base/security/ir.model.access.csv
+++ b/sf_base/security/ir.model.access.csv
@@ -192,4 +192,11 @@ access_sf_machine_brand_tags_group_purchase_director,sf_machine_brand_tags_group
access_printer,printer,model_printer,base.group_user,1,1,1,1
-access_printer_configuration,printer.configuration,model_printer_configuration,base.group_user,1,1,1,1
\ No newline at end of file
+access_printer_configuration,printer.configuration,model_printer_configuration,base.group_user,1,1,1,1
+
+access_group_sf_mrp_user,sf_tool_inventory,model_sf_tool_inventory,base.group_user,1,1,1,0
+access_group_sf_mrp_user_admin,sf_tool_inventory_admin,model_sf_tool_inventory,base.group_system,1,1,1,0
+access_group_sf_mrp_user_group_purchase_director,sf_tool_inventory_group_purchase_director,model_sf_tool_inventory,sf_base.group_purchase_director,1,0,1,0
+access_group_sf_mrp_user_group_sale_director,sf_tool_inventory_group_sale_director,model_sf_tool_inventory,sf_base.group_sale_director,1,0,1,0
+access_sf_cutting_tool_material_group_plan_director,sf_tool_inventory_group_plan_director,model_sf_tool_inventory,sf_base.group_plan_director,1,0,1,0
+access_group_sf_mrp_user_group_sf_mrp_user,sf_tool_inventory_group_sf_mrp_user,model_sf_tool_inventory,sf_base.group_sf_mrp_user,1,1,0,0
\ No newline at end of file
diff --git a/sf_base/static/src/scss/test.scss b/sf_base/static/src/scss/test.scss
index fdc5821e..c91a8a77 100644
--- a/sf_base/static/src/scss/test.scss
+++ b/sf_base/static/src/scss/test.scss
@@ -189,3 +189,6 @@ td.o_required_modifier {
flex-direction: row !important;
}
+.supplier_ids_set_css thead th[data-name=partner_id]{
+ width: 500px!important;
+}
\ No newline at end of file
diff --git a/sf_base/views/common_view.xml b/sf_base/views/common_view.xml
index 0826b51c..e829274a 100644
--- a/sf_base/views/common_view.xml
+++ b/sf_base/views/common_view.xml
@@ -269,7 +269,7 @@
-
+
diff --git a/sf_base/views/tool_menu.xml b/sf_base/views/tool_menu.xml
index 506a73df..bad606d6 100644
--- a/sf_base/views/tool_menu.xml
+++ b/sf_base/views/tool_menu.xml
@@ -59,14 +59,14 @@
id="menu_sf_cutting_tool_type"
parent="menu_sf_cutting_tool"
name="刀具类型"
- sequence="2"
+ sequence="10"
action="action_sf_cutting_tool_type"
/>
@@ -82,7 +82,7 @@
id="menu_sf_functional_cutting_tool_model_type"
parent="menu_sf_cutting_tool"
name="功能刀具类型"
- sequence="4"
+ sequence="30"
action="action_sf_functional_cutting_tool_model_type"
/>
@@ -91,14 +91,14 @@
name="能力特征库"
parent="menu_sf_cutting_tool"
action="action_maintenance_equipment_image"
- sequence="5"/>
+ sequence="40"/>
+ sequence="50"/>
diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml
index 34b87a41..e52a6222 100644
--- a/sf_base/views/tool_views.xml
+++ b/sf_base/views/tool_views.xml
@@ -123,7 +123,7 @@
+ attrs="{'readonly': [('id','!=', False)]}"/>
{'required': [('phone', '=', False)],'readonly': [('id','!=', False)]}
@@ -37,19 +37,19 @@
- {'required': [('supplier_rank','>', 0)],'readonly': [('id','!=', False)]}
+ {'readonly': [('id','!=', False)]}
- {'required': [('supplier_rank','>', 0)],'readonly': [('id','!=', False)]}
+ {'readonly': [('id','!=', False)]}
- {'required': [('supplier_rank','>', 0)],'readonly': [('id','!=', False)]}
+ {'readonly': [('id','!=', False)]}
- {'required': [('supplier_rank','>', 0)],'readonly': [('id','!=', False)]}
+ {'readonly': [('id','!=', False)]}
diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py
index 766bb8a9..d90c65bd 100644
--- a/sf_tool_management/models/base.py
+++ b/sf_tool_management/models/base.py
@@ -309,7 +309,8 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
_name = 'sf.real.time.distribution.of.functional.tools'
_description = '功能刀具安全库存'
- name = fields.Char('功能刀具名称', readonly=True, compute='_compute_name')
+ name = fields.Char('名称', readonly=True, compute='_compute_name', store=True)
+ functional_name_id = fields.Many2one('sf.tool.inventory', string='功能刀具名称', required=True)
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=False, required=True)
sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False,
group_expand='_read_mrs_cutting_tool_type_ids', store=True)
@@ -355,13 +356,13 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
active = fields.Boolean(string='已归档', default=True)
- @api.depends('tool_groups_id', 'diameter', 'knife_tip_r_angle')
+ @api.depends('functional_name_id')
def _compute_name(self):
for obj in self:
if obj.tool_groups_id:
- obj.sudo().name = '%s-D%sR%s' % (obj.tool_groups_id.name, obj.diameter, obj.knife_tip_r_angle)
+ obj.name = obj.functional_name_id.name
else:
- obj.sudo().name = None
+ obj.sudo().name = ''
@api.constrains('min_stock_num', 'max_stock_num')
def _check_stock_num(self):
@@ -452,7 +453,8 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
"""
# 根据功能刀具名称、刀具组、直径或尖刀R角、粗/中/精查询该功能刀具是否已经存在
record = self.env['sf.real.time.distribution.of.functional.tools'].search(
- [('name', '=', vals['name']), ('sf_cutting_tool_type_id', '=', vals['sf_cutting_tool_type_id']),
+ [('functional_name_id', '=', vals['functional_name_id']),
+ ('sf_cutting_tool_type_id', '=', vals['sf_cutting_tool_type_id']),
('diameter', '=', vals['diameter']), ('knife_tip_r_angle', '=', vals['knife_tip_r_angle']),
('coarse_middle_thin', '=', vals['coarse_middle_thin']), ('tool_groups_id', '=', vals['tool_groups_id'])])
if len(record) > 0:
diff --git a/sf_tool_management/models/functional_tool_enroll.py b/sf_tool_management/models/functional_tool_enroll.py
index d762c865..8fb781f8 100644
--- a/sf_tool_management/models/functional_tool_enroll.py
+++ b/sf_tool_management/models/functional_tool_enroll.py
@@ -40,7 +40,7 @@ class StockLot(models.Model):
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)])
+ objs_all = self.env['stock.lot'].search([('id', '=', self.id), ('active', 'in', [True, False])])
tool_material_stock_list = []
if objs_all:
for item in objs_all:
diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml
index 4406a90f..4dd23a4e 100644
--- a/sf_tool_management/views/tool_base_views.xml
+++ b/sf_tool_management/views/tool_base_views.xml
@@ -299,7 +299,8 @@
sf.real.time.distribution.of.functional.tools
-
+
+
@@ -329,9 +330,11 @@
-
+
+
@@ -1056,7 +1059,7 @@
-
+
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py
index dbece7b7..303c87d5 100644
--- a/sf_tool_management/wizard/wizard.py
+++ b/sf_tool_management/wizard/wizard.py
@@ -222,110 +222,162 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
image = fields.Binary('图片')
# 功能刀具组装信息
- # 整体式刀具型号
+ # ===============整体式刀具型号=================
+ integral_freight_barcode = fields.Char('整体式刀具货位')
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具'),
('tool_material_status', '=', '可用')])
+ 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='整体式刀具型号',
- related='integral_code_id.product_id.cutting_tool_model_id')
- integral_name = fields.Char('整体式刀具名称', related='integral_code_id.product_id.name')
+ related='integral_product_id.cutting_tool_model_id')
integral_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='整体式刀具规格',
- related='integral_code_id.product_id.specification_id')
+ related='integral_product_id.specification_id')
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
- related='integral_code_id.product_id.brand_id')
+ related='integral_product_id.brand_id')
- # 刀片型号
+ @api.depends('integral_freight_barcode')
+ def _compute_integral_product_id(self):
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)])
+ if location:
+ self.integral_product_id = location.product_id.id
+
+ # ===============刀片型号====================
+ blade_freight_barcode = fields.Char('刀片货位')
blade_code_id = fields.Many2one('stock.lot', '刀片序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀片'),
('tool_material_status', '=', '可用')])
+ 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='刀片型号',
- related='blade_code_id.product_id.cutting_tool_model_id')
- blade_name = fields.Char('刀片名称', related='blade_code_id.product_id.name')
+ related='blade_product_id.cutting_tool_model_id')
blade_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀片规格',
- related='blade_code_id.product_id.specification_id')
- sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_code_id.product_id.brand_id')
+ 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')
+ def _compute_blade_product_id(self):
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)])
+ if location:
+ self.blade_product_id = location.product_id.id
+
+ # ====================刀杆型号==================
+ bar_freight_barcode = fields.Char('刀杆货位')
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆'),
('tool_material_status', '=', '可用')])
+ 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='刀杆型号',
- related='bar_code_id.product_id.cutting_tool_model_id')
- bar_name = fields.Char('刀杆名称', related='bar_code_id.product_id.name')
+ related='bar_product_id.cutting_tool_model_id')
bar_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀杆规格',
- related='bar_code_id.product_id.specification_id')
- sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_code_id.product_id.brand_id')
+ 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')
+ def _compute_bar_product_id(self):
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)])
+ if location:
+ self.bar_product_id = location.product_id.id
+
+ # ===============刀盘型号===================
+ pad_freight_barcode = fields.Char('刀盘货位')
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘'),
('tool_material_status', '=', '可用')])
+ 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='刀盘型号',
- related='pad_code_id.product_id.cutting_tool_model_id')
- pad_name = fields.Char('刀盘名称', related='pad_code_id.product_id.name')
+ related='pad_product_id.cutting_tool_model_id')
pad_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀盘规格',
- related='pad_code_id.product_id.specification_id')
- sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_code_id.product_id.brand_id')
+ 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')
+ def _compute_pad_product_id(self):
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)])
+ if location:
+ self.pad_product_id = location.product_id.id
+
+ # ================刀柄型号===============
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True,
domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄'),
('tool_material_status', '=', '可用')])
+ handle_product_id = fields.Many2one('product.product', string='刀柄名称', related='handle_code_id.product_id')
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
related='handle_code_id.product_id.cutting_tool_model_id')
- handle_name = fields.Char('刀柄名称', related='handle_code_id.product_id.name')
handle_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀柄规格',
related='handle_code_id.product_id.specification_id')
sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', related='handle_code_id.product_id.brand_id')
- # 夹头型号
- chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', required=True,
+ # =================夹头型号==============
+ chuck_freight_barcode = fields.Char('夹头货位', required=True)
+ chuck_code_id = fields.Many2one('stock.lot', '夹头序列号',
domain=[('product_id.cutting_tool_material_id.name', '=', '夹头'),
('tool_material_status', '=', '可用')])
+ 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='夹头型号',
- related='chuck_code_id.product_id.cutting_tool_model_id')
- chuck_name = fields.Char('夹头名称', related='chuck_code_id.product_id.name')
+ related='chuck_product_id.cutting_tool_model_id')
chuck_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='夹头规格',
- related='chuck_code_id.product_id.specification_id')
- sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_code_id.product_id.brand_id')
+ 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')
+ def _compute_chuck_product_id(self):
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)])
+ if location:
+ self.chuck_product_id = location.product_id.id
+
+ # ========================================
def on_barcode_scanned(self, barcode):
"""
- 智能工厂组装单处扫码绑定刀具物料')
+ 智能工厂组装单处扫码绑定刀具物料
"""
for record in self:
- if 'DJWL' in barcode:
- records = record.env['stock.lot'].search([('name', '=', barcode)])
- if not records:
- raise ValidationError('扫描的条形码数据不存在,请重新扫描!')
- for record_stock_lot in records:
- if record_stock_lot.quant_ids[-1].location_id.name == '刀具组装位置':
- raise ValidationError('该刀具物料已使用,请重新选择!!!')
- elif record_stock_lot.quant_ids[-1].location_id.name not in '刀具房':
- raise ValidationError('该刀具物料未入库,请重新选择!!!')
- tool_material_name = record_stock_lot.product_id.cutting_tool_material_id.name
- if tool_material_name == '整体式刀具':
- record.integral_code_id = record_stock_lot.id
- elif tool_material_name == '刀片':
- record.blade_code_id = record_stock_lot.id
- elif tool_material_name == '刀杆':
- record.bar_code_id = record_stock_lot.id
- elif tool_material_name == '刀盘':
- record.pad_code_id = record_stock_lot.id
- elif tool_material_name == '刀柄':
- record.handle_code_id = record_stock_lot.id
- elif tool_material_name == '夹头':
- record.chuck_code_id = record_stock_lot.id
+ lot_ids = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)])
+ if lot_ids:
+ for lot_id in lot_ids:
+ if lot_id.quant_ids[-1].location_id.name in '刀具房':
+ record.handle_code_id = lot_id.id
+ elif lot_id.quant_ids[-1].location_id.name == '刀具组装位置':
+ raise ValidationError('该刀柄已使用,请重新扫描!!!')
+ else:
+ raise ValidationError('该刀柄未入库,请重新扫描!!!')
+ else:
+ location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', barcode)])
+ if location:
+ material_name = location.product_id.cutting_tool_material_id.name
+ if material_name == '整体式刀具':
+ record.integral_freight_barcode = barcode
+ elif material_name == '刀片':
+ record.blade_freight_barcode = barcode
+ elif material_name == '刀杆':
+ record.bar_freight_barcode = barcode
+ elif material_name == '刀盘':
+ record.pad_freight_barcode = barcode
+ elif material_name == '夹头':
+ record.chuck_freight_barcode = barcode
else:
raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
+ else:
+ raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
+
+ @api.depends('handle_code_id')
+ def _compute_rfid(self):
+ for item in self:
+ if item:
+ item.rfid = item.handle_code_id.rfid
else:
- record.rfid = barcode
+ item.rfid = None
# 组装功能刀具参数信息
+ after_name_id = fields.Many2one('sf.tool.inventory', string='功能刀具名称', required=True)
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
- rfid = fields.Char('Rfid', required=True)
+ rfid = fields.Char('Rfid', readonly=True, store=True, compute='_compute_rfid')
tool_code = fields.Char(string='功能刀具编码', readonly=True, compute='_compute_tool_code')
- after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name')
+ after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name', store=True)
after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
string='组装后功能刀具类型',
compute='_compute_after_assembly_functional_tool_type_id')
@@ -377,7 +429,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
num = self._get_code(str_2)
obj.tool_code = str_2 + str(num)
else:
- obj.tool_code = None
+ obj.tool_code = ''
def _get_code(self, str_2):
functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().search(
@@ -392,17 +444,15 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
num = "%03d" % m
return num
- @api.depends('after_assembly_functional_tool_diameter', 'after_assembly_knife_tip_r_angle', 'tool_groups_id')
+ @api.depends('after_name_id')
def _compute_name(self):
for obj in self:
- if obj.tool_groups_id:
- obj.after_assembly_functional_tool_name = '%s-D%sR%s' % (
- obj.tool_groups_id.name, obj.after_assembly_functional_tool_diameter,
- obj.after_assembly_knife_tip_r_angle)
+ if obj.after_name_id:
+ obj.after_assembly_functional_tool_name = obj.after_name_id.name
else:
- obj.after_assembly_functional_tool_name = None
+ obj.after_assembly_functional_tool_name = ''
- @api.onchange('integral_code_id')
+ @api.onchange('integral_freight_barcode')
def _onchange_after_assembly_functional_tool_diameter(self):
for obj in self:
if obj.integral_code_id:
@@ -434,28 +484,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
else:
record.L_D_number = 0
- @api.constrains('after_assembly_tool_loading_length', 'after_assembly_functional_tool_length')
+ @api.constrains('after_assembly_tool_loading_length', 'after_assembly_functional_tool_length',
+ 'after_assembly_max_lifetime_value', 'after_assembly_alarm_value',
+ 'after_assembly_effective_length', 'hiding_length')
def _check_length_control(self):
for obj in self:
if obj.after_assembly_tool_loading_length == 0:
raise ValidationError('组装参数信息【总长度】不能为0!!!')
if obj.after_assembly_functional_tool_length == 0:
raise ValidationError('组装参数信息【伸出长】不能为0!!!')
-
- @api.constrains('rfid')
- def _check_rfid(self):
- self.get_rfid()
-
- @api.onchange('rfid')
- def _onchange_rfid(self):
- self.get_rfid()
-
- def get_rfid(self):
- for obj in self:
- if obj.rfid:
- tool_entity = self.env['sf.functional.cutting.tool.entity'].sudo().search([('rfid', '=', obj.rfid)])
- if tool_entity:
- raise ValidationError('【%s】的Rfid已被使用,请重新录入!!!' % obj.rfid)
+ if obj.after_assembly_max_lifetime_value == 0:
+ raise ValidationError('组装参数信息【最大寿命值】不能为0!!!')
+ if obj.after_assembly_alarm_value == 0:
+ raise ValidationError('组装参数信息【报警值】不能为0!!!')
+ if obj.after_assembly_effective_length == 0:
+ raise ValidationError('组装参数信息【有效长】不能为0!!!')
+ if obj.hiding_length == 0:
+ raise ValidationError('组装参数信息【避空长】不能为0!!!')
def functional_tool_assembly(self):
"""
@@ -499,7 +544,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2)
# 创建安全库存信息
self.env['sf.real.time.distribution.of.functional.tools'].create_or_edit_safety_stock({
- 'name': self.after_assembly_functional_tool_name,
+ 'functional_name_id': self.after_name_id.id,
'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id,
'tool_groups_id': self.tool_groups_id.id,
'diameter': self.after_assembly_functional_tool_diameter,
@@ -543,12 +588,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'name': self.after_assembly_functional_tool_name,
'rfid': self.rfid,
'tool_groups_id': self.tool_groups_id.id,
- 'integral_code_id': self.integral_code_id.id,
- 'blade_code_id': self.blade_code_id.id,
- 'bar_code_id': self.bar_code_id.id,
- 'pad_code_id': self.pad_code_id.id,
+ 'integral_product_id': self.integral_product_id.id,
+ 'blade_product_id': self.blade_product_id.id,
+ 'bar_product_id': self.bar_product_id.id,
+ 'pad_product_id': self.pad_product_id.id,
'handle_code_id': self.handle_code_id.id,
- 'chuck_code_id': self.chuck_code_id.id,
+ 'chuck_product_id': self.chuck_product_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,
@@ -583,12 +628,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'tool_groups_id': self.tool_groups_id.id,
'functional_tool_name_id': functional_tool_assembly_id.id,
'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id,
- 'cutting_tool_integral_model_id': self.integral_code_id.product_id.id,
- 'cutting_tool_blade_model_id': self.blade_code_id.product_id.id,
- 'cutting_tool_cutterbar_model_id': self.bar_code_id.product_id.id,
- 'cutting_tool_cutterpad_model_id': self.pad_code_id.product_id.id,
- 'cutting_tool_cutterhandle_model_id': self.handle_code_id.product_id.id,
- 'cutting_tool_cutterhead_model_id': self.chuck_code_id.product_id.id,
+ 'cutting_tool_integral_model_id': self.integral_product_id.id,
+ 'cutting_tool_blade_model_id': self.blade_product_id.id,
+ 'cutting_tool_cutterbar_model_id': self.bar_product_id.id,
+ 'cutting_tool_cutterpad_model_id': self.pad_product_id.id,
+ 'cutting_tool_cutterhandle_model_id': self.handle_product_id.id,
+ 'cutting_tool_cutterhead_model_id': self.chuck_product_id.id,
'functional_tool_diameter': self.after_assembly_functional_tool_diameter,
'knife_tip_r_angle': self.after_assembly_knife_tip_r_angle,
diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml
index f055ffba..912f7dcf 100644
--- a/sf_tool_management/wizard/wizard_view.xml
+++ b/sf_tool_management/wizard/wizard_view.xml
@@ -201,20 +201,18 @@
+ attrs="{'invisible': ['|','|',('blade_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False),('pad_freight_barcode', '!=', False)]}">
-
+
-
+
@@ -223,20 +221,18 @@
-
+
-
+
-
+
@@ -246,20 +242,18 @@
+ attrs="{'invisible': ['|',('integral_freight_barcode', '!=', False),('pad_freight_barcode', '!=', False)]}">
-
+
-
+
@@ -269,20 +263,18 @@
+ attrs="{'invisible': ['|',('bar_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False)]}">
-
+
-
+
@@ -304,7 +296,7 @@
-
+
@@ -319,14 +311,12 @@
-
+
-
+
@@ -342,7 +332,8 @@
-
+
+
diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py
index 1e1d8328..37030471 100644
--- a/sf_warehouse/models/model.py
+++ b/sf_warehouse/models/model.py
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
+import re
+
import datetime
import logging
import base64
@@ -19,14 +21,6 @@ class SfLocation(models.Model):
name = fields.Char('Location Name', required=True, size=20)
barcode = fields.Char('Barcode', copy=False, size=15)
- check_state = fields.Selection([
- ('enable', '启用'),
- ('close', '关闭')
- ], string='审核状态', default='close')
-
- def action_check(self):
- self.check_state = 'enable'
-
# 仓库类别(selection:库区、库位、货位)
# location_type = fields.Selection([
# ('库区', '库区'),
@@ -444,6 +438,8 @@ class Sf_stock_move_line(models.Model):
current_product_id = fields.Integer(compute='_compute_location_dest_id_value', store=True)
there_is_no_sn = fields.Boolean('是否有序列号', default=False)
+ rfid = fields.Char('Rfid', readonly=True)
+
def action_revert_inventory(self):
# 检查用户是否有执行操作的权限
if not self.env.user.has_group('sf_warehouse.group_sf_stock_user'):
@@ -774,21 +770,30 @@ class SfStockPicking(models.Model):
# line.current_location_id.location_status = '空闲'
line.current_location_id.product_num = 0
+ for move in self.move_ids:
+ 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.location_dest_id.name == '进货':
+ if not item.rfid:
+ raise ValidationError('你需要提供%s的Rfid' % move.product_id.name)
+ self.env['stock.lot'].search([('name', '=', item.lot_name)]).write({'rfid': item.rfid})
return res
- # def print_all_barcode(self):
- # """
- # 打印所有编码
- # """
- # print('================')
- # for record in self.move_ids_without_package:
- # print('record', record)
- # print('record.move_line_ids', record.move_line_ids)
- #
- # # record.move_line_ids.print_qr_code()
- #
- # print('record.move_line_ids.lot_id', record.move_line_ids.lot_id)
- # print('record.move_line_ids.lot_id.name', record.move_line_ids.lot_id.name)
+
+# def print_all_barcode(self):
+# """
+# 打印所有编码
+# """
+# print('================')
+# for record in self.move_ids_without_package:
+# print('record', record)
+# print('record.move_line_ids', record.move_line_ids)
+#
+# # record.move_line_ids.print_qr_code()
+#
+# print('record.move_line_ids.lot_id', record.move_line_ids.lot_id)
+# print('record.move_line_ids.lot_id.name', record.move_line_ids.lot_id.name)
class SfProcurementGroup(models.Model):
@@ -854,117 +859,43 @@ class SfProcurementGroup(models.Model):
return res
-class SfWarehouse(models.Model):
- _inherit = 'stock.warehouse'
-
- check_state = fields.Selection([
- ('enable', '启用'),
- ('close', '关闭')
- ], string='审核状态', default='close')
-
- def action_check(self):
- self.check_state = 'enable'
-
-
-class SfRule(models.Model):
- _inherit = 'stock.rule'
-
- check_state = fields.Selection([
- ('enable', '启用'),
- ('close', '关闭')
- ], string='审核状态', default='close')
-
- def action_check(self):
- self.check_state = 'enable'
-
-
-class SfRoute(models.Model):
- _inherit = 'stock.route'
-
- check_state = fields.Selection([
- ('enable', '启用'),
- ('close', '关闭')
- ], string='审核状态', default='close')
-
- def action_check(self):
- self.check_state = 'enable'
-
-
class SfPickingType(models.Model):
_inherit = 'stock.picking.type'
- check_state = fields.Selection([
- ('enable', '启用'),
- ('close', '关闭')
- ], string='审核状态', default='close')
-
- def action_check(self):
- self.check_state = 'enable'
-
-
-class SfBarcodeNomenclature(models.Model):
- _inherit = 'barcode.nomenclature'
-
- check_state = fields.Selection([
- ('enable', '启用'),
- ('close', '关闭')
- ], string='审核状态', default='close')
-
- def action_check(self):
- self.check_state = 'enable'
-
-
-class SfPutawayRule(models.Model):
- _inherit = 'stock.putaway.rule'
-
- check_state = fields.Selection([
- ('enable', '同意'),
- ('close', '不同意')
- ], string='审核状态', default='close')
-
- def action_check(self):
- self.check_state = 'enable'
-
-
-class SfWarehouseOrderpoint(models.Model):
- _inherit = 'stock.warehouse.orderpoint'
-
- check_state = fields.Selection([
- ('enable', '同意'),
- ('close', '不同意')
- ], string='审核状态', default='close')
-
- def action_check(self):
- self.check_state = 'enable'
-
-
-class SfStockQuant(models.Model):
- _inherit = 'stock.quant'
-
- check_state = fields.Selection([
- ('enable', '同意'),
- ('close', '不同意')
- ], string='审核状态', default='close')
-
- def action_check(self):
- self.check_state = 'enable'
-
-
-class SfStockScrap(models.Model):
- _inherit = 'stock.scrap'
-
- check_state = fields.Selection([
- ('enable', '启用'),
- ('close', '关闭')
- ], string='审核状态', default='close')
-
- def action_check(self):
- self.check_state = 'enable'
+ def _default_show_operations(self):
+ return self.user_has_groups('stock.group_production_lot,'
+ 'stock.group_stock_multi_locations,'
+ 'stock.group_tracking_lot',
+ 'sf_warehouse.group_sf_stock_user',
+ 'sf_warehouse.group_sf_stock_manager')
class CustomStockMove(models.Model):
_name = 'stock.move'
- _inherit = ['stock.move', 'printing.utils']
+ _inherit = ['stock.move', 'printing.utils', 'barcodes.barcode_events_mixin']
+
+ def on_barcode_scanned(self, barcode):
+ """
+ 采购入库扫码绑定Rfid码
+ """
+ for record in self:
+ if record:
+ if '刀柄' in (record.product_id.cutting_tool_material_id.name or '') or '托盘' in (
+ record.product_id.fixture_material_id.name or ''):
+ for move_line_nosuggest_id in record.move_line_nosuggest_ids:
+ if move_line_nosuggest_id.rfid:
+ if move_line_nosuggest_id.rfid == barcode:
+ if record.product_id.cutting_tool_material_id.name:
+ raise ValidationError('该刀柄的Rfid已经录入,请勿重复录入!!!')
+ else:
+ raise ValidationError('该托盘的Rfid已经录入,请勿重复录入!!!')
+ else:
+ line_id = int(re.sub(r"\D", "", str(move_line_nosuggest_id.id)))
+ self.env['stock.move.line'].sudo().search([('id', '=', line_id)]).write({'rfid': barcode})
+ move_line_nosuggest_id.rfid = barcode
+ break
+ else:
+ raise ValidationError('该产品不需要录入Rfid!!!')
def action_assign_serial_show_details(self):
# 首先执行原有逻辑
diff --git a/sf_warehouse/views/change_stock_move_views.xml b/sf_warehouse/views/change_stock_move_views.xml
index c9db5059..0f328b4e 100644
--- a/sf_warehouse/views/change_stock_move_views.xml
+++ b/sf_warehouse/views/change_stock_move_views.xml
@@ -39,15 +39,16 @@
-
-
-
+
+
+
-
+
+
sf.stock.move.line.form
stock.move.line
@@ -71,6 +72,9 @@
stock.move.line
+
+
+
@@ -111,10 +115,10 @@
groups="sf_warehouse.group_sf_stock_user" data-hotkey="k"/>
-
-
-
-
+
+
+
+
@@ -153,11 +157,23 @@
stock.move
-
-
-
+
+
+
- -->
+
+ -->
+
+
+
+
+
+ mrp.subcontracting.stock.move.barcode.scanned.form
+ stock.move
+
+
+
+
diff --git a/sf_warehouse/views/view.xml b/sf_warehouse/views/view.xml
index 39d5a8c0..aa3293ce 100644
--- a/sf_warehouse/views/view.xml
+++ b/sf_warehouse/views/view.xml
@@ -67,16 +67,16 @@
-
-
+
+
+
+
+
+
+
+
-
+
@@ -188,23 +188,23 @@
-
- stock.warehouse.form.sf.inherit
- stock.warehouse
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
@@ -220,23 +220,23 @@
-
- stock.route.form.sf.inherit
- stock.route
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
@@ -251,23 +251,23 @@
-
- stock.rule.form.sf.inherit
- stock.rule
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
@@ -282,23 +282,23 @@
-
- stock.picking.type.form.sf.inherit
- stock.picking.type
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+