Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/前端样式修改

# Conflicts:
#	sf_maintenance/views/equipment_maintenance_standards_views.xml

增加owl监听必填标识功能
This commit is contained in:
黄焱
2024-03-14 16:47:20 +08:00
18 changed files with 494 additions and 343 deletions

View File

@@ -5,9 +5,42 @@ import {patch} from '@web/core/utils/patch';
import {_t} from "@web/core/l10n/translation";
import {FormStatusIndicator} from "@web/views/form/form_status_indicator/form_status_indicator";
import {Field} from "@web/views/fields/field";
var Dialog = require('web.Dialog');
// var {patch} = require("web.utils") 这句话也行
const filedRequiredList = {
// 设备大模块
'control_system_id': { multiple: false, noLabel: false },
'workbench_L': { multiple: true, noLabel: false },
'number_of_axles': { multiple: true, noLabel: false },
'x_axis': { multiple: true, noLabel: false },
'number_of_knife_library': { multiple: false, noLabel: false },
'brand_id': { multiple: false, noLabel: false },
'type_id': { multiple: false, noLabel: false },
'taper_type_id': { multiple: false, noLabel: false },
'maintenance_equipment_category_id': { multiple: false, noLabel: false },
'maintenance_type': { multiple: false, noLabel: false },
// 销售大模块
'partner_id': { multiple: false, noLabel: false },
'validity_date': { multiple: false, noLabel: false },
'vat': { multiple: false, noLabel: false },
'phone': { multiple: false, noLabel: false },
'mobile': { multiple: false, noLabel: false },
'email': { multiple: false, noLabel: false },
'category_id': { multiple: false, noLabel: false },
'radio_field_1_person': { multiple: false, noLabel: true },
// 采购大模块
'date_order': { multiple: false, noLabel: false },
'picking_type_id': { multiple: false, noLabel: false },
// 制造大模块
'production_line_id': { multiple: false, noLabel: false },
'date_approve': { multiple: false, noLabel: false },
}
patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', {
// 你可以重写或者添加一些方法和属性
async _onDiscardChanges() {
@@ -46,6 +79,38 @@ patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', {
}
);
patch(Field.prototype, 'jikimo_frontend.Field', {
setup() {
this.FieldComponent = this.props.fieldInfo.FieldComponent;
if (!this.FieldComponent) {
const fieldType = this.props.record.fields[this.props.name].type;
this.FieldComponent = getFieldClassFromRegistry(fieldType, this.props.type);
}
owl.onMounted(this.setRequired);
},
setRequired() {
const id = this.props.id
const isRequired = filedRequiredList[id]
if(id == 'number_of_axles') {
console.log(isRequired)
}
if(isRequired) {
let dom;
dom = $(`label[for=${id}]`)
if(isRequired.multiple && dom.length > 1) {
dom = dom.eq(-1)
dom = dom.parent().parent().next().find('label')
}
if(isRequired.noLabel) {
dom = dom.parent().parent()
}
let t = dom.html()
t = '<i class="c* r" style="color: red;margin-left: -4px">*</i>' + t
dom.html(t)
}
}
})
$(function () {
document.addEventListener('click', function () {
@@ -104,16 +169,7 @@ $(function () {
const lint = $('.o_form_view_container')
if (lint.length) {
clearInterval(domTimer)
const {label, table} = dom
if (label.length) {
$(dom.label.join(',')).each(function () {
let t = $(this).html()
if (t.indexOf('c*') < 0) {
t = '<i class="c*" style="color: red;margin-left: -6px;margin-right: 2px">*</i>' + t
}
$(this).html(t)
})
}
const { table} = dom
if (table.length) {
table.forEach(_ => {
@@ -133,7 +189,6 @@ $(function () {
var currentUrl = location.href
const customRequiredDom = {
label: ['label[for=production_line_id]','label[for=date_approve]','label[for=partner_id]', 'label[for=validity_date]', '.o_horizontal[role=radiogroup][aria-label="公司类别"]', 'label[for=vat]', 'label[for=phone]', 'label[for=mobile]', 'label[for=email]', 'label[for=category_id]','label[for=date_order]','label[for=picking_type_id]'],
table: ['product_template_id', 'product_uom_qty', 'price_unit','product_id','product_qty', 'name', 'fault_type', 'maintenance_standards', 'Period']
}
const listenerUrl = setInterval(() => {
@@ -143,9 +198,6 @@ $(function () {
customRequired()
setRequired(customRequiredDom)
}
if($('label[for=production_line_id]')) {
setRequired({table: [], label: ['label[for=production_line_id]']})
}
}, 500)
customRequired()
setRequired(customRequiredDom)

View File

@@ -4,6 +4,8 @@ import { registry } from "@web/core/registry";
import { url } from "@web/core/utils/urls";
import { ImageField, imageCacheKey } from '@web/views/fields/image/image_field';
const placeholder = "/web/static/img/placeholder.png";
export class CustomImageField extends ImageField {
setup() {
super.setup();

View File

@@ -90,7 +90,7 @@ class MrsProductionProcess(models.Model):
code = fields.Char("编码")
name = fields.Char('名称')
remark = fields.Text("备注")
processing_order_ids = fields.One2many('sf.processing.order', 'production_process_id', string='工序')
# processing_order_ids = fields.One2many('sf.processing.order', 'production_process_id', string='工序')
partner_process_ids = fields.Many2many('res.partner', 'process_ids', '加工工厂')
active = fields.Boolean('有效', default=True)
parameter_ids = fields.One2many('sf.production.process.parameter', 'process_id', string='可选参数')
@@ -98,25 +98,25 @@ class MrsProductionProcess(models.Model):
# workcenter_ids = fields.Many2many('mrp.workcenter', 'rel_workcenter_process', required=True)
class MrsProcessingTechnology(models.Model):
_name = 'sf.processing.technology'
_description = '加工工艺'
name = fields.Char('名称', index=True)
remark = fields.Text('备注', index=True)
code = fields.Char("编码")
processing_order_ids = fields.Many2many('sf.processing.order', 'sf_associated_processes',
index=True, string='工序')
active = fields.Boolean('有效', default=True)
# class MrsProcessingTechnology(models.Model):
# _name = 'sf.processing.technology'
# _description = '加工工艺'
#
# name = fields.Char('名称', index=True)
# remark = fields.Text('备注', index=True)
# code = fields.Char("编码")
# processing_order_ids = fields.Many2many('sf.processing.order', 'sf_associated_processes',
# index=True, string='工序')
# active = fields.Boolean('有效', default=True)
class MrsProcessingOrder(models.Model):
_name = 'sf.processing.order'
_description = '工序'
sequence = fields.Integer('Sequence')
processing_technology_ids = fields.Many2many('sf.processing.technology', 'sf_associated_processes',
index=True, string='加工工艺')
production_process_id = fields.Many2one('sf.production.process', string="表面工艺")
# class MrsProcessingOrder(models.Model):
# _name = 'sf.processing.order'
# _description = '工序'
# sequence = fields.Integer('Sequence')
# processing_technology_ids = fields.Many2many('sf.processing.technology', 'sf_associated_processes',
# index=True, string='加工工艺')
# production_process_id = fields.Many2one('sf.production.process', string="表面工艺")
class SupplierSort(models.Model):

View File

@@ -9,16 +9,13 @@ access_sf_machine_brand_tags,sf_machine_brand_tags,model_sf_machine_brand_tags,b
access_sf_machine_brand_tags_admin,sf_machine_brand_tags_admin,model_sf_machine_brand_tags,base.group_system,1,1,1,0
access_sf_machine_control_system,sf_machine_control_system,model_sf_machine_control_system,base.group_user,1,1,1,0
access_sf_machine_control_system_admin,sf_machine_control_system_admin,model_sf_machine_control_system,base.group_system,1,1,1,0
access_sf_processing_order,sf_processing_order,model_sf_processing_order,base.group_user,1,1,1,0
access_sf_processing_order_admin,sf_processing_order_admin,model_sf_processing_order,base.group_system,1,1,1,0
access_sf_production_process,sf_production_process,model_sf_production_process,base.group_user,1,1,1,0
access_sf_production_process_admin,sf_production_process_admin,model_sf_production_process,base.group_system,1,1,1,0
access_sf_production_materials,sf_production_materials,model_sf_production_materials,base.group_user,1,1,1,0
access_sf_production_materials_admin,sf_production_materials_admin,model_sf_production_materials,base.group_system,1,1,1,0
access_sf_materials_model,sf_materials_model,model_sf_materials_model,base.group_user,1,1,1,0
access_sf_materials_model_admin,sf_materials_model_admin,model_sf_materials_model,base.group_system,1,1,1,0
access_sf_processing_technology,sf_processing_technology,model_sf_processing_technology,base.group_user,1,1,1,0
access_sf_processing_technology_admin,sf_processing_technology_admin,model_sf_processing_technology,base.group_system,1,1,1,0
access_sf_supplier_sort,sf_supplier_sort,model_sf_supplier_sort,base.group_user,1,1,1,0
access_sf_supplier_sort_admin,sf_supplier_sort_admin,model_sf_supplier_sort,base.group_system,1,1,1,0
access_sf_production_process_parameter,sf_production_process_parameter,model_sf_production_process_parameter,base.group_user,1,1,1,0
@@ -94,7 +91,6 @@ access_sf_machine_brand_group_purchase_director,sf_machine_brand_group_purchase_
access_sf_machine_brand_group_sale_director,sf_machine_brand_group_sale_director,model_sf_machine_brand,sf_base.group_sale_director,1,0,0,0
access_sf_machine_brand_tags,sf_machine_brand_tags,model_sf_machine_brand_tags,base.group_user,1,1,1,1
access_sf_machine_control_system,sf_machine_control_system,model_sf_machine_control_system,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_processing_order,sf_processing_order,model_sf_processing_order,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_production_process,sf_production_process,model_sf_production_process,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_production_materials,sf_production_materials,model_sf_production_materials,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_production_materials_group_plan_director,sf_production_materials_group_plan_director,model_sf_production_materials,sf_base.group_plan_director,1,1,0,0
@@ -104,7 +100,6 @@ access_sf_materials_model,sf_materials_model,model_sf_materials_model,sf_base.gr
access_sf_materials_model_group_plan_director,sf_materials_model_group_plan_director,model_sf_materials_model,sf_base.group_plan_director,1,0,0,0
access_sf_materials_model_group_purchase_director,sf_materials_model_group_purchase_director,model_sf_materials_model,sf_base.group_purchase_director,1,0,0,0
access_sf_materials_model_group_sale_director,sf_materials_model_group_sale_director,model_sf_materials_model,sf_base.group_sale_director,1,0,0,0
access_sf_processing_technology,sf_processing_technology,model_sf_processing_technology,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_supplier_sort,sf_supplier_sort,model_sf_supplier_sort,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_production_process_parameter,sf_production_process_parameter,model_sf_production_process_parameter,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_production_process_category,sf_production_process_category,model_sf_production_process_category,sf_base.group_sf_mrp_user,1,0,0,0
@@ -161,11 +156,9 @@ access_sf_machine_tool_type,sf_machine_tool_type,model_sf_machine_tool_type,sf_b
access_sf_machine_brand,sf_machine_brand,model_sf_machine_brand,sf_base.group_sf_mrp_user,1,1,0,0
access_sf_machine_brand_tags,sf_machine_brand_tags,model_sf_machine_brand_tags,sf_base.group_sf_mrp_user,1,1,0,0
access_sf_machine_control_system,sf_machine_control_system,model_sf_machine_control_system,sf_base.group_sf_mrp_user,1,1,0,0
access_sf_processing_order,sf_processing_order,model_sf_processing_order,sf_base.group_sf_mrp_user,1,1,0,0
access_sf_production_process,sf_production_process,model_sf_production_process,sf_base.group_sf_mrp_user,1,1,0,0
access_sf_production_materials,sf_production_materials,model_sf_production_materials,sf_base.group_sf_mrp_user,1,1,0,0
access_sf_materials_model,sf_materials_model,model_sf_materials_model,sf_base.group_sf_mrp_user,1,1,0,0
access_sf_processing_technology,sf_processing_technology,model_sf_processing_technology,sf_base.group_sf_mrp_user,1,1,0,0
access_sf_supplier_sort,sf_supplier_sort,model_sf_supplier_sort,sf_base.group_sf_mrp_user,1,1,0,0
access_sf_production_process_parameter,sf_production_process_parameter,model_sf_production_process_parameter,sf_base.group_sf_mrp_user,1,1,0,0
access_sf_production_process_category,sf_production_process_category,model_sf_production_process_category,sf_base.group_sf_mrp_user,1,1,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
9 access_sf_machine_brand_tags_admin sf_machine_brand_tags_admin model_sf_machine_brand_tags base.group_system 1 1 1 0
10 access_sf_machine_control_system sf_machine_control_system model_sf_machine_control_system base.group_user 1 1 1 0
11 access_sf_machine_control_system_admin sf_machine_control_system_admin model_sf_machine_control_system base.group_system 1 1 1 0
12 access_sf_processing_order access_sf_production_process sf_processing_order sf_production_process model_sf_processing_order model_sf_production_process base.group_user 1 1 1 0
access_sf_processing_order_admin sf_processing_order_admin model_sf_processing_order base.group_system 1 1 1 0
13 access_sf_production_process access_sf_production_process_admin sf_production_process sf_production_process_admin model_sf_production_process base.group_user base.group_system 1 1 1 0
14 access_sf_production_process_admin access_sf_production_materials sf_production_process_admin sf_production_materials model_sf_production_process model_sf_production_materials base.group_system base.group_user 1 1 1 0
15 access_sf_production_materials access_sf_production_materials_admin sf_production_materials sf_production_materials_admin model_sf_production_materials base.group_user base.group_system 1 1 1 0
16 access_sf_production_materials_admin access_sf_materials_model sf_production_materials_admin sf_materials_model model_sf_production_materials model_sf_materials_model base.group_system base.group_user 1 1 1 0
17 access_sf_materials_model access_sf_materials_model_admin sf_materials_model sf_materials_model_admin model_sf_materials_model base.group_user base.group_system 1 1 1 0
18 access_sf_materials_model_admin access_sf_supplier_sort sf_materials_model_admin sf_supplier_sort model_sf_materials_model model_sf_supplier_sort base.group_system base.group_user 1 1 1 0
access_sf_processing_technology sf_processing_technology model_sf_processing_technology base.group_user 1 1 1 0
access_sf_processing_technology_admin sf_processing_technology_admin model_sf_processing_technology base.group_system 1 1 1 0
19 access_sf_supplier_sort access_sf_supplier_sort_admin sf_supplier_sort sf_supplier_sort_admin model_sf_supplier_sort base.group_user base.group_system 1 1 1 0
20 access_sf_supplier_sort_admin access_sf_production_process_parameter sf_supplier_sort_admin sf_production_process_parameter model_sf_supplier_sort model_sf_production_process_parameter base.group_system base.group_user 1 1 1 0
21 access_sf_production_process_parameter access_sf_production_process_parameter_group_plan_director sf_production_process_parameter sf_production_process_parameter_group_plan_director model_sf_production_process_parameter base.group_user sf_base.group_plan_director 1 1 0 1 0 0
91 access_sf_machine_brand_tags access_sf_machine_control_system sf_machine_brand_tags sf_machine_control_system model_sf_machine_brand_tags model_sf_machine_control_system base.group_user sf_base.group_sf_mrp_user 1 1 0 1 0 1 0
92 access_sf_machine_control_system access_sf_production_process sf_machine_control_system sf_production_process model_sf_machine_control_system model_sf_production_process sf_base.group_sf_mrp_user 1 0 0 0
93 access_sf_processing_order access_sf_production_materials sf_processing_order sf_production_materials model_sf_processing_order model_sf_production_materials sf_base.group_sf_mrp_user 1 0 0 0
access_sf_production_process sf_production_process model_sf_production_process sf_base.group_sf_mrp_user 1 0 0 0
94 access_sf_production_materials access_sf_production_materials_group_plan_director sf_production_materials sf_production_materials_group_plan_director model_sf_production_materials sf_base.group_sf_mrp_user sf_base.group_plan_director 1 0 1 0 0
95 access_sf_production_materials_group_plan_director access_sf_production_materials_group_purchase_director sf_production_materials_group_plan_director sf_production_materials_group_purchase_director model_sf_production_materials sf_base.group_plan_director sf_base.group_purchase_director 1 1 0 0
96 access_sf_production_materials_group_purchase_director access_sf_production_materials_group_sale_director sf_production_materials_group_purchase_director sf_production_materials_group_sale_director model_sf_production_materials sf_base.group_purchase_director sf_base.group_sale_director 1 1 0 0
100 access_sf_materials_model_group_purchase_director access_sf_materials_model_group_sale_director sf_materials_model_group_purchase_director sf_materials_model_group_sale_director model_sf_materials_model sf_base.group_purchase_director sf_base.group_sale_director 1 0 0 0
101 access_sf_materials_model_group_sale_director access_sf_supplier_sort sf_materials_model_group_sale_director sf_supplier_sort model_sf_materials_model model_sf_supplier_sort sf_base.group_sale_director sf_base.group_sf_mrp_user 1 0 0 0
102 access_sf_processing_technology access_sf_production_process_parameter sf_processing_technology sf_production_process_parameter model_sf_processing_technology model_sf_production_process_parameter sf_base.group_sf_mrp_user 1 0 0 0
access_sf_supplier_sort sf_supplier_sort model_sf_supplier_sort sf_base.group_sf_mrp_user 1 0 0 0
103 access_sf_production_process_parameter access_sf_production_process_category sf_production_process_parameter sf_production_process_category model_sf_production_process_parameter model_sf_production_process_category sf_base.group_sf_mrp_user 1 0 0 0
104 access_sf_production_process_category access_sf_machine_tool_category sf_production_process_category sf_machine_tool_category model_sf_production_process_category model_sf_machine_tool_category sf_base.group_sf_mrp_user 1 0 0 0
105 access_sf_machine_tool_category access_sf_cutting_tool_material_group_purchase_director sf_machine_tool_category sf_cutting_tool_material_group_purchase_director model_sf_machine_tool_category model_sf_cutting_tool_material sf_base.group_sf_mrp_user sf_base.group_purchase_director 1 0 0 1 0
156 access_sf_processing_order access_sf_production_materials sf_processing_order sf_production_materials model_sf_processing_order model_sf_production_materials sf_base.group_sf_mrp_user 1 1 0 0
157 access_sf_production_process access_sf_materials_model sf_production_process sf_materials_model model_sf_production_process model_sf_materials_model sf_base.group_sf_mrp_user 1 1 0 0
158 access_sf_production_materials access_sf_supplier_sort sf_production_materials sf_supplier_sort model_sf_production_materials model_sf_supplier_sort sf_base.group_sf_mrp_user 1 1 0 0
access_sf_materials_model sf_materials_model model_sf_materials_model sf_base.group_sf_mrp_user 1 1 0 0
159 access_sf_processing_technology access_sf_production_process_parameter sf_processing_technology sf_production_process_parameter model_sf_processing_technology model_sf_production_process_parameter sf_base.group_sf_mrp_user 1 1 0 0
160 access_sf_supplier_sort access_sf_production_process_category sf_supplier_sort sf_production_process_category model_sf_supplier_sort model_sf_production_process_category sf_base.group_sf_mrp_user 1 1 0 0
161 access_sf_production_process_parameter access_sf_machine_tool_category sf_production_process_parameter sf_machine_tool_category model_sf_production_process_parameter model_sf_machine_tool_category sf_base.group_sf_mrp_user 1 1 0 0
access_sf_production_process_category sf_production_process_category model_sf_production_process_category sf_base.group_sf_mrp_user 1 1 0 0
162 access_sf_machine_tool_category access_sf_cutting_tool_material sf_machine_tool_category sf_cutting_tool_material model_sf_machine_tool_category model_sf_cutting_tool_material sf_base.group_sf_mrp_user 1 1 0 0
163 access_sf_cutting_tool_material access_sf_cutting_tool_type sf_cutting_tool_material sf_cutting_tool_type model_sf_cutting_tool_material model_sf_cutting_tool_type sf_base.group_sf_mrp_user 1 1 0 0
164 access_sf_cutting_tool_type access_sf_functional_cutting_tool sf_cutting_tool_type sf_functional_cutting_tool model_sf_cutting_tool_type model_sf_functional_cutting_tool sf_base.group_sf_mrp_user 1 1 0 0

View File

@@ -1,6 +1,60 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<!--表面工艺可选参数-->
<record model="ir.ui.view" id="mrs_production_process_parameter_tree">
<field name="model">sf.production.process.parameter</field>
<field name="arch" type="xml">
<tree string="表面工艺可选参数" delete="0">
<field name="code"/>
<field name="name"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="mrs_production_process_parameter_form">
<field name="model">sf.production.process.parameter</field>
<field name="arch" type="xml">
<form string="表面工艺可选参数" edit="0" delete="0">
<sheet>
<div class="oe_title">
<h1>
<field name="name" required="1" placeholder="名称" />
</h1>
</div>
<group>
<group>
<field name="code" readonly="1"/>
</group>
<group>
<field name="process_id" required="1"/>
</group>
</group>
<notebook>
<page string="适用材料">
<field name="materials_model_ids"></field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="search_mrs_production_process_parameter_view">
<field name="name">search.mrs.production.process.parameter</field>
<field name="model">sf.production.process.parameter</field>
<field name="arch" type="xml">
<search>
<filter name="filter_active" string="已归档" domain="[('active','=',False)]"/>
<field name="name" string="名称" filter_domain="[('name','ilike',self)]"/>
<field name="code" string="编码" filter_domain="[('codeNum','ilike',self)]"/>
<searchpanel class="account_root">
<field name="process_id" icon="fa-filter"/>
</searchpanel>
</search>
</field>
</record>
<!--加工工艺-->
<!-- <record model="ir.ui.view" id="sf_processing_technology_form">-->
<!-- <field name="model">sf.processing.technology</field>-->
@@ -20,26 +74,26 @@
<!-- </form>-->
<!-- </field>-->
<!-- </record>-->
<record model="ir.ui.view" id="sf_processing_technology_tree">
<field name="model">sf.processing.technology</field>
<field name="arch" type="xml">
<tree string="加工工艺" create="0" edit="0" delete="1">
<field name="code"/>
<field name="name"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="search_sf_processing_technology_view">
<field name="name">search.sf.processing.technology.type</field>
<field name="model">sf.processing.technology</field>
<field name="arch" type="xml">
<search>
<field name="name" string="名称搜索" filter_domain="[('name','ilike',self)]"/>
<field name="code" string="编码搜索" filter_domain="[('code','ilike',self)]"/>
<filter name="filter_active" string="已归档" domain="[('active','=',False)]"/>
</search>
</field>
</record>
<!-- <record model="ir.ui.view" id="sf_processing_technology_tree">-->
<!-- <field name="model">sf.processing.technology</field>-->
<!-- <field name="arch" type="xml">-->
<!-- <tree string="加工工艺" create="0" edit="0" delete="1">-->
<!-- <field name="code"/>-->
<!-- <field name="name"/>-->
<!-- </tree>-->
<!-- </field>-->
<!-- </record>-->
<!-- <record model="ir.ui.view" id="search_sf_processing_technology_view">-->
<!-- <field name="name">search.sf.processing.technology.type</field>-->
<!-- <field name="model">sf.processing.technology</field>-->
<!-- <field name="arch" type="xml">-->
<!-- <search>-->
<!-- <field name="name" string="名称搜索" filter_domain="[('name','ilike',self)]"/>-->
<!-- <field name="code" string="编码搜索" filter_domain="[('code','ilike',self)]"/>-->
<!-- <filter name="filter_active" string="已归档" domain="[('active','=',False)]"/>-->
<!-- </search>-->
<!-- </field>-->
<!-- </record>-->
<!--表面工艺类别-->
<record model="ir.ui.view" id="sf_production_process_category_form">
@@ -156,19 +210,7 @@
</form>
</field>
</page>
<page string="工序">
<field name='processing_order_ids' options="{'no_create':True}" widget="one2many">
<tree editable='bottom'>
<field name="sequence" widget="handle"/>
<field name="processing_technology_ids" widget="many2many_tags">
</field>
</tree>
<form>
<field name="processing_technology_ids" widget="many2many">
</field>
</form>
</field>
</page>
</notebook>
</group>
<group>
@@ -350,12 +392,12 @@
<field name="res_model">sf.materials.model</field>
<field name="view_mode">tree,form</field>
</record>
<record id="sf_processing_technology" model="ir.actions.act_window">
<field name="name">加工工艺</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.processing.technology</field>
<field name="view_mode">tree</field>
</record>
<!-- <record id="sf_processing_technology" model="ir.actions.act_window">-->
<!-- <field name="name">加工工艺</field>-->
<!-- <field name="type">ir.actions.act_window</field>-->
<!-- <field name="res_model">sf.processing.technology</field>-->
<!-- <field name="view_mode">tree</field>-->
<!-- </record>-->
<record id="sf_production_process_category" model="ir.actions.act_window">
<field name="name">表面工艺类别</field>
@@ -363,6 +405,12 @@
<field name="res_model">sf.production.process.category</field>
<field name="view_mode">tree,form</field>
</record>
<record id="mrs_production_process_parameter_action" model="ir.actions.act_window">
<field name="name">表面工艺可选参数</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.production.process.parameter</field>
<field name="view_mode">tree,form</field>
</record>
</data>

View File

@@ -111,13 +111,19 @@
/>
<menuitem
id="menu_sf_processing_technology"
name="加工工艺"
<menuitem
id="mrs_production_process_parameter_view"
name="表面工艺可选参数"
parent="menu_sf_production_process_1"
sequence="3"
action="sf_processing_technology"/>
sequence="2"
action="mrs_production_process_parameter_action"
/>
<!-- <menuitem-->
<!-- id="menu_sf_processing_technology"-->
<!-- name="加工工艺"-->
<!-- parent="menu_sf_production_process_1"-->
<!-- sequence="3"-->
<!-- action="sf_processing_technology"/>-->
<!-- <menuitem-->
<!-- id="menu_sf_partner_views"-->
@@ -143,5 +149,6 @@
sequence="1"
action="action_sf_machine_control_system"/>
</data>
</odoo>

View File

@@ -1,5 +1,6 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_equipment_maintenance_standards,equipment_maintenance_standards,model_equipment_maintenance_standards,sf_maintenance.sf_group_equipment_user,1,1,1,0
access_equipment_maintenance_standards_manager,equipment_maintenance_standards,model_equipment_maintenance_standards,sf_maintenance.sf_group_equipment_manager,1,1,1,1
access_equipment_maintenance_standards,equipment_maintenance_standards,model_equipment_maintenance_standards,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_maintenance_logs_sf_group_equipment_user,sf_maintenance_logs,model_sf_maintenance_logs,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_maintenance_logs_sf_group_equipment_manager,sf_maintenance_logs,model_sf_maintenance_logs,sf_maintenance.sf_group_equipment_manager,1,1,1,0
access_maintenance_equipment_sf_group_equipment_user,maintenance_equipment,model_maintenance_equipment,sf_maintenance.sf_group_equipment_user,1,0,0,0
@@ -9,7 +10,7 @@ access_maintenance_equipment_oee,maintenance_equipment_oee,model_maintenance_equ
access_maintenance_equipment_oee_logs_sf_group_equipment_user,maintenance_equipment_oee_logs,model_maintenance_equipment_oee_logs,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_maintenance_equipment_oee_logs,maintenance_equipment_oee_logs,model_maintenance_equipment_oee_logs,sf_maintenance.sf_group_equipment_manager,1,1,1,0
access_maintenance_standards_sf_group_equipment_user,maintenance_standards,model_maintenance_standards,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_maintenance_standards,maintenance_standards,model_maintenance_standards,sf_maintenance.sf_group_equipment_manager,1,1,1,0
access_maintenance_standards,maintenance_standards,model_maintenance_standards,sf_maintenance.sf_group_equipment_manager,1,1,1,1
access_maintenance_standard_image_sf_group_equipment_user,maintenance_standard_image,model_maintenance_standard_image,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_maintenance_standard_image,maintenance_standard_image,model_maintenance_standard_image,sf_maintenance.sf_group_equipment_manager,1,1,1,0
access_sf_robot_axis_num_sf_group_equipment_user,sf_robot_axis_num,model_sf_robot_axis_num,sf_maintenance.sf_group_equipment_user,1,0,0,0
@@ -41,16 +42,13 @@ access_sf_machine_brand_tags_sf_group_equipment_user,sf_machine_brand_tags,sf_ba
access_sf_machine_brand_tags_admin_sf_group_equipment_user,sf_machine_brand_tags_admin,sf_base.model_sf_machine_brand_tags,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_machine_control_system_sf_group_equipment_user,sf_machine_control_system,sf_base.model_sf_machine_control_system,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_machine_control_system_admin_sf_group_equipment_user,sf_machine_control_system_admin,sf_base.model_sf_machine_control_system,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_processing_order_sf_group_equipment_user,sf_processing_order,sf_base.model_sf_processing_order,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_processing_order_admin_sf_group_equipment_user,sf_processing_order_admin,sf_base.model_sf_processing_order,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_production_process_sf_group_equipment_user,sf_production_process,sf_base.model_sf_production_process,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_production_process_admin_sf_group_equipment_user,sf_production_process_admin,sf_base.model_sf_production_process,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_production_materials_sf_group_equipment_user,sf_production_materials,sf_base.model_sf_production_materials,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_production_materials_admin_sf_group_equipment_user,sf_production_materials_admin,sf_base.model_sf_production_materials,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_materials_model_sf_group_equipment_user,sf_materials_model,sf_base.model_sf_materials_model,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_materials_model_admin_sf_group_equipment_user,sf_materials_model_admin,sf_base.model_sf_materials_model,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_processing_technology_sf_group_equipment_user,sf_processing_technology,sf_base.model_sf_processing_technology,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_processing_technology_admin_sf_group_equipment_user,sf_processing_technology_admin,sf_base.model_sf_processing_technology,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_supplier_sort_sf_group_equipment_user,sf_supplier_sort,sf_base.model_sf_supplier_sort,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_supplier_sort_admin_sf_group_equipment_user,sf_supplier_sort_admin,sf_base.model_sf_supplier_sort,sf_maintenance.sf_group_equipment_user,1,0,0,0
access_sf_production_process_parameter_sf_group_equipment_user,sf_production_process_parameter,sf_base.model_sf_production_process_parameter,sf_maintenance.sf_group_equipment_user,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_equipment_maintenance_standards access_equipment_maintenance_standards_manager equipment_maintenance_standards model_equipment_maintenance_standards sf_maintenance.sf_group_equipment_user sf_maintenance.sf_group_equipment_manager 1 1 1 0 1
3 access_equipment_maintenance_standards equipment_maintenance_standards model_equipment_maintenance_standards sf_maintenance.sf_group_equipment_user 1 0 0 0
4 access_sf_maintenance_logs_sf_group_equipment_user sf_maintenance_logs model_sf_maintenance_logs sf_maintenance.sf_group_equipment_user 1 0 0 0
5 access_sf_maintenance_logs_sf_group_equipment_manager sf_maintenance_logs model_sf_maintenance_logs sf_maintenance.sf_group_equipment_manager 1 1 1 0
6 access_maintenance_equipment_sf_group_equipment_user maintenance_equipment model_maintenance_equipment sf_maintenance.sf_group_equipment_user 1 0 0 0
10 access_maintenance_equipment_oee_logs_sf_group_equipment_user maintenance_equipment_oee_logs model_maintenance_equipment_oee_logs sf_maintenance.sf_group_equipment_user 1 0 0 0
11 access_maintenance_equipment_oee_logs maintenance_equipment_oee_logs model_maintenance_equipment_oee_logs sf_maintenance.sf_group_equipment_manager 1 1 1 0
12 access_maintenance_standards_sf_group_equipment_user maintenance_standards model_maintenance_standards sf_maintenance.sf_group_equipment_user 1 0 0 0
13 access_maintenance_standards maintenance_standards model_maintenance_standards sf_maintenance.sf_group_equipment_manager 1 1 1 0 1
14 access_maintenance_standard_image_sf_group_equipment_user maintenance_standard_image model_maintenance_standard_image sf_maintenance.sf_group_equipment_user 1 0 0 0
15 access_maintenance_standard_image maintenance_standard_image model_maintenance_standard_image sf_maintenance.sf_group_equipment_manager 1 1 1 0
16 access_sf_robot_axis_num_sf_group_equipment_user sf_robot_axis_num model_sf_robot_axis_num sf_maintenance.sf_group_equipment_user 1 0 0 0
42 access_sf_production_process_admin_sf_group_equipment_user access_sf_production_materials_admin_sf_group_equipment_user sf_production_process_admin sf_production_materials_admin sf_base.model_sf_production_process sf_base.model_sf_production_materials sf_maintenance.sf_group_equipment_user 1 0 0 0
43 access_sf_production_materials_sf_group_equipment_user access_sf_materials_model_sf_group_equipment_user sf_production_materials sf_materials_model sf_base.model_sf_production_materials sf_base.model_sf_materials_model sf_maintenance.sf_group_equipment_user 1 0 0 0
44 access_sf_production_materials_admin_sf_group_equipment_user access_sf_materials_model_admin_sf_group_equipment_user sf_production_materials_admin sf_materials_model_admin sf_base.model_sf_production_materials sf_base.model_sf_materials_model sf_maintenance.sf_group_equipment_user 1 0 0 0
access_sf_materials_model_sf_group_equipment_user sf_materials_model sf_base.model_sf_materials_model sf_maintenance.sf_group_equipment_user 1 0 0 0
access_sf_materials_model_admin_sf_group_equipment_user sf_materials_model_admin sf_base.model_sf_materials_model sf_maintenance.sf_group_equipment_user 1 0 0 0
45 access_sf_processing_technology_sf_group_equipment_user access_sf_supplier_sort_sf_group_equipment_user sf_processing_technology sf_supplier_sort sf_base.model_sf_processing_technology sf_base.model_sf_supplier_sort sf_maintenance.sf_group_equipment_user 1 0 0 0
46 access_sf_processing_technology_admin_sf_group_equipment_user access_sf_supplier_sort_admin_sf_group_equipment_user sf_processing_technology_admin sf_supplier_sort_admin sf_base.model_sf_processing_technology sf_base.model_sf_supplier_sort sf_maintenance.sf_group_equipment_user 1 0 0 0
47 access_sf_supplier_sort_sf_group_equipment_user access_sf_production_process_parameter_sf_group_equipment_user sf_supplier_sort sf_production_process_parameter sf_base.model_sf_supplier_sort sf_base.model_sf_production_process_parameter sf_maintenance.sf_group_equipment_user 1 0 0 0
48 access_sf_supplier_sort_admin_sf_group_equipment_user access_sf_production_process_parameter_group_plan_director_sf_group_equipment_user sf_supplier_sort_admin sf_production_process_parameter_group_plan_director sf_base.model_sf_supplier_sort sf_base.model_sf_production_process_parameter sf_maintenance.sf_group_equipment_user 1 0 0 0
49 access_sf_production_process_parameter_sf_group_equipment_user access_sf_production_process_parameter_group_purchase_director_sf_group_equipment_user sf_production_process_parameter sf_production_process_parameter_group_purchase_director sf_base.model_sf_production_process_parameter sf_maintenance.sf_group_equipment_user 1 0 0 0
50 access_sf_production_process_parameter_group_plan_director_sf_group_equipment_user access_sf_production_process_parameter_group_sale_director_sf_group_equipment_user sf_production_process_parameter_group_plan_director sf_production_process_parameter_group_sale_director sf_base.model_sf_production_process_parameter sf_maintenance.sf_group_equipment_user 1 0 0 0
51 access_sf_production_process_parameter_group_purchase_director_sf_group_equipment_user access_sf_production_process_parameter_admin_sf_group_equipment_user sf_production_process_parameter_group_purchase_director sf_production_process_parameter_admin sf_base.model_sf_production_process_parameter sf_maintenance.sf_group_equipment_user 1 0 0 0
access_sf_production_process_parameter_group_sale_director_sf_group_equipment_user sf_production_process_parameter_group_sale_director sf_base.model_sf_production_process_parameter sf_maintenance.sf_group_equipment_user 1 0 0 0
52 access_sf_production_process_parameter_admin_sf_group_equipment_user access_sf_production_process_category_sf_group_equipment_user sf_production_process_parameter_admin sf_production_process_category sf_base.model_sf_production_process_parameter sf_base.model_sf_production_process_category sf_maintenance.sf_group_equipment_user 1 0 0 0
53 access_sf_production_process_category_sf_group_equipment_user access_sf_production_process_category_admin_sf_group_equipment_user sf_production_process_category sf_production_process_category_admin sf_base.model_sf_production_process_category sf_maintenance.sf_group_equipment_user 1 0 0 0
54 access_sf_production_process_category_admin_sf_group_equipment_user access_sf_machine_tool_category_sf_group_equipment_user sf_production_process_category_admin sf_machine_tool_category sf_base.model_sf_production_process_category sf_base.model_sf_machine_tool_category sf_maintenance.sf_group_equipment_user 1 0 0 0

View File

@@ -12,14 +12,14 @@
<group>
<field name="code" readonly="1" force_save="1"/>
<field name="name" readonly="1" force_save="1"/>
<field name="maintenance_equipment_category_id" required="1" class="custom_required"/>
<field name="maintenance_equipment_category_id" required="1" />
<field name="eq_maintenance_ids" invisible='1'/>
<field name="overhaul_ids" invisible='1'/>
</group>
<group>
<field name="maintenance_type" required="1" class="custom_required"/>
<field name="maintenance_type" required="1"/>
<field name="created_user_id"/>
<field name="remark"/>
</group>
@@ -31,7 +31,7 @@
<notebook>
<page string="维保项目">
<field name="maintenance_standards_ids" >
<field name="maintenance_standards_ids" delete="1">
<tree editable="bottom" >
<field name="name" />
<field name="fault_type" />

View File

@@ -60,9 +60,9 @@
<field name="function_type"/>
<field name="code" readonly="1"/>
<field name="equipment_type" invisible="1"/>
<field name="brand_id" force_save="1" class="custom_required"/>
<field name="brand_id" force_save="1" />
<field name="type_id" attrs="{'required': [('equipment_type', '=', '机床')]}"
domain="[('brand_id', '=', brand_id)]" class="custom_required"/>
domain="[('brand_id', '=', brand_id)]" />
<field name="machine_tool_category" readonly="1" attrs="{'invisible': [('type_id', '=', False)]}"
force_save="1"/>
<field name="run_time" force_save="1"/>
@@ -73,9 +73,9 @@
<group>
<group string="基础参数">
<field name="control_system_id" attrs="{'required': [('equipment_type', '=', '机床')]}"
options="{'no_create': True}" class="custom_required"/>
options="{'no_create': True}" />
<label for="workbench_L" string="工作台尺寸(mm)"/>
<div class="test_model custom_required">
<div class="test_model">
<label for="workbench_L" string="长"/>
<field name="workbench_L" class="o_address_zip"
attrs="{'required': [('equipment_type', '=', '机床')]}"
@@ -134,7 +134,7 @@
<!-- <field name="guide_rail" required="1"/>-->
<field name="number_of_axles" attrs="{'required': [('equipment_type', '=', '机床')]}"
widget="radio"
options="{'horizontal': true}" class="custom_required"/>
options="{'horizontal': true}" />
<label for="x_axis" string="加工行程(mm)"
attrs="{'invisible': [('number_of_axles', '=', False)]}"/>
<div class="test_model"
@@ -177,8 +177,7 @@
<group string="刀具">
<!-- <field name="knife_type" required="1"/>-->
<field name="number_of_knife_library"
attrs="{'required': [('equipment_type', '=', '机床')]}"
class="custom_required"/>
attrs="{'required': [('equipment_type', '=', '机床')]}"/>
<!-- <field name="tool_speed" required="1"/>-->
<field name="tool_full_diameter_max"/>
<field name="tool_perimeter_diameter_max"/>
@@ -198,7 +197,7 @@
<field name="C_tool_time"/>
</group>
<group string="主轴">
<field name="taper_type_id" attrs="{'required': [('equipment_type', '=', '机床')]}" class="custom_required"/>
<field name="taper_type_id" attrs="{'required': [('equipment_type', '=', '机床')]}" />
<label for="distance_min" string="主轴端面-工作台距离(mm)"/>
<div class="test_model">
<label for="distance_min" string="最小(min)"/>

View File

@@ -34,8 +34,8 @@ class ResConfigSettings(models.TransientModel):
_logger.info("同步资源库表面工艺类别完成")
self.env['sf.production.process'].sync_all_production_process()
_logger.info("同步资源库表面工艺完成")
self.env['sf.processing.technology'].sync_all_processing_technology()
_logger.info("同步资源库加工工艺")
# self.env['sf.processing.technology'].sync_all_processing_technology()
# _logger.info("同步资源库加工工艺")
self.env['sf.machine.brand.tags'].sync_all_machine_brand_tags()
_logger.info("同步资源库品牌类别完成")
self.env['sf.machine.brand'].sync_all_machine_brand()

View File

@@ -40,10 +40,10 @@ class MrStaticResourceDataSync(models.Model):
logging.info("表面工艺已每日同步成功")
self.env['sf.production.process.parameter'].sync_production_process_parameter_yesterday()
logging.info("表面工艺可选参数已每日同步成功")
self.env['sf.processing.technology'].sync_processing_technology_yesterday()
logging.info("加工工艺已每日同步成功")
self.env['sf.processing.order'].sync_processing_order_yesterday()
logging.info("工序已同步已每日同步成功")
# self.env['sf.processing.technology'].sync_processing_technology_yesterday()
# logging.info("加工工艺已每日同步成功")
# self.env['sf.processing.order'].sync_processing_order_yesterday()
# logging.info("工序已同步已每日同步成功")
self.env['sf.fixture.material'].sync_fixture_material_yesterday()
logging.info("夹具物料已每日同步成功")
self.env['sf.multi_mounting.type'].sync_multi_mounting_type_yesterday()
@@ -367,64 +367,64 @@ class sfProductionProcess(models.Model):
raise ValidationError("表面工艺认证未通过")
class sfProcessingTechnology(models.Model):
_inherit = 'sf.processing.technology'
_description = '加工工艺'
url = '/api/processing_technology/list'
# 定时同步加工工艺
def sync_processing_technology_yesterday(self):
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['processing_technology_yesterday_list']:
if item:
processing_technology = self.search(
[("code", '=', item['process_encode']), ('active', 'in', [True, False])])
if processing_technology:
processing_technology.name = item['name']
processing_technology.remark = item['remark']
processing_technology.active = item['active']
else:
self.create({
"name": item['name'],
"code": item['process_encode'],
"remark": item['remark'],
"active": item['active'],
})
else:
raise ValidationError("加工工艺认证未通过")
# 同步所有加工工艺
def sync_all_processing_technology(self):
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['processing_technology_all_list']:
if item:
processing_technology = self.search(
[("code", '=', item['process_encode']), ('active', 'in', [True, False])])
if not processing_technology:
self.create({
"name": item['name'],
"code": item['process_encode'],
"remark": item['remark'],
"active": item['active'],
})
else:
processing_technology.name = item['name']
processing_technology.remark = item['remark']
processing_technology.active = item['active']
else:
raise ValidationError("加工工艺认证未通过")
# class sfProcessingTechnology(models.Model):
# _inherit = 'sf.processing.technology'
# _description = '加工工艺'
# url = '/api/processing_technology/list'
#
# # 定时同步加工工艺
# def sync_processing_technology_yesterday(self):
# config = self.env['res.config.settings'].get_values()
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
# strUrl = config['sf_url'] + self.url
# r = requests.post(strUrl, json={}, data=None, headers=headers)
# r = r.json()
# result = json.loads(r['result'])
# if result['status'] == 1:
# for item in result['processing_technology_yesterday_list']:
# if item:
# processing_technology = self.search(
# [("code", '=', item['process_encode']), ('active', 'in', [True, False])])
# if processing_technology:
# processing_technology.name = item['name']
# processing_technology.remark = item['remark']
# processing_technology.active = item['active']
# else:
# self.create({
# "name": item['name'],
# "code": item['process_encode'],
# "remark": item['remark'],
# "active": item['active'],
# })
# else:
# raise ValidationError("加工工艺认证未通过")
#
# # 同步所有加工工艺
# def sync_all_processing_technology(self):
# config = self.env['res.config.settings'].get_values()
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
# strUrl = config['sf_url'] + self.url
# r = requests.post(strUrl, json={}, data=None, headers=headers)
# r = r.json()
# result = json.loads(r['result'])
# if result['status'] == 1:
# for item in result['processing_technology_all_list']:
# if item:
# processing_technology = self.search(
# [("code", '=', item['process_encode']), ('active', 'in', [True, False])])
# if not processing_technology:
# self.create({
# "name": item['name'],
# "code": item['process_encode'],
# "remark": item['remark'],
# "active": item['active'],
# })
# else:
# processing_technology.name = item['name']
# processing_technology.remark = item['remark']
# processing_technology.active = item['active']
# else:
# raise ValidationError("加工工艺认证未通过")
class MachineBrandTags(models.Model):
@@ -1000,50 +1000,50 @@ class MachineToolType(models.Model):
raise ValidationError("机床型号认证未通过")
class sfProcessingOrder(models.Model):
_inherit = 'sf.processing.order'
_description = '工序'
url = '/api/processing_order/list'
# 定时同步工序
def sync_processing_order_yesterday(self):
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['processing_order_yesterday_list']:
processing_order = self.search([("id", '=', item['id']), ('active', 'in', [True, False])])
if processing_order:
processing_order.sequence = item['sequence']
else:
self.create({
"sequence": item['sequence'],
})
else:
raise ValidationError("工序认证未通过")
# 同步所有工序
def sync_all_processing_order(self):
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['processing_order_all_list']:
processing_order = self.search([("id", '=', item['id']), ('active', 'in', [True, False])])
if not processing_order:
self.create({
"sequence": item['sequence'],
})
else:
processing_order.sequence = item['sequence']
else:
raise ValidationError("工序认证未通过")
# class sfProcessingOrder(models.Model):
# _inherit = 'sf.processing.order'
# _description = '工序'
# url = '/api/processing_order/list'
#
# # 定时同步工序
# def sync_processing_order_yesterday(self):
# config = self.env['res.config.settings'].get_values()
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
# strUrl = config['sf_url'] + self.url
# r = requests.post(strUrl, json={}, data=None, headers=headers)
# r = r.json()
# result = json.loads(r['result'])
# if result['status'] == 1:
# for item in result['processing_order_yesterday_list']:
# processing_order = self.search([("id", '=', item['id']), ('active', 'in', [True, False])])
# if processing_order:
# processing_order.sequence = item['sequence']
# else:
# self.create({
# "sequence": item['sequence'],
# })
# else:
# raise ValidationError("工序认证未通过")
#
# # 同步所有工序
# def sync_all_processing_order(self):
# config = self.env['res.config.settings'].get_values()
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
# strUrl = config['sf_url'] + self.url
# r = requests.post(strUrl, json={}, data=None, headers=headers)
# r = r.json()
# result = json.loads(r['result'])
# if result['status'] == 1:
# for item in result['processing_order_all_list']:
# processing_order = self.search([("id", '=', item['id']), ('active', 'in', [True, False])])
# if not processing_order:
# self.create({
# "sequence": item['sequence'],
# })
# else:
# processing_order.sequence = item['sequence']
# else:
# raise ValidationError("工序认证未通过")
class sfProductionProcessParameter(models.Model):

View File

@@ -16,7 +16,7 @@ class FunctionalCuttingToolEntity(models.Model):
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
code = fields.Char('编码', related='functional_tool_name_id.code')
rfid = fields.Char('rfid', readonly=True)
name = fields.Char(related='functional_tool_name_id.name')
name = fields.Char('名称')
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称', readonly=True)
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
sf_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号')
@@ -69,22 +69,15 @@ class FunctionalCuttingToolEntity(models.Model):
"""
for obj in self:
if obj.current_location_id:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 0
if obj.current_location in ['刀具房']:
obj.tool_room_num = 1
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 0
elif "线边刀库" in obj.current_location:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 1
obj.machine_knife_library_num = 0
elif "机内刀库" in obj.current_location:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 1
else:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 0
@api.model
def _read_group_mrs_cutting_tool_type_id(self, categories, domain, order):
@@ -136,7 +129,6 @@ class FunctionalCuttingToolEntity(models.Model):
@api.depends('cutting_tool_integral_model_id', 'cutting_tool_blade_model_id')
def _compute_maintenance_equipment_image(self):
for record in self:
print('111')
if record.cutting_tool_integral_model_id:
print(record.cutting_tool_integral_model_id)
record.sudo().suitable_machining_method_ids = record.cutting_tool_integral_model_id.suitable_machining_method_ids.ids
@@ -194,36 +186,35 @@ class FunctionalCuttingToolEntity(models.Model):
stock_location_id = self.env['stock.location'].search([('name', '=', '制造前')])
# 创建功能刀具该批次/序列号 库存移动和移动历史
self.barcode_id.create_stock_quant(location_inventory_id, stock_location_id,
self.functional_tool_name_id.id, '机床装刀')
self.functional_tool_name_id.id, '机床装刀', self.functional_tool_name_id)
# ==========刀具组接口==========
# def _register_functional_tool_groups(self, obj):
# create_url = '/AutoDeviceApi/ToolGroup'
# 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(obj, token, sf_secret_key)
# strurl = sf_sync_config['sf_url'] + create_url
# val = {
# 'ToolName': obj.name,
# 'GroupName': obj.tool_groups_id.name,
# 'ToolId': obj.code
# }
# kw = json.dumps(val, ensure_ascii=False)
# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
# ret = r.json()
# if r == 200:
# return "刀具组发送成功"
# else:
# raise ValidationError("刀具组发送失败")
# ==========刀具组接口==========
# def _register_functional_tool_groups(self, obj):
# create_url = '/AutoDeviceApi/ToolGroup'
# 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(obj, token, sf_secret_key)
# strurl = sf_sync_config['sf_url'] + create_url
# val = {
# 'ToolName': obj.name,
# 'GroupName': obj.tool_groups_id.name,
# 'ToolId': obj.code
# }
# kw = json.dumps(val, ensure_ascii=False)
# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
# ret = r.json()
# if r == 200:
# return "刀具组发送成功"
# else:
# raise ValidationError("刀具组发送失败")
# @api.model_create_multi
# def create(self, vals):
# obj = super(FunctionalCuttingToolEntity, self).create(vals)
# # 调用刀具组接口
# self._register_functional_tool_groups(obj)
# return obj
# @api.model_create_multi
# def create(self, vals):
# obj = super(FunctionalCuttingToolEntity, self).create(vals)
# # 调用刀具组接口
# self._register_functional_tool_groups(obj)
# return obj
class FunctionalToolWarning(models.Model):
@@ -239,7 +230,8 @@ class FunctionalToolWarning(models.Model):
group_expand='_read_group_machine_table_name_ids')
maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床')
machine_tool_code = fields.Char(string='机台号', related='maintenance_equipment_id.name')
machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型')
machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型',
related='maintenance_equipment_id.category_id')
cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号',
domain="[('equipment_id', '=', maintenance_equipment_id)]")
# 功能刀具信息
@@ -298,14 +290,14 @@ class StockMoveLine(models.Model):
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称')
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
group_expand='_read_group_functional_tool_type_id',
related='functional_tool_name_id.functional_tool_type_id')
diameter = fields.Integer(string='刀具直径(mm)', related='functional_tool_name_id.functional_tool_diameter')
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', related='functional_tool_name_id.knife_tip_r_angle')
install_tool_time = fields.Datetime("刀具组装时间", related='functional_tool_name_id.tool_loading_time')
code = fields.Char('编码', related='functional_tool_name_id.code')
rfid = fields.Char('rfid', related='functional_tool_name_id.rfid')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
group_expand='_read_group_functional_tool_type_id')
functional_tool_name = fields.Char('刀具名称')
diameter = fields.Integer(string='刀具直径(mm)')
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)')
install_tool_time = fields.Datetime("刀具组装时间", default=fields.Datetime.now())
code = fields.Char('编码')
rfid = fields.Char('rfid')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组')
@api.model
def _read_group_functional_tool_type_id(self, categories, domain, order):
@@ -442,17 +434,17 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
计算刀具房数量、线边刀库数量、机内刀库数量
"""
if tool:
tool.sudo().tool_stock_num = 0
tool.sudo().side_shelf_num = 0
tool.sudo().on_tool_stock_num = 0
tool.tool_stock_num = 0
tool.side_shelf_num = 0
tool.on_tool_stock_num = 0
if tool.sf_functional_cutting_tool_entity_ids:
for cutting_tool in tool.sf_functional_cutting_tool_entity_ids:
if cutting_tool.tool_room_num > 0:
tool.sudo().tool_stock_num += 1
tool.tool_stock_num += 1
elif cutting_tool.line_edge_knife_library_num > 0:
tool.sudo().side_shelf_num += 1
tool.side_shelf_num += 1
elif cutting_tool.machine_knife_library_num > 0:
tool.sudo().on_tool_stock_num += 1
tool.on_tool_stock_num += 1
def create_or_edit_safety_stock(self, vals, sf_functional_cutting_tool_entity_ids):
"""
@@ -479,6 +471,14 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
records = super(RealTimeDistributionOfFunctionalTools, self).create(vals_list)
return records
def write(self, vals):
res = super().write(vals)
for item in self:
if item:
if vals.get('min_stock_num') or vals.get('max_stock_num'):
item.enroll_functional_tool_real_time_distribution()
return res
class MachineTableToolChangingApply(models.Model):
_name = 'sf.machine.table.tool.changing.apply'

View File

@@ -6,6 +6,30 @@ from odoo.addons.sf_base.commons.common import Common
from odoo.exceptions import UserError
def get_suitable_machining_method_names(item):
suitable_machining_method_names = []
for suitable_machining_method_id in item.suitable_machining_method_ids:
if suitable_machining_method_id:
suitable_machining_method_names.append(suitable_machining_method_id.name)
return suitable_machining_method_names
def get_cutting_direction_names(item):
cutting_direction_names = []
for cutting_direction_id in item.cutting_direction_ids:
if cutting_direction_id:
cutting_direction_names.append(cutting_direction_id.name)
return cutting_direction_names
def get_suitable_coolant_names(item):
suitable_coolant_names = []
for suitable_coolant_id in item.suitable_coolant_ids:
if suitable_coolant_id:
suitable_coolant_names.append(suitable_coolant_id.name)
return suitable_coolant_names
class StockLot(models.Model):
_inherit = 'stock.lot'
_description = '刀具物料序列号注册'
@@ -25,28 +49,24 @@ class StockLot(models.Model):
val = {
'name': item.name,
'tool_material_status': item.tool_material_status,
'location': item.quant_ids[-1].location_id.name
'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name,
'tool_material_search_id': item.tool_material_search_id.id,
}
tool_material_stock_list.append(val)
kw = json.dumps(tool_material_stock_list, ensure_ascii=False)
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
ret = r.json()
if r == 200:
if ret.get('code') == 200:
return '刀具物料序列号注册成功'
else:
raise UserError("没有注册刀具物料序列号信息")
@api.onchange('quant_ids')
def _onchange_quant_ids(self):
for item in self:
if item.product_id.categ_id == '刀具':
item.enroll_tool_material_stock()
@api.model_create_multi
def create(self, vals_list):
records = super(StockLot, self).create(vals_list)
for record in records:
if record.product_id.categ_id == '刀具':
if record.product_id.categ_id.name == '刀具':
record.tool_material_status = '可用'
record.enroll_tool_material_stock()
return records
@@ -73,11 +93,11 @@ class ToolMaterial(models.Model):
barcode_names.append(barcode_id.name)
val = {
'name': item.name,
'code': item.code,
'id': item.id,
'cutting_tool_material_code': item.cutting_tool_material_id.code,
'cutting_tool_standard_library_code': item.cutting_tool_standard_library_id.code,
'specification_name': item.specification_id.name,
'image': item.image,
'image': '' if not item.image else base64.b64encode(item.image).decode('utf-8'),
'number': item.number,
'usable_num': item.usable_num,
'have_been_used_num': item.have_been_used_num,
@@ -89,11 +109,19 @@ class ToolMaterial(models.Model):
kw = json.dumps(tool_material_list, ensure_ascii=False)
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
ret = r.json()
if r == 200:
if ret.get('code') == 200:
return '刀具物料注册成功'
else:
raise UserError("没有注册刀具物料信息")
@api.model_create_multi
def create(self, vals_list):
records = super(ToolMaterial, self).create(vals_list)
for record in records:
if record:
record.enroll_tool_material()
return records
class FunctionalCuttingToolEntity(models.Model):
_inherit = 'sf.functional.cutting.tool.entity'
@@ -116,6 +144,7 @@ class FunctionalCuttingToolEntity(models.Model):
'id': item.id,
'code': item.code,
'name': item.name,
'rfid': item.rfid,
'tool_groups_name': item.tool_groups_id.name,
'barcode': item.barcode_id.name,
'cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
@@ -126,9 +155,6 @@ class FunctionalCuttingToolEntity(models.Model):
'tool_loading_length': item.tool_loading_length,
'functional_tool_length': item.functional_tool_length,
'effective_length': item.effective_length,
'tool_room_num': item.tool_room_num,
'line_edge_knife_library_num': item.line_edge_knife_library_num,
'machine_knife_library_num': item.machine_knife_library_num,
'max_lifetime_value': item.max_lifetime_value,
'alarm_value': item.alarm_value,
'used_value': item.used_value,
@@ -141,21 +167,24 @@ class FunctionalCuttingToolEntity(models.Model):
'cut_time': item.cut_time,
'cut_length': item.cut_length,
'cut_number': item.cut_number,
'cutting_tool_integral_model_code': item.cutting_tool_integral_model_id.code,
'cutting_tool_blade_model_code': item.cutting_tool_blade_model_id.code,
'cutting_tool_cutterbar_model_code': item.cutting_tool_cutterbar_model_id.code,
'cutting_tool_cutterpad_model_code': item.cutting_tool_cutterpad_model_id.code,
'cutting_tool_cutterhandle_model_code': item.cutting_tool_cutterhandle_model_id.code,
'cutting_tool_cutterhead_model_code': item.cutting_tool_cutterhead_model_id.code,
'cutting_tool_integral_model_id': item.cutting_tool_integral_model_id.tool_material_id,
'cutting_tool_blade_model_id': item.cutting_tool_blade_model_id.tool_material_id,
'cutting_tool_cutterbar_model_id': item.cutting_tool_cutterbar_model_id.tool_material_id,
'cutting_tool_cutterpad_model_id': item.cutting_tool_cutterpad_model_id.tool_material_id,
'cutting_tool_cutterhandle_model_id': item.cutting_tool_cutterhandle_model_id.tool_material_id,
'cutting_tool_cutterhead_model_id': item.cutting_tool_cutterhead_model_id.tool_material_id,
'suitable_machining_method_names': get_suitable_machining_method_names(item),
'blade_tip_characteristics_name': item.blade_tip_characteristics_id.name,
'handle_type_name': item.handle_type_id.name,
'cutting_direction_names': get_cutting_direction_names(item),
'suitable_coolant_names': get_suitable_coolant_names(item),
'active': item.active,
}
functional_tool_list.append(val)
kw = json.dumps(functional_tool_list, ensure_ascii=False)
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
ret = r.json()
# self.code = ret['data']
# self.state_zc = "已注册"
if r == 200:
if ret.get('code') == 200:
return "功能刀具注册成功"
else:
raise UserError("没有注册功能刀具信息")
@@ -190,11 +219,11 @@ class FunctionalToolWarning(models.Model):
'id': item.id,
'name': item.name,
'code': item.code,
'rfid': item.rfid,
'tool_groups_name': item.tool_groups_id.name,
'production_line': item.production_line_id.name,
'machine_tool_id': item.maintenance_equipment_id.code,
'machine_tool_code': item.machine_tool_code,
'machine_table_type_code': item.machine_table_type_id.code,
'cutter_spacing_code': item.cutter_spacing_code_id.code,
'functional_tool_name': item.name,
'barcode': item.barcode_id.name,
@@ -207,18 +236,16 @@ class FunctionalToolWarning(models.Model):
'alarm_value': item.alarm_value,
'used_value': item.used_value,
'functional_tool_status': item.functional_tool_status,
'alarm_time': item.alarm_time,
'alarm_time': item.alarm_time.strftime('%Y-%m-%d %H:%M:%S'),
'dispose_user': item.dispose_user,
'dispose_time': item.dispose_time.strftime('%Y-%m-%d %H:%M:%S'),
'dispose_time': item.dispose_time,
'dispose_func': item.dispose_func,
}
tool_warning_list.append(val)
kw = json.dumps(tool_warning_list, ensure_ascii=False)
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
ret = r.json()
# self.code = ret['data']
# self.state_zc = "已注册"
if r == 200:
if ret.get('code') == 200:
return "功能刀具预警注册成功"
else:
raise UserError("没有注册功能刀具预警信息")
@@ -251,8 +278,9 @@ class StockMoveLine(models.Model):
for item in objs_all:
val = {
'id': item.id,
'name': item.functional_tool_name_id.name,
'name': item.functional_tool_name,
'code': item.code,
'rfid': item.rfid,
'tool_groups_name': item.tool_groups_id.name,
'reference': item.reference,
'barcode': item.lot_id.name,
@@ -269,9 +297,7 @@ class StockMoveLine(models.Model):
kw = json.dumps(tool_stock_list, ensure_ascii=False)
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
ret = r.json()
# self.code = ret['data']
# self.state_zc = "已注册"
if r == 200:
if ret.get('code') == 200:
return "功能刀具出入库记录注册成功"
else:
raise UserError("没有注册功能刀具出入库记录信息")
@@ -309,7 +335,7 @@ class RealTimeDistributionFunctionalTools(models.Model):
'id': item.id,
'name': item.name,
'tool_groups_name': item.tool_groups_id.name,
'sf_cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
'cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
'diameter': item.diameter,
'knife_tip_r_angle': item.knife_tip_r_angle,
'tool_stock_num': item.tool_stock_num,
@@ -322,17 +348,20 @@ class RealTimeDistributionFunctionalTools(models.Model):
'unit': item.unit,
'image': '' if not item.image else base64.b64encode(item.image).decode('utf-8'),
'functional_tool_codes': str(functional_tool_codes),
'whether_standard_knife': item.whether_standard_knife,
'coarse_middle_thin': item.coarse_middle_thin,
'whether_standard_knife': item.whether_standard_knife,
'suitable_machining_method_names': get_suitable_machining_method_names(item),
'blade_tip_characteristics_name': item.blade_tip_characteristics_id.name,
'handle_type_name': item.handle_type_id.name,
'cutting_direction_names': get_cutting_direction_names(item),
'suitable_coolant_names': get_suitable_coolant_names(item),
'active': item.active
}
tool_distribution_list.append(val)
kw = json.dumps(tool_distribution_list, ensure_ascii=False)
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
ret = r.json()
# self.code = ret['data']
# self.state_zc = "已注册"
if r == 200:
if ret.get('code') == 200:
return "功能刀具出入库记录注册成功"
else:
raise UserError("没有注册功能刀具出入库记录信息")
@@ -341,11 +370,6 @@ class RealTimeDistributionFunctionalTools(models.Model):
def create(self, vals_list):
records = super(RealTimeDistributionFunctionalTools, self).create(vals_list)
for record in records:
if record.functional_tool_name_id:
record.enroll_functional_tool_move()
if record:
record.enroll_functional_tool_real_time_distribution()
return records
def write(self, vals):
res = super().write(vals)
self.enroll_functional_tool_move()
return res

View File

@@ -98,7 +98,7 @@ class StockLot(models.Model):
tool_material_search_id = fields.Many2one('sf.tool.material.search', string='刀具物料搜索')
tool_material_status = fields.Selection([('可用', '可用'), ('在用', '在用'), ('报废', '报废')], string='状态',
compute='_compute_tool_material_status')
compute='_compute_tool_material_status', store=True)
@api.depends('quant_ids')
def _compute_tool_material_status(self):
@@ -110,6 +110,13 @@ class StockLot(models.Model):
else:
record.tool_material_status = '可用'
@api.onchange('tool_material_status')
def _onchange_tool_material_status(self):
for obj in self:
if obj:
# 注册刀具物料状态到cloud平台
obj.enroll_tool_material_stock()
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
# 调用父类的name_search方法
@@ -137,9 +144,7 @@ class StockLot(models.Model):
for record in records:
if record.product_id.categ_id.name == '刀具':
tool_material_search = self.env['sf.tool.material.search'].sudo().search(
[('cutting_tool_material_id', '=', record.product_id.cutting_tool_material_id.id),
('cutting_tool_standard_library_id', '=', record.product_id.cutting_tool_model_id.id),
('specification_id', '=', record.product_id.specification_id.id)])
[('id', '=', record.product_id.tool_material_id)])
if tool_material_search:
record.tool_material_search_id = tool_material_search
return records
@@ -148,12 +153,15 @@ class StockLot(models.Model):
class ProductProduct(models.Model):
_inherit = 'product.product'
tool_material_id = fields.Char('刀具物料搜索模型ID')
@api.model_create_multi
def create(self, vals_list):
records = super(ProductProduct, self).create(vals_list)
for record in records:
if record.categ_id.name == '刀具':
self.env['sf.tool.material.search'].sudo().create({
tool_material = self.env['sf.tool.material.search'].sudo().create({
'product_id': record.id
})
record.tool_material_id = tool_material.id
return records

View File

@@ -311,7 +311,7 @@ class ToolMaterial(models.Model):
product_id = fields.Many2one('product.product', string='刀具物料产品')
name = fields.Char('名称', related='product_id.name')
code = fields.Char('编码', store=True)
code = fields.Char('编码')
cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料',
related='product_id.cutting_tool_material_id',
store=True,
@@ -331,14 +331,6 @@ class ToolMaterial(models.Model):
active = fields.Boolean(string='已归档', default=True)
@api.depends('product_id')
def _compute_code(self):
for record in self:
if record:
code = '%s_%s' % (record.cutting_tool_standard_library_id.code, record.specification_id.name)
obj = self.search([('code', 'like', code)], limit=1, order="id desc")
record.code = '%s_%03d' % (code, 1 if obj else int(obj.code[-3:]) + 1)
@api.depends('barcode_ids')
def _compute_number(self):
for record in self:

View File

@@ -40,8 +40,8 @@
<field name="arch" type="xml">
<form create="0" edit="0" delete="0">
<header>
<button name="enroll_functional_tool_entity" string="功能刀具注册" type="object"
class="btn-primary"/>
<!-- <button name="enroll_functional_tool_entity" string="功能刀具注册" type="object"-->
<!-- class="btn-primary"/>-->
<field name="functional_tool_status" widget="statusbar" statusbar_visible="正常,报警,已拆除"/>
</header>
<sheet>
@@ -245,8 +245,8 @@
<field name="dispose_user"/>
<field name="dispose_time"/>
<field name="dispose_func"/>
<button name="enroll_functional_tool_warning" string="刀具预警注册" type="object"
class="btn-primary"/>
<!-- <button name="enroll_functional_tool_warning" string="刀具预警注册" type="object"-->
<!-- class="btn-primary"/>-->
</tree>
</field>
</record>
@@ -322,10 +322,10 @@
<field name="model">sf.real.time.distribution.of.functional.tools</field>
<field name="arch" type="xml">
<form>
<header>
<button name="enroll_functional_tool_real_time_distribution" string="安全库存注册" type="object"
class="btn-primary"/>
</header>
<!-- <header>-->
<!-- <button name="enroll_functional_tool_real_time_distribution" string="安全库存注册" type="object"-->
<!-- class="btn-primary"/>-->
<!-- </header>-->
<sheet>
<div class="oe_title">
<h1>
@@ -462,7 +462,7 @@
<field name="date"/>
<field name="qty_done" string="数量"/>
<field name="functional_tool_type_id" invisible="True"/>
<button name="enroll_functional_tool_move" string="安全库存注册" type="object" class="btn-primary"/>
<!-- <button name="enroll_functional_tool_move" string="安全库存注册" type="object" class="btn-primary"/>-->
</tree>
</field>
</record>

View File

@@ -62,6 +62,7 @@
<tree>
<field name="name"/>
<field name="tool_material_status"/>
<button name="enroll_tool_material_stock" string="序列号注册" type="object" class="btn-primary"/>
</tree>
</field>
</page>

View File

@@ -481,9 +481,9 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
product_id = self.env['product.product'].search([('name', '=', '功能刀具')])
# 创建组装入库单
# 创建功能刀具批次/序列号记录
stock_lot = product_id.create_assemble_warehouse_receipt(self.id, functional_tool_assembly)
stock_lot = product_id.create_assemble_warehouse_receipt(self.id, functional_tool_assembly, self)
# 创建刀具组装入库单
self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly)
self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly, self)
# 刀具物料出库
if self.integral_code_id:
product_id.tool_material_stock_moves(self.integral_code_id)
@@ -583,6 +583,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
return {
'barcode_id': stock_lot.id,
'code': self.tool_code,
'name': self.after_assembly_functional_tool_name,
'rfid': self.rfid,
'tool_groups_id': self.tool_groups_id.id,
'functional_tool_name_id': functional_tool_assembly_id.id,
@@ -618,7 +619,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
class StockPicking(models.Model):
_inherit = 'stock.picking'
def create_stocking_picking(self, stock_lot, functional_tool_assembly):
def create_stocking_picking(self, stock_lot, functional_tool_assembly, obj):
"""
创建刀具组装入库单
"""
@@ -639,7 +640,14 @@ class StockPicking(models.Model):
'location_dest_id': picking_id.location_dest_id.id,
'lot_id': stock_lot.id,
'qty_done': 1,
'functional_tool_name_id': functional_tool_assembly.id
'functional_tool_name_id': functional_tool_assembly.id,
'functional_tool_type_id': obj.functional_tool_type_id.id,
'diameter': obj.after_assembly_functional_tool_diameter,
'knife_tip_r_angle': obj.after_assembly_knife_tip_r_angle,
'code': obj.tool_code,
'rfid': obj.rfid,
'functional_tool_name': obj.after_assembly_functional_tool_name,
'tool_groups_id': obj.tool_groups_id.id
})
# 将刀具组装入库单的状态更改为就绪
picking_id.action_confirm()
@@ -664,7 +672,7 @@ class StockPicking(models.Model):
class ProductProduct(models.Model):
_inherit = 'product.product'
def create_assemble_warehouse_receipt(self, tool_assembly_order_id, functional_tool_assembly):
def create_assemble_warehouse_receipt(self, tool_assembly_order_id, functional_tool_assembly, obj):
"""
创建功能刀具批次/序列号记录
"""
@@ -680,7 +688,7 @@ class ProductProduct(models.Model):
stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')])
# 创建功能刀具该批次/序列号 库存移动和移动历史
stock_lot.create_stock_quant(location_inventory_id, stock_location_id, functional_tool_assembly.id,
'功能刀具组装')
'功能刀具组装', obj)
return stock_lot
@@ -714,13 +722,13 @@ class ProductProduct(models.Model):
location_inventory_id = tool_material.quant_ids.location_id[-1]
stock_location_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
# 创建功能刀具该批次/序列号 库存移动和移动历史
tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, '功能刀具组装')
tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, '功能刀具组装', False)
class StockLot(models.Model):
_inherit = 'stock.lot'
def create_stock_quant(self, location_inventory_id, stock_location_id, functional_tool_assembly_id, name):
def create_stock_quant(self, location_inventory_id, stock_location_id, functional_tool_assembly_id, name, obj):
"""
对功能刀具组装过程的功能刀具和刀具物料进行库存移动,以及创建移动历史
"""
@@ -743,6 +751,25 @@ class StockLot(models.Model):
'move_id': stock_move_id.id,
'install_tool_time': fields.Datetime.now(),
'qty_done': 1.0,
'state': 'done'
'state': 'done',
'functional_tool_type_id': False if not obj else obj.functional_tool_type_id.id,
'diameter': None if not obj else obj.after_assembly_functional_tool_diameter,
'knife_tip_r_angle': None if not obj else obj.after_assembly_knife_tip_r_angle,
'code': '' if not obj else obj.tool_code,
'rfid': '' if not obj else obj.rfid,
'functional_tool_name': '' if not obj else obj.after_assembly_functional_tool_name,
'tool_groups_id': False if not obj else obj.tool_groups_id.id
})
return stock_move_id, stock_move_line_id
class StockQuant(models.Model):
_inherit = 'stock.quant'
@api.model_create_multi
def create(self, vals_list):
records = super(StockQuant, self).create(vals_list)
for record in records:
if record.lot_id.product_id.categ_id.name == '刀具':
record.lot_id.enroll_tool_material_stock()
return records