Compare commits

..

3 Commits

52 changed files with 956 additions and 1307 deletions

View File

@@ -527,7 +527,3 @@ div:has(.o_required_modifier) > label::before {
.o_form_view .o_group .o_wrap_label .o_form_label { .o_form_view .o_group .o_wrap_label .o_form_label {
white-space: nowrap; white-space: nowrap;
} }
// 修复表格内容覆盖表头bug
.o_list_renderer .o_list_table tbody th {
position: unset;
}

View File

@@ -301,25 +301,51 @@ def unlink(self):
# This is used to restrict the access right to unlink a record # This is used to restrict the access right to unlink a record
current_model_id = self.env['ir.model'].sudo().search( current_model_id = self.env['ir.model'].sudo().search(
[('model', '=', self._name)]).id [('model', '=', self._name)]).id
# access_right_rec = self.env['access.right'].sudo().search_read(
# [('model_id', '=', current_model_id)], ['model_id', 'is_delete',
# 'groups_id'])
# if access_right_rec and not self.env.is_admin():
# for rec in access_right_rec:
# group_name = self.env['ir.model.data'].sudo().search([
# ('model', '=', 'res.groups'),
# ('res_id', '=', rec['groups_id'][0])
# ]).name
# module_name = self.env['ir.model.data'].sudo().search([
# ('model', '=', 'res.groups'),
# ('res_id', '=', rec['groups_id'][0])
# ]).module
# group = module_name + "." + group_name
# if self.env.user.has_group(group):
# if rec['is_delete']:
# raise UserError(_('You are restricted from performing this'
# ' operation. Please contact the'
# ' administrator.'))
# 检查 'access.right' 模型是否存在于环境中
if 'access.right' in self.env:
# current_model_id = self.env['ir.model'].sudo().search([('model', '=', self._name)]).id
access_right_rec = self.env['access.right'].sudo().search_read( access_right_rec = self.env['access.right'].sudo().search_read(
[('model_id', '=', current_model_id)], ['model_id', 'is_delete', [('model_id', '=', current_model_id)], ['model_id', 'is_delete', 'groups_id']
'groups_id']) )
if access_right_rec and not self.env.is_admin(): if access_right_rec and not self.env.is_admin():
for rec in access_right_rec: for rec in access_right_rec:
group_name = self.env['ir.model.data'].sudo().search([ group_data = self.env['ir.model.data'].sudo().search_read(
('model', '=', 'res.groups'), [('model', '=', 'res.groups'), ('res_id', '=', rec['groups_id'][0])],
('res_id', '=', rec['groups_id'][0]) ['name', 'module']
]).name )
module_name = self.env['ir.model.data'].sudo().search([
('model', '=', 'res.groups'), if group_data:
('res_id', '=', rec['groups_id'][0]) group_name = group_data[0]['name']
]).module module_name = group_data[0]['module']
group = module_name + "." + group_name group_xml_id = f"{module_name}.{group_name}"
if self.env.user.has_group(group):
if rec['is_delete']: if self.env.user.has_group(group_xml_id) and rec['is_delete']:
raise UserError(_('You are restricted from performing this' raise UserError(
' operation. Please contact the' _('You are restricted from performing this operation. Please contact the administrator.'))
' administrator.')) else:
# 如果 'access.right' 模型不存在,可以在这里定义备选逻辑
pass
return True return True

View File

@@ -11,10 +11,11 @@ class Printer(models.Model):
class TableStyle(models.Model): class TableStyle(models.Model):
_name = 'table.style' _name = 'label.style'
_description = '标签样式' _description = '标签样式'
name = fields.Char(string='名称', required=True) name = fields.Char(string='名称', required=True)
zpl_code = fields.Text(string='zpl指令')
# todo # todo
@@ -25,4 +26,5 @@ class PrinterConfiguration(models.Model):
name = fields.Char(string='名称', required=True) name = fields.Char(string='名称', required=True)
printer_id = fields.Many2one('printer', string='打印机') printer_id = fields.Many2one('printer', string='打印机')
model = fields.Many2one('ir.model', string='模型名称') model = fields.Many2one('ir.model', string='模型名称')
label_id = fields.Many2one('label.style', '标签')
# # 其他相关字段... # # 其他相关字段...

View File

@@ -43,19 +43,19 @@ class PrintingUtils(models.AbstractModel):
zpl_code += "^CI28\n" zpl_code += "^CI28\n"
# 设置二维码位置 # 设置二维码位置
zpl_code += "^FO50,50\n" # 调整二维码位置,使其与资产编号在同一行 zpl_code += "^FO50,260\n" # 调整二维码位置,使其与资产编号在同一行
zpl_code += f"^BQN,2,6^FDLM,B0093{code}^FS\n" zpl_code += f"^BQN,2,5^FDLM,B0093{code}^FS\n"
# 设置资产编号文本位置 # # 设置资产编号文本位置
zpl_code += "^FO300,60\n" # 资产编号文本的位置,与二维码在同一行 # zpl_code += "^FO300,60\n" # 资产编号文本的位置,与二维码在同一行
zpl_code += "^A1N,45,45^FD编码名称: ^FS\n" # zpl_code += "^A1N,45,45^FD编码名称: ^FS\n"
# 设置{code}文本位置 # 设置{code}文本位置
# 假设{code}文本需要位于资产编号和二维码下方,中间位置 # 假设{code}文本需要位于资产编号和二维码下方,中间位置
# 设置{code}文本位置并启用自动换行 # 设置{code}文本位置并启用自动换行
zpl_code += "^FO300,120\n" # {code}文本的起始位置 zpl_code += "^FO240,10\n" # {code}文本的起始位置
zpl_code += "^FB400,4,0,L,0\n" # 定义一个宽度为500点的文本框最多4行左对齐 zpl_code += "^FB600,10,0,L,0\n" # 定义一个宽度为500点的文本框最多4行左对齐
zpl_code += f"^A1N,40,40^FD{code}^FS\n" zpl_code += f"^A1B,40,40^FD{code}^FS\n"
# 在{code}文本框周围绘制线框 # 在{code}文本框周围绘制线框
# 假设线框的外部尺寸为宽度500点高度200点 # 假设线框的外部尺寸为宽度500点高度200点

View File

@@ -331,7 +331,7 @@ class ToolInventory(models.Model):
work_material = fields.Selection([('', ''), ('', '')], string='加工材料') work_material = fields.Selection([('', ''), ('', '')], string='加工材料')
life_span = fields.Float('寿命(min)') life_span = fields.Float('寿命(min)')
tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组', required=True) tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组')
active = fields.Boolean('已归档', default=True) active = fields.Boolean('已归档', default=True)

View File

@@ -11,8 +11,8 @@ access_sf_machine_control_system,sf_machine_control_system,model_sf_machine_cont
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_machine_control_system_admin,sf_machine_control_system_admin,model_sf_machine_control_system,base.group_system,1,1,1,0
access_sf_production_process_group_sale_director,sf_production_process_group_sale_director,model_sf_production_process,sf_base.group_sale_director,1,0,0,0 access_sf_production_process_group_sale_director,sf_production_process_group_sale_director,model_sf_production_process,sf_base.group_sale_director,1,0,0,0
access_sf_production_process_group_sale_salemanager,sf_production_process_group_sale_salemanager,model_sf_production_process,sf_base.group_sale_salemanager,1,0,0,0 access_sf_production_process_group_sale_salemanager,sf_production_process_group_sale_salemanager,model_sf_production_process,sf_base.group_sale_salemanager,1,0,0,0
access_res_partner_category_group_sale_salemanager,res_partner_category_group_sale_salemanager,base.model_res_partner_category,sf_base.group_sale_salemanager,1,1,1,0 access_res_partner_category_group_sale_salemanager,res_partner_category_group_sale_salemanager,base.model_res_partner_category,sf_base.group_sale_salemanager,1,0,1,0
access_res_partner_category_group_sale_director,res_partner_category_group_sale_director,base.model_res_partner_category,sf_base.group_sale_director,1,1,1,0 access_res_partner_category_group_sale_director,res_partner_category_group_sale_director,base.model_res_partner_category,sf_base.group_sale_director,1,0,1,0
access_sf_production_process,sf_production_process,model_sf_production_process,base.group_user,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_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,sf_production_materials,model_sf_production_materials,base.group_user,1,1,1,0
@@ -208,6 +208,7 @@ 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,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 access_printer_configuration,printer.configuration,model_printer_configuration,base.group_user,1,1,1,1
access_label_style,label.style,model_label_style,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,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_admin,sf_tool_inventory_admin,model_sf_tool_inventory,base.group_system,1,1,1,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
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_production_process_group_sale_director sf_production_process_group_sale_director model_sf_production_process sf_base.group_sale_director 1 0 0 0
13 access_sf_production_process_group_sale_salemanager sf_production_process_group_sale_salemanager model_sf_production_process sf_base.group_sale_salemanager 1 0 0 0
14 access_res_partner_category_group_sale_salemanager res_partner_category_group_sale_salemanager base.model_res_partner_category sf_base.group_sale_salemanager 1 1 0 1 0
15 access_res_partner_category_group_sale_director res_partner_category_group_sale_director base.model_res_partner_category sf_base.group_sale_director 1 1 0 1 0
16 access_sf_production_process sf_production_process model_sf_production_process base.group_user 1 1 1 0
17 access_sf_production_process_admin sf_production_process_admin model_sf_production_process base.group_system 1 1 1 0
18 access_sf_production_materials sf_production_materials model_sf_production_materials base.group_user 1 1 1 0
208 access_sf_multi_mounting_type_group_purchase_director access_sf_fixture_material_group_purchase_director sf_multi_mounting_type_group_purchase_director sf_fixture_material_group_purchase_director model_sf_multi_mounting_type model_sf_fixture_material sf_base.group_purchase_director 1 0 0 0
209 access_sf_fixture_model_group_purchase_director access_sf_multi_mounting_type_group_purchase_director sf_fixture_model_group_purchase_director sf_multi_mounting_type_group_purchase_director model_sf_fixture_model model_sf_multi_mounting_type sf_base.group_purchase_director 1 0 0 0
210 access_sf_fixture_materials_basic_parameters_group_purchase_director access_sf_fixture_model_group_purchase_director sf_fixture_materials_basic_parameters_group_purchase_director sf_fixture_model_group_purchase_director model_sf_fixture_materials_basic_parameters model_sf_fixture_model sf_base.group_purchase_director 1 0 0 0
211 access_sf_fixture_materials_basic_parameters_group_purchase_director sf_fixture_materials_basic_parameters_group_purchase_director model_sf_fixture_materials_basic_parameters sf_base.group_purchase_director 1 0 0 0
212 access_sf_machine_tool_type_group_purchase_director sf_machine_tool_type_group_purchase_director model_sf_machine_tool_type sf_base.group_purchase_director 1 0 0 0
213 access_sf_fixture_material_group_sale_director sf_fixture_material_group_sale_director model_sf_fixture_material sf_base.group_sale_director 1 0 0 0
214 access_sf_multi_mounting_type_group_sale_director sf_multi_mounting_type_group_sale_director model_sf_multi_mounting_type sf_base.group_sale_director 1 0 0 0

View File

@@ -38,6 +38,7 @@
<field name="name"/> <field name="name"/>
<field name="printer_id"/> <field name="printer_id"/>
<field name="model"/> <field name="model"/>
<field name="label_id"/>
<!-- 其他字段... --> <!-- 其他字段... -->
</tree> </tree>
</field> </field>
@@ -53,6 +54,36 @@
<field name="name"/> <field name="name"/>
<field name="printer_id"/> <field name="printer_id"/>
<field name="model"/> <field name="model"/>
<field name="label_id"/>
<!-- 其他字段... -->
</group>
</sheet>
</form>
</field>
</record>
<record id="view_label_style_tree" model="ir.ui.view">
<field name="name">label.style.tree</field>
<field name="model">label.style</field>
<field name="arch" type="xml">
<tree string="label style">
<field name="name"/>
<!-- <field name="zpl_code"/> -->
<!-- 其他字段... -->
</tree>
</field>
</record>
<record id="view_label_style_form" model="ir.ui.view">
<field name="name">label.style.form</field>
<field name="model">label.style</field>
<field name="arch" type="xml">
<form string="label style">
<sheet>
<group>
<field name="name"/>
<field name="zpl_code"/>
<!-- 其他字段... --> <!-- 其他字段... -->
</group> </group>
</sheet> </sheet>
@@ -74,6 +105,11 @@
<field name="res_model">printer.configuration</field> <field name="res_model">printer.configuration</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
</record> </record>
<record id="action_label_style" model="ir.actions.act_window">
<field name="name">标签样式</field>
<field name="res_model">label.style</field>
<field name="view_mode">tree,form,kanban</field>
</record>
<!-- Add a menu item for the printer configuration --> <!-- Add a menu item for the printer configuration -->
<!-- <record id="menu_printer_configuration" model="ir.ui.menu"> --> <!-- <record id="menu_printer_configuration" model="ir.ui.menu"> -->
@@ -108,5 +144,12 @@
sequence="2" sequence="2"
parent="printer_main_menu"/> parent="printer_main_menu"/>
<menuitem
id="menu_label_style"
name="标签样式"
action="action_label_style"
sequence="3"
parent="printer_main_menu"/>
</data> </data>
</odoo> </odoo>

View File

@@ -555,9 +555,9 @@
<field name="model">sf.tool.inventory</field> <field name="model">sf.tool.inventory</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="功能刀具清单" create="1" edit="1" delete="0" editable="bottom"> <tree string="功能刀具清单" create="1" edit="1" delete="0" editable="bottom">
<field name="name" attrs="{'readonly': [('id', '!=', False)]}"/> <field name="name"/>
<field name="functional_cutting_tool_model_id"/> <field name="functional_cutting_tool_model_id"/>
<field name="tool_groups_id" required="1" attrs="{'readonly': [('id', '!=', False)]}"/> <field name="tool_groups_id"/>
<field name="work_material"/> <field name="work_material"/>
<field name="life_span"/> <field name="life_span"/>
<field name="prefix" optional="hide"/> <field name="prefix" optional="hide"/>

View File

@@ -21,7 +21,6 @@ class Http(models.AbstractModel):
def _auth_method_sf_token(cls): def _auth_method_sf_token(cls):
# 从headers.environ中获取对方传过来的token,timestamp,加密的校验字符串 # 从headers.environ中获取对方传过来的token,timestamp,加密的校验字符串
datas = request.httprequest.headers.environ datas = request.httprequest.headers.environ
_logger.info('datas:%s' % datas)
if 'HTTP_TOKEN' in datas: if 'HTTP_TOKEN' in datas:
_logger.info('token:%s' % datas['HTTP_TOKEN']) _logger.info('token:%s' % datas['HTTP_TOKEN'])
# 查询密钥 # 查询密钥

View File

@@ -5,7 +5,7 @@ import requests
import cpca import cpca
# from odoo.exceptions import UserError # from odoo.exceptions import UserError
# from odoo.exceptions import ValidationError # from odoo.exceptions import ValidationError
from odoo import api, fields, models, _ from odoo import api, fields, models
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@@ -14,7 +14,7 @@ _logger = logging.getLogger(__name__)
class JdEclp(models.Model): class JdEclp(models.Model):
_inherit = 'stock.picking' _inherit = 'stock.picking'
senderNickName = fields.Char(string='寄件工厂简称', required=True, default='XT') senderNickName = fields.Char(string='寄件工厂简称', required=True, default='MW')
# receiverName = fields.Char(string='收件人姓名') # receiverName = fields.Char(string='收件人姓名')
# receiverMobile = fields.Char(string='收件人电话') # receiverMobile = fields.Char(string='收件人电话')
@@ -161,25 +161,15 @@ class JdEclp(models.Model):
url2 = config['bfm_url'] + '/api/get/jd/no' url2 = config['bfm_url'] + '/api/get/jd/no'
response = requests.post(url2, json=json2, data=None) response = requests.post(url2, json=json2, data=None)
# _logger.info('调用成功2', response.json()['result']['wbNo']) # _logger.info('调用成功2', response.json()['result']['wbNo'])
self.carrier_tracking_ref = response.json()['result'].get('wbNo') self.carrier_tracking_ref = response.json()['result']['wbNo']
if not self.carrier_tracking_ref:
raise ValidationError('物流下单未成功,请联系管理员')
self.is_bill = True self.is_bill = True
self.logistics_status = '1' self.logistics_status = '1'
notification = { # # 京东物流下单后,销售订单状态改为待收货
'type': 'ir.actions.client', # self.env['sale.order'].search([('name', '=', self.origin)]).write({'scheduled_status': 'to receive'})
'tag': 'display_notification',
'params': {
'title': _('成功'),
'type': 'success',
'message': '物流下单成功',
'sticky': False,
'next': {'type': 'ir.actions.client', 'tag': 'reload'}
}
}
return notification # else:
# raise UserError("选择京东物流才能下单呦")
def get_bill(self): def get_bill(self):
""" """

View File

@@ -32,7 +32,7 @@
<field name="is_bill" invisible="True"/> <field name="is_bill" invisible="True"/>
<field name="logistics_status" invisible="True"/> <field name="logistics_status" invisible="True"/>
<field name="logistics_way" invisible="True"/> <field name="logistics_way" invisible="True"/>
<button string="物流下单" name="create_order" type="object" confirm="是否确认物流下单" class="btn-primary" <button string="京东物流下单" name="create_order" type="object" confirm="是否确认物流下单" class="btn-primary"
attrs="{'invisible': ['|', '|', '|', ('check_out', '!=', 'OUT'), ('state', '!=', 'assigned'), ('is_bill', '=', True), ('logistics_way', '=', '自提')]}"/> attrs="{'invisible': ['|', '|', '|', ('check_out', '!=', 'OUT'), ('state', '!=', 'assigned'), ('is_bill', '=', True), ('logistics_way', '=', '自提')]}"/>
<button string="获取物流面单" name="get_bill" type="object" confirm="是否获取物流面单" class="btn-primary" <button string="获取物流面单" name="get_bill" type="object" confirm="是否获取物流面单" class="btn-primary"
attrs="{'invisible': ['|', '|', '|', '|', ('check_out', '!=', 'OUT'), ('state', '!=', 'assigned'), ('logistics_status', '=', '2'), ('is_bill', '=', False), ('logistics_way', '=', '自提')]}"/> attrs="{'invisible': ['|', '|', '|', '|', ('check_out', '!=', 'OUT'), ('state', '!=', 'assigned'), ('logistics_status', '=', '2'), ('is_bill', '=', False), ('logistics_way', '=', '自提')]}"/>
@@ -45,26 +45,16 @@
<field name="model">stock.picking</field> <field name="model">stock.picking</field>
<field name="inherit_id" ref="delivery.view_picking_withcarrier_out_form"/> <field name="inherit_id" ref="delivery.view_picking_withcarrier_out_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="location_id" position="after"> <field name="location_id" position="after">
<field name="logistics_status" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/> <field name="logistics_status" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="logistics_way" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/> <field name="logistics_way" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
</field> </field>
</field>
</record>
<record id="tracking_only_view" model="ir.ui.view"> <xpath expr="//group//field[@name='carrier_id']" position="after">
<field name="name">tracking only</field> <!-- <field name="senderNickName" domain="[('self.name', 'like', '%OUT%')]"/> -->
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//form//sheet//notebook//page[@name='operations']" position="after">
<page string="发货信息" name="tracking">
<group>
<group>
<field name="senderNickName" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/> <field name="senderNickName" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="expressItemName" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/> <field name="expressItemName" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="grossWeight" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="grossVolume" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="deliveryType" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/> <field name="deliveryType" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="receiverName" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/> <field name="receiverName" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="receiverMobile" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/> <field name="receiverMobile" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
@@ -74,21 +64,23 @@
<field name="receiverTownName" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/> <field name="receiverTownName" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="receiverCompany" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/> <field name="receiverCompany" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="remark" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/> <field name="remark" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="grossWeight" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="grossVolume" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<field name="pickupBeginTime" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/> <field name="pickupBeginTime" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
</group> <field name="bill_show" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
<group>
<field name="logistics_status"/> <field name="logistics_status"/>
<field name="carrier_id"/>
<field name="carrier_tracking_ref"/>
<field name="bill_show" attrs="{'invisible': [('check_out', '!=', 'OUT')]}" string='面单下载'/>
<field name="bill_show" widget="pdf_viewer" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
</group>
</group>
</page>
</xpath> </xpath>
<xpath expr="//group//field[@name='group_id']" position="after">
<field name="bill_show" widget="pdf_viewer" attrs="{'invisible': [('check_out', '!=', 'OUT')]}"/>
</xpath>
<!-- <xpath expr="//group[@name='other_infos']" position="after"> -->
<!-- <div> -->
<!-- <button string="京东物流下单" name="create_order" type="object" confirm="是否确认物流下单" class="btn-primary"/> -->
<!-- </div> -->
<!-- <div> -->
<!-- <button string="获取物流面单" name="get_bill" type="object" confirm="是否获取物流面单" class="btn-primary"/> -->
<!-- </div> -->
<!-- </xpath> -->
</field> </field>
</record> </record>
</odoo> </odoo>

View File

@@ -88,7 +88,7 @@
</div> </div>
<field name="model_volume" string="体积[mm³]"/> <field name="model_volume" string="体积[mm³]"/>
<field name="product_model_type_id" string="模型类型"/> <field name="product_model_type_id" string="模型类型"/>
<field name="model_processing_panel" placeholder="例如R,U" string="加工面板" readonly="1"/> <field name="model_processing_panel" placeholder="例如R,U" string="加工面板"/>
<field name="model_machining_precision"/> <field name="model_machining_precision"/>
<field name="model_process_parameters_ids" string="表面工艺参数" <field name="model_process_parameters_ids" string="表面工艺参数"
widget="many2many_tags" widget="many2many_tags"
@@ -305,7 +305,7 @@
<field name="cutting_tool_blade_type" <field name="cutting_tool_blade_type"
attrs="{'invisible': [('cutting_tool_type', '!=', '整体式刀具')],'readonly': [('id', '!=', False)]}"/> attrs="{'invisible': [('cutting_tool_type', '!=', '整体式刀具')],'readonly': [('id', '!=', False)]}"/>
<field name="cutting_tool_coarse_medium_fine" string="粗/中/精" placeholder="请选择" <field name="cutting_tool_coarse_medium_fine" string="粗/中/精" placeholder="请选择"
attrs="{'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀片'))],'readonly': [('id', '!=', False)]}"/> attrs="{'required': [('cutting_tool_type','=','整体式刀具')],'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀片'))],'readonly': [('id', '!=', False)]}"/>
<!--整体式刀具--> <!--整体式刀具-->
<field name="cutting_tool_shank_diameter" string="柄部直径(mm)" class="diameter" <field name="cutting_tool_shank_diameter" string="柄部直径(mm)" class="diameter"
attrs="{'invisible': [('cutting_tool_type', '!=', '整体式刀具')],'readonly': [('id', '!=', False)]}"/> attrs="{'invisible': [('cutting_tool_type', '!=', '整体式刀具')],'readonly': [('id', '!=', False)]}"/>

View File

@@ -25,10 +25,6 @@
<filter string="人工编程" name="manual_quotation" domain="[('manual_quotation', '=', True)]"/> <filter string="人工编程" name="manual_quotation" domain="[('manual_quotation', '=', True)]"/>
<filter string="自动编程" name="no_manual_quotation" domain="[('manual_quotation', '=', False)]"/> <filter string="自动编程" name="no_manual_quotation" domain="[('manual_quotation', '=', False)]"/>
</xpath> </xpath>
<xpath expr="//field[@name='production_id']" position="before">
<field name="product_tmpl_name"/>
<field name="rfid_code"/>
</xpath>
</field> </field>
</record> </record>
</odoo> </odoo>

View File

@@ -5,10 +5,10 @@
<field name="model">mrp.workorder</field> <field name="model">mrp.workorder</field>
<field name="inherit_id" ref="sf_manufacturing.view_mrp_production_workorder_tray_form_inherit_sf"/> <field name="inherit_id" ref="sf_manufacturing.view_mrp_production_workorder_tray_form_inherit_sf"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<!-- <xpath expr="//header" position="inside">&ndash;&gt;--> <xpath expr="//header" position="inside">
<!-- <button string="程序下载" name="cnc_file_download" type="object" class="oe_highlight" attrs='{"invisible": ["|",--> <button string="程序下载" name="cnc_file_download" type="object" class="oe_highlight" attrs='{"invisible": ["|",
<!-- ("user_permissions","=",False),("routing_type","!=","CNC加工")]}'/>--> ("user_permissions","=",False),("routing_type","!=","CNC加工")]}'/>
<!-- </xpath>--> </xpath>
<xpath expr="//page//field[@name='cnc_ids']" position="before"> <xpath expr="//page//field[@name='cnc_ids']" position="before">
<group> <group>
<group> <group>
@@ -17,30 +17,23 @@
</group> </group>
<div> <div>
<div> <div>
<!-- <field name="button_compensation_state" attrs='{"invisible": ["|",--> <field name="button_compensation_state" attrs='{"invisible": ["|",
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>--> ("state","!=","progress"),("user_permissions","=",False)]}'/>
<!-- <span>&#32;</span>--> <button string="一键补偿" name="compensation" type="object" confirm="是否确认下发补偿"
<!-- <button name="button_send_program_again" type="object" string="重新下发NC程序"--> class="btn-primary" attrs='{"invisible": ["|",
<!-- class="btn-primary"--> ("state","!=","progress"),("user_permissions","=",False)]}'/>
<!-- confirm="是否确认重新下发NC程序"--> <span>&#32;</span>
<!-- groups="sf_base.group_sf_order_user,sf_base.group_sf_equipment_user"--> <button string="一键下发" name="up_all" type="object" style="text-align: right;" confirm="是否确认一键下发"
<!-- attrs="{'invisible': ['|', '|', '|',('routing_type','!=','装夹预调'),('state','in',['done', 'cancel',--> class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",
<!-- 'progress']),('processing_drawing','=',False),('is_send_program_again','=',True)]}"/>--> ("state","!=","progress"),("user_permissions","=",False)]}'/>
<!-- <button string="一键补偿" name="compensation" type="object" confirm="是否确认下发补偿"--> <span>&#32;</span>
<!-- class="btn-primary" attrs='{"invisible": ["|",--> <button string="合并下发" id="action_up_select" name="%(sf_machine_connect.action_up_select)d"
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>--> type="action" class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",
<!-- <span>&#32;</span>--> ("state","!=","progress"),("user_permissions","=",False)]}'/>
<!-- <button string="一键下发" name="up_all" type="object" style="text-align: right;" confirm="是否确认一键下发"--> <span>&#32;</span>
<!-- class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",--> <button string="一键合并下发" name="up_merge_all" type="object" style="text-align: right;" confirm="是否确认一键合并下发"
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>--> class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",
<!-- <span>&#32;</span>--> ("state","!=","progress"),("user_permissions","=",False)]}'/>
<!-- <button string="合并下发" id="action_up_select" name="%(sf_machine_connect.action_up_select)d"-->
<!-- type="action" class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",-->
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>-->
<!-- <span>&#32;</span>-->
<!-- <button string="一键合并下发" name="up_merge_all" type="object" style="text-align: right;" confirm="是否确认一键合并下发"-->
<!-- class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",-->
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>-->
</div> </div>
</div> </div>
</group> </group>

View File

@@ -9,6 +9,7 @@
<tree> <tree>
<field name="sequence_number"/> <field name="sequence_number"/>
<field name="program_name"/> <field name="program_name"/>
<field name="cnc_id" string="文件"/>
<field name="functional_tool_type_id"/> <field name="functional_tool_type_id"/>
<field name="cutting_tool_name"/> <field name="cutting_tool_name"/>
<field name="cutting_tool_no"/> <field name="cutting_tool_no"/>

View File

@@ -19,7 +19,7 @@
<!-- attrs='{"invisible": ["|",("state","!=","progress"), --> <!-- attrs='{"invisible": ["|",("state","!=","progress"), -->
<!-- ("user_permissions","!=",True)]}'/> --> <!-- ("user_permissions","!=",True)]}'/> -->
<!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序" context="{'default_cnc_ids': cnc_ids}"/> --> <!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序" context="{'default_cnc_ids': cnc_ids}"/> -->
<!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"--> <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"
context="{'default_sf_cnc_processing_id': id}" attrs='{"invisible": ["|",("state","!=","progress"), context="{'default_sf_cnc_processing_id': id}" attrs='{"invisible": ["|",("state","!=","progress"),
("user_permissions","!=",True)]}'/> ("user_permissions","!=",True)]}'/>
<!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"--> <!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"-->

View File

@@ -14,7 +14,7 @@
<!-- <field name="program_ids" domain="[('workorder_id', '=', workorder_id)]"/>--> <!-- <field name="program_ids" domain="[('workorder_id', '=', workorder_id)]"/>-->
</group> </group>
<footer> <footer>
<!-- <button string="合并下发" name="confirm_up" type="object" class="btn-primary" confirm="是否确认合并下发"/>--> <button string="合并下发" name="confirm_up" type="object" class="btn-primary" confirm="是否确认合并下发"/>
<button string="取消" class="btn-secondary" special="cancel"/> <button string="取消" class="btn-secondary" special="cancel"/>
</footer> </footer>
</form> </form>

View File

@@ -8,7 +8,7 @@ from odoo.http import request
class Manufacturing_Connect(http.Controller): class Manufacturing_Connect(http.Controller):
@http.route('/AutoDeviceApi/GetWoInfo', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False, @http.route('/AutoDeviceApi/GetWoInfo', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*") cors="*")
def get_Work_Info(self, **kw): def get_Work_Info(self, **kw):
""" """
@@ -162,8 +162,7 @@ class Manufacturing_Connect(http.Controller):
routing_type = ret['CraftId'] routing_type = ret['CraftId']
equipment_id = ret["DeviceId"] equipment_id = ret["DeviceId"]
workorder = request.env['mrp.workorder'].sudo().search( workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type), [('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
('rfid_code', '!=', False)], limit=1)
if not workorder: if not workorder:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单不存在'} res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单不存在'}
return json.JSONEncoder().encode(res) return json.JSONEncoder().encode(res)
@@ -204,14 +203,12 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': True, 'Datas': ['工单已结束']} res = {'Succeed': True, 'Datas': ['工单已结束']}
datas = request.httprequest.data datas = request.httprequest.data
ret = json.loads(datas) ret = json.loads(datas)
logging.info('button_Work_End:%s' % ret)
request.env['center_control.interface.log'].sudo().create( request.env['center_control.interface.log'].sudo().create(
{'content': ret, 'name': 'AutoDeviceApi/FeedBackEnd'}) {'content': ret, 'name': 'AutoDeviceApi/FeedBackEnd'})
production_id = ret['BillId'] production_id = ret['BillId']
routing_type = ret['CraftId'] routing_type = ret['CraftId']
workorder = request.env['mrp.workorder'].sudo().search( workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type), [('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
('rfid_code', '!=', False)], limit=1)
if not workorder: if not workorder:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单不存在'} res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单不存在'}
return json.JSONEncoder().encode(res) return json.JSONEncoder().encode(res)
@@ -219,20 +216,19 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单未开始'} res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单未开始'}
return json.JSONEncoder().encode(res) return json.JSONEncoder().encode(res)
# workorder.write({'date_finished': datetime.now()}) # workorder.write({'date_finished': datetime.now()})
if ret['IsComplete'] is True:
workorder.button_finish() workorder.button_finish()
# workorder.process_state = '待解除装夹' # workorder.process_state = '待解除装夹'
# workorder.sudo().production_id.process_state = '待解除装夹' # workorder.sudo().production_id.process_state = '待解除装夹'
# 根据工单的实际结束时间修改排程单的结束时间、状态,同时修改销售订单的状态 # 根据工单的实际结束时间修改排程单的结束时间、状态,同时修改销售订单的状态
# if workorder.date_finished: if workorder.date_finished:
# request.env['sf.production.plan'].sudo().search([('production_id', '=', production_id)]).write( request.env['sf.production.plan'].sudo().search([('production_id', '=', production_id)]).write(
# {'actual_end_time': workorder.date_finished, {'actual_end_time': workorder.date_finished,
# 'state': 'finished'}) 'state': 'finished'})
# production_obj = request.env['mrp.production'].sudo().search([('name', '=', production_id)]) production_obj = request.env['mrp.production'].sudo().search([('name', '=', production_id)])
# if production_obj: if production_obj:
# production_obj.sudo().work_order_state = '已完成' production_obj.sudo().work_order_state = '已完成'
# production_obj.write({'state': 'done'}) production_obj.write({'state': 'completed'})
# request.env['sale.order'].sudo().search( # request.env['sale.order'].sudo().search(
# [('name', '=', production_obj.origin)]).write({'schedule_status': 'to deliver'}) # [('name', '=', production_obj.origin)]).write({'schedule_status': 'to deliver'})
@@ -320,15 +316,15 @@ class Manufacturing_Connect(http.Controller):
[('rfid_code', '=', ret['RfidCode']), ('routing_type', '=', 'CNC加工')]) [('rfid_code', '=', ret['RfidCode']), ('routing_type', '=', 'CNC加工')])
if workorder: if workorder:
for item in workorder.cmm_ids: for item in workorder.cmm_ids:
if item.program_create_date is not False: if item.program_date is not False:
program_create_date = item.program_create_date.strftime("%Y-%m-%d %H:%M:%S") program_date = item.program_date.strftime("%Y-%m-%d %H:%M:%S")
program_date_str = request.env['sf.sync.common'].sudo().get_add_time(program_create_date) program_date_str = request.env['sf.sync.common'].sudo().get_add_time(program_date)
res['Datas'].append({ res['Datas'].append({
'CraftId': workorder.id, 'CraftId': workorder.id,
'CraftKey': workorder.name, 'CraftKey': workorder.name,
'ProgramDate': '' if not item.program_create_date else program_date_str, 'ProgramDate': '' if not item.program_date else program_date_str,
'ProgramPath': item.program_path, 'ProgramPath': item.program_path,
'PostProcessing': item.program_name, 'PostProcessing': item.post_processing_name,
}) })
else: else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '暂无工单及对应的CNC程序数据'} res = {'Succeed': False, 'ErrorCode': 203, 'Error': '暂无工单及对应的CNC程序数据'}
@@ -463,7 +459,6 @@ class Manufacturing_Connect(http.Controller):
if f'RfidCode{i}' in ret: if f'RfidCode{i}' in ret:
rfid_code = ret[f'RfidCode{i}'] rfid_code = ret[f'RfidCode{i}']
logging.info('RfidCode:%s' % rfid_code) logging.info('RfidCode:%s' % rfid_code)
if rfid_code is not None:
domain = [ domain = [
('rfid_code', '=', rfid_code), ('rfid_code', '=', rfid_code),
('routing_type', '=', 'CNC加工') ('routing_type', '=', 'CNC加工')
@@ -471,16 +466,11 @@ class Manufacturing_Connect(http.Controller):
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc') workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
if workorder: if workorder:
for order in workorder: for order in workorder:
if order.production_line_state == '待上产线': if order.production_id.production_line_state == '待上产线':
logging.info( logging.info(
'单产线状态:%s' % order.production_line_state) '制造订单产线状态:%s' % order.production_id.production_line_state)
panel_workorder = request.env['mrp.workorder'].sudo().search( order.production_id.write({'production_line_state': '已上产线'})
[('rfid_code', '=', rfid_code), workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search([
('processing_panel', '=', order.processing_panel)])
if panel_workorder:
panel_workorder.write({'production_line_state': '已上产线'})
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[
('rfid_code', '=', rfid_code), ('type', '=', '上产线'), ('rfid_code', '=', rfid_code), ('type', '=', '上产线'),
('production_id', '=', order.production_id.id)]) ('production_id', '=', order.production_id.id)])
if workpiece_delivery.status == '待下发': if workpiece_delivery.status == '待下发':
@@ -524,7 +514,6 @@ class Manufacturing_Connect(http.Controller):
if f'RfidCode{i}' in ret: if f'RfidCode{i}' in ret:
rfid_code = ret[f'RfidCode{i}'] rfid_code = ret[f'RfidCode{i}']
logging.info('RfidCode:%s' % rfid_code) logging.info('RfidCode:%s' % rfid_code)
if rfid_code is not None:
domain = [ domain = [
('rfid_code', '=', rfid_code), ('rfid_code', '=', rfid_code),
('routing_type', '=', 'CNC加工') ('routing_type', '=', 'CNC加工')
@@ -532,16 +521,11 @@ class Manufacturing_Connect(http.Controller):
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc') workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
if workorder: if workorder:
for order in workorder: for order in workorder:
if order.production_line_state == '已上产线': if order.production_id.production_line_state == '已上产线':
logging.info( logging.info(
'单产线状态:%s' % order.production_line_state) '制造订单产线状态:%s' % order.production_id.production_line_state)
panel_workorder = request.env['mrp.workorder'].sudo().search( order.production_id.write({'production_line_state': '已下产线'})
[('rfid_code', '=', rfid_code), workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search([
('processing_panel', '=', order.processing_panel)])
if panel_workorder:
panel_workorder.write({'production_line_state': '已下产线'})
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[
('rfid_code', '=', rfid_code), ('type', '=', '下产线'), ('rfid_code', '=', rfid_code), ('type', '=', '下产线'),
('production_id', '=', order.production_id.id)]) ('production_id', '=', order.production_id.id)])
delivery_Arr.append(workpiece_delivery.id) delivery_Arr.append(workpiece_delivery.id)

View File

@@ -30,10 +30,13 @@ class MrpProduction(models.Model):
# ('completed', '已完工') # ('completed', '已完工')
# ]) # ])
state = fields.Selection([ state = fields.Selection([
('draft', '草稿'), ('draft', 'Draft'),
('confirmed', '待排程'), ('confirmed', 'Confirmed'),
('pending_cam', '加工'), ('progress', '排程'),
('progress', '加工中'), ('pending_cam', '待装夹'),
('pending_processing', '待加工'),
('pending_era_cam', '待解除装夹'),
('completed', '已完工'),
('to_close', 'To Close'), ('to_close', 'To Close'),
('done', 'Done'), ('done', 'Done'),
('cancel', 'Cancelled')], string='State', ('cancel', 'Cancelled')], string='State',
@@ -50,14 +53,13 @@ class MrpProduction(models.Model):
active = fields.Boolean(string='已归档', default=True) active = fields.Boolean(string='已归档', default=True)
programming_no = fields.Char('编程单号') programming_no = fields.Char('编程单号')
work_state = fields.Char('业务状态') work_state = fields.Char('业务状态')
programming_state = fields.Selection( programming_state = fields.Char('编程状态', tracking=True)
[('编程中', '编程中'), ('已编程', '已编程')], string='编程状态', tracking=True)
glb_file = fields.Binary("glb模型文件") glb_file = fields.Binary("glb模型文件")
production_line_id = fields.Many2one('sf.production.line', string='生产线', tracking=True) production_line_id = fields.Many2one('sf.production.line', string='生产线', tracking=True)
plan_start_processing_time = fields.Datetime('计划开始加工时间') plan_start_processing_time = fields.Datetime('计划开始加工时间')
# production_line_state = fields.Selection( production_line_state = fields.Selection(
# [('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')], [('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
# string='上/下产线', default='待上产线', tracking=True) string='上/下产线', default='待上产线', tracking=True)
# 工序状态 # 工序状态
# Todo 研究下用法 # Todo 研究下用法
process_state = fields.Selection([ process_state = fields.Selection([
@@ -79,7 +81,7 @@ class MrpProduction(models.Model):
@api.depends( @api.depends(
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state',
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state') 'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state', 'process_state')
def _compute_state(self): def _compute_state(self):
for production in self: for production in self:
if not production.state or not production.product_uom_id: if not production.state or not production.product_uom_id:
@@ -107,19 +109,22 @@ class MrpProduction(models.Model):
production.state = 'progress' production.state = 'progress'
elif any(not float_is_zero(move.quantity_done, elif any(not float_is_zero(move.quantity_done,
precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding) precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding)
for move in production.move_raw_ids if move.product_id): for move in production.move_raw_ids):
production.state = 'progress' production.state = 'progress'
# # 新添加的状态逻辑 # 新添加的状态逻辑
if ( if production.state == 'progress' and production.schedule_state == '已排' and production.process_state == '待装夹':
production.state == 'to_close' or production.state == 'progress') and production.schedule_state == '未排': # production.state = 'pending_processing'
production.state = 'confirmed'
elif production.state == 'to_close' and production.schedule_state == '已排':
production.state = 'pending_cam'
if production.state == 'progress':
if all(wo_state not in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'pending_cam' production.state = 'pending_cam'
if production.state == 'progress' and production.schedule_state == '已排' and production.process_state == '待加工':
# if production.state == 'pending_cam' and production.process_state == '待加工':
production.state = 'pending_processing'
elif production.state == 'progress' and production.process_state == '待解除装夹':
production.state = 'pending_era_cam'
elif production.state == 'progress' and production.process_state == '已完工':
production.state = 'completed'
elif production.state == 'progress' and production.work_order_state == '已完成':
production.state = 'completed'
def action_check(self): def action_check(self):
""" """
@@ -173,7 +178,7 @@ class MrpProduction(models.Model):
raise UserError("更新程单失败,请联系管理员") raise UserError("更新程单失败,请联系管理员")
# cnc程序获取 # cnc程序获取
def fetchCNC(self, production_names): def fetchCNC(self, production_names, scrap_production):
cnc = self.env['mrp.production'].search([('id', '=', self.id)]) cnc = self.env['mrp.production'].search([('id', '=', self.id)])
quick_order = self.env['quick.easy.order'].search( quick_order = self.env['quick.easy.order'].search(
[('name', '=', cnc.product_id.default_code.rsplit('-', 1)[0])]) [('name', '=', cnc.product_id.default_code.rsplit('-', 1)[0])])
@@ -189,7 +194,8 @@ class MrpProduction(models.Model):
'production_no': production_names, 'production_no': production_names,
'machine_tool_code': '', 'machine_tool_code': '',
'product_name': cnc.product_id.name, 'product_name': cnc.product_id.name,
'remanufacture_type': '', 'remanufacture_type': '' if not scrap_production else scrap_production.workorder_ids.filtered(
lambda b: b.routing_type == "CNC加工").test_results,
'model_code': cnc.product_id.model_code, 'model_code': cnc.product_id.model_code,
'material_code': self.env['sf.production.materials'].search( 'material_code': self.env['sf.production.materials'].search(
[('id', '=', cnc.product_id.materials_id.id)]).materials_no, [('id', '=', cnc.product_id.materials_id.id)]).materials_no,
@@ -287,7 +293,15 @@ class MrpProduction(models.Model):
# 则根据设备找到工作中心;否则采用前面描述的工作中心分配机制; # 则根据设备找到工作中心;否则采用前面描述的工作中心分配机制;
# 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心; # 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心;
def _create_workorder3(self, item): def _create_workorder3(self):
# 根据product_id对self进行分组
grouped_product_ids = {k: list(g) for k, g in groupby(self, key=lambda x: x.product_id.id)}
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
product_id_to_production_names = {}
# 对于每个product_id获取其所有生产订单的名称
for product_id, productions in grouped_product_ids.items():
# 为同一个product_id创建一个生产订单名称列表
product_id_to_production_names[product_id] = [production.name for production in productions]
for production in self: for production in self:
if not production.bom_id or not production.product_id: if not production.bom_id or not production.product_id:
continue continue
@@ -315,6 +329,20 @@ class MrpProduction(models.Model):
'state': 'pending', 'state': 'pending',
}] }]
if production.product_id.categ_id.type == '成品': if production.product_id.categ_id.type == '成品':
if production.product_id.id in product_id_to_production_names:
# # 同一个产品多个制造订单对应一个编程单和模型库
# # 只调用一次fetchCNC并将所有生产订单的名称作为字符串传递
if not production.programming_no:
production_programming = self.search(
[('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)],
limit=1, order='id asc')
if not production_programming.programming_no:
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]),
scrap_production)
else:
production.write({'programming_no': production_programming.programming_no,
'programming_state': '编程中'})
# # 根据加工面板的面数及对应的工序模板生成工单 # # 根据加工面板的面数及对应的工序模板生成工单
i = 0 i = 0
processing_panel_len = len(production.product_id.model_processing_panel.split(',')) processing_panel_len = len(production.product_id.model_processing_panel.split(','))
@@ -327,14 +355,13 @@ class MrpProduction(models.Model):
for route in product_routing_workcenter: for route in product_routing_workcenter:
if route.is_repeat is True: if route.is_repeat is True:
workorders_values.append( workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(k, production, route, item)) self.env['mrp.workorder'].json_workorder_str(k, production, route))
# if i == processing_panel_len and route.routing_type == '解除装夹': if i == processing_panel_len and route.routing_type == '解除装夹':
# workorders_values.append( workorders_values.append(
# self.env['mrp.workorder'].json_workorder_str(k, production, route)) self.env['mrp.workorder'].json_workorder_str(k, production, route))
# 表面工艺工序 # 表面工艺工序
# 获取表面工艺id # 获取表面工艺id
if production.product_id.model_process_parameters_ids: if production.product_id.model_process_parameters_ids:
logging.info('model_process_parameters_ids:%s' % production.product_id.model_process_parameters_ids)
surface_technics_arr = [] surface_technics_arr = []
# 工序id # 工序id
route_workcenter_arr = [] route_workcenter_arr = []
@@ -349,7 +376,6 @@ class MrpProduction(models.Model):
# 用filter刷选表面工艺id'是否存在工艺类别对象里 # 用filter刷选表面工艺id'是否存在工艺类别对象里
if production_process_category: if production_process_category:
for p in production_process_category: for p in production_process_category:
logging.info('production_process_category:%s' % p.name)
production_process = p.production_process_ids.filtered( production_process = p.production_process_ids.filtered(
lambda pp: pp.id in surface_technics_arr) lambda pp: pp.id in surface_technics_arr)
if production_process: if production_process:
@@ -380,52 +406,6 @@ class MrpProduction(models.Model):
workorders_values.append( workorders_values.append(
self.env['mrp.workorder'].json_workorder_str('', production, route)) self.env['mrp.workorder'].json_workorder_str('', production, route))
production.workorder_ids = workorders_values production.workorder_ids = workorders_values
# for production_item in productions:
process_parameter_workorder = self.env['mrp.workorder'].search(
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
('is_subcontract', '=', True)])
if process_parameter_workorder:
is_pick = False
consecutive_workorders = []
m = 0
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
for i in range(len(sorted_workorders) - 1):
if m == 0:
is_pick = False
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
if sorted_workorders[i] not in consecutive_workorders:
consecutive_workorders.append(sorted_workorders[i])
consecutive_workorders.append(sorted_workorders[i + 1])
m += 1
continue
else:
if m == len(consecutive_workorders) - 1 and m != 0:
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
production)
if sorted_workorders[i] in consecutive_workorders:
is_pick = True
consecutive_workorders = []
m = 0
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
if is_pick is False:
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
production)
if m == len(consecutive_workorders) - 1 and m != 0:
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
production)
if sorted_workorders[i] in consecutive_workorders:
is_pick = True
consecutive_workorders = []
m = 0
if m == len(consecutive_workorders) - 1 and m != 0:
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
if is_pick is False and m == 0:
if len(sorted_workorders) == 1:
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production)
else:
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production)
for workorder in production.workorder_ids: for workorder in production.workorder_ids:
workorder.duration_expected = workorder._get_duration_expected() workorder.duration_expected = workorder._get_duration_expected()
@@ -520,23 +500,15 @@ class MrpProduction(models.Model):
def _reset_work_order_sequence(self): def _reset_work_order_sequence(self):
for rec in self: for rec in self:
sequence_list = {} sequence_list = {}
# 产品模型类型
model_type_id = rec.product_id.product_model_type_id model_type_id = rec.product_id.product_model_type_id
# 产品加工面板
model_processing_panel = rec.product_id.model_processing_panel
if model_type_id: if model_type_id:
if model_processing_panel:
tmpl_num = 1 tmpl_num = 1
panel_list = model_processing_panel.split(',')
for panel in panel_list:
panel_sequence_list = {}
# 成品工序 # 成品工序
product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids
if product_routing_tmpl_ids: if product_routing_tmpl_ids:
for tmpl_id in product_routing_tmpl_ids: for tmpl_id in product_routing_tmpl_ids:
panel_sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num}) sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
tmpl_num += 1 tmpl_num += 1
sequence_list.update({panel: panel_sequence_list})
# 表面工艺工序 # 表面工艺工序
# 模型类型的表面工艺工序模版 # 模型类型的表面工艺工序模版
surface_tmpl_ids = model_type_id.surface_technics_routing_tmpl_ids surface_tmpl_ids = model_type_id.surface_technics_routing_tmpl_ids
@@ -562,21 +534,12 @@ class MrpProduction(models.Model):
for tmpl_id in embryo_routing_tmpl_ids: for tmpl_id in embryo_routing_tmpl_ids:
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num}) sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
tmpl_num += 1 tmpl_num += 1
else:
raise ValidationError('该产品【加工面板】为空!')
else: else:
raise ValidationError('该产品没有选择【模版类型】!') raise ValidationError('该产品没有选择【模版类型】!')
for work in rec.workorder_ids: for work in rec.workorder_ids:
if sequence_list.get(work.name): if sequence_list.get(work.name):
work.sequence = sequence_list[work.name] work.sequence = sequence_list[work.name]
elif sequence_list.get(work.processing_panel):
processing_panel = sequence_list.get(work.processing_panel)
if processing_panel.get(work.name):
work.sequence = processing_panel[work.name]
else:
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
else: else:
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name) raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
# if work.name == '获取CNC加工程序': # if work.name == '获取CNC加工程序':
@@ -585,8 +548,8 @@ class MrpProduction(models.Model):
# work.button_finish() # work.button_finish()
# 创建工单并进行排序 # 创建工单并进行排序
def _create_workorder(self, item): def _create_workorder(self):
self._create_workorder3(item) self._create_workorder3()
self._reset_work_order_sequence() self._reset_work_order_sequence()
return True return True
@@ -630,10 +593,9 @@ class MrpProduction(models.Model):
}) })
for production in self: for production in self:
logging.info('qty_produced:%s' % production.qty_produced)
production.write({ production.write({
'date_finished': fields.Datetime.now(), 'date_finished': fields.Datetime.now(),
'product_qty': production.product_qty if production.qty_produced < 1.0 else production.qty_produced, 'product_qty': production.qty_produced,
'priority': '0', 'priority': '0',
'is_locked': True, 'is_locked': True,
'state': 'done', 'state': 'done',
@@ -659,7 +621,6 @@ class MrpProduction(models.Model):
if any(mo.show_allocation for mo in self): if any(mo.show_allocation for mo in self):
action = self.action_view_reception_report() action = self.action_view_reception_report()
return action return action
logging.info('last-product_qty:%s' % production.product_qty)
return True return True
context = self.env.context.copy() context = self.env.context.copy()
context = {k: v for k, v in context.items() if not k.startswith('default_')} context = {k: v for k, v in context.items() if not k.startswith('default_')}

View File

@@ -1,5 +1,5 @@
import re import re
import json
import logging import logging
import base64 import base64
import urllib.parse import urllib.parse
@@ -19,9 +19,7 @@ from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController
class ResMrpWorkOrder(models.Model): class ResMrpWorkOrder(models.Model):
_inherit = 'mrp.workorder' _inherit = 'mrp.workorder'
_order = 'id' _order = 'sequence asc,create_date desc'
product_tmpl_name = fields.Char('坯料产品名称', related='production_bom_id.bom_line_ids.product_id.name')
product_tmpl_id_length = fields.Float(related='production_id.product_tmpl_id.length', readonly=True, store=True, product_tmpl_id_length = fields.Float(related='production_id.product_tmpl_id.length', readonly=True, store=True,
string="坯料长度(mm)") string="坯料长度(mm)")
@@ -136,6 +134,11 @@ class ResMrpWorkOrder(models.Model):
supplier_id = fields.Many2one('res.partner', string='外协供应商') supplier_id = fields.Many2one('res.partner', string='外协供应商')
equipment_id = fields.Many2one('maintenance.equipment', string='加工设备', tracking=True) equipment_id = fields.Many2one('maintenance.equipment', string='加工设备', tracking=True)
is_ok = fields.Boolean(string='是否合格')
# 加工人
processing_user_id = fields.Many2one('res.users', string='加工人')
# 检测人
inspection_user_id = fields.Many2one('res.users', string='检测人')
# 保存名称 # 保存名称
save_name = fields.Char(string='检测文件保存名称', compute='_compute_save_name') save_name = fields.Char(string='检测文件保存名称', compute='_compute_save_name')
# 获取数据状态 # 获取数据状态
@@ -193,9 +196,8 @@ class ResMrpWorkOrder(models.Model):
production_line_id = fields.Many2one('sf.production.line', related='production_id.production_line_id', production_line_id = fields.Many2one('sf.production.line', related='production_id.production_line_id',
string='生产线', store=True, tracking=True) string='生产线', store=True, tracking=True)
production_line_state = fields.Selection( production_line_state = fields.Selection(related='production_id.production_line_state',
[('待上产线', '待上产线'), ('已上产线', '上产线'), ('已下产线', '已下产线')], string='/下产线', store=True, tracking=True)
string='上/下产线', default='待上产线', tracking=True)
detection_report = fields.Binary('检测报告', readonly=True) detection_report = fields.Binary('检测报告', readonly=True)
is_remanufacture = fields.Boolean(string='重新生成制造订单', default=False) is_remanufacture = fields.Boolean(string='重新生成制造订单', default=False)
is_fetchcnc = fields.Boolean(string='重新获取NC程序', default=False) is_fetchcnc = fields.Boolean(string='重新获取NC程序', default=False)
@@ -204,8 +206,6 @@ class ResMrpWorkOrder(models.Model):
("technology", "工艺"), ("customer redrawing", "客户改图"), ("other", "其他"), ], string="原因", tracking=True) ("technology", "工艺"), ("customer redrawing", "客户改图"), ("other", "其他"), ], string="原因", tracking=True)
detailed_reason = fields.Text('详细原因') detailed_reason = fields.Text('详细原因')
# is_send_program_again = fields.Boolean(string='是否重新下发NC程序', default=False)
@api.onchange('rfid_code') @api.onchange('rfid_code')
def _onchange(self): def _onchange(self):
if self.rfid_code and self.state == 'progress': if self.rfid_code and self.state == 'progress':
@@ -231,6 +231,16 @@ class ResMrpWorkOrder(models.Model):
ids = [t[0] for t in self.env.cr.fetchall()] ids = [t[0] for t in self.env.cr.fetchall()]
return [('id', 'in', ids)] return [('id', 'in', ids)]
@api.onchange('is_ok')
def _onchange_inspection_user_id(self):
"""
检测is_ok(是否合格)被修改的话就将当前用户赋值给inspection_user_id
"""
if not self.inspection_user_id:
self.inspection_user_id = self.env.user.id
else:
self.inspection_user_id = False
@api.onchange('functional_fixture_id') @api.onchange('functional_fixture_id')
def _onchange_functional_fixture_id(self): def _onchange_functional_fixture_id(self):
if self.functional_fixture_id: if self.functional_fixture_id:
@@ -461,7 +471,7 @@ class ResMrpWorkOrder(models.Model):
raise UserError(_("该工单暂未完成,无法进行工件配送")) raise UserError(_("该工单暂未完成,无法进行工件配送"))
# 拼接工单对象属性值 # 拼接工单对象属性值
def json_workorder_str(self, k, production, route, item): def json_workorder_str(self, k, production, route):
# 计算预计时长duration_expected # 计算预计时长duration_expected
if route.routing_type == '切割': if route.routing_type == '切割':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search( duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
@@ -494,7 +504,7 @@ class ResMrpWorkOrder(models.Model):
'processing_panel': k, 'processing_panel': k,
'quality_point_ids': route.route_workcenter_id.quality_point_ids, 'quality_point_ids': route.route_workcenter_id.quality_point_ids,
'routing_type': route.routing_type, 'routing_type': route.routing_type,
# 'work_state': '待发起', 'work_state': '待发起',
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids, 'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
route.routing_type, route.routing_type,
production.product_id), production.product_id),
@@ -503,10 +513,6 @@ class ResMrpWorkOrder(models.Model):
'date_planned_finished': datetime.now() + timedelta(days=1), 'date_planned_finished': datetime.now() + timedelta(days=1),
'duration_expected': duration_expected, 'duration_expected': duration_expected,
'duration': 0, 'duration': 0,
'cnc_ids': False if route.routing_type != 'CNC加工' else self.env['sf.cnc.processing']._json_cnc_processing(
k, item),
'cmm_ids': False if route.routing_type != 'CNC加工' else self.env['sf.cmm.program']._json_cmm_program(k,
item),
'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self._json_workpiece_delivery_list( 'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self._json_workpiece_delivery_list(
production) production)
}] }]
@@ -678,7 +684,7 @@ class ResMrpWorkOrder(models.Model):
values) values)
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values()) # self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
self.env['stock.move'].sudo().create(productions._get_moves_finished_values()) self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
productions._create_workorder() productions._create_workorder(is_fetchcnc=self.is_fetchcnc, scrap_production=self.production_id)
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \ productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
( (
p.move_dest_ids.procure_method != 'make_to_order' and p.move_dest_ids.procure_method != 'make_to_order' and
@@ -843,12 +849,12 @@ class ResMrpWorkOrder(models.Model):
limit=1, order='id asc') limit=1, order='id asc')
if not cnc_workorder.cnc_ids: if not cnc_workorder.cnc_ids:
raise UserError(_('该制造订单还未下发CNC程序请稍后再试')) raise UserError(_('该制造订单还未下发CNC程序请稍后再试'))
# else: else:
# for item in cnc_workorder.cnc_ids: for item in cnc_workorder.cnc_ids:
# functional_cutting_tool = self.env['sf.functional.cutting.tool.entity'].search( functional_cutting_tool = self.env['sf.functional.cutting.tool.entity'].search(
# [('tool_name_id.name', '=', item.cutting_tool_name)]) [('tool_name_id.name', '=', item.cutting_tool_name)])
# if not functional_cutting_tool: if not functional_cutting_tool:
# raise UserError(_('该制造订单的CNC程序为%s没有对应的功能刀具' % item.cutting_tool_name)) raise UserError(_('该制造订单的CNC程序为%s没有对应的功能刀具' % item.cutting_tool_name))
if self.routing_type == '解除装夹': if self.routing_type == '解除装夹':
''' '''
记录开始时间 记录开始时间
@@ -863,9 +869,10 @@ class ResMrpWorkOrder(models.Model):
('location_dest_id', '=', self.env['stock.location'].search( ('location_dest_id', '=', self.env['stock.location'].search(
[('barcode', 'ilike', 'VL-SPOC')]).id), [('barcode', 'ilike', 'VL-SPOC')]).id),
('origin', '=', self.production_id.name)]) ('origin', '=', self.production_id.name)])
if move_out: purchase = self.env['purchase.order'].search([('origin', '=', self.production_id.name)])
if purchase and move_out:
move_out.write({'state': 'assigned'}) move_out.write({'state': 'assigned'})
self.env['stock.move.line'].create(move_out.get_move_line(self.production_id, self)) self.env['stock.move.line'].create(move_out.get_move_line(purchase, self))
# move_out._action_assign() # move_out._action_assign()
if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress': if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress':
@@ -1002,29 +1009,22 @@ class ResMrpWorkOrder(models.Model):
for workorder in record.production_id.workorder_ids: for workorder in record.production_id.workorder_ids:
if workorder.state != 'done': if workorder.state != 'done':
is_production_id = False is_production_id = False
if record.routing_type == '解除装夹':
for workorder in record.production_id.workorder_ids:
if workorder.processing_panel == record.processing_panel:
rfid_code = workorder.rfid_code
workorder.write({'rfid_code_old': rfid_code,
'rfid_code': False})
workorder.rfid_code_old = rfid_code
workorder.rfid_code = False
if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺']: if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺']:
logging.info('product_qty:%s' % record.production_id.product_qty) for workorder in record.production_id.workorder_ids:
workorder.rfid_code_old = workorder.rfid_code
workorder.rfid_code = None
for move_raw_id in record.production_id.move_raw_ids: for move_raw_id in record.production_id.move_raw_ids:
move_raw_id.quantity_done = move_raw_id.product_uom_qty move_raw_id.quantity_done = move_raw_id.product_uom_qty
record.process_state = '已完工' record.process_state = '已完工'
record.production_id.process_state = '已完工' record.production_id.process_state = '已完工'
if record.routing_type in ['解除装夹', '表面工艺']: if record.routing_type in ['表面工艺']:
raw_move = self.env['stock.move'].sudo().search( raw_move = self.env['stock.move'].sudo().search(
[('origin', '=', record.production_id.name), [('origin', '=', record.production_id.name), ('procure_method', '=', 'make_to_order'),
('procure_method', 'in', ['make_to_order', 'make_to_stock']),
('state', '!=', 'done')]) ('state', '!=', 'done')])
if raw_move: if raw_move:
raw_move.write({'state': 'done'}) raw_move.write({'state': 'done'})
record.production_id.button_mark_done1() record.production_id.button_mark_done1()
# record.production_id.state = 'done' # self.production_id.state = 'done'
# 将FTP的检测报告文件下载到临时目录 # 将FTP的检测报告文件下载到临时目录
def download_reportfile_tmp(self, workorder, reportpath): def download_reportfile_tmp(self, workorder, reportpath):
@@ -1066,32 +1066,6 @@ class ResMrpWorkOrder(models.Model):
workorder.detection_report = base64.b64encode(open(report_file_path, 'rb').read()) workorder.detection_report = base64.b64encode(open(report_file_path, 'rb').read())
return True return True
# 重新下发nc程序
# def button_send_program_again(self):
# try:
# res = {'programming_no': self.production_id.programming_no}
# configsettings = self.env['res.config.settings'].get_values()
# config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
# url = '/api/intelligent_programming/reset_state_again'
# config_url = configsettings['sf_url'] + url
# r = requests.post(config_url, json=res, data=None, headers=config_header)
# r = r.json()
# result = json.loads(r['result'])
# if result['status'] == 1:
# productions = self.env['mrp.production'].search(
# [('programming_no', '=', self.production_id.programming_no), ('programming_state', '=', '已编程')])
# if productions:
# workorder = productions.workorder_ids.filtered(
# lambda ap: ap.routing_type in ['装夹预调', 'CNC加工'] and ap.state not in ['done', 'cancel',
# 'progress'])
# if workorder:
# productions.write({'work_state': '编程中', 'programming_state': '编程中'})
# else:
# raise UserError(result['message'])
# except Exception as e:
# logging.info('button_send_program_again error:%s' % e)
# raise UserError("重新下发nc程序失败,请联系管理员")
class CNCprocessing(models.Model): class CNCprocessing(models.Model):
_name = 'sf.cnc.processing' _name = 'sf.cnc.processing'
@@ -1117,7 +1091,6 @@ class CNCprocessing(models.Model):
production_id = fields.Many2one('mrp.production', string="制造订单") production_id = fields.Many2one('mrp.production', string="制造订单")
button_state = fields.Boolean(string='是否已经下发') button_state = fields.Boolean(string='是否已经下发')
program_path = fields.Char('程序文件路径') program_path = fields.Char('程序文件路径')
program_create_date = fields.Datetime('程序创建日期')
# mrs下发编程单创建CNC加工 # mrs下发编程单创建CNC加工
def cnc_processing_create(self, cnc_workorder, ret, program_path, program_path_tmp): def cnc_processing_create(self, cnc_workorder, ret, program_path, program_path_tmp):
@@ -1150,27 +1123,24 @@ class CNCprocessing(models.Model):
cnc_workorder.write({'programming_state': '已编程', 'work_state': '已编程'}) cnc_workorder.write({'programming_state': '已编程', 'work_state': '已编程'})
return cnc_processing return cnc_processing
def _json_cnc_processing(self, panel, ret): def _json_cnc_processing(self, obj):
cnc_processing = [] cnc_processing_str = (0, 0, {
for item in ret['programming_list']: 'sequence_number': obj['sequence_number'],
if item['processing_panel'] == panel and item['ftp_path'].find('.dmi') == -1: 'program_name': obj['program_name'],
cnc_processing.append((0, 0, { 'cutting_tool_name': obj['cutting_tool_name'],
'sequence_number': item['sequence_number'], 'cutting_tool_no': obj['cutting_tool_no'],
'program_name': item['program_name'], 'processing_type': obj['processing_type'],
'cutting_tool_name': item['cutting_tool_name'], 'margin_x_y': obj['margin_x_y'],
'cutting_tool_no': item['cutting_tool_no'], 'margin_z': obj['margin_z'],
'processing_type': item['processing_type'], 'depth_of_processing_z': obj['depth_of_processing_z'],
'margin_x_y': item['margin_x_y'], 'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
'margin_z': item['margin_z'], 'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
'depth_of_processing_z': item['depth_of_processing_z'], 'estimated_processing_time': obj['estimated_processing_time'],
'cutting_tool_extension_length': item['cutting_tool_extension_length'], 'program_path': obj['program_path'],
'cutting_tool_handle_type': item['cutting_tool_handle_type'], 'cnc_id': obj['cnc_id'].id,
'estimated_processing_time': item['estimated_processing_time'], 'remark': obj['remark']
'program_path': item['ftp_path'], })
'program_create_date': datetime.strptime(item['program_create_date'], '%Y-%m-%d %H:%M:%S'), return cnc_processing_str
'remark': item['remark']
}))
return cnc_processing
# 根据程序名和加工面匹配到ftp里对应的Nc程序名,可优化为根据cnc_processing.program_path进行匹配 # 根据程序名和加工面匹配到ftp里对应的Nc程序名,可优化为根据cnc_processing.program_path进行匹配
def get_cnc_processing_file(self, serverdir, cnc_processing, program_path): def get_cnc_processing_file(self, serverdir, cnc_processing, program_path):
@@ -1200,16 +1170,14 @@ class CNCprocessing(models.Model):
}) })
return attachment return attachment
# 将FTP的多面的程序单文件下载到临时目录 # 将FTP的nc文件下载到临时目录
def download_file_tmp(self, production_no, processing_panel): def download_file_tmp(self, production_no, processing_panel):
remotepath = os.path.join('/home/ftp/ftp_root/NC', production_no, 'return', processing_panel) remotepath = os.path.join('/NC', production_no, 'return', processing_panel)
serverdir = os.path.join('/tmp', production_no, 'return', processing_panel) serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
ftp_resconfig = self.env['res.config.settings'].get_values() ftp_resconfig = self.env['res.config.settings'].get_values()
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'], ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
ftp_resconfig['ftp_password']) ftp_resconfig['ftp_password'])
if not ftp.file_exists_1(remotepath): download_state = ftp.download_file_tree(remotepath, serverdir)
logging.info('目录不存在:%s' % remotepath)
download_state = ftp.download_program_file(remotepath, serverdir)
logging.info('download_state:%s' % download_state) logging.info('download_state:%s' % download_state)
return download_state return download_state
@@ -1254,7 +1222,6 @@ class SfWorkOrderBarcodes(models.Model):
_inherit = ["mrp.workorder", "barcodes.barcode_events_mixin"] _inherit = ["mrp.workorder", "barcodes.barcode_events_mixin"]
def on_barcode_scanned(self, barcode): def on_barcode_scanned(self, barcode):
logging.info('Rfid:%s' % barcode)
workorder = self.env['mrp.workorder'].browse(self.ids) workorder = self.env['mrp.workorder'].browse(self.ids)
# workorder_preset = self.env['mrp.workorder'].search( # workorder_preset = self.env['mrp.workorder'].search(
# [('routing_type', '=', '装夹预调'), ('rfid_code', '=', barcode)]) # [('routing_type', '=', '装夹预调'), ('rfid_code', '=', barcode)])
@@ -1287,18 +1254,17 @@ class SfWorkOrderBarcodes(models.Model):
workorder.write(val) workorder.write(val)
self.write(val) self.write(val)
workorder_rfid = self.env['mrp.workorder'].search( workorder_rfid = self.env['mrp.workorder'].search(
[('production_id', '=', workorder.production_id.id), [('production_id', '=', workorder.production_id.id)])
('processing_panel', '=', workorder.processing_panel)])
if workorder_rfid: if workorder_rfid:
for item in workorder_rfid: for item in workorder_rfid:
item.write({'rfid_code': barcode}) item.write({'rfid_code': barcode})
logging.info("Rfid[%s]绑定成功!!!" % barcode) logging.info("Rfid绑定成功")
else: else:
raise UserError('该Rfid【%s】绑定的是【%s】, 不是托盘!!!' % (barcode, lot.product_id.name)) raise UserError('该Rfid【%s】绑定的是【%s】, 不是托盘!!!' % (barcode, lot.product_id.name))
self.process_state = '待检测' self.process_state = '待检测'
self.date_start = datetime.now() self.date_start = datetime.now()
else: else:
raise UserError('没有找到Rfid为【%s】的托盘信息!!!' % barcode) raise UserError('托盘信息不存在')
# stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)]) # stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)])
# if stock_move_line.product_id.categ_type == '夹具': # if stock_move_line.product_id.categ_type == '夹具':
# workorder.write({ # workorder.write({
@@ -1615,22 +1581,80 @@ class CMMprogram(models.Model):
_name = 'sf.cmm.program' _name = 'sf.cmm.program'
_description = "CMM程序" _description = "CMM程序"
cmm_id = fields.Many2one('ir.attachment')
sequence_number = fields.Integer('序号') sequence_number = fields.Integer('序号')
program_name = fields.Char('程序名') program_name = fields.Char('程序名')
cutting_tool_name = fields.Char('刀具名称')
cutting_tool_no = fields.Char('刀号')
processing_type = fields.Char('加工类型')
margin_x_y = fields.Char('余量_X/Y')
margin_z = fields.Char('余量_Z')
depth_of_processing_z = fields.Char('加工深度(Z)')
cutting_tool_extension_length = fields.Char('刀具伸出长度')
cutting_tool_handle_type = fields.Char('刀柄型号')
estimated_processing_time = fields.Char('预计加工时间')
remark = fields.Text('备注') remark = fields.Text('备注')
workorder_id = fields.Many2one('mrp.workorder', string="工单") workorder_id = fields.Many2one('mrp.workorder', string="工单")
production_id = fields.Many2one('mrp.production', string="制造订单") production_id = fields.Many2one('mrp.production', string="制造订单")
program_path = fields.Char('程序文件路径') program_path = fields.Char('程序文件路径')
program_create_date = fields.Datetime('程序创建日期')
def _json_cmm_program(self, panel, ret): def cmm_program_create(self, ret, program_path, program_path_tmp):
cmm_program = [] cmm_program = None
for item in ret['programming_list']: for obj in ret['programming_list']:
if item['processing_panel'] == panel and item['ftp_path'].find('.dmi') != -1: workorder = self.env['mrp.workorder'].search(
cmm_program.append((0, 0, { [('production_id.name', '=', ret['production_order_no'].split(',')[0]),
'sequence_number': 1, ('processing_panel', '=', obj['processing_panel']),
'program_name': item['program_name'], ('routing_type', '=', 'CNC加工')])
'program_path': item['ftp_path'], if obj['program_name'] in program_path:
'program_create_date': datetime.strptime(item['program_create_date'], '%Y-%m-%d %H:%M:%S'), logging.info('obj:%s' % obj['program_name'])
})) cmm_program = self.sudo().create({
'workorder_id': workorder.id,
'sequence_number': obj['sequence_number'],
'program_name': obj['program_name'],
'cutting_tool_name': obj['cutting_tool_name'],
'cutting_tool_no': obj['cutting_tool_no'],
'processing_type': obj['processing_type'],
'margin_x_y': obj['margin_x_y'],
'margin_z': obj['margin_z'],
'depth_of_processing_z': obj['depth_of_processing_z'],
'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
'estimated_processing_time': obj['estimated_processing_time'],
'remark': obj['remark'],
'program_path': program_path.replace('/tmp', '')
})
cmm_program.get_cmm_program_file(program_path_tmp, cmm_program, program_path)
return cmm_program return cmm_program
# 根据程序名和加工面匹配到ftp里对应的cmm程序名
def get_cmm_program_file(self, serverdir, cmm_program, program_path):
logging.info('cmm-serverdir:%s' % serverdir)
for root, dirs, files in os.walk(serverdir):
for f in files:
if f in program_path:
cmm_program_file_path = os.path.join(serverdir, root, f)
self.write_file_cmm(cmm_program_file_path, cmm_program)
# 创建附件(nc文件)
def attachment_create(self, name, data):
attachment = self.env['ir.attachment'].create({
'datas': base64.b64encode(data),
'type': 'binary',
'public': True,
'description': '程序文件',
'name': name
})
return attachment
# 将cmm文件存到attach的datas里
def write_file_cmm(self, cmm_file_path, cnc):
cmm_file_name = cmm_file_path.split('/')
logging.info('cmm_file_name:%s' % cmm_file_name[-1])
if os.path.exists(cmm_file_path):
with open(cmm_file_path, 'rb') as file:
data_bytes = file.read()
attachment = self.attachment_create(cnc.program_name + cmm_file_name[-1], data_bytes)
cnc.write({'cmm_id': attachment.id})
file.close()
else:
return False

View File

@@ -616,7 +616,7 @@ class ResProductMo(models.Model):
item['model_width'] + model_type.embryo_tolerance) * ( item['model_width'] + model_type.embryo_tolerance) * (
item['model_height'] + model_type.embryo_tolerance), item['model_height'] + model_type.embryo_tolerance),
'product_model_type_id': model_type.id, 'product_model_type_id': model_type.id,
# 'model_processing_panel': 'R', 'model_processing_panel': 'R',
'model_machining_precision': item['model_machining_precision'], 'model_machining_precision': item['model_machining_precision'],
'model_code': item['barcode'], 'model_code': item['barcode'],
'length': item['model_long'], 'length': item['model_long'],
@@ -634,10 +634,9 @@ class ResProductMo(models.Model):
'model_process_parameters_ids': [(6, 0, [])] if not item.get( 'model_process_parameters_ids': [(6, 0, [])] if not item.get(
'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']), 'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']),
'model_remark': item['remark'], 'model_remark': item['remark'],
'single_manufacturing': True,
'default_code': '%s-%s' % (order_number, i), 'default_code': '%s-%s' % (order_number, i),
'manual_quotation': item['manual_quotation'] or False, 'manual_quotation': item['manual_quotation'] or False,
'part_number': item.get('part_number') or '', 'part_number': item['part_number'] or '',
'active': True, 'active': True,
} }
copy_product_id.sudo().write(vals) copy_product_id.sudo().write(vals)

View File

@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import base64 import base64
import qrcode import qrcode
from itertools import groupby
from collections import defaultdict, namedtuple from collections import defaultdict, namedtuple
import logging import logging
import io import io
@@ -204,18 +203,64 @@ class StockRule(models.Model):
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create( productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
productions_values) productions_values)
self.env['stock.move'].sudo().create(productions._get_moves_raw_values()) # self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
''' '''
创建工单 创建工单
''' '''
# productions._create_workorder() productions._create_workorder(is_fetchcnc=False, scrap_production=False)
#
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \ productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
( (
p.move_dest_ids.procure_method != 'make_to_order' and not p.move_dest_ids.procure_method != 'make_to_order' and not
p.move_raw_ids and not p.workorder_ids)).action_confirm() p.move_raw_ids and not p.workorder_ids)).action_confirm()
for production_item in productions:
process_parameter_workorder = self.env['mrp.workorder'].search(
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production_item.id),
('is_subcontract', '=', True)])
if process_parameter_workorder:
is_pick = False
consecutive_workorders = []
m = 0
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
for i in range(len(sorted_workorders) - 1):
if m == 0:
is_pick = False
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
if sorted_workorders[i] not in consecutive_workorders:
consecutive_workorders.append(sorted_workorders[i])
consecutive_workorders.append(sorted_workorders[i + 1])
m += 1
continue
else:
if m == len(consecutive_workorders) - 1 and m != 0:
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
production_item)
if sorted_workorders[i] in consecutive_workorders:
is_pick = True
consecutive_workorders = []
m = 0
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
if is_pick is False:
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
production_item)
if m == len(consecutive_workorders) - 1 and m != 0:
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
production_item)
if sorted_workorders[i] in consecutive_workorders:
is_pick = True
consecutive_workorders = []
m = 0
if m == len(consecutive_workorders) - 1 and m != 0:
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production_item)
if is_pick is False and m == 0:
if len(sorted_workorders) == 1:
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production_item)
else:
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production_item)
for production in productions: for production in productions:
''' '''
创建制造订单时生成序列号 创建制造订单时生成序列号
@@ -261,29 +306,6 @@ class StockRule(models.Model):
'product_id': production.product_id.id, 'product_id': production.product_id.id,
'state': 'draft', 'state': 'draft',
}) })
all_production = productions
grouped_product_ids = {k: list(g) for k, g in groupby(all_production, key=lambda x: x.product_id.id)}
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
product_id_to_production_names = {}
# 对于每个product_id获取其所有生产订单的名称
for product_id, all_production in grouped_product_ids.items():
# 为同一个product_id创建一个生产订单名称列表
product_id_to_production_names[product_id] = [production.name for production in all_production]
for production_item in productions:
if production_item.product_id.id in product_id_to_production_names:
# # 同一个产品多个制造订单对应一个编程单和模型库
# # 只调用一次fetchCNC并将所有生产订单的名称作为字符串传递
if not production_item.programming_no:
production_programming = self.env['mrp.production'].search(
[('product_id.id', '=', production_item.product_id.id),
('origin', '=', production_item.origin)],
limit=1, order='id asc')
if not production_programming.programming_no:
production_item.fetchCNC(
', '.join(product_id_to_production_names[production_item.product_id.id]))
else:
production_item.write({'programming_no': production_programming.programming_no,
'programming_state': '编程中'})
return True return True
@@ -487,10 +509,10 @@ class StockPicking(models.Model):
('location_dest_id', '=', self.env['stock.location'].search( ('location_dest_id', '=', self.env['stock.location'].search(
[('barcode', 'ilike', 'VL-SPOC')]).id), [('barcode', 'ilike', 'VL-SPOC')]).id),
('origin', '=', self.origin)]) ('origin', '=', self.origin)])
# if self.id == move_out.picking_id.id: if self.id == move_out.picking_id.id:
# if move_out.move_line_ids.workorder_id.state not in ['progress']: if move_out.move_line_ids.workorder_id.state not in ['progress']:
# raise UserError( raise UserError(
# _('该出库单里源单据内的单号为%s的工单还未开始,不能进行验证操作!' % move_out.move_line_ids.workorder_id.name)) _('该出库单里源单据内的单号为%s的工单还未开始,不能进行验证操作!' % move_out.move_line_ids.workorder_id.name))
# 入库单验证 # 入库单验证
move_in = self.env['stock.move'].search( move_in = self.env['stock.move'].search(
[('location_dest_id', '=', self.env['stock.location'].search( [('location_dest_id', '=', self.env['stock.location'].search(
@@ -506,17 +528,18 @@ class StockPicking(models.Model):
res = super().button_validate() res = super().button_validate()
if res is True: if res is True:
if self.id == move_out.picking_id.id: if self.id == move_out.picking_id.id:
# if move_out.move_line_ids.workorder_id.state == 'progress': if move_out.move_line_ids.workorder_id.state == 'progress':
move_in = self.env['stock.move'].search( move_in = self.env['stock.move'].search(
[('location_dest_id', '=', self.env['stock.location'].search( [('location_dest_id', '=', self.env['stock.location'].search(
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id), [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
('location_id', '=', self.env['stock.location'].search( ('location_id', '=', self.env['stock.location'].search(
[('barcode', 'ilike', 'VL-SPOC')]).id), [('barcode', 'ilike', 'VL-SPOC')]).id),
('origin', '=', self.origin)]) ('origin', '=', self.origin)])
production = self.env['mrp.production'].search([('name', '=', self.origin)]) # purchase = self.env['purchase.order'].search([('origin', '=', self.origin)])
if move_in: if move_in:
move_in.write({'state': 'assigned'}) move_in.write({'state': 'assigned'})
self.env['stock.move.line'].create(move_in.get_move_line(production, None)) purchase = self.env['purchase.order'].search([('origin', '=', self.origin)])
self.env['stock.move.line'].create(move_in.get_move_line(purchase, None))
return res return res
@@ -598,7 +621,7 @@ class ReStockMove(models.Model):
'state': 'confirmed', 'state': 'confirmed',
} }
def get_move_line(self, production_id, sorted_workorders): def get_move_line(self, purchase, sorted_workorders):
return { return {
'move_id': self.id, 'move_id': self.id,
'product_id': self.product_id.id, 'product_id': self.product_id.id,
@@ -607,7 +630,7 @@ class ReStockMove(models.Model):
'location_dest_id': self.picking_id.location_dest_id.id, 'location_dest_id': self.picking_id.location_dest_id.id,
'picking_id': self.picking_id.id, 'picking_id': self.picking_id.id,
'reserved_uom_qty': 1.0, 'reserved_uom_qty': 1.0,
'lot_id': production_id.move_line_raw_ids.lot_id.id, 'lot_id': purchase.picking_ids.move_line_ids.lot_id.id,
'company_id': self.company_id.id, 'company_id': self.company_id.id,
# 'workorder_id': '' if not sorted_workorders else sorted_workorders.id, # 'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
# 'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id, # 'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,
@@ -678,36 +701,13 @@ class ReStockMove(models.Model):
), ),
} }
def put_move_line(self):
"""
确认订单时,自动分配序列号
"""
if self.product_id.tracking == "serial":
if self.product_id.categ_id.name == '刀具':
self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
else:
self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
self._generate_serial_numbers()
for item in self.move_line_nosuggest_ids:
if item.lot_name:
lot_name = item.lot_name
if item.product_id.categ_id.name == '坯料':
lot_name = lot_name.split('[', 1)[0]
item.lot_qr_code = self.compute_lot_qr_code(lot_name)
def _put_tool_lot(self, company, product, origin): def _put_tool_lot(self, company, product, origin):
if product.tracking == "lot" and self.product_id.categ_id.name == '刀具': if product.tracking == "lot" and self.product_id.categ_id.name == '刀具':
if not self.move_line_nosuggest_ids: if not self.move_line_nosuggest_ids:
lot_code = '%s-%s-%s' % ('%s-T-DJWL-%s' % ( lot_names = self.env['stock.lot'].generate_lot_names(
'%s-%s-%s' % ('%s-T-DJWL-%s' % (
product.cutting_tool_model_id.code.split('-')[0], product.cutting_tool_material_id.code), product.cutting_tool_model_id.code.split('-')[0], product.cutting_tool_material_id.code),
datetime.now().strftime("%Y%m%d"), origin) datetime.now().strftime("%Y%m%d"), origin), 1)
move_line_ids = self.env['stock.move.line'].sudo().search([('lot_name', 'like', lot_code)], limit=1,
order='id desc')
if not move_line_ids:
lot_code = '%s-001' % lot_code
else:
lot_code = '%s-%03d' % (lot_code, int(move_line_ids.lot_name[-3:]) + 1)
lot_names = self.env['stock.lot'].generate_lot_names(lot_code, 1)
move_lines_commands = self._generate_serial_move_line_commands_tool_lot(lot_names) move_lines_commands = self._generate_serial_move_line_commands_tool_lot(lot_names)
self.write({'move_line_nosuggest_ids': move_lines_commands}) self.write({'move_line_nosuggest_ids': move_lines_commands})
for item in self.move_line_nosuggest_ids: for item in self.move_line_nosuggest_ids:

View File

@@ -1,9 +1,8 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sf_cnc_processing_group_sf_mrp_user,sf_cnc_processing,model_sf_cnc_processing,sf_base.group_sf_mrp_user,1,0,0,0 access_sf_cnc_processing_group_sf_mrp_user,sf_cnc_processing,model_sf_cnc_processing,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_cnc_processing_manager,sf_cnc_processing,model_sf_cnc_processing,sf_base.group_sf_mrp_manager,1,1,1,0 access_sf_cnc_processing_manager,sf_cnc_processing,model_sf_cnc_processing,sf_base.group_sf_mrp_manager,1,1,1,0
access_sf_cmm_program_group_sf_mrp_user,sf_cmm_program_group_sf_mrp_user,model_sf_cmm_program,sf_base.group_sf_mrp_user,1,0,0,0 access_sf_cmm_program_group_sf_mrp_user_group_sf_mrp_user,sf_cmm_program_group_sf_mrp_user,model_sf_cmm_program,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_cmm_program_group_sf_mrp_manager,sf_cmm_program_group_sf_mrp_manager,model_sf_cmm_program,sf_base.group_sf_mrp_manager,1,0,0,0 access_sf_cmm_program_group_sf_mrp_manager,sf_cmm_program_group_sf_mrp_manager,model_sf_cmm_program,sf_base.group_sf_mrp_manager,1,0,0,0
access_sf_cmm_program_admin,sf_cmm_program_admin,model_sf_cmm_program,base.group_system,1,1,1,1
access_sf_model_type_group_sf_mrp_user,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_user,1,0,0,0 access_sf_model_type_group_sf_mrp_user,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_model_type_admin,sf_model_type_admin,model_sf_model_type,base.group_system,1,1,1,0 access_sf_model_type_admin,sf_model_type_admin,model_sf_model_type,base.group_system,1,1,1,0
access_sf_model_type_manager,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_manager,1,1,1,0 access_sf_model_type_manager,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_manager,1,1,1,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_sf_cnc_processing_group_sf_mrp_user sf_cnc_processing model_sf_cnc_processing sf_base.group_sf_mrp_user 1 0 0 0
3 access_sf_cnc_processing_manager sf_cnc_processing model_sf_cnc_processing sf_base.group_sf_mrp_manager 1 1 1 0
4 access_sf_cmm_program_group_sf_mrp_user access_sf_cmm_program_group_sf_mrp_user_group_sf_mrp_user sf_cmm_program_group_sf_mrp_user model_sf_cmm_program sf_base.group_sf_mrp_user 1 0 0 0
5 access_sf_cmm_program_group_sf_mrp_manager sf_cmm_program_group_sf_mrp_manager model_sf_cmm_program sf_base.group_sf_mrp_manager 1 0 0 0
access_sf_cmm_program_admin sf_cmm_program_admin model_sf_cmm_program base.group_system 1 1 1 1
6 access_sf_model_type_group_sf_mrp_user sf_model_type model_sf_model_type sf_base.group_sf_mrp_user 1 0 0 0
7 access_sf_model_type_admin sf_model_type_admin model_sf_model_type base.group_system 1 1 1 0
8 access_sf_model_type_manager sf_model_type model_sf_model_type sf_base.group_sf_mrp_manager 1 1 1 0

View File

@@ -64,10 +64,10 @@
<xpath expr="//field[@name='state']" position="attributes"> <xpath expr="//field[@name='state']" position="attributes">
<!-- <attribute name="statusbar_visible">draft,confirmed,progress,pending_processing,completed,done --> <!-- <attribute name="statusbar_visible">draft,confirmed,progress,pending_processing,completed,done -->
<!-- </attribute> --> <!-- </attribute> -->
<attribute name="statusbar_visible"> <attribute name="statusbar_visible">progress,pending_cam,pending_processing,pending_era_cam,completed,done
confirmed,pending_cam,progress,done
</attribute> </attribute>
</xpath> </xpath>
<xpath expr="//sheet//group//group[2]//label" position="before"> <xpath expr="//sheet//group//group[2]//label" position="before">
<!-- <field name="process_state"/> --> <!-- <field name="process_state"/> -->
<field name="state"/> <field name="state"/>
@@ -75,19 +75,18 @@
</xpath> </xpath>
<xpath expr="//sheet//group//group//div[3]" position="after"> <xpath expr="//sheet//group//group//div[3]" position="after">
<field name="manual_quotation" readonly="1"/>
<field name="programming_no" readonly="1"/> <field name="programming_no" readonly="1"/>
<field name="programming_state" readonly="1" decoration-success="programming_state == '已编程'"
decoration-warning="programming_state =='编程中'"/>
<field name="work_state" invisible="1"/> <field name="work_state" invisible="1"/>
<field name="schedule_state" invisible='1'/> <field name="schedule_state" invisible='1'/>
<field name="manual_quotation" readonly="1"/>
<field name="programming_state" readonly="1"/>
</xpath> </xpath>
<xpath expr="//field[@name='user_id']" position="before"> <xpath expr="//field[@name='user_id']" position="before">
<field name="plan_start_processing_time" readonly="1"/> <field name="plan_start_processing_time" readonly="1"/>
</xpath> </xpath>
<xpath expr="//field[@name='user_id']" position="after"> <xpath expr="//field[@name='user_id']" position="after">
<field name="production_line_id" readonly="1"/> <field name="production_line_id" readonly="1"/>
<!-- <field name="production_line_state" readonly="1"/>--> <field name="production_line_state" readonly="1"/>
<field name="part_number" string="成品的零件图号"/> <field name="part_number" string="成品的零件图号"/>
<field name="part_drawing"/> <field name="part_drawing"/>
</xpath> </xpath>
@@ -255,9 +254,7 @@
</xpath> </xpath>
<xpath expr="//sheet//notebook//page[@name='operations']" position="attributes"> <xpath expr="//sheet//notebook//page[@name='operations']" position="attributes">
<attribute name="attrs">{'invisible': ['|',('schedule_state', '=', '未排'),('workorder_ids', '=', <attribute name="attrs">{'invisible': [('schedule_state', '=', '未排')]}</attribute>
[])]}
</attribute>
</xpath> </xpath>
</field> </field>
</record> </record>
@@ -282,10 +279,8 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//tree//button[@name='button_start']" position="replace"> <xpath expr="//tree//button[@name='button_start']" position="replace">
<field name="routing_type" invisible="True"/> <field name="routing_type" invisible="True"/>
<button name="button_start" type="object" string="开始" class="btn-success" confirm="是否确认开始?" <button name="button_start" type="object" string="开始" class="btn-success"
attrs="{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done', 'cancel')), attrs="{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False), ('routing_type', '=', 'CNC加工')]}"
('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=',
False), ('routing_type', '=', 'CNC加工')]}"
groups="sf_base.group_sf_mrp_user"/> groups="sf_base.group_sf_mrp_user"/>
</xpath> </xpath>
<xpath expr="//tree//button[@name='button_pending']" position="replace"> <xpath expr="//tree//button[@name='button_pending']" position="replace">
@@ -296,8 +291,7 @@
<xpath expr="//tree//button[@name='button_finish']" position="replace"> <xpath expr="//tree//button[@name='button_finish']" position="replace">
<button name="button_finish" type="object" string="Done" class="btn-success" <button name="button_finish" type="object" string="Done" class="btn-success"
attrs="{'invisible': ['|', '|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False), ('routing_type', '=', 'CNC加工')]}" attrs="{'invisible': ['|', '|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False), ('routing_type', '=', 'CNC加工')]}"
groups="sf_base.group_sf_mrp_user" groups="sf_base.group_sf_mrp_user"/>
confirm="是否确认完成?"/>
</xpath> </xpath>
<xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace"> <xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace">
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="Block" <button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="Block"
@@ -328,7 +322,7 @@
<xpath expr="//tree//button[@name='button_finish']" position="replace"> <xpath expr="//tree//button[@name='button_finish']" position="replace">
<button name="button_finish" type="object" string="完成" class="btn-success" <button name="button_finish" type="object" string="完成" class="btn-success"
attrs="{'invisible': ['|', '|','|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False), ('routing_type', '=', 'CNC加工')]}" attrs="{'invisible': ['|', '|','|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False), ('routing_type', '=', 'CNC加工')]}"
groups="sf_base.group_sf_mrp_user" confirm="是否确认完成?"/> groups="sf_base.group_sf_mrp_user"/>
</xpath> </xpath>
<xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace"> <xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace">
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="阻塞" <button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="阻塞"

View File

@@ -11,7 +11,7 @@
<field name="name" decoration-success="is_subcontract" decoration-bf="is_subcontract"/> <field name="name" decoration-success="is_subcontract" decoration-bf="is_subcontract"/>
</field> </field>
<field name="name" position="before"> <field name="name" position="before">
<field name="sequence" optional="hide"/> <field name="sequence"/>
<field name='user_permissions' invisible="1"/> <field name='user_permissions' invisible="1"/>
</field> </field>
<field name="name" position="after"> <field name="name" position="after">
@@ -19,13 +19,6 @@
</field> </field>
<field name="state" position="after"> <field name="state" position="after">
<field name="work_state" optional="hide"/> <field name="work_state" optional="hide"/>
<field name="product_tmpl_name" invisible="1"/>
</field>
<field name="duration" position="replace">
<field name="duration" optional="hide"/>
</field>
<field name="workcenter_id" position="replace">
<field name="workcenter_id" optional="hide"/>
</field> </field>
<field name="product_id" position="after"> <field name="product_id" position="after">
<field name="equipment_id" optional="hide"/> <field name="equipment_id" optional="hide"/>
@@ -37,7 +30,7 @@
<field name="date_planned_start" string="计划开始日期" optional="show"/> <field name="date_planned_start" string="计划开始日期" optional="show"/>
</xpath> </xpath>
<xpath expr="//field[@name='date_planned_finished']" position="replace"> <xpath expr="//field[@name='date_planned_finished']" position="replace">
<field name="date_planned_finished" string="计划结束日期" optional="hide"/> <field name="date_planned_finished" string="计划结束日期" optional="show"/>
</xpath> </xpath>
<xpath expr="//button[@name='button_start']" position="attributes"> <xpath expr="//button[@name='button_start']" position="attributes">
<attribute name="attrs">{'invisible': ['|', '|', '|','|','|', ('production_state','in', ('draft', <attribute name="attrs">{'invisible': ['|', '|', '|','|','|', ('production_state','in', ('draft',
@@ -91,7 +84,7 @@
<!-- <field name="target">fullscreen</field>--> <!-- <field name="target">fullscreen</field>-->
<field name="target">current</field> <field name="target">current</field>
<field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field> <field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field>
<field name="context">{'search_default_product': 1, 'search_default_workcenter_id': active_id}</field> <field name="context">{'search_default_workcenter_id': active_id}</field>
<field name="help" type="html"> <field name="help" type="html">
<p class="o_view_nocontent_workorder"> <p class="o_view_nocontent_workorder">
没有工单要做! 没有工单要做!
@@ -124,7 +117,6 @@
<field name='user_permissions' invisible="1"/> <field name='user_permissions' invisible="1"/>
<field name='name' invisible="1"/> <field name='name' invisible="1"/>
<field name='is_delivery' invisible="1"/> <field name='is_delivery' invisible="1"/>
<!-- <field name='is_send_program_again' invisible="1"/>-->
<!-- 工单form页面的开始停工按钮等 --> <!-- 工单form页面的开始停工按钮等 -->
<!-- <button name="button_start" type="object" string="开始" class="btn-success" --> <!-- <button name="button_start" type="object" string="开始" class="btn-success" -->
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'not in', ('pending_processing', 'pending_cam', 'pending_era_cam')), ('state','!=','ready'), ('routing_type', 'not in', ('装夹预调', 'CNC加工', '解除装夹'))]}" --> <!-- attrs="{'invisible': ['|', '|', ('production_state', 'not in', ('pending_processing', 'pending_cam', 'pending_era_cam')), ('state','!=','ready'), ('routing_type', 'not in', ('装夹预调', 'CNC加工', '解除装夹'))]}" -->
@@ -136,7 +128,7 @@
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'not in', ('pending_processing', 'pending_cam', 'pending_era_cam')), ('state','!=','progress'), ('routing_type', 'not in', ('装夹预调', 'CNC加工', '解除装夹'))]}" --> <!-- attrs="{'invisible': ['|', '|', ('production_state', 'not in', ('pending_processing', 'pending_cam', 'pending_era_cam')), ('state','!=','progress'), ('routing_type', 'not in', ('装夹预调', 'CNC加工', '解除装夹'))]}" -->
<!-- groups="sf_base.group_sf_mrp_user" confirm="是否确认完工"/> --> <!-- groups="sf_base.group_sf_mrp_user" confirm="是否确认完工"/> -->
<button name="button_start" type="object" string="开始" class="btn-success" confirm="是否确认开始" <button name="button_start" type="object" string="开始" class="btn-success"
attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False)]}"/> attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False)]}"/>
<button name="button_pending" type="object" string="暂停" class="btn-warning" <button name="button_pending" type="object" string="暂停" class="btn-warning"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/> attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
@@ -159,12 +151,7 @@
<!-- groups="sf_base.group_sf_mrp_user" --> <!-- groups="sf_base.group_sf_mrp_user" -->
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('state','=','done')]}"/> --> <!-- attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('state','=','done')]}"/> -->
<button name="button_workpiece_delivery" type="object" string="工件配送" class="btn-primary" <button name="button_workpiece_delivery" type="object" string="工件配送" class="btn-primary"
attrs="{'invisible': ['|','|',('routing_type','!=','装夹预调'),('is_delivery','=',True),('state','!=','done')]}"/> attrs="{'invisible': ['|',('routing_type','!=','装夹预调'),('is_delivery','=',True)]}"/>
<!-- <button name="button_send_program_again" type="object" string="重新下发NC程序" class="btn-primary"-->
<!-- confirm="是否确认重新下发NC程序"-->
<!-- groups="sf_base.group_sf_order_user,sf_base.group_sf_equipment_user"-->
<!-- attrs="{'invisible': ['|', '|', '|',('routing_type','!=','装夹预调'),('state','in',['done', 'cancel',-->
<!-- 'progress']),('cnc_worksheet','=',False),('is_send_program_again','=',True)]}"/>-->
</xpath> </xpath>
<xpath expr="//page[1]" position="before"> <xpath expr="//page[1]" position="before">
<page string="开料要求" attrs='{"invisible": [("routing_type","!=","切割")]}'> <page string="开料要求" attrs='{"invisible": [("routing_type","!=","切割")]}'>
@@ -183,11 +170,8 @@
</page> </page>
</xpath> </xpath>
<xpath expr="//label[1]" position="before"> <xpath expr="//label[1]" position="before">
<field name='routing_type' readonly="1"/> <field name='routing_type'/>
<field name='process_state' attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> <field name='process_state' attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="rfid_code" force_save="1" readonly="1" cache="True"
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
</xpath> </xpath>
<xpath expr="//label[1]" position="attributes"> <xpath expr="//label[1]" position="attributes">
<attribute name="string">计划加工时间</attribute> <attribute name="string">计划加工时间</attribute>
@@ -219,17 +203,20 @@
<field name="processing_panel" readonly="1" <field name="processing_panel" readonly="1"
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/> attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
<field name="equipment_id" <field name="equipment_id"
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割","装夹预调"))]}'/> attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
<field name="production_line_id" <field name="production_line_id"
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/> attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
<field name="production_line_state" <field name="production_line_state"
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割","装夹预调"))]}'/> attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
<!-- <field name="functional_fixture_id" --> <field name="functional_fixture_id"
<!-- attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> --> attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<!-- <field name="functional_fixture_code" force_save="1" --> <field name="functional_fixture_code" force_save="1"
<!-- attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> --> attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<!-- <field name="functional_fixture_type_id" --> <field name="functional_fixture_type_id"
<!-- attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> --> attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="rfid_code" cache="True"
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
</group> </group>
<!-- <group>--> <!-- <group>-->
<!-- <div>--> <!-- <div>-->
@@ -242,6 +229,23 @@
<!-- <field name="processing_panel" readonly="1" attrs="{'invisible': [('routing_type', 'in', ('获取CNC加工程序','装夹','解除装夹',--> <!-- <field name="processing_panel" readonly="1" attrs="{'invisible': [('routing_type', 'in', ('获取CNC加工程序','装夹','解除装夹',-->
<!-- '前置三元定位检测','后置三元质量检测','解除装夹'))]}"/>--> <!-- '前置三元定位检测','后置三元质量检测','解除装夹'))]}"/>-->
</field> </field>
<xpath expr="//page[1]" position="before">
<page string="获取CNC加工程序" attrs='{"invisible": [("routing_type","!=","获取CNC加工程序")]}'>
<group>
<field name="programming_no" readonly="1"
attrs='{"invisible": [("programming_no","=",False)]}'/>
<field name="programming_state" readonly="1"
attrs='{"invisible": [("programming_no","=",False)]}'/>
</group>
<!-- <group>-->
<!-- <div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">-->
<!-- <button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码"-->
<!-- />-->
<!-- </div>-->
<!-- </group>-->
</page>
</xpath>
<!-- <page string="Components" name="components">--> <!-- <page string="Components" name="components">-->
<xpath expr="//page[1]" position="before"> <xpath expr="//page[1]" position="before">
<!-- <page string="装夹托盘" attrs='{"invisible": [("routing_type","!=","装夹")]}'>--> <!-- <page string="装夹托盘" attrs='{"invisible": [("routing_type","!=","装夹")]}'>-->
@@ -277,26 +281,20 @@
<!-- </group>--> <!-- </group>-->
<group string="托盘"> <group string="托盘">
<field name="tray_serial_number" readonly="1" string="序列号"/> <field name="tray_serial_number" readonly="1" string="序列号"/>
</group>
</group>
<group>
<group>
<field name="tray_product_id" readonly="1" string="名称"/> <field name="tray_product_id" readonly="1" string="名称"/>
<field name="tray_brand_id" readonly="1" string="品牌"/> <field name="tray_brand_id" readonly="1" string="品牌"/>
</group>
<group>
<field name="tray_type_id" readonly="1" string="类型"/> <field name="tray_type_id" readonly="1" string="类型"/>
<field name="tray_model_id" readonly="1" string="型号"/> <field name="tray_model_id" readonly="1" string="型号"/>
</group> </group>
</group> </group>
<group string="加工图纸">
<!-- 隐藏加工图纸字段名 -->
<field name="processing_drawing" widget="pdf_viewer" string="" readonly="1"/>
</group>
<group string="预调程序信息"> <group string="预调程序信息">
<field name="preset_program_information" colspan="2" nolabel="1" <field name="preset_program_information" colspan="2" nolabel="1"
placeholder="如有预调程序信息请在此处输入....."/> placeholder="如有预调程序信息请在此处输入....."/>
</group> </group>
<group string="加工图纸">
<!-- 隐藏加工图纸字段名 -->
<field name="processing_drawing" widget="pdf_viewer" string=""/>
</group>
</page> </page>
<page string="前置三元检测定位参数" attrs='{"invisible": [("routing_type","!=","装夹预调")]}'> <page string="前置三元检测定位参数" attrs='{"invisible": [("routing_type","!=","装夹预调")]}'>
@@ -466,10 +464,7 @@
<field name="production_line_id" readonly="1"/> <field name="production_line_id" readonly="1"/>
<field name="task_delivery_time" readonly="1"/> <field name="task_delivery_time" readonly="1"/>
<field name="task_completion_time" readonly="1"/> <field name="task_completion_time" readonly="1"/>
<field name="status" readonly="1" widget="badge" <field name="status" readonly="1"/>
decoration-success="status == '已配送'"
decoration-warning="status == '待下发'"
decoration-danger="status == '待配送'"/>
</tree> </tree>
</field> </field>
</page> </page>
@@ -482,13 +477,13 @@
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'> <page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
<group> <group>
<field name="test_results" attrs='{"invisible":[("results","!=",False)]}'/> <field name="test_results" attrs='{"invisible":[("results","!=",False)]}'/>
<!-- <field name="is_remanufacture" attrs='{"invisible":[("test_results","!=","报废")]}'/>--> <field name="is_remanufacture" attrs='{"invisible":[("test_results","!=","报废")]}'/>
<!-- <field name="is_fetchcnc"--> <field name="is_fetchcnc"
<!-- attrs='{"invisible":["|",("test_results","=","合格"),("is_remanufacture","=",False)]}'/>--> attrs='{"invisible":["|",("test_results","=","合格"),("is_remanufacture","=",False)]}'/>
<!-- <field name="reason"--> <field name="reason"
<!-- attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")]}'/>--> attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")]}'/>
<!-- <field name="detailed_reason" attrs='{"invisible":[("test_results","=","合格")]}'/>--> <field name="detailed_reason" attrs='{"invisible":[("test_results","=","合格")]}'/>
<!-- <field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>--> <field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>
<field name="detection_report" attrs='{"invisible":[("results","!=",False)]}' <field name="detection_report" attrs='{"invisible":[("results","!=",False)]}'
widget="pdf_viewer"/> widget="pdf_viewer"/>
</group> </group>
@@ -501,11 +496,11 @@
</xpath> </xpath>
<xpath expr="//page[1]" position="before"> <xpath expr="//page[1]" position="before">
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'> <page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
<field name="cnc_ids" widget="one2many" string="工作程序" default_order="sequence_number,id" <field name="cnc_ids" widget="one2many" string="工作程序" default_order="sequence_number,id">
readonly="1"> <tree decoration-success="button_state" decoration-bf="button_state">
<tree>
<field name="sequence_number"/> <field name="sequence_number"/>
<field name="program_name"/> <field name="program_name"/>
<field name="cnc_id" string="文件"/>
<field name="cutting_tool_name"/> <field name="cutting_tool_name"/>
<field name="cutting_tool_no"/> <field name="cutting_tool_no"/>
<field name="processing_type"/> <field name="processing_type"/>
@@ -515,10 +510,8 @@
<field name="cutting_tool_extension_length"/> <field name="cutting_tool_extension_length"/>
<field name="cutting_tool_handle_type"/> <field name="cutting_tool_handle_type"/>
<field name="estimated_processing_time"/> <field name="estimated_processing_time"/>
<field name="program_path"/>
<field name="program_create_date"/>
<field name="remark"/> <field name="remark"/>
<!-- <field name="button_state" invisible="1"/>--> <field name="button_state" invisible="1"/>
</tree> </tree>
</field> </field>
<group> <group>
@@ -526,12 +519,20 @@
</group> </group>
</page> </page>
<page string="CMM程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'> <page string="CMM程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
<field name="cmm_ids" widget="one2many" string="CMM程序" readonly="1"> <field name="cmm_ids" widget="one2many" string="CMM程序">
<tree> <tree>
<field name="sequence_number"/> <field name="sequence_number"/>
<field name="program_name"/> <field name="program_name"/>
<field name="program_path"/> <field name="cmm_id" string="文件"/>
<field name="program_create_date"/> <field name="cutting_tool_name"/>
<field name="cutting_tool_no"/>
<field name="processing_type"/>
<field name="margin_x_y"/>
<field name="margin_z"/>
<field name="depth_of_processing_z"/>
<field name="cutting_tool_extension_length"/>
<field name="cutting_tool_handle_type"/>
<field name="estimated_processing_time"/>
<field name="remark"/> <field name="remark"/>
</tree> </tree>
</field> </field>
@@ -561,6 +562,9 @@
</div> </div>
</xpath> </xpath>
<xpath expr="//form//sheet//group//group//div[3]" position="after"> <xpath expr="//form//sheet//group//group//div[3]" position="after">
<field name="is_ok"/>
<field name="processing_user_id"/>
<field name="inspection_user_id"/>
<field name="save_name" widget="CopyClipboardChar" <field name="save_name" widget="CopyClipboardChar"
attrs="{'invisible':[('routing_type','!=','装夹预调')]}"/> attrs="{'invisible':[('routing_type','!=','装夹预调')]}"/>
<label for="material_length" string="物料尺寸"/> <label for="material_length" string="物料尺寸"/>
@@ -579,17 +583,6 @@
</field> </field>
</record> </record>
<record id="workcenter_form_workorder_search" model="ir.ui.view">
<field name="name">custom.workorder.search</field>
<field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.view_mrp_production_work_order_search"/>
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="part_number" string="成品零件图号"/>
</field>
</field>
</record>
<record id="mrp_workorder_action_schedule" model="ir.actions.act_window"> <record id="mrp_workorder_action_schedule" model="ir.actions.act_window">
<field name="name">工单</field> <field name="name">工单</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
@@ -709,7 +702,7 @@
</search> </search>
</field> </field>
</record> </record>
<record id="sf_workpiece_delivery_act" model="ir.actions.act_window"> <record id="sf_workpiece_delivery_act" model="ir.actions.act_window">
<field name="name">工件配送</field> <field name="name">工件配送</field>
<field name="res_model">sf.workpiece.delivery</field> <field name="res_model">sf.workpiece.delivery</field>

View File

@@ -41,8 +41,8 @@
<field name="model">stock.lot</field> <field name="model">stock.lot</field>
<field name="inherit_id" ref="stock.view_production_lot_tree"/> <field name="inherit_id" ref="stock.view_production_lot_tree"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after"> <xpath expr="//field[@name='create_date']" position="after">
<field name="rfid"/> <field name="rfid" invisible="1"/>
</xpath> </xpath>
</field> </field>
</record> </record>

View File

@@ -24,91 +24,78 @@ class Sf_Mrs_Connect(http.Controller):
ret = json.loads(datas) ret = json.loads(datas)
ret = json.loads(ret['result']) ret = json.loads(ret['result'])
logging.info('下发编程单:%s' % ret) logging.info('下发编程单:%s' % ret)
productions = request.env['mrp.production'].with_user( is_delete_file = False
# 查询状态为进行中且类型为获取CNC加工程序的工单
cnc_production = request.env['mrp.production'].with_user(
request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'].split(',')[0])])
cnc_program = request.env['mrp.production'].with_user(
request.env.ref("base.user_admin")).search( request.env.ref("base.user_admin")).search(
[('programming_no', '=', ret['programming_no'])]) [('programming_no', '=', cnc_production.programming_no), ('id', '!=', cnc_production.id)])
if productions: if cnc_production.workorder_ids.filtered(lambda a: a.routing_type == 'CNC加工').cnc_ids:
# # 拉取所有加工面的程序文件 is_delete_file = True
for r in ret['processing_panel'].split(','): cnc_production.workorder_ids.filtered(
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) lambda a1: a1.routing_type == 'CNC加工').cnc_ids.sudo().unlink()
if os.path.exists(program_path_tmp_r): request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(cnc_production)
if cnc_program.workorder_ids.filtered(lambda c: c.routing_type == 'CNC加工').cnc_ids:
cnc_program.workorder_ids.filtered(
lambda c1: c1.routing_type == 'CNC加工').cnc_ids.sudo().unlink()
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(cnc_program)
# cnc_program = request.env['mrp.production'].with_user(
# request.env.ref("base.user_admin")).search([('programming_no', '=', cnc_production.programming_no)])
logging.info('制造订单号:%s' % cnc_production.name)
if cnc_production:
# if ret['glb_file']:
# cnc_production.glb_file = base64.b64encode(ret['glb_file'])
# 拉取所有加工面的程序文件
if is_delete_file is True:
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', 'R')
files_r = os.listdir(program_path_tmp_r) files_r = os.listdir(program_path_tmp_r)
if files_r: if files_r:
for file_name in files_r: for file_name in files_r:
file_path = os.path.join(program_path_tmp_r, file_name) file_path = os.path.join(program_path_tmp_r, file_name)
os.remove(file_path) os.remove(file_path)
for r in ret['processing_panel']:
download_state = request.env['sf.cnc.processing'].with_user( download_state = request.env['sf.cnc.processing'].with_user(
request.env.ref("base.user_admin")).download_file_tmp( request.env.ref("base.user_admin")).download_file_tmp(
ret['folder_name'], r) ret['folder_name'], r)
if download_state is False: if download_state == 0:
res['status'] = -2 res['status'] = -2
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name)
return json.JSONEncoder().encode(res) return json.JSONEncoder().encode(res)
for production in productions: logging.info('创建cnc工单')
if not production.workorder_ids: program_path_tmp = os.path.join('/tmp', ret['folder_name'], 'return', r)
production.product_id.model_processing_panel = ret['processing_panel'] # program_path_tmp = "C://Users//43484//Desktop//机企猫工作文档//其他//model_analysis"
production._create_workorder(ret) files = os.listdir(program_path_tmp)
# else: cnc_processing_arr = []
# for panel in ret['processing_panel'].split(','): for f in files:
# # 查询状态为进行中且工序类型为CNC加工的工单 program_path = os.path.join(program_path_tmp, f)
# cnc_workorder = production.workorder_ids.filtered( logging.info('cnc程序路径 :%s' % program_path)
# lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', if f.endswith(".doc"):
# 'cancel'] and ac.processing_panel == panel) # 插入cmm程序数据
# if cnc_workorder: cmm_program = request.env['sf.cmm.program'].with_user(
# if cnc_workorder.cnc_ids: request.env.ref("base.user_admin")).cmm_program_create(ret, program_path, program_path_tmp)
# cnc_workorder.cmm_ids.sudo().unlink() cnc_processing = request.env['sf.cnc.processing'].with_user(
# cnc_workorder.cnc_ids.sudo().unlink() request.env.ref("base.user_admin")).cnc_processing_create(cnc_production, ret, program_path,
# request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( program_path_tmp)
# production) logging.info('cnc_processing111:%s' % cnc_processing)
# # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', if cnc_processing:
# # panel) cnc_processing_arr.append(cnc_processing._json_cnc_processing(cnc_processing))
# program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) if (cnc_program and cnc_processing_arr) or (not cnc_program and cnc_processing_arr):
# logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) cnc_production.workorder_ids.filtered(lambda g: g.routing_type == '装夹预调').write(
# files_panel = os.listdir(program_path_tmp_panel) {'processing_drawing': cnc_production.workorder_ids.filtered(
# if files_panel: lambda g1: g1.routing_type == 'CNC加工').cnc_worksheet})
# for file in files_panel: if cnc_program and cnc_processing_arr:
# file_extension = os.path.splitext(file)[1] cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
# logging.info('file_extension:%s' % file_extension) cnc_program.workorder_ids.filtered(lambda d: d.routing_type == '装夹预调').write(
# if file_extension.lower() == '.pdf': {'processing_drawing': cnc_production.workorder_ids.filtered(
# panel_file_path = os.path.join(program_path_tmp_panel, file) lambda d1: d1.routing_type == 'CNC加工').cnc_worksheet})
# logging.info('panel_file_path:%s' % panel_file_path) cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
# cnc_workorder.write( {'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
# {'cnc_ids': cnc_workorder.cnc_ids.sudo()._json_cnc_processing(panel, ret), lambda b1: b1.routing_type == 'CNC加工').cnc_worksheet})
# 'cmm_ids': cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel, ret), cnc_program |= cnc_production
# 'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) if not cnc_program and cnc_processing_arr:
# pre_workorder = production.workorder_ids.filtered( cnc_program = cnc_production
# lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', cnc_program_ids = [item.id for item in cnc_program]
# 'cancel'] and ap.processing_panel == panel)
# if pre_workorder:
# pre_workorder.write(
# {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
for panel in ret['processing_panel'].split(','):
# 查询状态为进行中且工序类型为CNC加工的工单
cnc_workorder = productions.workorder_ids.filtered(
lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done',
'cancel'] and ac.processing_panel == panel)
if cnc_workorder:
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
# panel)
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
files_panel = os.listdir(program_path_tmp_panel)
if files_panel:
for file in files_panel:
file_extension = os.path.splitext(file)[1]
logging.info('file_extension:%s' % file_extension)
if file_extension.lower() == '.pdf':
panel_file_path = os.path.join(program_path_tmp_panel, file)
logging.info('panel_file_path:%s' % panel_file_path)
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
pre_workorder = productions.workorder_ids.filtered(
lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done',
'cancel'] and ap.processing_panel == panel)
if pre_workorder:
pre_workorder.write(
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
cnc_program_ids = [item.id for item in productions]
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('production_id', 'in', cnc_program_ids)]) [('production_id', 'in', cnc_program_ids)])
if workpiece_delivery: if workpiece_delivery:

View File

@@ -21,23 +21,6 @@ class FtpController():
except Exception: except Exception:
logging.info("ftp连接失败") logging.info("ftp连接失败")
def file_exists_1(self, path):
# 检查文件是否存在于FTP服务器上
try:
logging.info("path:%s" % path)
logging.info("dirname:%s" % os.path.dirname(path))
directories = os.path.normpath(path).split(os.path.sep)
# 切换到上级目录
for directory in directories:
if directory:
# 检查目录是否存在
if (directory in ['NC']) or (directory not in ['home', 'ftp', 'ftp_root', 'NC']):
self.ftp.cwd(directory)
return os.path.basename(path)
except Exception as e:
logging.error(f"Error checking file: {e}")
return False
def file_exists(self, path): def file_exists(self, path):
# 检查文件是否存在于FTP服务器上 # 检查文件是否存在于FTP服务器上
try: try:
@@ -49,25 +32,8 @@ class FtpController():
logging.error(f"Error checking file: {e}") logging.error(f"Error checking file: {e}")
return False return False
# 下载目录下的pdf文件(程序单)
def download_program_file(self, target_dir, serverdir):
if not os.path.exists(serverdir):
os.makedirs(serverdir)
try:
logging.info('FTP目录:%s' % target_dir)
logging.info("进入FTP目录 ")
remotenames = self.ftp.nlst()
logging.info('FTP目录文件:%s' % remotenames)
for file in remotenames:
server = os.path.join(serverdir, file)
if file.find(".pdf") != -1:
self.download_file(server, file)
return True
except:
return False
finally:
self.ftp.quit()
logging.info("ftp已关闭")
# # 检测字符串的编码 # # 检测字符串的编码
# def detect_encoding(self, s): # def detect_encoding(self, s):

View File

@@ -19,7 +19,7 @@ class sf_production_plan(models.Model):
('done', '已排程'), ('done', '已排程'),
('processing', '加工中'), ('processing', '加工中'),
('finished', '已完成') ('finished', '已完成')
], string='状态', tracking=True) ], string='工单状态', tracking=True)
state_order = fields.Integer(compute='_compute_state_order', store=True) state_order = fields.Integer(compute='_compute_state_order', store=True)
@@ -36,8 +36,8 @@ class sf_production_plan(models.Model):
_order = 'state_order asc, write_date desc' _order = 'state_order asc, write_date desc'
name = fields.Char(string='制造订单') name = fields.Char(string='工单编号')
# active = fields.Boolean(string='已归档', default=True) active = fields.Boolean(string='已归档', default=True)
# selected = fields.Boolean(default=False) # selected = fields.Boolean(default=False)
# order_number = fields.Char(string='订单号') # order_number = fields.Char(string='订单号')
order_deadline = fields.Datetime(string='订单交期') order_deadline = fields.Datetime(string='订单交期')
@@ -52,7 +52,7 @@ class sf_production_plan(models.Model):
schedule_setting = fields.Selection([ schedule_setting = fields.Selection([
('reverse', '倒排'), ('positive', '顺排')], string='排程设置', default='reverse') ('reverse', '倒排'), ('positive', '顺排')], string='排程设置', default='reverse')
product_id = fields.Many2one('product.product', '关联产品') product_id = fields.Many2one('product.product', '关联产品')
origin = fields.Char(string='销售订单') origin = fields.Char(string='订单')
# # 加工时长 # # 加工时长
# process_time = fields.Float(string='加工时长', digits=(16, 2)) # process_time = fields.Float(string='加工时长', digits=(16, 2))
# 实际加工时长、实际开始时间、实际结束时间 # 实际加工时长、实际开始时间、实际结束时间
@@ -101,17 +101,17 @@ class sf_production_plan(models.Model):
# return super(sf_production_plan, self.with_context(active_test=False))._search( # return super(sf_production_plan, self.with_context(active_test=False))._search(
# args, offset, limit, order, count, access_rights_uid) # args, offset, limit, order, count, access_rights_uid)
# def archive(self): def archive(self):
# """ """
# 归档 归档
# """ """
# self.write({'active': False}) self.write({'active': False})
#
# def unarchive(self): def unarchive(self):
# """ """
# 取消归档 取消归档
# """ """
# self.write({'active': True}) self.write({'active': True})
@api.model @api.model
def get_import_templates(self): def get_import_templates(self):
@@ -200,7 +200,6 @@ class sf_production_plan(models.Model):
raise ValidationError("未选择生产线") raise ValidationError("未选择生产线")
else: else:
workorder_id_list = record.production_id.workorder_ids.ids workorder_id_list = record.production_id.workorder_ids.ids
if record.production_id:
if record.production_id.workorder_ids: if record.production_id.workorder_ids:
for item in record.production_id.workorder_ids: for item in record.production_id.workorder_ids:
if item.name == 'CNC加工': if item.name == 'CNC加工':
@@ -232,12 +231,12 @@ class sf_production_plan(models.Model):
# record.production_id.date_planned_start = record.date_planned_start # record.production_id.date_planned_start = record.date_planned_start
# record.production_id.date_planned_finished = record.date_planned_finished # record.production_id.date_planned_finished = record.date_planned_finished
record.sudo().production_id.production_line_id = record.production_line_id.id record.sudo().production_id.production_line_id = record.production_line_id.id
if record.production_id.workorder_ids:
record.sudo().production_id.workorder_ids.filtered( record.sudo().production_id.workorder_ids.filtered(
lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write( lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write(
{'production_line_id': record.production_line_id.id, {'production_line_id': record.production_line_id.id,
'plan_start_processing_time': record.date_planned_start}) 'plan_start_processing_time': record.date_planned_start})
else:
raise ValidationError("未找到工单")
# record.date_planned_finished = record.date_planned_start + timedelta(days=3) # record.date_planned_finished = record.date_planned_start + timedelta(days=3)
# record.state = 'done' # record.state = 'done'
return { return {

View File

@@ -17,18 +17,18 @@
decoration-danger="state == 'finished'"/> decoration-danger="state == 'finished'"/>
<field name="name"/> <field name="name"/>
<field name="origin"/> <field name="origin"/>
<field name="order_deadline" widget="date"/> <field name="order_deadline"/>
<field name="product_qty"/> <field name="product_qty"/>
<field name="production_line_id"/> <field name="production_line_id"/>
<field name="date_planned_start"/> <field name="date_planned_start"/>
<field name="date_planned_finished"/> <field name="date_planned_finished"/>
<field name="actual_start_time" optional='hide'/> <field name="actual_start_time"/>
<field name="actual_end_time" optional='hide'/> <field name="actual_end_time"/>
<field name="actual_process_time" optional='hide'/> <field name="actual_process_time"/>
<field name="schedule_setting" optional='hide'/> <field name="schedule_setting"/>
<!-- <button name="do_production_schedule" class="btn schedule_done" string="生产排程" type="object" --> <button name="do_production_schedule" class="btn schedule_done" string="生产排程" type="object"
<!-- attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('actual_start_time', '!=', False)]}" --> attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('actual_start_time', '!=', False)]}"
<!-- groups="sf_base.group_plan_dispatch"/> --> groups="sf_base.group_plan_dispatch"/>
<button name="cancel_production_schedule" class="btn schedule_cancel" string="取消排程" type="object" <button name="cancel_production_schedule" class="btn schedule_cancel" string="取消排程" type="object"
attrs="{'invisible': ['|', ('state', '!=', 'done'), ('actual_start_time', '!=', False)]}" attrs="{'invisible': ['|', ('state', '!=', 'done'), ('actual_start_time', '!=', False)]}"
groups="sf_base.group_plan_dispatch"/> groups="sf_base.group_plan_dispatch"/>
@@ -63,12 +63,12 @@
</div> </div>
<group> <group>
<group string="基本信息"> <group string="基本信息">
<!-- <field name="active" invisible="1"/> --> <field name="active" invisible="1"/>
<field name="production_id" widget="many2one_button"/> <field name="production_id" widget="many2one_button"/>
<field name="product_id"/> <field name="product_id"/>
<field name="origin"/> <field name="origin"/>
<field name="product_qty"/> <field name="product_qty"/>
<field name="order_deadline" widget="date"/> <field name="order_deadline"/>
<!-- <field name="process_time"/> --> <!-- <field name="process_time"/> -->
<field name="schedule_setting"/> <field name="schedule_setting"/>
<field name="production_line_id" domain="[('name', 'ilike', 'CNC')]"/> <field name="production_line_id" domain="[('name', 'ilike', 'CNC')]"/>
@@ -152,27 +152,16 @@
<field name="model">sf.production.plan</field> <field name="model">sf.production.plan</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<search string="订单计划"> <search string="订单计划">
<!-- Your other filters go here --> <!-- Your other filters go here -->
<!-- <filter name="archived" string="已归档" domain="[('active','=',False)]"/> --> <filter name="archived" string="已归档" domain="[('active','=',False)]"/>
<!-- <filter name="not archived" string="未归档" domain="[('active','=',True)]"/> --> <filter name="not archived" string="未归档" domain="[('active','=',True)]"/>
<field name="name"/> <field name="name"/>
<field name="product_qty"/> <field name="product_qty"/>
<field name="date_planned_start"/>
<field name="date_planned_finished"/>
<field name="state"/> <field name="state"/>
<filter string="待排程" name="draft" domain="[('state','=','draft')]"/> <searchpanel class="account_root">
<filter string="已排程" name="done" domain="[('state','=','done')]"/> <field name="state" icon="fa-filter"/>
<filter string="加工中" name="processing" domain="[('state','=','processing')]"/>
<filter string="已完成" name="finished" domain="[('state','=','finished')]"/>
<group expand="0" string="Group By">
<filter name="group_by_state" string="状态" domain="[]" context="{'group_by': 'state'}"/>
</group>
<group expand="0" string="Group By">
<filter name="group_by_production_line_id" string="生产线" domain="[]" context="{'group_by': 'production_line_id'}"/>
</group>
<searchpanel>
<!-- <field name="state" icon="fa-filter"/> -->
<field name="production_line_id" select="multi" string="生产线" icon="fa-building" enable_counters="1"/>
<field name="state" select="multi" string="状态" icon="fa-building" enable_counters="1"/>
</searchpanel> </searchpanel>
</search> </search>
</field> </field>
@@ -199,41 +188,30 @@
<field name="date_planned_start"/> <field name="date_planned_start"/>
<field name="date_planned_finished"/> <field name="date_planned_finished"/>
<field name="state"/> <field name="state"/>
<field name="origin"/>
<field name="order_deadline"/>
<field name="product_id"/>
<templates> <templates>
<div t-name="gantt-popover" class="container-fluid"> <div t-name="gantt-popover" class="container-fluid">
<div class="row g-0"> <div class="row g-0">
<div class="col"> <div class="col">
<ul class="ps-1 mb-0 list-unstyled"> <ul class="ps-1 mb-0 list-unstyled">
<li> <li>
<strong>销售订单号:</strong> <strong>开始时间:</strong>
<t t-out="origin"/> <t t-out="userTimezoneStartDate.format('L LTS')"/>
</li> </li>
<li> <li>
<strong>制造订单号:</strong> <strong>结束时间:</strong>
<t t-out="userTimezoneStopDate.format('L LTS')"/>
</li>
<li>
<strong>名称:</strong>
<t t-out="name"/> <t t-out="name"/>
</li> </li>
<li>
<strong>订单交期:</strong>
<t t-out="order_deadline.format('L LTS')"/>
</li>
<li>
<strong>产品名称:</strong>
<t t-out="product_id[1]"/>
</li>
<li> <li>
<strong>数量:</strong> <strong>数量:</strong>
<t t-out="product_qty"/> <t t-out="product_qty"/>
</li> </li>
<li> <li>
<strong>计划开始时间:</strong> <strong>状态:</strong>
<t t-out="userTimezoneStartDate.format('L LTS')"/> <t t-out="state"/>
</li>
<li>
<strong>计划结束时间:</strong>
<t t-out="userTimezoneStopDate.format('L LTS')"/>
</li> </li>
</ul> </ul>
</div> </div>
@@ -268,8 +246,6 @@
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.production.plan</field> <field name="res_model">sf.production.plan</field>
<field name="view_mode">tree,gantt,form</field> <field name="view_mode">tree,gantt,form</field>
<!-- <field name="context">{'search_default_group_by_state': 1, 'search_default_draft': 1, 'display_complete': True}</field> -->
<field name="context">{'search_default_draft': 1, 'display_complete': True}</field>
</record> </record>
<menuitem <menuitem

View File

@@ -114487,21 +114487,10 @@ msgstr ""
msgid "径跳精度(mm)" msgid "径跳精度(mm)"
msgstr "" msgstr ""
#. module: sf_manufacturing
#: model:ir.model.fields.selection,name:sf_manufacturing.selection__mrp_production__state__draft
msgid "待排程"
msgstr "待排程"
#. module: sf_manufacturing
#: model:ir.model.fields.selection,name:sf_manufacturing.selection__mrp_production__process_state__待加工
#: model:ir.model.fields.selection,name:sf_manufacturing.selection__mrp_production__state__confirmed
msgid "待加工"
msgstr "待加工"
#. module: sf_manufacturing #. module: sf_manufacturing
#: model:ir.model.fields.selection,name:sf_manufacturing.selection__mrp_production__state__progress #: model:ir.model.fields.selection,name:sf_manufacturing.selection__mrp_production__state__progress
msgid "待排程" msgid "待排程"
msgstr "加工中" msgstr "待排程"
#. module: sf_base #. module: sf_base
#: model:ir.model.fields,field_description:sf_base.field_sf_cutting_tool_model__jump_accuracy #: model:ir.model.fields,field_description:sf_base.field_sf_cutting_tool_model__jump_accuracy

View File

@@ -171,11 +171,6 @@ class ProductTemplate(models.Model):
class RePurchaseOrder(models.Model): class RePurchaseOrder(models.Model):
_inherit = 'purchase.order' _inherit = 'purchase.order'
mrp_production_count = fields.Integer(
"Count of MO Source",
compute='_compute_mrp_production_count',
groups='mrp.group_mrp_user,sf_base.group_purchase,sf_base.group_purchase_director')
remark = fields.Text('备注') remark = fields.Text('备注')
user_id = fields.Many2one( user_id = fields.Many2one(
'res.users', string='买家', index=True, tracking=True, 'res.users', string='买家', index=True, tracking=True,
@@ -220,17 +215,6 @@ class RePurchaseOrder(models.Model):
if len(product_id) != len(line): if len(product_id) != len(line):
raise ValidationError('%s】已存在,请勿重复添加' % product[-1].name) raise ValidationError('%s】已存在,请勿重复添加' % product[-1].name)
def button_confirm(self):
result = super(RePurchaseOrder, self).button_confirm()
for item in self:
# 确认订单时,自动分配序列号
if item.picking_ids:
for picking_id in item.picking_ids:
if picking_id.move_ids:
for move_id in picking_id.move_ids:
move_id.put_move_line()
return result
class ResPartnerToSale(models.Model): class ResPartnerToSale(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'

View File

@@ -54,7 +54,7 @@
<record model="ir.rule" id="sale_order_rule_my"> <record model="ir.rule" id="sale_order_rule_my">
<field name="name">销售经理查看自己的订单</field> <field name="name">销售经理查看自己的订单</field>
<field name="model_id" ref="model_sale_order"/> <field name="model_id" ref="model_sale_order"/>
<field name="domain_force">['|','|',('user_id','=',user.id),('user_id', '=', False),('create_uid', '=',user.id)]</field> <field name="domain_force">['|',('user_id','=',user.id),('create_uid', '=',user.id)]</field>
<field name="groups" eval="[(4, ref('sf_base.group_sale_salemanager'))]"/> <field name="groups" eval="[(4, ref('sf_base.group_sale_salemanager'))]"/>
<field name="perm_read" eval="1"/> <field name="perm_read" eval="1"/>
<field name="perm_write" eval="1"/> <field name="perm_write" eval="1"/>
@@ -74,7 +74,7 @@
<record model="ir.rule" id="inventory_purchase_order_rule_my"> <record model="ir.rule" id="inventory_purchase_order_rule_my">
<field name="name">采购岗查看自己的订单</field> <field name="name">采购岗查看自己的订单</field>
<field name="model_id" ref="purchase.model_purchase_order"/> <field name="model_id" ref="purchase.model_purchase_order"/>
<field name="domain_force">['|','|',('user_id','=',user.id),('user_id', '=', False),('create_uid', '=',user.id)]</field> <field name="domain_force">['|',('user_id','=',user.id),('create_uid', '=',user.id)]</field>
<field name="groups" eval="[(4, ref('sf_base.group_purchase'))]"/> <field name="groups" eval="[(4, ref('sf_base.group_purchase'))]"/>
<field name="perm_read" eval="1"/> <field name="perm_read" eval="1"/>
<field name="perm_write" eval="0"/> <field name="perm_write" eval="0"/>

View File

@@ -79,13 +79,6 @@
<xpath expr="//form/header/button[@name='button_done']" position="attributes"> <xpath expr="//form/header/button[@name='button_done']" position="attributes">
<attribute name="groups">sf_base.group_purchase,sf_base.group_purchase_director</attribute> <attribute name="groups">sf_base.group_purchase,sf_base.group_purchase_director</attribute>
</xpath> </xpath>
<xpath expr="//form/sheet/div[@name='button_box']/button[@name='action_view_mrp_productions']"
position="attributes">
<attribute name="groups">mrp.group_mrp_user,sf_base.group_purchase,sf_base.group_purchase_director
</attribute>
</xpath>
<xpath expr="//field[@name='order_line']" position="attributes"> <xpath expr="//field[@name='order_line']" position="attributes">
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]} <attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
</attribute> </attribute>

View File

@@ -22,7 +22,6 @@
'views/tool_material_search.xml', 'views/tool_material_search.xml',
'views/fixture_material_search_views.xml', 'views/fixture_material_search_views.xml',
'views/menu_view.xml', 'views/menu_view.xml',
'views/stock.xml',
'data/tool_data.xml', 'data/tool_data.xml',
], ],
'demo': [ 'demo': [

View File

@@ -109,7 +109,6 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': True, 'Datas': []} res = {'Succeed': True, 'Datas': []}
try: try:
datas = request.httprequest.data datas = request.httprequest.data
logging.info('datas: %s' % datas)
ret = str(datas, 'utf-8') ret = str(datas, 'utf-8')
data_lists = ret.split(",") data_lists = ret.split(",")
data_list = [data.replace('+', '') for data in data_lists] data_list = [data.replace('+', '') for data in data_lists]
@@ -121,7 +120,7 @@ class Manufacturing_Connect(http.Controller):
{'Succeed': False, 'ErrorCode': 201, 'code': data_list[0], 'Error': '没有找到正在组装的组装单!'}) {'Succeed': False, 'ErrorCode': 201, 'code': data_list[0], 'Error': '没有找到正在组装的组装单!'})
tool_assembly.write({ tool_assembly.write({
'after_assembly_tool_loading_length': float(data_list[1] or "0"), # 高度(总长度) 'after_assembly_tool_loading_length': float(data_list[1] or "0"), # 高度(总长度)
'after_assembly_functional_tool_diameter': float(data_list[2] or "0") * 2, # 直径 'after_assembly_functional_tool_diameter': float(data_list[2] or "0"), # 直径
'after_assembly_knife_tip_r_angle': float(data_list[3] or "0") # R角 'after_assembly_knife_tip_r_angle': float(data_list[3] or "0") # R角
}) })
except Exception as e: except Exception as e:

View File

@@ -7,5 +7,4 @@ from . import functional_tool_enroll
from . import fixture_material_search from . import fixture_material_search
from . import fixture_enroll from . import fixture_enroll
from . import temporary_data_processing_methods from . import temporary_data_processing_methods
from . import stock

View File

@@ -581,15 +581,6 @@ class FunctionalToolAssembly(models.Model):
active = fields.Boolean(string='已归档', default=True) active = fields.Boolean(string='已归档', default=True)
def action_open_reference1(self):
self.ensure_one()
return {
'res_model': self._name,
'type': 'ir.actions.act_window',
'views': [[False, "form"]],
'res_id': self.id,
}
def put_start_preset(self): def put_start_preset(self):
self.search([('start_preset_bool', '=', True)]).write({'start_preset_bool': False}) self.search([('start_preset_bool', '=', True)]).write({'start_preset_bool': False})
self.write({ self.write({
@@ -759,8 +750,7 @@ class FunctionalToolDismantle(models.Model):
return 'GNDJ-CJD-%s-%s' % (datetime, num) return 'GNDJ-CJD-%s-%s' % (datetime, num)
functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True, functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True,
domain=[('functional_tool_status', '!=', '已拆除'), domain=[('functional_tool_status', '!=', '已拆除')])
('current_location', '=', '刀具房')])
tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True, tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
compute='_compute_functional_tool_num') compute='_compute_functional_tool_num')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_functional_tool_num', store=True) tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_functional_tool_num', store=True)
@@ -936,7 +926,7 @@ class FunctionalToolDismantle(models.Model):
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')]) location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')]) location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
# =================刀柄是否[报废]拆解======= # =================刀柄是否[报废]拆解=======
location_dest_scrap_ids = self.env['stock.location'].search([('name', 'in', ('Scrap', '报废'))]) location_dest_scrap = self.env['stock.location'].search([('name', '=', 'Scrap')])
if self.handle_rfid: if self.handle_rfid:
lot = self.env['stock.lot'].sudo().search([('rfid', '=', self.handle_rfid)]) lot = self.env['stock.lot'].sudo().search([('rfid', '=', self.handle_rfid)])
if not lot: if not lot:
@@ -944,31 +934,30 @@ class FunctionalToolDismantle(models.Model):
functional_tool_assembly = self.functional_tool_id.functional_tool_name_id functional_tool_assembly = self.functional_tool_id.functional_tool_name_id
if self.scrap_boolean: if self.scrap_boolean:
# 刀柄报废 入库到Scrap # 刀柄报废 入库到Scrap
lot.create_stock_quant(location, location_dest_scrap_ids[-1], False, code, False, False) lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, code,
lot.tool_material_status = '报废' functional_tool_assembly, functional_tool_assembly.tool_groups_id)
else: else:
# 刀柄不报废 入库到刀具房 # 刀柄不报废 入库到刀具房
lot.create_stock_quant(location, location_dest, False, code, False, False) lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, code,
lot.tool_material_status = '可用' functional_tool_assembly, functional_tool_assembly.tool_groups_id)
# ==============功能刀具[报废]拆解================ # ==============功能刀具[报废]拆解================
if self.dismantle_cause in ['寿命到期报废', '崩刀报废']: if self.dismantle_cause in ['寿命到期报废', '崩刀报废']:
# 除刀柄外物料报废 入库到Scrap # 除刀柄外物料报废 入库到Scrap
if self.integral_product_id: if self.integral_product_id:
self.integral_product_id.dismantle_stock_moves(False, self.integral_lot_id, location, self.integral_product_id.dismantle_stock_moves(False, self.integral_lot_id, location,
location_dest_scrap_ids[-1], code) location_dest_scrap, code)
elif self.blade_product_id: elif self.blade_product_id:
self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location, self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location, location_dest_scrap,
location_dest_scrap_ids[-1], code) code)
if self.bar_product_id: if self.bar_product_id:
self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location, self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location, location_dest_scrap,
location_dest_scrap_ids[-1], code) code)
elif self.pad_product_id: elif self.pad_product_id:
self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location, self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location, location_dest_scrap,
location_dest_scrap_ids[-1], code) code)
if self.chuck_product_id: if self.chuck_product_id:
self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location, self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location, location_dest_scrap,
location_dest_scrap_ids[-1], code) code)
# ===========功能刀具[磨削]拆解============== # ===========功能刀具[磨削]拆解==============
# elif self.dismantle_cause in ['刀具需磨削']: # elif self.dismantle_cause in ['刀具需磨削']:
# location_dest = self.env['stock.location'].search([('name', '=', '磨削房')]) # location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
@@ -1036,7 +1025,7 @@ class ProductProduct(models.Model):
'product_id': self.id, 'product_id': self.id,
'lot_id': lot_id.id, 'lot_id': lot_id.id,
'move_id': stock_move_id.id, 'move_id': stock_move_id.id,
'destination_location_id': shelf_location_id.id if shelf_location_id else False, 'destination_location_id': shelf_location_id.id,
'install_tool_time': fields.Datetime.now(), 'install_tool_time': fields.Datetime.now(),
'qty_done': 1.0, 'qty_done': 1.0,
'state': 'done', 'state': 'done',

View File

@@ -34,17 +34,15 @@ class FunctionalCuttingToolEntity(models.Model):
handle_length = fields.Float(string='刀柄长度(mm)', readonly=True, digits=(10, 3)) handle_length = fields.Float(string='刀柄长度(mm)', readonly=True, digits=(10, 3))
functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True, digits=(10, 3)) functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True, digits=(10, 3))
effective_length = fields.Float(string='有效长(mm)', readonly=True) effective_length = fields.Float(string='有效长(mm)', readonly=True)
tool_room_num = fields.Integer(string='刀具房数量', compute='_compute_num', store=True) tool_room_num = fields.Integer(string='刀具房数量', readonly=True)
line_edge_knife_library_num = fields.Integer(string='线边刀库数量', compute='_compute_num', store=True) line_edge_knife_library_num = fields.Integer(string='线边刀库数量', readonly=True)
machine_knife_library_num = fields.Integer(string='机内刀库数量', compute='_compute_num', store=True) machine_knife_library_num = fields.Integer(string='机内刀库数量', readonly=True)
max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True)
alarm_value = fields.Integer(string='报警值(min)', readonly=True) alarm_value = fields.Integer(string='报警值(min)', readonly=True)
used_value = fields.Integer(string='已使用值(min)', readonly=True) used_value = fields.Integer(string='已使用值(min)', readonly=True)
functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')], functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')],
string='状态', store=True, default='正常') string='状态', store=True, default='正常')
current_location_id = fields.Many2one('stock.location', string='当前位置', compute='_compute_current_location_id', current_location_id = fields.Many2one('stock.location', string='当前位置', readonly=True)
store=True)
current_shelf_location_id = fields.Many2one('sf.shelf.location', string='当前货位', readonly=True)
current_location = fields.Selection( current_location = fields.Selection(
[('组装后', '组装后'), ('刀具房', '刀具房'), ('线边刀库', '线边刀库'), ('机内刀库', '机内刀库')], [('组装后', '组装后'), ('刀具房', '刀具房'), ('线边刀库', '线边刀库'), ('机内刀库', '机内刀库')],
string='位置', compute='_compute_current_location_id', store=True) string='位置', compute='_compute_current_location_id', store=True)
@@ -53,39 +51,34 @@ class FunctionalCuttingToolEntity(models.Model):
safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools', safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools',
string='功能刀具安全库存', readonly=True) string='功能刀具安全库存', readonly=True)
@api.depends('barcode_id.quant_ids', 'functional_tool_status', 'current_shelf_location_id') @api.depends('barcode_id.quant_ids', 'functional_tool_status')
def _compute_current_location_id(self): def _compute_current_location_id(self):
for record in self: for record in self:
if record.functional_tool_status == '已拆除':
record.current_location_id = False
record.current_location = False
else:
if record.barcode_id.quant_ids: if record.barcode_id.quant_ids:
for quant_id in record.barcode_id.quant_ids: for quant_id in record.barcode_id.quant_ids:
if quant_id.inventory_quantity_auto_apply > 0: if quant_id.inventory_quantity_auto_apply > 0:
record.current_location_id = quant_id.location_id record.current_location_id = quant_id.location_id
if quant_id.location_id.name == '制造前': if quant_id.location_id.name == '制造前':
if not record.current_shelf_location_id:
record.current_location = '机内刀库' record.current_location = '机内刀库'
else: else:
record.current_location = '线边刀库' record.current_location = quant_id.location_id.name
else: if record.current_location_id:
record.current_location = '刀具房' record.sudo().get_location_num()
else: else:
record.current_location_id = False record.current_location_id = False
record.current_location = False record.current_location = False
if record.functional_tool_status == '已拆除':
record.current_location_id = False
record.current_location = False
record.tool_room_num = 0
record.line_edge_knife_library_num = 0
record.machine_knife_library_num = 0
@api.depends('current_location', 'functional_tool_status') def get_location_num(self):
def _compute_num(self):
""" """
计算库存位置数量 计算库存位置数量
""" """
for obj in self: for obj in self:
if obj.functional_tool_status == '已拆除':
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 0
else:
if obj.current_location_id: if obj.current_location_id:
obj.tool_room_num = 0 obj.tool_room_num = 0
obj.line_edge_knife_library_num = 0 obj.line_edge_knife_library_num = 0
@@ -97,70 +90,6 @@ class FunctionalCuttingToolEntity(models.Model):
elif "机内刀库" in obj.current_location: elif "机内刀库" in obj.current_location:
obj.machine_knife_library_num = 1 obj.machine_knife_library_num = 1
def tool_in_out_stock_location(self, location_id):
tool_room_id = self.env['stock.location'].search([('name', '=', '刀具房')])
pre_manufacturing_id = self.env['stock.location'].search([('name', '=', '制造前')])
for item in self:
# 中控反馈该位置有刀
if item:
# 系统该位置有刀
if location_id.product_sn_id:
# 中控反馈和系统中,该位置是同一把刀
if item.barcode_id == location_id.product_sn_id:
return True
# 中控反馈和系统中,该位置不是同一把刀
else:
# 原刀从线边出库
item.tool_in_out_stock_location_1(location_id, tool_room_id)
# 新刀入库到线边
item.create_stock_move(pre_manufacturing_id, location_id)
item.current_shelf_location_id = location_id.id
# 中控反馈该位置没有刀
else:
# 系统该位置有刀
if location_id.product_sn_id:
item.tool_in_out_stock_location_1(location_id, tool_room_id)
def tool_in_out_stock_location_1(self, location_id, tool_room_id):
tool = self.env['sf.functional.cutting.tool.entity'].search(
[('barcode_id', '=', location_id.product_sn_id.id)])
if tool.current_location == '线边刀库':
tool.create_stock_move(tool_room_id, False)
# 修改功能刀具的当前位置
tool.current_shelf_location_id = False
def create_stock_move(self, location_dest_id, destination_location_id):
# 创建库存移动记录
stock_move_id = self.env['stock.move'].sudo().create({
'name': '/',
'product_id': self.barcode_id.product_id.id,
'location_id': self.current_location_id.id,
'location_dest_id': location_dest_id.id,
'product_uom_qty': 1.00,
'state': 'done'
})
# 创建移动历史记录
stock_move_line_id = self.env['stock.move.line'].sudo().create({
'product_id': self.barcode_id.product_id.id,
'lot_id': self.barcode_id.id,
'move_id': stock_move_id.id,
'current_location_id': False if not self.current_shelf_location_id else self.current_shelf_location_id.id,
'destination_location_id': False if not destination_location_id else destination_location_id.id,
'qty_done': 1.0,
'state': 'done',
'functional_tool_type_id': self.sf_cutting_tool_type_id.id,
'diameter': self.functional_tool_diameter,
'knife_tip_r_angle': self.knife_tip_r_angle,
'code': self.code,
'rfid': self.rfid,
'functional_tool_name': self.name,
'tool_groups_id': self.tool_groups_id.id
})
return stock_move_id, stock_move_line_id
@api.model @api.model
def _read_group_mrs_cutting_tool_type_id(self, categories, domain, order): def _read_group_mrs_cutting_tool_type_id(self, categories, domain, order):
mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
@@ -262,14 +191,12 @@ class FunctionalCuttingToolEntity(models.Model):
机床当前刀库实时信息接口,功能刀具出库 机床当前刀库实时信息接口,功能刀具出库
""" """
# 获取位置对象 # 获取位置对象
location_inventory_id = self.current_location_id
stock_location_id = self.env['stock.location'].search([('name', '=', '制造前')]) stock_location_id = self.env['stock.location'].search([('name', '=', '制造前')])
# 创建功能刀具该批次/序列号 库存移动和移动历史 # 创建功能刀具该批次/序列号 库存移动和移动历史
self.create_stock_move(stock_location_id, False) self.barcode_id.create_stock_quant(location_inventory_id, stock_location_id,
self.current_location_id = stock_location_id.id self.functional_tool_name_id.id, '机床装刀', self.functional_tool_name_id,
self.current_shelf_location_id = False self.functional_tool_name_id.tool_groups_id)
# self.barcode_id.create_stock_quant(location_inventory_id, stock_location_id,
# self.functional_tool_name_id.id, '机床装刀', self.functional_tool_name_id,
# self.functional_tool_name_id.tool_groups_id)
# ==========刀具组接口========== # ==========刀具组接口==========
# def _register_functional_tool_groups(self, obj): # def _register_functional_tool_groups(self, obj):
@@ -377,7 +304,7 @@ class StockMoveLine(models.Model):
functional_tool_name = fields.Char('刀具名称') functional_tool_name = fields.Char('刀具名称')
diameter = fields.Float(string='刀具直径(mm)') diameter = fields.Float(string='刀具直径(mm)')
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)') knife_tip_r_angle = fields.Float(string='刀尖R角(mm)')
install_tool_time = fields.Datetime("刀具组装时间") install_tool_time = fields.Datetime("刀具组装时间", default=fields.Datetime.now())
code = fields.Char('编码') code = fields.Char('编码')
rfid = fields.Char('Rfid') rfid = fields.Char('Rfid')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组') tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组')
@@ -387,22 +314,6 @@ class StockMoveLine(models.Model):
names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(names) return categories.browse(names)
def action_open_reference1(self):
self.ensure_one()
if self.functional_tool_name_id:
action = self.functional_tool_name_id.action_open_reference1()
return action
elif self.move_id:
action = self.move_id.action_open_reference()
if action['res_model'] != 'stock.move':
return action
return {
'res_model': self._name,
'type': 'ir.actions.act_window',
'views': [[False, "form"]],
'res_id': self.id,
}
class RealTimeDistributionOfFunctionalTools(models.Model): class RealTimeDistributionOfFunctionalTools(models.Model):
_name = 'sf.real.time.distribution.of.functional.tools' _name = 'sf.real.time.distribution.of.functional.tools'
@@ -416,10 +327,10 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
group_expand='_read_mrs_cutting_tool_type_ids', store=True) group_expand='_read_mrs_cutting_tool_type_ids', store=True)
diameter = fields.Float(string='刀具直径(mm)', readonly=False) diameter = fields.Float(string='刀具直径(mm)', readonly=False)
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=False) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=False)
tool_stock_num = fields.Integer(string='刀具房数量', compute='_compute_stock_num', store=True) tool_stock_num = fields.Integer(string='刀具房数量')
side_shelf_num = fields.Integer(string='线边刀库数量', compute='_compute_stock_num', store=True) side_shelf_num = fields.Integer(string='线边刀库数量')
on_tool_stock_num = fields.Integer(string='机内刀库数量', compute='_compute_stock_num', store=True) on_tool_stock_num = fields.Integer(string='机内刀库数量')
tool_stock_total = fields.Integer(string='当前库存量', compute='_compute_tool_stock_total', store=True) tool_stock_total = fields.Integer(string='当前库存量', readonly=True)
min_stock_num = fields.Integer('最低库存量', tracking=True) min_stock_num = fields.Integer('最低库存量', tracking=True)
max_stock_num = fields.Integer('最高库存量', tracking=True) max_stock_num = fields.Integer('最高库存量', tracking=True)
batch_replenishment_num = fields.Integer('批次补货量', readonly=True, compute='_compute_batch_replenishment_num', batch_replenishment_num = fields.Integer('批次补货量', readonly=True, compute='_compute_batch_replenishment_num',
@@ -492,6 +403,10 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
def _compute_batch_replenishment_num(self): def _compute_batch_replenishment_num(self):
for tool in self: for tool in self:
if tool: if tool:
# 计算刀具房数量、线边刀库数量、机内刀库数量
tool.sudo().get_stock_num(tool)
# 计算当前库存量
tool.sudo().tool_stock_total = tool.tool_stock_num + tool.side_shelf_num + tool.on_tool_stock_num
# 如果当前库存量小于最低库存量,计算批次补货量 # 如果当前库存量小于最低库存量,计算批次补货量
tool.sudo().open_batch_replenishment_num(tool) tool.sudo().open_batch_replenishment_num(tool)
@@ -510,38 +425,6 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
else: else:
tool.sudo().batch_replenishment_num = 0 tool.sudo().batch_replenishment_num = 0
@api.depends('sf_functional_tool_entity_ids', 'sf_functional_tool_entity_ids.tool_room_num',
'sf_functional_tool_entity_ids.line_edge_knife_library_num',
'sf_functional_tool_entity_ids.machine_knife_library_num')
def _compute_stock_num(self):
"""
计算刀具房数量、线边刀库数量、机内刀库数量
"""
for tool in self:
if tool:
tool.tool_stock_num = 0
tool.side_shelf_num = 0
tool.on_tool_stock_num = 0
if tool.sf_functional_tool_entity_ids:
for cutting_tool in tool.sf_functional_tool_entity_ids:
if cutting_tool.tool_room_num > 0:
tool.tool_stock_num += 1
elif cutting_tool.line_edge_knife_library_num > 0:
tool.side_shelf_num += 1
elif cutting_tool.machine_knife_library_num > 0:
tool.on_tool_stock_num += 1
else:
tool.tool_stock_num = 0
tool.side_shelf_num = 0
tool.on_tool_stock_num = 0
@api.depends('tool_stock_num', 'side_shelf_num', 'on_tool_stock_num')
def _compute_tool_stock_total(self):
for tool in self:
if tool:
# 计算当前库存量
tool.tool_stock_total = tool.tool_stock_num + tool.side_shelf_num + tool.on_tool_stock_num
def create_functional_tool_assembly(self, tool): def create_functional_tool_assembly(self, tool):
""" """
创建功能刀具组装单 创建功能刀具组装单
@@ -562,6 +445,27 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
}) })
tool.sudo().sf_functional_tool_assembly_ids = [(4, functional_tool_assembly.id)] tool.sudo().sf_functional_tool_assembly_ids = [(4, functional_tool_assembly.id)]
def get_stock_num(self, tool):
"""
计算刀具房数量、线边刀库数量、机内刀库数量
"""
if tool:
tool.tool_stock_num = 0
tool.side_shelf_num = 0
tool.on_tool_stock_num = 0
if tool.sf_functional_tool_entity_ids:
for cutting_tool in tool.sf_functional_tool_entity_ids:
if cutting_tool.tool_room_num > 0:
tool.tool_stock_num += 1
elif cutting_tool.line_edge_knife_library_num > 0:
tool.side_shelf_num += 1
elif cutting_tool.machine_knife_library_num > 0:
tool.on_tool_stock_num += 1
else:
tool.tool_stock_num = 0
tool.side_shelf_num = 0
tool.on_tool_stock_num = 0
def create_or_edit_safety_stock(self, vals, sf_functional_tool_entity_ids): def create_or_edit_safety_stock(self, vals, sf_functional_tool_entity_ids):
""" """
根据传入的信息新增或者更新功能刀具安全库存的信息 根据传入的信息新增或者更新功能刀具安全库存的信息

View File

@@ -80,7 +80,7 @@ class StockLot(models.Model):
headers = Common.get_headers(self, token, sf_secret_key) headers = Common.get_headers(self, token, sf_secret_key)
str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create" str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
product_ids = self.env['product.product'].sudo().search([('categ_type', '=', '刀具')]).ids product_ids = self.env['product.product'].sudo().search([('categ_type', '=', '刀具')]).ids
objs_all = self.env['stock.lot'].search([('product_id', 'in', product_ids)]) objs_all = self.env['stock.lot'].search([('rfid', '!=', False), ('product_id', 'in', product_ids)])
self._get_sync_stock_lot(objs_all, str_url, token, headers) self._get_sync_stock_lot(objs_all, str_url, token, headers)
def _get_sync_stock_lot(self, objs_all, str_url, token, headers): def _get_sync_stock_lot(self, objs_all, str_url, token, headers):
@@ -90,7 +90,6 @@ class StockLot(models.Model):
for item in objs_all: for item in objs_all:
val = { val = {
'name': item.name, 'name': item.name,
'qty': item.product_qty,
'tool_material_status': item.tool_material_status, 'tool_material_status': item.tool_material_status,
'location': [] if not item.quant_ids else 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_search_id': item.tool_material_search_id.id,
@@ -164,6 +163,8 @@ class ToolMaterial(models.Model):
logging.info("刀具物料同步失败:%s" % e) logging.info("刀具物料同步失败:%s" % e)
class FunctionalCuttingToolEntity(models.Model): class FunctionalCuttingToolEntity(models.Model):
_inherit = 'sf.functional.cutting.tool.entity' _inherit = 'sf.functional.cutting.tool.entity'
_description = '功能刀具列表注册' _description = '功能刀具列表注册'
@@ -234,7 +235,8 @@ class FunctionalCuttingToolEntity(models.Model):
'blade_tip_characteristics_name': item.blade_tip_characteristics_id.name, 'blade_tip_characteristics_name': item.blade_tip_characteristics_id.name,
'handle_type_name': item.handle_type_id.name, 'handle_type_name': item.handle_type_id.name,
'cutting_direction_names': get_cutting_direction_names(item), 'cutting_direction_names': get_cutting_direction_names(item),
'suitable_coolant_names': get_suitable_coolant_names(item) 'suitable_coolant_names': get_suitable_coolant_names(item),
'active': item.active,
} }
functional_tool_list.append(val) functional_tool_list.append(val)
kw = json.dumps(functional_tool_list, ensure_ascii=False) kw = json.dumps(functional_tool_list, ensure_ascii=False)
@@ -249,6 +251,8 @@ class FunctionalCuttingToolEntity(models.Model):
logging.info("功能刀具同步失败:%s" % e) logging.info("功能刀具同步失败:%s" % e)
class FunctionalToolWarning(models.Model): class FunctionalToolWarning(models.Model):
_inherit = 'sf.functional.tool.warning' _inherit = 'sf.functional.tool.warning'
_description = '功能刀具预警注册' _description = '功能刀具预警注册'

View File

@@ -3,7 +3,6 @@ import requests
import logging import logging
from odoo import models, api, fields from odoo import models, api, fields
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
from datetime import datetime, timedelta
from odoo.addons.sf_base.commons.common import Common from odoo.addons.sf_base.commons.common import Common
@@ -45,7 +44,6 @@ class SfMaintenanceEquipment(models.Model):
# ==========机床当前刀库实时信息接口========== # ==========机床当前刀库实时信息接口==========
def register_equipment_tool(self): def register_equipment_tool(self):
try:
config = self.env['res.config.settings'].get_values() config = self.env['res.config.settings'].get_values()
# token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A] # token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A]
headers = {'Authorization': config['center_control_Authorization']} headers = {'Authorization': config['center_control_Authorization']}
@@ -60,11 +58,8 @@ class SfMaintenanceEquipment(models.Model):
return "机床当前刀库实时信息指令发送成功" return "机床当前刀库实时信息指令发送成功"
else: else:
raise ValidationError("机床当前刀库实时信息指令发送失败") raise ValidationError("机床当前刀库实时信息指令发送失败")
except Exception as e:
logging.info("register_equipment_tool()捕获错误信息:%s" % e)
def write_maintenance_equipment_tool(self, datas): def write_maintenance_equipment_tool(self, datas):
try:
if datas: if datas:
# 清除设备机床刀位的刀具信息 # 清除设备机床刀位的刀具信息
for obj in self.product_template_ids: for obj in self.product_template_ids:
@@ -81,8 +76,6 @@ class SfMaintenanceEquipment(models.Model):
functional_tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search( functional_tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search(
[('rfid', '=', data['RfidCode'])]) [('rfid', '=', data['RfidCode'])])
if functional_tool_id: if functional_tool_id:
if len(functional_tool_id) > 1:
functional_tool_id = functional_tool_id[-1]
# 查询该功能刀具是否已经装在机床内其他位置,如果是就删除 # 查询该功能刀具是否已经装在机床内其他位置,如果是就删除
equipment_tools = self.env['maintenance.equipment.tool'].sudo().search( equipment_tools = self.env['maintenance.equipment.tool'].sudo().search(
[('functional_tool_name_id', '=', functional_tool_id.id), ('code', '!=', tool_id)]) [('functional_tool_name_id', '=', functional_tool_id.id), ('code', '!=', tool_id)])
@@ -102,10 +95,10 @@ class SfMaintenanceEquipment(models.Model):
tool_install_time = {'Nomal': '正常', 'Warning': '报警'} tool_install_time = {'Nomal': '正常', 'Warning': '报警'}
equipment_tool_id.write({ equipment_tool_id.write({
'functional_tool_name_id': functional_tool_id.id, 'functional_tool_name_id': functional_tool_id.id,
'tool_install_time': time - timedelta(hours=8) 'tool_install_time': time
}) })
if functional_tool_id.current_location != '机内刀库': if functional_tool_id.current_location_id.name != '制造前':
# 对功能刀具进行移动到生产线 # 对功能刀具进行出库到生产线
functional_tool_id.tool_inventory_displacement_out() functional_tool_id.tool_inventory_displacement_out()
functional_tool_id.write({ functional_tool_id.write({
'max_lifetime_value': data['MaxLife'], 'max_lifetime_value': data['MaxLife'],
@@ -113,11 +106,9 @@ class SfMaintenanceEquipment(models.Model):
'functional_tool_status': tool_install_time.get(data['State']) 'functional_tool_status': tool_install_time.get(data['State'])
}) })
else: else:
logging.info('获取的【%s】设备不存在!!!' % data['DeviceId']) raise ValidationError('获取的【%s】设备不存在!!!' % data['DeviceId'])
else: else:
logging.info('没有获取到【%s】设备的刀具库信息!!!' % self.name) raise ValidationError('没有获取到刀具库信息!!!')
except Exception as e:
logging.info("write_maintenance_equipment_tool()捕获错误信息:%s" % e)
class StockLot(models.Model): class StockLot(models.Model):
@@ -143,6 +134,9 @@ class StockLot(models.Model):
record.tool_material_status = '报废' record.tool_material_status = '报废'
else: else:
record.tool_material_status = '未入库' record.tool_material_status = '未入库'
if record.fixture_material_search_id:
# 注册夹具物料状态到cloud平台
record.enroll_fixture_material_stock()
@api.model @api.model
def name_search(self, name='', args=None, operator='ilike', limit=100): def name_search(self, name='', args=None, operator='ilike', limit=100):

View File

@@ -1,23 +0,0 @@
from odoo import api, fields, models, _
class ShelfLocation(models.Model):
_inherit = 'sf.shelf.location'
tool_rfid = fields.Char('Rfid', compute='_compute_tool', store=True)
tool_name_id = fields.Many2one('sf.functional.cutting.tool.entity', string='功能刀具名称', compute='_compute_tool',
store=True)
@api.depends('product_id')
def _compute_tool(self):
for item in self:
if item.product_id:
if item.product_id.categ_id.name == '功能刀具':
tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search(
[('barcode_id', '=', item.product_sn_id.id)])
if tool_id:
item.tool_rfid = tool_id.rfid
item.tool_name_id = tool_id.id
continue
item.tool_rfid = ''
item.tool_name_id = False

View File

@@ -25,8 +25,7 @@ class ToolMaterial(models.Model):
have_been_used_num = fields.Integer('在用数量', compute='_compute_number', store=True) have_been_used_num = fields.Integer('在用数量', compute='_compute_number', store=True)
scrap_num = fields.Integer('报废数量', compute='_compute_number', store=True) scrap_num = fields.Integer('报废数量', compute='_compute_number', store=True)
barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True, barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True)
domain=[('tool_material_status', '!=', '未入库')])
@api.depends('product_id.stock_quant_ids.quantity') @api.depends('product_id.stock_quant_ids.quantity')
def _compute_number(self): def _compute_number(self):
@@ -47,6 +46,8 @@ class ToolMaterial(models.Model):
record.scrap_num = scrap_num record.scrap_num = scrap_num
record.number = usable_num + have_been_used_num + scrap_num record.number = usable_num + have_been_used_num + scrap_num
@api.model @api.model
def _read_group_cutting_tool_material_id(self, categories, domain, order): def _read_group_cutting_tool_material_id(self, categories, domain, order):
cutting_tool_material_id = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) cutting_tool_material_id = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)

View File

@@ -29,7 +29,6 @@
<field name="current_location" string="当前位置"/> <field name="current_location" string="当前位置"/>
<field name="current_location_id" invisible="1"/> <field name="current_location_id" invisible="1"/>
<field name="current_location" optional="hide"/>
<field name="sf_cutting_tool_type_id" invisible="True"/> <field name="sf_cutting_tool_type_id" invisible="True"/>
</tree> </tree>
</field> </field>
@@ -174,10 +173,7 @@
<field name="cut_time" attrs="{'invisible': [('new_former','=','0')]}"/> <field name="cut_time" attrs="{'invisible': [('new_former','=','0')]}"/>
<field name="cut_length" attrs="{'invisible': [('new_former','=','0')]}"/> <field name="cut_length" attrs="{'invisible': [('new_former','=','0')]}"/>
<field name="cut_number" attrs="{'invisible': [('new_former','=','0')]}"/> <field name="cut_number" attrs="{'invisible': [('new_former','=','0')]}"/>
<field name="current_location_id" string="当前位置"/>
<field name="current_location" string="当前位置"/> <field name="current_location" string="当前位置"/>
<field name="current_shelf_location_id" string="当前货位"
attrs="{'invisible': [('current_shelf_location_id', '=', False)]}"/>
</group> </group>
</group> </group>
</page> </page>
@@ -193,7 +189,6 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<search> <search>
<field name="rfid"/> <field name="rfid"/>
<field name="barcode_id"/>
<field name="tool_name_id"/> <field name="tool_name_id"/>
<field name="functional_tool_diameter"/> <field name="functional_tool_diameter"/>
<field name="knife_tip_r_angle"/> <field name="knife_tip_r_angle"/>
@@ -209,8 +204,8 @@
domain="[('functional_tool_status', '!=', '已拆除')]"/> domain="[('functional_tool_status', '!=', '已拆除')]"/>
<filter string="已拆除" name="state_removed" domain="[('functional_tool_status', '=', '已拆除')]"/> <filter string="已拆除" name="state_removed" domain="[('functional_tool_status', '=', '已拆除')]"/>
<searchpanel> <searchpanel>
<field name="current_location" icon="fa-building" enable_counters="1"/>
<field name="functional_tool_status" icon="fa-building" enable_counters="1"/> <field name="functional_tool_status" icon="fa-building" enable_counters="1"/>
<field name="current_location" icon="fa-building" enable_counters="1"/>
<field name="sf_cutting_tool_type_id" icon="fa-building" enable_counters="1"/> <field name="sf_cutting_tool_type_id" icon="fa-building" enable_counters="1"/>
</searchpanel> </searchpanel>
<group expand="0"> <group expand="0">
@@ -477,8 +472,7 @@
<field name="name">功能刀具出入库记录</field> <field name="name">功能刀具出入库记录</field>
<field name="model">stock.move.line</field> <field name="model">stock.move.line</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="功能刀具出入库记录" create="0" edit="0" delete="0" default_order="id desc" <tree string="功能刀具出入库记录" create="0" edit="0" delete="0">
action="action_open_reference1" type="object">
<field name="reference" string="单据号"/> <field name="reference" string="单据号"/>
<field name="lot_id" invisible="1"/> <field name="lot_id" invisible="1"/>
<field name="rfid"/> <field name="rfid"/>
@@ -488,9 +482,7 @@
<field name="knife_tip_r_angle"/> <field name="knife_tip_r_angle"/>
<field name="install_tool_time"/> <field name="install_tool_time"/>
<field name="location_id"/> <field name="location_id"/>
<field name="current_location_id"/>
<field name="location_dest_id"/> <field name="location_dest_id"/>
<field name="destination_location_id"/>
<field name="date"/> <field name="date"/>
<field name="qty_done" string="数量"/> <field name="qty_done" string="数量"/>
<field name="functional_tool_type_id" invisible="True"/> <field name="functional_tool_type_id" invisible="True"/>
@@ -505,20 +497,21 @@
<field name="model">stock.move.line</field> <field name="model">stock.move.line</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<search> <search>
<field name="reference"/>
<field name="lot_id"/>
<field name="rfid"/> <field name="rfid"/>
<field name="functional_tool_name"/> <field name="functional_tool_name"/>
<field name="diameter"/> <field name="diameter"/>
<field name="knife_tip_r_angle"/> <field name="knife_tip_r_angle"/>
<field name="reference"/> <field name="install_tool_time"/>
<field name="lot_id"/> <field name="location_id"/>
<field name="location_dest_id"/>
<field name="date"/>
<field name="qty_done"/>
<field name="functional_tool_type_id" invisible="True"/>
<searchpanel> <searchpanel>
<field name="functional_tool_type_id" enable_counters="1" icon="fa-building"/> <field name="functional_tool_type_id" enable_counters="1" icon="fa-building"/>
</searchpanel> </searchpanel>
<group expand="0">
<filter string="功能刀具名称" name="functional_tool_name" domain="[]"
context="{'group_by': 'functional_tool_name'}"/>
<filter string="日期" name="date" domain="[]" context="{'group_by': 'date'}"/>
</group>
</search> </search>
</field> </field>
</record> </record>
@@ -532,7 +525,7 @@
ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_tree"/> ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_tree"/>
<field name="search_view_id" <field name="search_view_id"
ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_search"/> ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_search"/>
<field name="domain">[('rfid', '!=', ''),('functional_tool_name', '!=', '')]</field> <field name="domain">[('functional_tool_name_id', '!=', False)]</field>
</record> </record>
</data> </data>

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_shelf_location_tool" model="ir.ui.view">
<field name="name">sf.shelf.location.form.tool</field>
<field name="model">sf.shelf.location</field>
<field name="inherit_id" ref="sf_warehouse.view_shelf_location_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='product_id']" position="after">
<field name="tool_rfid" attrs="{'invisible': [('tool_name_id', '=', False)]}"/>
<field name="tool_name_id" attrs="{'invisible': [('tool_name_id', '=', False)]}"/>
</xpath>
</field>
</record>
</odoo>

View File

@@ -62,8 +62,6 @@
<tree> <tree>
<field name="name"/> <field name="name"/>
<field name="rfid"/> <field name="rfid"/>
<field name="product_qty"/>
<field name="create_date" string="入库日期"/>
<field name="tool_material_status"/> <field name="tool_material_status"/>
<!-- <button name="enroll_tool_material_stock" string="序列号注册" type="object" class="btn-primary"/>--> <!-- <button name="enroll_tool_material_stock" string="序列号注册" type="object" class="btn-primary"/>-->
</tree> </tree>

View File

@@ -854,10 +854,10 @@ class ProductProduct(models.Model):
'company_id': self.env.company.id 'company_id': self.env.company.id
}) })
# 获取位置对象 # 获取位置对象
location_inventory_ids = self.env['stock.location'].search([('name', 'in', ('Production', '生产'))]) location_inventory_id = self.env['stock.location'].search([('name', '=', 'Production')])
stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')]) stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')])
# 创建功能刀具该批次/序列号 库存移动和移动历史 # 创建功能刀具该批次/序列号 库存移动和移动历史
stock_lot.create_stock_quant(location_inventory_ids[-1], stock_location_id, functional_tool_assembly.id, stock_lot.create_stock_quant(location_inventory_id, stock_location_id, functional_tool_assembly.id,
obj.assembly_order_code, obj, obj.after_tool_groups_id) obj.assembly_order_code, obj, obj.after_tool_groups_id)
return stock_lot return stock_lot

View File

@@ -416,19 +416,19 @@ class ShelfLocation(models.Model):
host = printer_config.printer_id.ip_address host = printer_config.printer_id.ip_address
port = printer_config.printer_id.port port = printer_config.printer_id.port
self.print_qr_code(barcode, host, port) self.print_qr_code(barcode, host, port)
# 获取当前wizard的视图ID或其他标识信息 # # 获取当前wizard的视图ID或其他标识信息
view_id = self.env.context.get('view_id') # view_id = self.env.context.get('view_id')
# 构造返回wizard页面的action字典 # # 构造返回wizard页面的action字典
action = { # action = {
'type': 'ir.actions.act_window', # 'type': 'ir.actions.act_window',
'name': '返回 Wizard', # 'name': '返回 Wizard',
'res_model': 'sf.shelf', # 替换为你的wizard模型名称 # 'res_model': 'sf.shelf', # 替换为你的wizard模型名称
'view_mode': 'form', # 'view_mode': 'form',
'view_id': view_id, # 如果需要基于特定的视图返回 # 'view_id': view_id, # 如果需要基于特定的视图返回
'target': 'new', # 如果需要在新的窗口或标签页打开 # 'target': 'new', # 如果需要在新的窗口或标签页打开
'res_id': self.shelf_id, # 如果你想要返回当前记录的视图 # 'res_id': self.shelf_id, # 如果你想要返回当前记录的视图
} # }
return action # return action
# # 仓库类别selection库区、库位、货位 # # 仓库类别selection库区、库位、货位
# location_type = fields.Selection([ # location_type = fields.Selection([
@@ -557,10 +557,8 @@ class SfStockMoveLine(models.Model):
_name = 'stock.move.line' _name = 'stock.move.line'
_inherit = ['stock.move.line', 'printing.utils'] _inherit = ['stock.move.line', 'printing.utils']
stock_lot_name = fields.Char('序列号名称', related='lot_id.name')
current_location_id = fields.Many2one( current_location_id = fields.Many2one(
'sf.shelf.location', string='当前货位', compute='_compute_current_location_id', store=True, readonly=False, 'sf.shelf.location', string='当前货位', compute='_compute_current_location_id', store=True)
domain="[('product_id', '=', product_id),'|',('product_sn_id.name', '=', stock_lot_name),('product_sn_ids.lot_id.name','=',stock_lot_name)]")
# location_dest_id = fields.Many2one('stock.location', string='目标库位') # location_dest_id = fields.Many2one('stock.location', string='目标库位')
location_dest_id_product_type = fields.Many2many(related='location_dest_id.product_type') location_dest_id_product_type = fields.Many2many(related='location_dest_id.product_type')
location_dest_id_value = fields.Integer(compute='_compute_location_dest_id_value', store=True) location_dest_id_value = fields.Integer(compute='_compute_location_dest_id_value', store=True)
@@ -624,11 +622,6 @@ class SfStockMoveLine(models.Model):
if not qr_code_data: if not qr_code_data:
raise UserError("没有找到二维码数据。") raise UserError("没有找到二维码数据。")
lot_name = self.lot_name lot_name = self.lot_name
# 增加"当为坯料时,只打印序列号的前面部分"
if self.lot_name: # 确保 lot_name 存在
if self.product_id.categ_id.name == '坯料':
lot_name = lot_name.split('[', 1)[0]
# host = "192.168.50.110" # 可以根据实际情况修改 # host = "192.168.50.110" # 可以根据实际情况修改
# port = 9100 # 可以根据实际情况修改 # port = 9100 # 可以根据实际情况修改
@@ -858,9 +851,7 @@ class SfStockMoveLine(models.Model):
def compute_destination_location_id(self): def compute_destination_location_id(self):
for record in self: for record in self:
obj = self.env['sf.shelf.location'].search([('name', '=', obj = self.env['sf.shelf.location'].search([('name', '=',
record.destination_location_id.name)]) self.destination_location_id.name)])
if obj and obj.product_id and obj.product_id != record.product_id:
raise ValidationError('目标货位【%s】已被【%s】产品占用!' % (obj.code, obj.product_id))
if record.lot_id: if record.lot_id:
if record.product_id.tracking == 'serial': if record.product_id.tracking == 'serial':
shelf_location_obj = self.env['sf.shelf.location'].search( shelf_location_obj = self.env['sf.shelf.location'].search(
@@ -873,7 +864,7 @@ class SfStockMoveLine(models.Model):
if obj: if obj:
obj.product_sn_id = record.lot_id.id obj.product_sn_id = record.lot_id.id
elif record.product_id.tracking == 'lot': elif record.product_id.tracking == 'lot':
record.put_shelf_location(record) self.put_shelf_location(record)
if not obj.product_id: if not obj.product_id:
obj.product_id = record.product_id.id obj.product_id = record.product_id.id
else: else:
@@ -984,26 +975,15 @@ class SfStockPicking(models.Model):
# 调用入库方法进行入库刀货位 # 调用入库方法进行入库刀货位
line.compute_destination_location_id() line.compute_destination_location_id()
else: else:
# 对除刀柄之外的刀具物料入库到刀具房进行 目标货位必填校验 # 对除刀柄之外的刀具物料进行 目标货位必填校验
if self.location_dest_id.name == '刀具房' and line.product_id.cutting_tool_material_id.name not in ( if self.location_dest_id.name == '刀具房' and line.product_id.cutting_tool_material_id.name not in (
'刀柄', False): '刀柄', False):
raise ValidationError('请选择【%s】产品的目标货位!' % line.product_id.name) raise ValidationError('请选择【%s】产品的目标货位!' % line.product_id.name)
if line.current_location_id: if line.current_location_id:
# 对货位的批次产品进行出货
line.put_shelf_location(line)
if line.current_location_id:
# 按序列号管理的产品
if line.current_location_id.product_sn_id: if line.current_location_id.product_sn_id:
line.current_location_id.product_sn_id = False line.current_location_id.product_sn_id = False
# line.current_location_id.location_status = '空闲' # line.current_location_id.location_status = '空闲'
line.current_location_id.product_num = 0 line.current_location_id.product_num = 0
line.current_location_id.product_id = False
else:
# 对除刀柄之外的刀具物料从刀具房出库进行 当前货位必填校验
if self.location_id.name == '刀具房' and line.product_id.cutting_tool_material_id.name not in (
'刀柄', False):
raise ValidationError('请选择【%s】产品的当前货位!' % line.product_id.name)
# 对入库作业的刀柄和托盘进行Rfid绑定校验 # 对入库作业的刀柄和托盘进行Rfid绑定校验
for move in self.move_ids: for move in self.move_ids:
@@ -1130,7 +1110,6 @@ class CustomStockMove(models.Model):
采购入库扫码绑定Rfid码 采购入库扫码绑定Rfid码
""" """
for record in self: for record in self:
logging.info('Rfid%s' % barcode)
if record: if record:
lot = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)]) lot = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)])
if lot: if lot:
@@ -1142,9 +1121,7 @@ class CustomStockMove(models.Model):
'该Rfid【%s】已经被序列号为【%s】的【%s】物料所占用!' % (barcode, lot.name, material)) '该Rfid【%s】已经被序列号为【%s】的【%s】物料所占用!' % (barcode, lot.name, material))
if '刀柄' in (record.product_id.cutting_tool_material_id.name or '') or '托盘' in ( if '刀柄' in (record.product_id.cutting_tool_material_id.name or '') or '托盘' in (
record.product_id.fixture_material_id.name or ''): record.product_id.fixture_material_id.name or ''):
logging.info('开始录入Rfid:%s' % record.move_line_nosuggest_ids)
for move_line_nosuggest_id in record.move_line_nosuggest_ids: for move_line_nosuggest_id in record.move_line_nosuggest_ids:
logging.info('录入的记录%s , Rfid:%s' % (move_line_nosuggest_id, move_line_nosuggest_id.rfid))
if move_line_nosuggest_id.rfid: if move_line_nosuggest_id.rfid:
if move_line_nosuggest_id.rfid == barcode: if move_line_nosuggest_id.rfid == barcode:
if record.product_id.cutting_tool_material_id.name: if record.product_id.cutting_tool_material_id.name:
@@ -1153,9 +1130,7 @@ class CustomStockMove(models.Model):
raise ValidationError('该托盘的Rfid已经录入请勿重复录入') raise ValidationError('该托盘的Rfid已经录入请勿重复录入')
else: else:
line_id = int(re.sub(r"\D", "", str(move_line_nosuggest_id.id))) line_id = int(re.sub(r"\D", "", str(move_line_nosuggest_id.id)))
res = self.env['stock.move.line'].sudo().search([('id', '=', line_id)]).write( self.env['stock.move.line'].sudo().search([('id', '=', line_id)]).write({'rfid': barcode})
{'rfid': barcode})
logging.info('Rfid是否录入:%s' % res)
move_line_nosuggest_id.rfid = barcode move_line_nosuggest_id.rfid = barcode
break break
else: else:
@@ -1168,10 +1143,7 @@ class CustomStockMove(models.Model):
move_lines = self.move_line_ids # 获取当前 stock.move 对应的所有 stock.move.line 记录 move_lines = self.move_line_ids # 获取当前 stock.move 对应的所有 stock.move.line 记录
for line in move_lines: for line in move_lines:
if line.lot_name: # 确保 lot_name 存在 if line.lot_name: # 确保 lot_name 存在
lot_name = line.lot_name qr_data = self.compute_lot_qr_code(line.lot_name)
if line.product_id.categ_id.name == '坯料':
lot_name = lot_name.split('[', 1)[0]
qr_data = self.compute_lot_qr_code(lot_name)
# 假设 stock.move.line 模型中有一个字段叫做 lot_qr_code 用于存储二维码数据 # 假设 stock.move.line 模型中有一个字段叫做 lot_qr_code 用于存储二维码数据
line.lot_qr_code = qr_data line.lot_qr_code = qr_data
return result return result
@@ -1209,12 +1181,6 @@ class CustomStockMove(models.Model):
# todo 待控制 # todo 待控制
if not lot_name: if not lot_name:
raise ValidationError("请先分配序列号") raise ValidationError("请先分配序列号")
# 增加"当为坯料时,只打印序列号的前面部分"
if record.lot_name: # 确保 lot_name 存在
if record.product_id.categ_id.name == '坯料':
lot_name = lot_name.split('[', 1)[0]
# host = "192.168.50.110" # 可以根据实际情况修改 # host = "192.168.50.110" # 可以根据实际情况修改
# port = 9100 # 可以根据实际情况修改 # port = 9100 # 可以根据实际情况修改

View File

@@ -95,29 +95,12 @@ class MrsShelfLocationDataSync(models.Model):
return code_pair[0] return code_pair[0]
return None # 如果没有找到对应的值返回None或适当的默认值 return None # 如果没有找到对应的值返回None或适当的默认值
# 定时更新所有设备机床刀库信息
equipment_ids = self.env['maintenance.equipment'].search(
[('equipment_type', '=', '机床'), ('function_type', '!=', False)])
for equipment_id in equipment_ids:
if equipment_id:
equipment_id.register_equipment_tool()
shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info() shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info()
print('shelfinfo:', shelfinfo) print('shelfinfo:', shelfinfo)
for item in shelfinfo: for item in shelfinfo:
shelf_barcode = find_our_code(item['Postion'], total_data) shelf_barcode = find_our_code(item['Postion'], total_data)
location_id = self.env['sf.shelf.location'].search([('barcode', '=', shelf_barcode)], limit=1) location_id = self.env['sf.shelf.location'].search([('barcode', '=', shelf_barcode)], limit=1)
if location_id: if location_id:
# 如果是线边刀库信息,则对功能刀具移动生成记录
if 'Tool' in item['Postion']:
tool = self.env['sf.functional.cutting.tool.entity'].sudo().search(
[('rfid', '=', item['RfidCode']), ('functional_tool_status', '!=', '已拆除')])
tool.tool_in_out_stock_location(location_id)
if tool:
location_id.product_sn_id = tool.barcode_id.id
else:
location_id.product_sn_id = False
else:
stock_lot_obj = self.env['stock.lot'].search([('rfid', '=', item['RfidCode'])], limit=1) stock_lot_obj = self.env['stock.lot'].search([('rfid', '=', item['RfidCode'])], limit=1)
if stock_lot_obj: if stock_lot_obj:
location_id.product_sn_id = stock_lot_obj.id location_id.product_sn_id = stock_lot_obj.id

View File

@@ -7,9 +7,7 @@
<field name="inherit_id" ref="stock.view_stock_move_line_detailed_operation_tree"/> <field name="inherit_id" ref="stock.view_stock_move_line_detailed_operation_tree"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='location_id'][2]" position="after"> <xpath expr="//field[@name='location_id'][2]" position="after">
<field name="stock_lot_name" invisible="1"/> <field name="current_location_id" force_save="1"/>
<field name="current_location_id" force_save="1"
options="{'no_create': True,'no_create_edit':True}"/>
</xpath> </xpath>
<xpath expr="//field[@name='location_dest_id'][2]" position="after"> <xpath expr="//field[@name='location_dest_id'][2]" position="after">
<field name="current_product_id" invisible="1"/> <field name="current_product_id" invisible="1"/>
@@ -57,7 +55,6 @@
<field name="inherit_id" ref="stock.view_move_line_form"/> <field name="inherit_id" ref="stock.view_move_line_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//form//sheet//group//group//field[@name='location_id']" position="after"> <xpath expr="//form//sheet//group//group//field[@name='location_id']" position="after">
<field name="stock_lot_name" invisible="1"/>
<field name="current_location_id" options="{'no_create': False}" force_save="1"/> <field name="current_location_id" options="{'no_create': False}" force_save="1"/>
</xpath> </xpath>
<xpath expr="//form//sheet//group//group//field[@name='location_dest_id']" position="after"> <xpath expr="//form//sheet//group//group//field[@name='location_dest_id']" position="after">

View File

@@ -592,23 +592,8 @@ var GanttRow = Widget.extend({
}); });
pill.decorations = pillDecorations; pill.decorations = pillDecorations;
// let isDelay = false
// if(pill.state != 'processing' && pill.state != 'finished') { // 判断待加工
// isDelay = pill.order_deadline.isBefore(new Date())
// }
pill.exState = ''
if (self.colorField) { if (self.colorField) {
// console.log(self.colorField, self, pill, '颜色') pill._color = self._getColor(pill[self.colorField]);
// pill._color = self._getColor(pill[self.colorField]);
// 设置pill背景颜色2 修改时间2024年6月25日17:09:43
let isDelay = false
if(pill.state != 'processing' && pill.state != 'finished') { // 判断待加工
isDelay = pill.order_deadline.isBefore(new Date())
}
if(isDelay) {
pill.disableDragdrop = true
}
pill._color = self._getColor2(isDelay ? 'delay' : pill.state);
} }
if (self.progressField) { if (self.progressField) {
@@ -628,13 +613,6 @@ var GanttRow = Widget.extend({
} }
return 0; return 0;
}, },
_getColor2 (state) {
return {
'finished': 'ccc',
'delay': 9,
'processing': 13 // 绿色
}[state]
},
/** /**
* Get context to evaluate decoration * Get context to evaluate decoration
* *
@@ -889,11 +867,10 @@ var GanttRow = Widget.extend({
if ($pill.hasClass('ui-draggable-dragging')) { if ($pill.hasClass('ui-draggable-dragging')) {
return; return;
} }
var self = this; var self = this;
var pill = _.findWhere(this.pills, { id: $pill.data('id') }); var pill = _.findWhere(this.pills, { id: $pill.data('id') });
if(pill.state == 'finished'){ // 已完成状态不能拖拽
return;
}
// DRAGGABLE // DRAGGABLE
if (this.options.canEdit && !pill.disableStartResize && !pill.disableStopResize && !this.isGroup) { if (this.options.canEdit && !pill.disableStartResize && !pill.disableStopResize && !this.isGroup) {

View File

@@ -754,7 +754,3 @@
left: -0.5 * $o-connector-creator-bullet-diameter; left: -0.5 * $o-connector-creator-bullet-diameter;
} }
} }
.o_gantt_view .o_gantt_row_nogroup .o_gantt_pill.o_gantt_color_ccc {
background-color: #ccc;
}