Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化制造功能

This commit is contained in:
mgw
2024-09-19 09:04:20 +08:00
23 changed files with 180 additions and 67 deletions

View File

@@ -38,8 +38,7 @@ class SfMaintenanceEquipment(models.Model):
crea_url = "/api/machine_tool/create"
#AGV运行日志
# AGV运行日志
agv_logs = fields.One2many('maintenance.equipment.agv.log', 'equipment_id', string='AGV运行日志')
# 1212修改后的字段
number_of_axles = fields.Selection(
@@ -117,7 +116,6 @@ class SfMaintenanceEquipment(models.Model):
# num = "%04d" % m
# return num
equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards',
'sf_maintenance_equipment_ids', string='设备维保标准')
eq_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备保养标准',
@@ -179,7 +177,8 @@ class SfMaintenanceEquipment(models.Model):
type_id = fields.Many2one('sf.machine_tool.type', '型号')
state = fields.Selection(
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"), ("封存(报废)", "封存(报废)")],
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"),
("封存(报废)", "封存(报废)")],
default='正常', string="机床状态")
run_time = fields.Char('总运行时长')
# 0606新增字段
@@ -328,7 +327,7 @@ class SfMaintenanceEquipment(models.Model):
item.tool_diameter_min = item.type_id.tool_diameter_min
item.machine_tool_category = item.type_id.machine_tool_category.id
item.brand_id = item.type_id.brand_id.id
#新增修改字段
# 新增修改字段
item.taper_type_id = item.type_id.taper_type_id.id
item.function_type = item.type_id.function_type
item.a_axis = item.type_id.a_axis
@@ -370,7 +369,6 @@ class SfMaintenanceEquipment(models.Model):
item.image_id = item.type_id.jg_image_id.ids
item.image_lq_id = item.type_id.lq_image_id.ids
# AGV小车设备参数
AGV_L = fields.Char('AGV尺寸(长)')
AGV_W = fields.Char('AGV尺寸(宽)')
@@ -461,18 +459,6 @@ class SfMaintenanceEquipment(models.Model):
original_value = fields.Char('原值')
incomplete_value = fields.Char('残值')
# 注册同步机床
def enroll_machine_tool(self):
sf_sync_config = self.env['res.config.settings'].get_values()
@@ -763,7 +749,7 @@ class SfMaintenanceEquipment(models.Model):
image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id',
domain="[('type', '=', '加工能力')]")
image_lq_id = fields.Many2many('maintenance.equipment.image', 'equipment_lq_id', string='冷却方式',
domain="[('type', '=', '冷却方式')]")
domain="[('type', '=', '冷却方式')]")
class SfRobotAxisNum(models.Model):
@@ -777,4 +763,5 @@ class SfRobotAxisNum(models.Model):
weight = fields.Char('最大负载(kg)')
permissible_load_torque = fields.Char('允许负载扭矩(N-m)')
permissible_inertial_torque = fields.Char('允许惯性扭矩(kg-m²)')
equipment_id = fields.Many2one('maintenance.equipment', string='机器人', domain="[('equipment_type', '=', '机器人')]")
equipment_id = fields.Many2one('maintenance.equipment', string='机器人',
domain="[('equipment_type', '=', '机器人')]")

View File

@@ -806,6 +806,10 @@ class MrpProduction(models.Model):
backorders = backorders - productions_to_backorder
productions_not_to_backorder._post_inventory(cancel_backorder=True)
# if self.workorder_ids.filtered(lambda w: w.routing_type in ['表面工艺']):
# move_finish = self.env['stock.move'].search([('created_production_id', '=', self.id)])
# if move_finish:
# move_finish._action_assign()
productions_to_backorder._post_inventory(cancel_backorder=True)
# if completed products make other confirmed/partially_available moves available, assign them

View File

@@ -179,18 +179,14 @@ class WorkpieceDeliveryWizard(models.TransientModel):
self.feeder_station_destination_id = self.route_id.end_site_id.id
def on_barcode_scanned(self, barcode):
delivery_type = self.env.context.get('default_delivery_type')
# 判断barcode是否是数字
if not barcode.isdigit():
# 判断是否是AGV接驳站名称
agv_site = self.env['sf.agv.site'].search([('name', '=', barcode)])
if agv_site:
if not self.feeder_station_start_id:
self.feeder_station_start_id = agv_site.id
else:
if self.feeder_station_start_id.id != agv_site.id:
raise UserError('起点接驳站不匹配!')
self.feeder_station_start_id = agv_site.id # 修正:移除 .id
return
delivery_type = self.env.context.get('default_delivery_type')
if delivery_type == '上产线':
workorder = self.env['mrp.workorder'].search(
[('production_line_state', '=', '待上产线'), ('rfid_code', '=', barcode),
@@ -214,7 +210,7 @@ class WorkpieceDeliveryWizard(models.TransientModel):
self.production_ids |= workorder.production_id
self.workorder_ids |= workorder
down_product_agv_scheduling = self.get_down_product_agv_scheduling()
down_product_agv_scheduling = workorder.get_down_product_agv_scheduling()
if down_product_agv_scheduling:
if not self.feeder_station_start_id:
self.feeder_station_start_id = down_product_agv_scheduling.end_site_id.id
@@ -226,4 +222,11 @@ class WorkpieceDeliveryWizard(models.TransientModel):
raise UserError('该rfid码对应的工单不存在')
return
@api.onchange('feeder_station_start_id')
def on_start_id_change(self):
if self.delivery_type == '运送空料架' and len(self.workorder_ids) > 0:
down_product_agv_scheduling = self.workorder_ids[0].get_down_product_agv_scheduling()
if down_product_agv_scheduling and self.feeder_station_start_id \
and down_product_agv_scheduling.end_site_id.id != self.feeder_station_start_id.id:
raise UserError('当前接驳站不匹配!')

View File

@@ -11,7 +11,7 @@
""",
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
'depends': ['base', 'sf_base'],
'depends': ['base', 'sf_plan', 'sf_sale'],
'data': [
'security/ir.model.access.csv',
'views/sf_message_template_view.xml',

View File

@@ -1 +1,8 @@
from . import sf_message_template
from . import sf_message_sale
from . import sf_message_plan
from . import sf_message_stock_picking
from . import sf_message_cam_program
from . import sf_message_functional_tool_assembly
from . import sf_message_purchase
from . import sf_message_workorder

View File

@@ -0,0 +1,6 @@
from odoo import models, fields, api, _
class SFMessageCamProgram(models.Model):
_name = 'sf.cam.work.order.program.knife.plan'
_inherit = ['sf.cam.work.order.program.knife.plan', 'sf.message.template']

View File

@@ -0,0 +1,6 @@
from odoo import models, fields, api, _
class SFMessagefunctionalToolAssembly(models.Model):
_name = 'sf.functional.tool.assembly'
_inherit = ['sf.functional.tool.assembly', 'sf.message.template']

View File

@@ -0,0 +1,6 @@
from odoo import models, fields, api, _
class SFMessagePlan(models.Model):
_name = 'sf.production.plan'
_inherit = ['sf.production.plan', 'sf.message.template']

View File

@@ -0,0 +1,6 @@
from odoo import models, fields, api, _
class SFMessagePurchase(models.Model):
_name = 'purchase.order'
_inherit = ['purchase.order', 'sf.message.template']

View File

@@ -0,0 +1,6 @@
from odoo import models, fields, api, _
class SFMessageSale(models.Model):
_name = 'sale.order'
_inherit = ['sale.order', 'sf.message.template']

View File

@@ -0,0 +1,6 @@
from odoo import models, fields, api, _
class SFMessageStockPicking(models.Model):
_name = 'stock.picking'
_inherit = ['stock.picking', 'sf.message.template']

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api
from abc import ABC, abstractmethod
class SfMessageTemplate(models.Model):
@@ -7,30 +8,30 @@ class SfMessageTemplate(models.Model):
_description = u'消息模板'
name = fields.Char(string=u"名称", required=True)
type = fields.Selection([
('待接单', '待接单'),
('待排程', '待排程'),
('坯料采购', '坯料采购'),
('坯料发料', '坯料发料'),
('待编程', '待编程'),
('调拨入库', '调拨入库'),
('功能刀具组装', '功能刀具组装'),
('功能刀具寿命到期', '功能刀具寿命到期'),
('程序用刀计划异常', '程序用刀计划异常'),
('工单无CNC程序', '工单无CNC程序'),
('生产线无功能刀具', '生产线无功能刀具'),
('工单无定位数据', '工单无定位数据'),
('工单FTP无文件', '工单FTP无文件'),
('工单加工失败', '工单加工失败'),
('设备故障及异常', '设备故障及异常'),
('工单逾期预警', '工单逾期预警'),
('工单已逾期', '工单已逾期'),
('销售订单逾期', '销售订单逾期'),
('销售订单已逾期', '销售订单已逾期'),
('待质量判定', '待质量判定'),
('生产完工待入库', '生产完工待入库'),
('订单发货', '订单发货')
], string='类型', required=True)
# type = fields.Selection([
# ('待接单', '待接单'),
# ('待排程', '待排程'),
# ('坯料采购', '坯料采购'),
# ('坯料发料', '坯料发料'),
# ('待编程', '待编程'),
# ('调拨入库', '调拨入库'),
# ('功能刀具组装', '功能刀具组装'),
# ('功能刀具寿命到期', '功能刀具寿命到期'),
# ('程序用刀计划异常', '程序用刀计划异常'),
# ('工单无CNC程序', '工单无CNC程序'),
# ('生产线无功能刀具', '生产线无功能刀具'),
# ('工单无定位数据', '工单无定位数据'),
# ('工单FTP无文件', '工单FTP无文件'),
# ('工单加工失败', '工单加工失败'),
# ('设备故障及异常', '设备故障及异常'),
# ('工单逾期预警', '工单逾期预警'),
# ('工单已逾期', '工单已逾期'),
# ('销售订单逾期', '销售订单逾期'),
# ('销售订单已逾期', '销售订单已逾期'),
# ('待质量判定', '待质量判定'),
# ('生产完工待入库', '生产完工待入库'),
# ('订单发货', '订单发货')
# ], string='类型', required=True)
description = fields.Char(string=u"描述")
content = fields.Html(string=u"内容", render_engine='qweb', translate=True, prefetch=True, sanitize=False)
msgtype = fields.Selection(
@@ -46,3 +47,9 @@ class SfMessageTemplate(models.Model):
def _clear_employee_ids(self):
if self.notification_department_id:
self.notification_employee_ids = False
@abstractmethod
def dispatch(self, args):
"""
强迫继承该类必走该抽象方法'
"""

View File

@@ -0,0 +1,6 @@
from odoo import models, fields, api, _
class SFMessageWork(models.Model):
_name = 'mrp.workorder'
_inherit = ['mrp.workorder', 'sf.message.template']

View File

@@ -18,12 +18,11 @@
</h1>
</div>
<group>
<field name="type"/>
<!-- <field name="type"/>-->
<field name="content" widget="html" class="oe-bordered-editor"
options="{'style-inline': true, 'codeview': true, 'dynamic_placeholder': true}"/>
<field name="description"/>
<field name="msgtype"/>
<field name="type"/>
<field name="notification_department_id"/>
<field name="notification_employee_ids" widget="many2many_tags"/>
</group>
@@ -38,10 +37,9 @@
<field name="arch" type="xml">
<tree string="消息模板">
<field name="name"/>
<field name="type"/>
<!-- <field name="type"/>-->
<field name="content"/>
<field name="msgtype"/>
<field name="type"/>
<field name="notification_department_id"/>
<field name="notification_employee_ids" widget="many2many_tags"/>
<field name="description"/>
@@ -55,7 +53,7 @@
<field name="arch" type="xml">
<search>
<field name="name" string="模糊搜索"
filter_domain="['|','|',('name','like',self),('type','like',self),('description','like',self)]"/>
filter_domain="['|','|',('name','like',self),('description','like',self)]"/>
<field name="name"/>
<filter name="filter_active" string="已归档" domain="[('active','=',False)]"/>
</search>

View File

@@ -10,11 +10,12 @@
""",
'category': 'sf',
'website': 'https://www.sf.cs.jikimo.com',
'depends': ['sf_base', 'base_setup'],
'depends': ['sf_base', 'base_setup','sf_bf_connect'],
'data': [
'data/ir_cron_data.xml',
'security/ir.model.access.csv',
'views/res_config_settings_views.xml'
'views/res_config_settings_views.xml',
'views/order_price.xml',
],
'demo': [
],

View File

@@ -1,3 +1,4 @@
from . import ftp_operate
from . import res_config_setting
from . import sync_common
from . import order_price

View File

@@ -0,0 +1,29 @@
from odoo import fields, models, api
class OrderPrice(models.Model):
_name = 'order.price'
_description = '订单价格对比'
sale_order_id = fields.Many2one('sale.order', '销售订单')
bfm_order_name = fields.Char(related="sale_order_id.default_code", string='bfm订单号')
sale_order_name = fields.Char(related="sale_order_id.name", string='销售订单号')
currency_id = fields.Many2one(
related='sale_order_id.currency_id', string='货币', store=True)
sale_order_amount_total = fields.Monetary(related="sale_order_id.amount_total", tracking=4, string='销售订单金额')
bfm_amount_total = fields.Float(string='价格合计', compute='_compute_bfm_amount_total', store=True)
def is_float(self,value):
try:
float(value)
return True
except ValueError:
return False
@api.depends('sale_order_id.remark')
def _compute_bfm_amount_total(self):
for record in self:
amount_total = 0
for line in record.sale_order_id.order_line:
# 判断remark是否存在并且是否是数字
if line.remark and self.is_float(line.remark):
amount_total += float(line.remark)
record.bfm_amount_total = amount_total

View File

@@ -184,7 +184,10 @@ class ResConfigSettings(models.TransientModel):
new_price = res_order_lines_map.get(str(index))
if order_line:
# 修改单价
order_line.write({'remark': new_price})
order_line.write({'remark': new_price*order_line.product_uom_qty})
order_price = self.env['order.price'].sudo().search([('sale_order_id', '=',need_change_sale_order.id )])
if not order_price:
self.env['order.price'].sudo().create({'sale_order_id':need_change_sale_order.id})
else:
logging.error('同步销售订单价格失败 {}'.format(response.text))
raise UserError('同步销售订单价格失败')

View File

@@ -1,7 +1,7 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sf_static_resource_datasync,sf_static_resource_datasync,model_sf_static_resource_datasync,base.group_user,1,1,1,1
access_order_price,order.price,model_order_price,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_sf_static_resource_datasync sf_static_resource_datasync model_sf_static_resource_datasync base.group_user 1 1 1 1
3 access_order_price order.price model_order_price base.group_user 1 1 1 1
4
5
6
7

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem sequence="22" name="销售订单bfm对比" id="menu_sale_order_bfm_price"
action="order_price_tree_act"
parent="sale.sale_order_menu"
groups="base.group_user"
/>
<record model="ir.actions.act_window" id="order_price_tree_act">
<field name="name">bfm订单价格对比</field>
<field name="res_model">order.price</field>
<field name="view_mode">tree,form</field>
</record>
<record id="view_order_price_tree" model="ir.ui.view">
<field name="name">order.price.list</field>
<field name="model">order.price</field>
<field name="arch" type="xml">
<tree string="订单计划">
<field name="bfm_order_name"/>
<field name="sale_order_name"/>
<field name="sale_order_amount_total"/>
<field name="bfm_amount_total"/>
</tree>
</field>
</record>
</odoo>

View File

@@ -75,16 +75,21 @@ class sf_production_plan(models.Model):
if self.date_planned_start:
self.date_planned_finished = self.date_planned_start + timedelta(hours=1)
#处理计划状态非排程,计划结束时间为空的数据处理
#处理计划状态非排程,计划结束时间为空的数据处理
def deal_no_date_planned_finished(self):
plans = self.env['sf.production.plan'].search(
[('date_planned_finished', '=', False), ('state', 'in', ['processing', 'done', 'finished'])])
for item in plans:
if item.date_planned_start:
item.date_planned_finished = item.date_planned_start + timedelta(hours=1)
if not item.order_deadline and item.date_planned_start:
item.order_deadline = item.date_planned_start + timedelta(days=7)
# 处理计划订单截止时间为空的数据
def deal_no_order_deadline(self):
plans = self.env['sf.production.plan'].sudo().search(
[('order_deadline', '=', False)])
for item in plans:
if item.date_planned_start:
item.order_deadline = item.date_planned_start + timedelta(days=7)
@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):

View File

@@ -3,4 +3,4 @@ from odoo import models, fields
class SyncFunctionalCuttingToolModel(models.Model):
_inherit = 'sf.functional.cutting.tool.model'
cutting_tool_type_ids = fields.Many2many('sf.cutting.tool.type', string='适用刀具物料类型', required=True)
cutting_tool_type_ids = fields.Many2many('sf.cutting.tool.type', string='适用刀具物料类型')

View File

@@ -8,7 +8,7 @@
<field name="inherit_id" ref="sf_base.view_cutter_function_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="cutting_tool_type_ids" widget="many2many_tags"/>
<field name="cutting_tool_type_ids" widget="many2many_tags" options="{'no_create': True}"/>
</xpath>
</field>
</record>