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

This commit is contained in:
mgw
2024-09-27 09:20:36 +08:00
16 changed files with 124 additions and 60 deletions

View File

@@ -6,6 +6,6 @@ import { patch } from "web.utils";
patch(WebClient.prototype, "kolpolok_custom_title_and_favicon.WebClient", {
setup() {
this._super();
this.title.setParts({ zopenerp: "JIKIMO" });
// this.title.setParts({ zopenerp: "JIKIMO" });
},
});

View File

@@ -321,7 +321,7 @@ class ToolInventory(models.Model):
prefix = fields.Char('前缀')
postfix = fields.Char('后缀')
diameter = fields.Float('直径(mm)')
angle = fields.Float('R角(mm)')
angle = fields.Float('R角(mm)',default=0)
tool_length = fields.Float('刀具总长(mm)')
blade_length = fields.Float('避空长/刃长(mm)')
knife_head_name = fields.Char('刀头名称')

View File

@@ -23,7 +23,7 @@ class ToolMaterialsBasicParameters(models.Model):
handle_length = fields.Float('柄部长度(mm)')
blade_tip_diameter = fields.Float('刀尖直径(mm)')
blade_tip_working_size = fields.Char('刀尖倒角度(°)', size=20)
tip_r_size = fields.Float('刀尖R角(mm)')
tip_r_size = fields.Float('刀尖R角(mm)',default=0)
blade_tip_taper = fields.Integer('刀尖锥度(°)')
blade_diameter = fields.Float('刃部直径(mm)')
blade_length = fields.Float('刃部长度(mm)')
@@ -38,7 +38,7 @@ class ToolMaterialsBasicParameters(models.Model):
width = fields.Float('宽度(mm)')
cutting_blade_length = fields.Float('切削刃长(mm)')
relief_angle = fields.Integer('后角(°)')
blade_tip_circular_arc_radius = fields.Char('刀尖圆弧半径(mm)', size=20)
blade_tip_circular_arc_radius = fields.Char('刀尖圆弧半径(mm)', size=20,default='0')
inscribed_circle_diameter = fields.Float('内接圆直径IC/D(mm)')
install_aperture_diameter = fields.Float('安装孔直径(mm)')
chip_breaker_groove = fields.Selection([('', ''), ('单面', '单面'), ('双面', '双面')],

View File

@@ -11,7 +11,6 @@
'data': [
'views/hr_employee.xml',
'views/res_config_settings_views.xml',
'views/res_users_view.xml',
'data/cron_data.xml',
],
'demo': [

View File

@@ -2,4 +2,3 @@
from . import hr_employee
from . import res_config_setting
from . import res_users

View File

@@ -1,12 +0,0 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api
import logging
_logger = logging.getLogger(__name__)
class ResUsers(models.Model):
_inherit = 'res.users'
we_employee_id = fields.Char(string=u'企业微信账号', default="")

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_users_account_form" model="ir.ui.view">
<field name="name">res.users.account.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<page name="preferences" position="after">
<page name="account" string="企业微信">
<group>
<field name="we_employee_id"/>
</group>
</page>
</page>
</field>
</record>
</data>
</odoo>

View File

@@ -990,8 +990,8 @@ class MrpProduction(models.Model):
panel_workorder.cmm_ids.sudo().unlink()
if panel_workorder.cnc_ids:
panel_workorder.cnc_ids.sudo().unlink()
self.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
production)
# self.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
# production)
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
# processing_panel)
logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)

View File

@@ -11,9 +11,9 @@
""",
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify','stock'],
'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify','stock', 'sf_tool_management', 'sf_manufacturing', 'sf_hr'],
'data': [
'data/bussiness_node.xml'
'data/bussiness_node.xml',
],
'test': [
],

View File

@@ -8,8 +8,12 @@ class SFMessagefunctionalToolDismantle(models.Model):
@api.model
def create(self, vals):
# 判断是否为web页面创建请求
is_web_request = self.env.context.get('is_web_request', False)
result = super(SFMessagefunctionalToolDismantle, self).create(vals)
if is_web_request:
return result
for obj in result:
if obj.dismantle_cause in ['寿命到期报废', '崩刀报废']and obj.state=='待拆解':
if obj.dismantle_cause in ['寿命到期报废', '崩刀报废'] and obj.state == '待拆解':
obj.add_queue('功能刀具寿命到期')
return result

View File

@@ -1,6 +1,35 @@
from odoo import models, fields, api, _
from urllib.parse import urlencode
class SFMessagePurchase(models.Model):
_name = 'purchase.order'
_inherit = ['purchase.order', 'jikimo.message.dispatch']
def _get_message(self, message_queue_ids):
contents = []
for message_queue_id in message_queue_ids:
if message_queue_id.message_template_id.name == '坯料采购提醒':
content = message_queue_id.message_template_id.content
url = self.request_url(int(message_queue_id.res_id))
purchase_order_line = self.env['purchase.order'].search([('id', '=', int(message_queue_id.res_id))])
content = content.replace('{{name}}', purchase_order_line.name).replace(
'{{request_url}}', url)
contents.append(content)
return contents
def request_url(self, id):
we_config_info = self.env['we.config'].sudo().search([], limit=1)
redirect_domain = self.env['we.app'].sudo().search([('id', '=', we_config_info.odoo_app_id.id)]).redirect_domain
full_url = 'https://%s/' % redirect_domain
action_id = self.env.ref('purchase.purchase_form_action').id
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_website_payment')]).id
# 查询参数
params = {'id': id, 'menu_id': menu_id, 'action': action_id,
'model': 'purchase.order',
'view_type': 'form'}
# 拼接查询参数
query_string = urlencode(params)
# 拼接URL
full_url = full_url + "web#" + query_string
return full_url

View File

@@ -1,5 +1,6 @@
import re
from odoo import models, fields, api, _
from urllib.parse import urlencode
class SFMessageStockPicking(models.Model):
@@ -7,11 +8,13 @@ class SFMessageStockPicking(models.Model):
_description = "库存调拨"
_inherit = ['stock.picking', 'jikimo.message.dispatch']
def button_validate(self):
res = super(SFMessageStockPicking, self).button_validate()
if self.location_id.name == 'Vendors' and self.location_dest_id.name == '进货':
self.add_queue('调拨入库')
return res
@api.model_create_multi
def create(self, vals):
result = super(SFMessageStockPicking, self).create(vals)
for obj in result:
if obj.location_id.name == '进货' and obj.location_dest_id.name == '刀具房':
obj.add_queue('调拨入库')
return result
@api.depends('move_type', 'immediate_transfer', 'move_ids.state', 'move_ids.picking_id')
def _compute_state(self):
@@ -38,7 +41,7 @@ class SFMessageStockPicking(models.Model):
if picking_id.state == 'assigned' and picking_id.check_in == 'PC':
i += 1
if i > 0 and mrp_production_info.product_id.id not in product_id:
url = message_queue_id.message_template_id.get_url(int(message_queue_id.res_id))
url = self.request_url()
content = content.replace('{{product_id}}', mrp_production_info.product_id.name).replace(
'{{number}}', str(i)).replace('{{request_url}}', url)
product_id.append(mrp_production_info.product_id.id)
@@ -47,3 +50,18 @@ class SFMessageStockPicking(models.Model):
else:
res = super(SFMessageStockPicking, self)._get_message(message_queue_id)
return res
def request_url(self):
we_config_info = self.env['we.config'].sudo().search([], limit=1)
redirect_domain = self.env['we.app'].sudo().search([('id', '=', we_config_info.odoo_app_id.id)]).redirect_domain
full_url = 'https://%s/' % redirect_domain
action_id = self.env.ref('stock.stock_picking_type_action').id
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_theme_treehouse')]).id
# 查询参数
params = {'menu_id': menu_id, 'action': action_id, 'model': 'stock.picking',
'view_type': 'kanban'}
# 拼接查询参数
query_string = urlencode(params)
# 拼接URL
full_url = full_url + "web#" + query_string
return full_url

View File

@@ -1,5 +1,10 @@
from odoo import models, fields, api, _
import logging, json
import requests
from odoo.addons.sf_base.commons.common import Common
from urllib.parse import urlencode
_logger = logging.getLogger(__name__)
class SFMessageWork(models.Model):
_name = 'mrp.workorder'
@@ -10,7 +15,10 @@ class SFMessageWork(models.Model):
super(SFMessageWork, self)._compute_state()
for workorder in self:
if workorder.state == 'ready' and workorder.routing_type == '装夹预调':
workorder.add_queue('工单已下发通知')
jikimo_message_queue = self.env['jikimo.message.queue'].sudo().search(
[('res_id', '=', workorder.id), ("message_status", "=", "pending")])
if not jikimo_message_queue:
workorder.add_queue('工单已下发通知')
def _get_message(self, message_queue_ids):
contents = []
@@ -23,12 +31,47 @@ class SFMessageWork(models.Model):
[('product_id', '=', mrp_workorder_line.product_id.id), ('state', '=', 'ready'),
('routing_type', '=', '装夹预调')])
if len(mrp_workorder_list) > 0 and mrp_workorder_line.product_id.id not in product_id:
url = message_queue_id.message_template_id.get_url(int(message_queue_id.res_id)) + "&active_id=1"
url = self.request_url()
content = content.replace('{{product_id}}', mrp_workorder_line.product_id.name).replace(
'{{number}}', str(len(mrp_workorder_list))).replace(
'{{part_number}}',
mrp_workorder_line.part_number if mrp_workorder_line.part_number else "").replace(
'{{request_url}}', url)
product_id.append(mrp_workorder_line.product_id.id)
contents.append(content)
return contents
@api.depends('cnc_ids.tool_state')
def _compute_tool_state(self):
# 将self的id与tool_state进行保存
tool_state_dict = {record.id: record.tool_state for record in self}
res = super(SFMessageWork, self)._compute_tool_state()
data = {'name': []}
for record in self:
if tool_state_dict[record.id] != '2' and record.tool_state == '2':
data['name'].append(record.production_id.programming_no)
if data['name']:
# 请求cloud接口发送微信消息推送
configsettings = self.env['res.config.settings'].get_values()
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
url = '/api/message/invalid_tool_state'
config_url = configsettings['sf_url'] + url
data['token'] = configsettings['token']
ret = requests.post(config_url, json=data, headers=config_header)
ret = ret.json()
_logger.info('无效用刀异常消息推送接口:%s' % ret)
return res
def request_url(self):
we_config_info = self.env['we.config'].sudo().search([], limit=1)
redirect_domain = self.env['we.app'].sudo().search([('id', '=', we_config_info.odoo_app_id.id)]).redirect_domain
full_url = 'https://%s/' % redirect_domain
action_id = self.env.ref('sf_manufacturing.mrp_workorder_action_tablet').id
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_stock_dropshipping')]).id
# 查询参数
params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder',
'view_type': 'list', 'active_id': 1}
# 拼接查询参数
query_string = urlencode(params)
# 拼接URL
full_url = full_url + "web#" + query_string
return full_url

View File

@@ -62,8 +62,8 @@ class Sf_Mrs_Connect(http.Controller):
if cnc_workorder_has.cnc_ids:
cnc_workorder_has.cmm_ids.sudo().unlink()
cnc_workorder_has.cnc_ids.sudo().unlink()
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
production)
# request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
# production)
cnc_workorder_has.write(
{'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret),
'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)})

View File

@@ -2676,7 +2676,8 @@ class CuttingToolBasicParameters(models.Model):
'interface_diameter': cutter_head_item['interface_diameter'],
'total_length': cutter_head_item['total_length'],
'blade_length': cutter_head_item['blade_length'],
'cutting_depth': cutter_head_item['cutting_depth_max'],
'cutting_blade_length': cutter_head_item['cutting_blade_length'],
'cut_depth_max': cutter_head_item['cutting_depth_max'],
'main_included_angle': cutter_head_item['edge_angle'],
'installing_structure': cutter_head_item['mounting_structure'],
'blade_id': False if not cutter_head_item['fit_blade_model_code'] else self.env[
@@ -2698,7 +2699,8 @@ class CuttingToolBasicParameters(models.Model):
'interface_diameter': cutter_head_item['interface_diameter'],
'total_length': cutter_head_item['total_length'],
'blade_length': cutter_head_item['blade_length'],
'cutting_depth': cutter_head_item['cutting_depth_max'],
'cutting_blade_length': cutter_head_item['cutting_blade_length'],
'cut_depth_max': cutter_head_item['cutting_depth_max'],
'main_included_angle': cutter_head_item['edge_angle'],
'installing_structure': cutter_head_item['mounting_structure'],
'blade_id': False if not cutter_head_item['fit_blade_model_code'] else self.env[
@@ -3031,7 +3033,8 @@ class CuttingToolBasicParameters(models.Model):
'interface_diameter': cutter_head_item['interface_diameter'],
'total_length': cutter_head_item['total_length'],
'blade_length': cutter_head_item['blade_length'],
'cutting_depth': cutter_head_item['cutting_depth_max'],
'cutting_blade_length': cutter_head_item['cutting_blade_length'],
'cut_depth_max': cutter_head_item['cutting_depth_max'],
'main_included_angle': cutter_head_item['edge_angle'],
'installing_structure': cutter_head_item['mounting_structure'],
'blade_id': False if not cutter_head_item['fit_blade_model_code'] else self.env[
@@ -3053,7 +3056,8 @@ class CuttingToolBasicParameters(models.Model):
'interface_diameter': cutter_head_item['interface_diameter'],
'total_length': cutter_head_item['total_length'],
'blade_length': cutter_head_item['blade_length'],
'cutting_depth': cutter_head_item['cutting_depth_max'],
'cutting_blade_length': cutter_head_item['cutting_blade_length'],
'cut_depth_max': cutter_head_item['cutting_depth_max'],
'main_included_angle': cutter_head_item['edge_angle'],
'installing_structure': cutter_head_item['mounting_structure'],
'blade_id': False if not cutter_head_item['fit_blade_model_code'] else self.env[

View File

@@ -1046,7 +1046,7 @@
<field name="res_model">sf.functional.tool.dismantle</field>
<field name="view_mode">tree,form,search</field>
<field name="search_view_id" ref="sf_functional_tool_dismantle_search"/>
<field name="context">{'search_default_no_dismantle_state':1}</field>
<field name="context">{'search_default_no_dismantle_state':1,'is_web_request':True}</field>
</record>
</data>
</odoo>