Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化sf
# Conflicts: # sf_manufacturing/models/__init__.py # sf_manufacturing/models/mrp_workcenter.py # sf_manufacturing/models/mrp_workorder.py # sf_manufacturing/views/mrp_workorder_view.xml
This commit is contained in:
@@ -19,6 +19,9 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
res = {'status': 1, 'factory_order_no': ''}
|
res = {'status': 1, 'factory_order_no': ''}
|
||||||
logging.info('get_bfm_process_order_list:%s' % kw)
|
logging.info('get_bfm_process_order_list:%s' % kw)
|
||||||
try:
|
try:
|
||||||
|
logging.info('get_bfm_process_order_list===================================:%s' % kw['order_number'])
|
||||||
|
# aa = request.env['sale.order'].sudo().get_default_code(kw['order_number'])
|
||||||
|
|
||||||
# datas = request.httprequest.data
|
# datas = request.httprequest.data
|
||||||
# ret = json.loads(datas)
|
# ret = json.loads(datas)
|
||||||
# ret = json.loads(ret['result'])
|
# ret = json.loads(ret['result'])
|
||||||
@@ -101,6 +104,11 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
purchase_embryo)
|
purchase_embryo)
|
||||||
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
||||||
res['factory_order_no'] = order_id.name
|
res['factory_order_no'] = order_id.name
|
||||||
|
aa = request.env['sale.order'].sudo().search([('name', '=', order_id.name)])
|
||||||
|
logging.info('get_bfm_process_or===================================:%s' % order_id.name)
|
||||||
|
aa.default_code = kw['order_number']
|
||||||
|
logging.info('get_bfm_process_order_listaaaaaaaaaaaaaaaaaaaaaaaaaaaa================:%s' % aa.default_code)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info('get_bfm_process_order_list error:%s' % e)
|
logging.info('get_bfm_process_order_list error:%s' % e)
|
||||||
res['status'] = -1
|
res['status'] = -1
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
from . import http
|
from . import http
|
||||||
from . import models
|
from . import models
|
||||||
|
from . import process_status
|
||||||
|
|
||||||
|
|||||||
110
sf_bf_connect/models/process_status.py
Normal file
110
sf_bf_connect/models/process_status.py
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
from datetime import datetime
|
||||||
|
import logging
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
import requests
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class StatusChange(models.Model):
|
||||||
|
_inherit = 'sale.order'
|
||||||
|
|
||||||
|
default_code = fields.Char(string='内部编码')
|
||||||
|
|
||||||
|
def action_confirm(self):
|
||||||
|
logging.info('函数已经执行=============')
|
||||||
|
if self._get_forbidden_state_confirm() & set(self.mapped('state')):
|
||||||
|
raise UserError(_(
|
||||||
|
"It is not allowed to confirm an order in the following states: %s",
|
||||||
|
", ".join(self._get_forbidden_state_confirm()),
|
||||||
|
))
|
||||||
|
logging.info('函数已经执行=============1')
|
||||||
|
for order in self:
|
||||||
|
if order.partner_id in order.message_partner_ids:
|
||||||
|
logging.info('函数已经执行=============2')
|
||||||
|
continue
|
||||||
|
order.message_subscribe([order.partner_id.id])
|
||||||
|
logging.info('函数已经执行=============3')
|
||||||
|
self.write(self._prepare_confirmation_values())
|
||||||
|
|
||||||
|
# Context key 'default_name' is sometimes propagated up to here.
|
||||||
|
# We don't need it and it creates issues in the creation of linked records.
|
||||||
|
context = self._context.copy()
|
||||||
|
context.pop('default_name', None)
|
||||||
|
logging.info('函数已经执行=============4')
|
||||||
|
|
||||||
|
self.with_context(context)._action_confirm()
|
||||||
|
if self.env.user.has_group('sale.group_auto_done_setting'):
|
||||||
|
logging.info('函数已经执行=============5')
|
||||||
|
self.action_done()
|
||||||
|
process_start_time = str(datetime.now())
|
||||||
|
json1 = {
|
||||||
|
'params': {
|
||||||
|
'model_name': 'jikimo.process.order',
|
||||||
|
'field_name': 'name',
|
||||||
|
# 'default_code': 'PO-2022-1214-0022',
|
||||||
|
'default_code': self.default_code,
|
||||||
|
# 'default_code': self.name,
|
||||||
|
'state': '加工中',
|
||||||
|
'process_start_time': process_start_time,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
url1 = 'https://bfm.cs.jikimo.com/api/get/state/get_order'
|
||||||
|
requests.post(url1, json=json1, data=None)
|
||||||
|
logging.info('接口已经执行=============')
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def action_cancel(self):
|
||||||
|
""" Cancel SO after showing the cancel wizard when needed. (cfr `_show_cancel_wizard`)
|
||||||
|
|
||||||
|
For post-cancel operations, please only override `_action_cancel`.
|
||||||
|
|
||||||
|
note: self.ensure_one() if the wizard is shown.
|
||||||
|
"""
|
||||||
|
logging.info('函数已经执行=============')
|
||||||
|
cancel_warning = self._show_cancel_wizard()
|
||||||
|
logging.info('函数已经执行=============2')
|
||||||
|
json1 = {
|
||||||
|
'params': {
|
||||||
|
'model_name': 'jikimo.process.order',
|
||||||
|
'field_name': 'name',
|
||||||
|
'default_code': self.default_code,
|
||||||
|
# 'default_code': self.name,
|
||||||
|
'state': '待派单',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
url1 = 'https://bfm.cs.jikimo.com/api/get/state/cancel_order'
|
||||||
|
requests.post(url1, json=json1, data=None)
|
||||||
|
if cancel_warning:
|
||||||
|
logging.info('函数已经执行=============3')
|
||||||
|
self.ensure_one()
|
||||||
|
logging.info('函数已经执行=============4')
|
||||||
|
template_id = self.env['ir.model.data']._xmlid_to_res_id(
|
||||||
|
'sale.mail_template_sale_cancellation', raise_if_not_found=False
|
||||||
|
)
|
||||||
|
lang = self.env.context.get('lang')
|
||||||
|
template = self.env['mail.template'].browse(template_id)
|
||||||
|
if template.lang:
|
||||||
|
lang = template._render_lang(self.ids)[self.id]
|
||||||
|
ctx = {
|
||||||
|
'default_use_template': bool(template_id),
|
||||||
|
'default_template_id': template_id,
|
||||||
|
'default_order_id': self.id,
|
||||||
|
'mark_so_as_canceled': True,
|
||||||
|
'default_email_layout_xmlid': "mail.mail_notification_layout_with_responsible_signature",
|
||||||
|
'model_description': self.with_context(lang=lang).type_name,
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'name': _('Cancel %s', self.type_name),
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_model': 'sale.order.cancel',
|
||||||
|
'view_id': self.env.ref('sale.sale_order_cancel_view_form').id,
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'context': ctx,
|
||||||
|
'target': 'new'
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return self._action_cancel()
|
||||||
|
|
||||||
@@ -11,4 +11,3 @@ from . import res_user
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,13 @@ class ResWorkcenter(models.Model):
|
|||||||
|
|
||||||
users_ids = fields.Many2many("res.users", 'users_workcenter')
|
users_ids = fields.Many2many("res.users", 'users_workcenter')
|
||||||
|
|
||||||
|
# @api.onchange('machine_tool_id')
|
||||||
|
# def get_machine_tool_is_binding(self):
|
||||||
|
# print('1111111')
|
||||||
|
# for item in self:
|
||||||
|
# item.machine_tool_id.is_binding = False
|
||||||
|
|
||||||
|
|
||||||
equipment_ids = fields.One2many(
|
equipment_ids = fields.One2many(
|
||||||
'maintenance.equipment', 'workcenter_id', string="Maintenance Equipment",
|
'maintenance.equipment', 'workcenter_id', string="Maintenance Equipment",
|
||||||
check_company=True)
|
check_company=True)
|
||||||
|
|||||||
@@ -258,9 +258,6 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# def fetchCNCing(self):
|
|
||||||
# return None
|
|
||||||
|
|
||||||
# cnc程序获取
|
# cnc程序获取
|
||||||
def fetchCNC(self):
|
def fetchCNC(self):
|
||||||
try:
|
try:
|
||||||
@@ -316,14 +313,50 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
logging.info('fetchCNC error:%s' % e)
|
logging.info('fetchCNC error:%s' % e)
|
||||||
raise UserError(e)
|
raise UserError(e)
|
||||||
|
|
||||||
# return {
|
# cnc程序获取
|
||||||
# 'name': _("工单"),
|
def fetchCNC(self):
|
||||||
# 'view_mode': 'form',
|
cnc = self.env['mrp.workorder'].search(
|
||||||
# 'res_model': 'mrp.workorder',
|
[('routing_type', '=', 'CNC加工'), ('production_id', '=', self.production_id.id)], limit=1)
|
||||||
# 'res_id': self.id,
|
if cnc.product_id.upload_model_file:
|
||||||
# 'type': 'ir.actions.act_window',
|
attachment = cnc.product_id.upload_model_file[0]
|
||||||
# 'target': 'new'
|
base64_data = base64.b64encode(attachment.datas)
|
||||||
# }
|
base64_datas = base64_data.decode('utf-8')
|
||||||
|
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||||
|
res = {'model_code': '' if not cnc.product_id.upload_model_file else model_code,
|
||||||
|
'production_no': self.production_id.name,
|
||||||
|
'machine_tool_code': cnc.workcenter_id.machine_tool_id.code,
|
||||||
|
'material_code': cnc.env['sf.production.materials'].search(
|
||||||
|
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
|
||||||
|
'material_type_code': cnc.env['sf.materials.model'].search(
|
||||||
|
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
|
||||||
|
'machining_processing_panel': cnc.product_id.model_processing_panel,
|
||||||
|
'machining_precision': cnc.product_id.model_machining_precision,
|
||||||
|
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
|
||||||
|
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
|
||||||
|
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
|
||||||
|
'order_no': cnc.production_id.origin,
|
||||||
|
'user': self.env.user.name,
|
||||||
|
'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
|
||||||
|
cnc.product_id.model_file).decode('utf-8')
|
||||||
|
}
|
||||||
|
logging.info('res:%s' % res)
|
||||||
|
configsettings = self.env['res.config.settings'].get_values()
|
||||||
|
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||||
|
url = '/api/intelligent_programming/create'
|
||||||
|
config_url = configsettings['sf_url'] + url
|
||||||
|
# res_str = json.dumps(res)
|
||||||
|
ret = requests.post(config_url, json={}, data=res, headers=config_header)
|
||||||
|
ret = ret.json()
|
||||||
|
if ret['status'] == 1:
|
||||||
|
self.write({'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'})
|
||||||
|
return {
|
||||||
|
'name': _("工单"),
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_model': 'mrp.workorder',
|
||||||
|
'res_id': self.id,
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'target': 'new'
|
||||||
|
}
|
||||||
|
|
||||||
def json_workorder_str1(self, k, production, route):
|
def json_workorder_str1(self, k, production, route):
|
||||||
workorders_values_str = [0, '', {
|
workorders_values_str = [0, '', {
|
||||||
@@ -436,7 +469,7 @@ class CNCprocessing(models.Model):
|
|||||||
cnc_workorder.state = 'done'
|
cnc_workorder.state = 'done'
|
||||||
cnc_workorder.work_state = '已编程'
|
cnc_workorder.work_state = '已编程'
|
||||||
cnc_workorder.programming_state = '已编程'
|
cnc_workorder.programming_state = '已编程'
|
||||||
cnc_workorder.time_ids.date_end = datetime.now()
|
# cnc_workorder.time_ids.date_end = datetime.now()
|
||||||
|
|
||||||
def get_cnc_processing_file(self, folder_name, cnc_processing):
|
def get_cnc_processing_file(self, folder_name, cnc_processing):
|
||||||
logging.info('folder_name:%s' % folder_name)
|
logging.info('folder_name:%s' % folder_name)
|
||||||
@@ -501,6 +534,9 @@ class SfWorkOrderBarcodes(models.Model):
|
|||||||
|
|
||||||
def on_barcode_scanned(self, barcode):
|
def on_barcode_scanned(self, barcode):
|
||||||
tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
|
tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
|
||||||
self.tray_code = tray_code.code
|
# 在这里,用等号赋值只是一次性的,只是一种展示
|
||||||
|
# self.tray_code = tray_code.code
|
||||||
|
# 用write方法写入数据库是永久的
|
||||||
|
self.write({'tray_code': tray_code.code})
|
||||||
workorder = self.env['mrp.workorder'].browse(self.ids)
|
workorder = self.env['mrp.workorder'].browse(self.ids)
|
||||||
workorder.gettray_auto(barcode)
|
workorder.gettray_auto(barcode)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<field name="name" position="before">
|
<field name="name" position="before">
|
||||||
<field name="sequence"/>
|
<field name="sequence"/>
|
||||||
<field name='user_permissions'/>
|
<field name='user_permissions'/>
|
||||||
|
<field name='user_permissions'/>
|
||||||
</field>
|
</field>
|
||||||
<field name="name" position="after">
|
<field name="name" position="after">
|
||||||
<field name="processing_panel"/>
|
<field name="processing_panel"/>
|
||||||
@@ -31,6 +32,22 @@
|
|||||||
<attribute name="multi_edit"></attribute>
|
<attribute name="multi_edit"></attribute>
|
||||||
<attribute name="editable"></attribute>
|
<attribute name="editable"></attribute>
|
||||||
</tree>
|
</tree>
|
||||||
|
<xpath expr="//button[@name='button_start']" position="attributes">
|
||||||
|
<attribute name="attrs">{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done',
|
||||||
|
'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')),
|
||||||
|
('is_user_working', '!=', False),("user_permissions","=",False)]}
|
||||||
|
</attribute>
|
||||||
|
</xpath>
|
||||||
|
<!-- <button name="button_start" type="object" string="Start" class="btn-success"-->
|
||||||
|
<!-- 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="Pause" class="btn-warning"-->
|
||||||
|
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>-->
|
||||||
|
<!-- <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)]}"/>-->
|
||||||
|
<tree position="attributes">
|
||||||
|
<attribute name="multi_edit"></attribute>
|
||||||
|
<attribute name="editable"></attribute>
|
||||||
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -80,8 +97,6 @@
|
|||||||
<xpath expr="field[@name='is_user_working']" position="before">
|
<xpath expr="field[@name='is_user_working']" position="before">
|
||||||
<field name='user_permissions' invisible="1"/>
|
<field name='user_permissions' invisible="1"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
|
|
||||||
<xpath expr="//page[last()]" position="after">
|
<xpath expr="//page[last()]" position="after">
|
||||||
<page string="获取CNC加工程序" attrs='{"invisible": [("routing_type","!=","获取CNC加工程序")]}'>
|
<page string="获取CNC加工程序" attrs='{"invisible": [("routing_type","!=","获取CNC加工程序")]}'>
|
||||||
<group>
|
<group>
|
||||||
@@ -99,7 +114,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="field[@name='is_user_working']" position="before">
|
||||||
|
<field name='user_permissions' invisible="1"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//page[last()]" position="after">
|
<xpath expr="//page[last()]" position="after">
|
||||||
<page string="装夹托盘" attrs='{"invisible": [("routing_type","!=","装夹")]}'>
|
<page string="装夹托盘" attrs='{"invisible": [("routing_type","!=","装夹")]}'>
|
||||||
@@ -221,6 +238,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 col-lg-6 o_setting_box">
|
<div class="col-12 col-lg-6 o_setting_box">
|
||||||
|
|
||||||
|
<button type="object" class="oe_highlight" name="getcenter" string="计算定位"
|
||||||
|
attrs='{"invisible": [("user_permissions","=",False)]}'/>
|
||||||
|
|
||||||
<button type="object" class="oe_highlight" name="getcenter" string="计算定位"
|
<button type="object" class="oe_highlight" name="getcenter" string="计算定位"
|
||||||
attrs='{"invisible": [("user_permissions","=",False)]}'/>
|
attrs='{"invisible": [("user_permissions","=",False)]}'/>
|
||||||
</div>
|
</div>
|
||||||
@@ -260,7 +281,6 @@
|
|||||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'>
|
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'>
|
||||||
<group>
|
<group>
|
||||||
<field name="test_results" widget="selection"/>
|
<field name="test_results" widget="selection"/>
|
||||||
|
|
||||||
</group>
|
</group>
|
||||||
<div class="col-12 col-lg-6 o_setting_box">
|
<div class="col-12 col-lg-6 o_setting_box">
|
||||||
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
|
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
|
||||||
@@ -271,6 +291,7 @@
|
|||||||
<xpath expr="//page[last()]" position="after">
|
<xpath expr="//page[last()]" position="after">
|
||||||
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'>
|
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'>
|
||||||
|
|
||||||
|
|
||||||
<div class="col-12 col-lg-6 o_setting_box">
|
<div class="col-12 col-lg-6 o_setting_box">
|
||||||
<button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"
|
<button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"
|
||||||
attrs='{"invisible": [("user_permissions","=",False)]}'/>
|
attrs='{"invisible": [("user_permissions","=",False)]}'/>
|
||||||
@@ -280,6 +301,16 @@
|
|||||||
string="打印标签" attrs='{"invisible": [("user_permissions","=",False)]}'/>
|
string="打印标签" attrs='{"invisible": [("user_permissions","=",False)]}'/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 col-lg-6 o_setting_box">
|
||||||
|
<button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"
|
||||||
|
attrs='{"invisible": [("user_permissions","=",False)]}'/>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-lg-6 o_setting_box">
|
||||||
|
<button type="action" class="oe_highlight" name="sf_manufacturing.label_sf_tray_code1"
|
||||||
|
string="打印标签" attrs='{"invisible": [("user_permissions","=",False)]}'/>
|
||||||
|
</div>
|
||||||
|
>>>>>>> 3d882f5492685cfdb3cd9960bd24cdf9ef247f79
|
||||||
|
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
Reference in New Issue
Block a user