Accept Merge Request #1216: (feature/优化表面工艺 -> develop)
Merge Request: 优化表面工艺 Created By: @杨金灵 Reviewed By: @马广威 Approved By: @马广威 Accepted By: @杨金灵 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1216
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
from odoo import fields, models
|
from odoo.exceptions import UserError
|
||||||
|
from odoo import fields, models, _
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -14,6 +15,17 @@ class StatusChange(models.Model):
|
|||||||
def action_confirm(self):
|
def action_confirm(self):
|
||||||
# 在原有方法执行前记录日志和执行其他操作
|
# 在原有方法执行前记录日志和执行其他操作
|
||||||
logging.info('函数已经执行=============')
|
logging.info('函数已经执行=============')
|
||||||
|
server_product_none = []
|
||||||
|
for order in self.order_line:
|
||||||
|
for item in order.product_template_id.model_process_parameters_ids:
|
||||||
|
if item.gain_way == '外协':
|
||||||
|
server_product = self.env['product.template'].search(
|
||||||
|
[('server_product_process_parameters_id', '=', item.id),
|
||||||
|
('detailed_type', '=', 'service')])
|
||||||
|
if not server_product:
|
||||||
|
server_product_none.append(item.name)
|
||||||
|
if server_product_none:
|
||||||
|
raise UserError(_("请先至【产品】中创建【表面工艺参数】为%s的服务产品", ", ".join(server_product_none)))
|
||||||
|
|
||||||
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
|
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
|
||||||
res = super(StatusChange, self).action_confirm()
|
res = super(StatusChange, self).action_confirm()
|
||||||
@@ -202,12 +214,12 @@ class FinishStatusChange(models.Model):
|
|||||||
[('id', 'child_of', self.picking_type_id.warehouse_id.view_location_id.id),
|
[('id', 'child_of', self.picking_type_id.warehouse_id.view_location_id.id),
|
||||||
('usage', '!=', 'supplier')])
|
('usage', '!=', 'supplier')])
|
||||||
if self.env['stock.move'].search([
|
if self.env['stock.move'].search([
|
||||||
('state', 'in', ['confirmed', 'partially_available', 'waiting', 'assigned']),
|
('state', 'in', ['confirmed', 'partially_available', 'waiting', 'assigned']),
|
||||||
('product_qty', '>', 0),
|
('product_qty', '>', 0),
|
||||||
('location_id', 'in', wh_location_ids),
|
('location_id', 'in', wh_location_ids),
|
||||||
('move_orig_ids', '=', False),
|
('move_orig_ids', '=', False),
|
||||||
('picking_id', 'not in', self.ids),
|
('picking_id', 'not in', self.ids),
|
||||||
('product_id', 'in', lines.product_id.ids)], limit=1):
|
('product_id', 'in', lines.product_id.ids)], limit=1):
|
||||||
action = self.action_view_reception_report()
|
action = self.action_view_reception_report()
|
||||||
action['context'] = {'default_picking_ids': self.ids}
|
action['context'] = {'default_picking_ids': self.ids}
|
||||||
return action
|
return action
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
logging.info('get_qcCheck error:%s' % e)
|
logging.info('get_qcCheck error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/FeedBackStart', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/FeedBackStart', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def button_Work_START(self, **kw):
|
def button_Work_START(self, **kw):
|
||||||
"""
|
"""
|
||||||
@@ -193,7 +193,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
logging.info('button_Work_START error:%s' % e)
|
logging.info('button_Work_START error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/FeedBackEnd', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/FeedBackEnd', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def button_Work_End(self, **kw):
|
def button_Work_End(self, **kw):
|
||||||
"""
|
"""
|
||||||
@@ -244,7 +244,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
logging.info('button_Work_End error:%s' % e)
|
logging.info('button_Work_End error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def PartQualityInspect(self, **kw):
|
def PartQualityInspect(self, **kw):
|
||||||
"""
|
"""
|
||||||
@@ -290,7 +290,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
logging.info('PartQualityInspect error:%s' % e)
|
logging.info('PartQualityInspect error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/CMMProgDolod', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/CMMProgDolod', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def CMMProgDolod(self, **kw):
|
def CMMProgDolod(self, **kw):
|
||||||
"""
|
"""
|
||||||
@@ -330,7 +330,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
logging.info('CMMProgDolod error:%s' % e)
|
logging.info('CMMProgDolod error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/NCProgDolod', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/NCProgDolod', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def NCProgDolod(self, **kw):
|
def NCProgDolod(self, **kw):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -185,8 +185,8 @@ class MrpProduction(models.Model):
|
|||||||
production.workorder_ids):
|
production.workorder_ids):
|
||||||
production.state = 'rework'
|
production.state = 'rework'
|
||||||
# 如果制造订单的功能刀具为【无效刀】则制造订单状态改为返工
|
# 如果制造订单的功能刀具为【无效刀】则制造订单状态改为返工
|
||||||
if production.tool_state == '2':
|
# if production.tool_state == '2':
|
||||||
production.state = 'rework'
|
# production.state = 'rework'
|
||||||
|
|
||||||
def action_check(self):
|
def action_check(self):
|
||||||
"""
|
"""
|
||||||
@@ -905,7 +905,6 @@ class MrpProduction(models.Model):
|
|||||||
# production.write(
|
# production.write(
|
||||||
# {'state': 'progress', 'programming_state': '已编程', 'is_rework': False})
|
# {'state': 'progress', 'programming_state': '已编程', 'is_rework': False})
|
||||||
# logging.info('返工含有已编程未下发的程序更新完成:%s' % production.name)
|
# logging.info('返工含有已编程未下发的程序更新完成:%s' % production.name)
|
||||||
logging.info('更新程序完成:%s' % production.name)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise UserError(result['message'])
|
raise UserError(result['message'])
|
||||||
|
|||||||
@@ -131,7 +131,9 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
is_subcontract = fields.Boolean(string='是否外协')
|
is_subcontract = fields.Boolean(string='是否外协')
|
||||||
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
||||||
picking_ids = fields.Many2many('stock.picking', string='外协出入库单')
|
picking_ids = fields.Many2many('stock.picking', string='外协出入库单')
|
||||||
|
# purchase_id = fields.Many2one('purchase.order', string='外协采购单')
|
||||||
surface_technics_picking_count = fields.Integer("外协出入库", compute='_compute_surface_technics_picking_ids')
|
surface_technics_picking_count = fields.Integer("外协出入库", compute='_compute_surface_technics_picking_ids')
|
||||||
|
surface_technics_purchase_count = fields.Integer("外协采购", compute='_compute_surface_technics_purchase_ids')
|
||||||
|
|
||||||
@api.depends('name', 'production_id.name')
|
@api.depends('name', 'production_id.name')
|
||||||
def _compute_surface_technics_picking_ids(self):
|
def _compute_surface_technics_picking_ids(self):
|
||||||
@@ -153,6 +155,43 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
action['context'] = dict(self._context, default_origin=self.name)
|
action['context'] = dict(self._context, default_origin=self.name)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
@api.depends('state', 'production_id.name')
|
||||||
|
def _compute_surface_technics_purchase_ids(self):
|
||||||
|
for order in self:
|
||||||
|
if order.routing_type == '表面工艺':
|
||||||
|
production_programming = self.env['mrp.production'].search(
|
||||||
|
[('programming_no', '=', order.production_id.programming_no)], order='name asc')
|
||||||
|
production_list = [production.name for production in production_programming]
|
||||||
|
purchase = self.env['purchase.order'].search([('origin', '=', ','.join(production_list))])
|
||||||
|
for line in purchase.order_line:
|
||||||
|
if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id and line.product_qty == len(
|
||||||
|
production_programming):
|
||||||
|
# server_product = self.env['product.template'].search(
|
||||||
|
# [('server_product_process_parameters_id', '=', pp.id),
|
||||||
|
# ('detailed_type', '=', 'service')])
|
||||||
|
# purchase_order_line = self.env['purchase.order.line'].search(
|
||||||
|
# [('product_id', '=', server_product.id), ('product_qty', '=', len(production_programming))])
|
||||||
|
# if purchase_order_line:
|
||||||
|
order.surface_technics_purchase_count = len(purchase)
|
||||||
|
else:
|
||||||
|
order.surface_technics_purchase_count = 0
|
||||||
|
|
||||||
|
def action_view_surface_technics_purchase(self):
|
||||||
|
self.ensure_one()
|
||||||
|
production_programming = self.env['mrp.production'].search(
|
||||||
|
[('programming_no', '=', self.production_id.programming_no)], order='name asc')
|
||||||
|
production_list = [production.name for production in production_programming]
|
||||||
|
purchase_orders = self.env['purchase.order'].search([('origin', '=', ','.join(production_list))])
|
||||||
|
result = {
|
||||||
|
"type": "ir.actions.act_window",
|
||||||
|
"res_model": "purchase.order",
|
||||||
|
"res_id": purchase_orders.id,
|
||||||
|
# "domain": [['id', 'in', self.purchase_id]],
|
||||||
|
"name": _("Purchase Orders"),
|
||||||
|
'view_mode': 'form',
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
|
||||||
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)
|
||||||
# 保存名称
|
# 保存名称
|
||||||
@@ -885,7 +924,22 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# workorder.state = 'ready'
|
# workorder.state = 'ready'
|
||||||
if workorder.routing_type == '表面工艺' and workorder.state not in ['done', 'progress']:
|
if workorder.routing_type == '表面工艺' and workorder.state not in ['done', 'progress']:
|
||||||
if unclamp_workorder:
|
if unclamp_workorder:
|
||||||
workorder.state = 'ready'
|
if workorder.is_subcontract is False:
|
||||||
|
workorder.state = 'ready'
|
||||||
|
else:
|
||||||
|
production_programming = self.env['mrp.production'].search(
|
||||||
|
[('programming_no', '=', self.production_id.programming_no)], order='name asc')
|
||||||
|
production_list = [production.name for production in production_programming]
|
||||||
|
purchase_orders = self.env['purchase.order'].search(
|
||||||
|
[('origin', '=', ','.join(production_list))])
|
||||||
|
for line in purchase_orders.order_line:
|
||||||
|
if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id and line.product_qty == len(
|
||||||
|
production_programming):
|
||||||
|
if purchase_orders.state == 'purchase':
|
||||||
|
workorder.state = 'ready'
|
||||||
|
else:
|
||||||
|
workorder.state = 'waiting'
|
||||||
|
|
||||||
# else:
|
# else:
|
||||||
# if workorder.state not in ['cancel', 'rework']:
|
# if workorder.state not in ['cancel', 'rework']:
|
||||||
# workorder.state = 'rework'
|
# workorder.state = 'rework'
|
||||||
@@ -1110,28 +1164,13 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
picking_out = record.env['stock.move.line'].search(
|
picking_out = record.env['stock.move.line'].search(
|
||||||
[('picking_id', '=', record.picking_ids[0].id)])
|
[('picking_id', '=', record.picking_ids[0].id)])
|
||||||
logging.info('picking_out:%s' % picking_out.picking_id.name)
|
logging.info('picking_out:%s' % picking_out.picking_id.name)
|
||||||
if picking_out:
|
# if picking_out:
|
||||||
order_line_ids = []
|
# order_line_ids = []
|
||||||
logging.info('surface_technics_parameters_id:%s' % record.surface_technics_parameters_id.name)
|
# logging.info('surface_technics_parameters_id:%s' % record.surface_technics_parameters_id.name)
|
||||||
server_product = self.env['product.template'].search(
|
#
|
||||||
[('server_product_process_parameters_id', '=', record.surface_technics_parameters_id.id),
|
# else:
|
||||||
('detailed_type', '=', 'service')])
|
# raise UserError(
|
||||||
logging.info('server_product:%s' % server_product.name)
|
# '请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
|
||||||
if server_product:
|
|
||||||
order_line_ids.append((0, 0, {
|
|
||||||
'product_id': server_product.product_variant_id.id,
|
|
||||||
'product_qty': 1,
|
|
||||||
'product_uom': server_product.uom_id.id
|
|
||||||
}))
|
|
||||||
self.env['purchase.order'].sudo().create({
|
|
||||||
'partner_id': server_product.seller_ids.partner_id.id,
|
|
||||||
'origin': record.production_id.name,
|
|
||||||
'state': 'draft',
|
|
||||||
'order_line': order_line_ids,
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
raise UserError(
|
|
||||||
'请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
|
|
||||||
tem_date_planned_finished = record.date_planned_finished
|
tem_date_planned_finished = record.date_planned_finished
|
||||||
tem_date_finished = record.date_finished
|
tem_date_finished = record.date_finished
|
||||||
logging.info('routing_type:%s' % record.routing_type)
|
logging.info('routing_type:%s' % record.routing_type)
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import base64
|
|||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError, UserError
|
||||||
from odoo.modules import get_resource_path
|
from odoo.modules import get_resource_path
|
||||||
|
|
||||||
|
|
||||||
from OCC.Extend.DataExchange import read_step_file
|
from OCC.Extend.DataExchange import read_step_file
|
||||||
from OCC.Extend.DataExchange import write_stl_file
|
from OCC.Extend.DataExchange import write_stl_file
|
||||||
|
|
||||||
@@ -106,6 +108,15 @@ class ResProductMo(models.Model):
|
|||||||
|
|
||||||
name = fields.Char('产品名称', compute='_compute_tool_name', store=True, required=False)
|
name = fields.Char('产品名称', compute='_compute_tool_name', store=True, required=False)
|
||||||
|
|
||||||
|
@api.constrains('seller_ids')
|
||||||
|
def _check_seller_ids(self):
|
||||||
|
if self.categ_type == '表面工艺':
|
||||||
|
if self.seller_ids:
|
||||||
|
if self.seller_ids[0].price == 0.0:
|
||||||
|
raise UserError("请在该产品【采购】中的【价格】进行输入")
|
||||||
|
else:
|
||||||
|
raise UserError("请在【采购】中输入供应商信息")
|
||||||
|
|
||||||
@api.depends('cutting_tool_model_id', 'specification_id')
|
@api.depends('cutting_tool_model_id', 'specification_id')
|
||||||
def _compute_tool_name(self):
|
def _compute_tool_name(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
@@ -113,6 +124,10 @@ class ResProductMo(models.Model):
|
|||||||
name = '%s%s' % (item.cutting_tool_model_id.name, item.specification_id.name)
|
name = '%s%s' % (item.cutting_tool_model_id.name, item.specification_id.name)
|
||||||
item.name = name
|
item.name = name
|
||||||
|
|
||||||
|
def _get_process_parameters_product(self, production_process):
|
||||||
|
return self.env['product.template'].search(
|
||||||
|
[('server_product_process_parameters_id', '=', production_process.id)]).seller_ids[0]
|
||||||
|
|
||||||
@api.onchange('cutting_tool_model_id')
|
@api.onchange('cutting_tool_model_id')
|
||||||
def _onchange_cutting_tool_model_id(self):
|
def _onchange_cutting_tool_model_id(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
|
|||||||
@@ -289,6 +289,54 @@ class StockRule(models.Model):
|
|||||||
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
||||||
for production_item in productions:
|
for production_item in productions:
|
||||||
if production_item.product_id.id in product_id_to_production_names:
|
if production_item.product_id.id in product_id_to_production_names:
|
||||||
|
sorted_process_parameters = sorted(production_item.product_id.model_process_parameters_ids,
|
||||||
|
key=lambda w: w.id)
|
||||||
|
|
||||||
|
consecutive_process_parameters = []
|
||||||
|
m = 0
|
||||||
|
for i in range(len(sorted_process_parameters) - 1):
|
||||||
|
if m == 0:
|
||||||
|
is_purchase = False
|
||||||
|
if self.env['product.template']._get_process_parameters_product(
|
||||||
|
sorted_process_parameters[i]).partner_id == self.env[
|
||||||
|
'product.template']._get_process_parameters_product(sorted_process_parameters[
|
||||||
|
i + 1]).partner_id and \
|
||||||
|
sorted_process_parameters[i].gain_way == '外协':
|
||||||
|
if sorted_process_parameters[i] not in consecutive_process_parameters:
|
||||||
|
consecutive_process_parameters.append(sorted_process_parameters[i])
|
||||||
|
consecutive_process_parameters.append(sorted_process_parameters[i + 1])
|
||||||
|
m += 1
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||||
|
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
||||||
|
production_item,
|
||||||
|
product_id_to_production_names)
|
||||||
|
if sorted_process_parameters[i] in consecutive_process_parameters:
|
||||||
|
is_purchase = True
|
||||||
|
consecutive_process_parameters = []
|
||||||
|
m = 0
|
||||||
|
# 当前面的连续采购单生成再生成当前工序的外协采购单
|
||||||
|
if is_purchase is False:
|
||||||
|
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
||||||
|
production_item, product_id_to_production_names)
|
||||||
|
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||||
|
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
||||||
|
production_item, product_id_to_production_names)
|
||||||
|
if sorted_process_parameters[i] in consecutive_process_parameters:
|
||||||
|
is_purchase = True
|
||||||
|
consecutive_process_parameters = []
|
||||||
|
m = 0
|
||||||
|
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||||
|
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters, production_item,
|
||||||
|
product_id_to_production_names)
|
||||||
|
if is_purchase is False and m == 0:
|
||||||
|
if len(sorted_process_parameters) == 1:
|
||||||
|
self.env['purchase.order'].get_purchase_order(sorted_process_parameters, production_item,
|
||||||
|
product_id_to_production_names)
|
||||||
|
else:
|
||||||
|
self.env['purchase.order'].get_purchase_order(sorted_process_parameters[i], production_item,
|
||||||
|
product_id_to_production_names)
|
||||||
# # 同一个产品多个制造订单对应一个编程单和模型库
|
# # 同一个产品多个制造订单对应一个编程单和模型库
|
||||||
# # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
# # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
||||||
if not production_item.programming_no:
|
if not production_item.programming_no:
|
||||||
@@ -516,7 +564,7 @@ class StockPicking(models.Model):
|
|||||||
[('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), ('picking_id', '=', self.id)])
|
||||||
if self.location_id == move_in.location_id and self.location_dest_id == move_in.location_dest_id:
|
if self.location_id == move_in.location_id and self.location_dest_id == move_in.location_dest_id:
|
||||||
if move_out.origin == move_in.origin:
|
if move_out.origin == move_in.origin:
|
||||||
if move_out.picking_id.state != 'done':
|
if move_out.picking_id.state != 'done':
|
||||||
|
|||||||
@@ -122,7 +122,7 @@
|
|||||||
groups="sf_base.group_sf_mrp_user"/>
|
groups="sf_base.group_sf_mrp_user"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="(//header//button[@name='button_scrap'])" position="replace">
|
<xpath expr="(//header//button[@name='button_scrap'])" position="replace">
|
||||||
<button name="button_scrap" invisible="1"/>
|
<button name="button_scrap" invisible="0"/>
|
||||||
<button name="do_update_program" string="更新程序" type="object" groups="sf_base.group_sf_mrp_user"
|
<button name="do_update_program" string="更新程序" type="object" groups="sf_base.group_sf_mrp_user"
|
||||||
confirm="是否确认更新程序"
|
confirm="是否确认更新程序"
|
||||||
attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程未下发')]}"/>
|
attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程未下发')]}"/>
|
||||||
@@ -285,7 +285,7 @@
|
|||||||
|
|
||||||
<xpath expr="//sheet//notebook//page[@name='operations']" position="after">
|
<xpath expr="//sheet//notebook//page[@name='operations']" position="after">
|
||||||
<page string="检测结果" attrs="{'invisible': [('detection_result_ids', '=', [])]}">
|
<page string="检测结果" attrs="{'invisible': [('detection_result_ids', '=', [])]}">
|
||||||
<field name="detection_result_ids" string="" readonly="1">
|
<field name="detection_result_ids" string="" readonly="0">
|
||||||
<tree sample="1">
|
<tree sample="1">
|
||||||
<field name="production_id" invisible="1"/>
|
<field name="production_id" invisible="1"/>
|
||||||
<field name="processing_panel"/>
|
<field name="processing_panel"/>
|
||||||
@@ -568,7 +568,7 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form>
|
<form>
|
||||||
<group>
|
<group>
|
||||||
<!-- <field name="handle_result"/>-->
|
<field name="handle_result"/>
|
||||||
<field name="test_report" readonly="1" widget="pdf_viewer"/>
|
<field name="test_report" readonly="1" widget="pdf_viewer"/>
|
||||||
</group>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -118,6 +118,17 @@
|
|||||||
statusbar_visible="pending,waiting,ready,progress,to be detected,done,rework"/>
|
statusbar_visible="pending,waiting,ready,progress,to be detected,done,rework"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//div[@name='button_box']" position="inside">
|
<xpath expr="//div[@name='button_box']" position="inside">
|
||||||
|
<button type="object" name="action_view_surface_technics_purchase" class="oe_stat_button"
|
||||||
|
icon="fa-credit-card"
|
||||||
|
groups="base.group_user,sf_base.group_sf_order_user"
|
||||||
|
attrs="{'invisible': [('surface_technics_purchase_count', '=', 0),('routing_type', '!=', '表面工艺')]}">
|
||||||
|
<div class="o_field_widget o_stat_info">
|
||||||
|
<span class="o_stat_value">
|
||||||
|
<field name="surface_technics_purchase_count"/>
|
||||||
|
</span>
|
||||||
|
<span class="o_stat_text">采购</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
<button type="object" name="action_view_surface_technics_picking" class="oe_stat_button" icon="fa-truck"
|
<button type="object" name="action_view_surface_technics_picking" class="oe_stat_button" icon="fa-truck"
|
||||||
groups="base.group_user,sf_base.group_sf_order_user"
|
groups="base.group_user,sf_base.group_sf_order_user"
|
||||||
attrs="{'invisible': [('surface_technics_picking_count', '=', 0)]}">
|
attrs="{'invisible': [('surface_technics_picking_count', '=', 0)]}">
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done',
|
lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done',
|
||||||
'cancel'] and ac.processing_panel == panel)
|
'cancel'] and ac.processing_panel == panel)
|
||||||
if cnc_workorder:
|
if cnc_workorder:
|
||||||
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
||||||
# panel)
|
panel)
|
||||||
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', 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)
|
logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
|
||||||
files_panel = os.listdir(program_path_tmp_panel)
|
files_panel = os.listdir(program_path_tmp_panel)
|
||||||
|
|||||||
@@ -219,6 +219,47 @@ class RePurchaseOrder(models.Model):
|
|||||||
if not line.taxes_id:
|
if not line.taxes_id:
|
||||||
raise UserError('请对【产品】中的【税】进行选择')
|
raise UserError('请对【产品】中的【税】进行选择')
|
||||||
|
|
||||||
|
def get_purchase_order(self, consecutive_process_parameters, production, product_id_to_production_names):
|
||||||
|
is_exist = True
|
||||||
|
server_product_process = []
|
||||||
|
production_process = product_id_to_production_names.get(
|
||||||
|
production.product_id.id)
|
||||||
|
for pp in consecutive_process_parameters:
|
||||||
|
if pp.gain_way == '外协':
|
||||||
|
server_product = self.env['product.template'].search(
|
||||||
|
[('server_product_process_parameters_id', '=', pp.id),
|
||||||
|
('detailed_type', '=', 'service')])
|
||||||
|
purchase_order_line = self.env['purchase.order.line'].search(
|
||||||
|
[('product_id', '=', server_product.id), ('product_qty', '=', len(production_process))])
|
||||||
|
if not purchase_order_line:
|
||||||
|
is_exist = False
|
||||||
|
server_product_process.append((0, 0, {
|
||||||
|
'product_id': server_product.product_variant_id.id,
|
||||||
|
'product_qty': len(production_process),
|
||||||
|
'product_uom': server_product.uom_id.id
|
||||||
|
}))
|
||||||
|
else:
|
||||||
|
for item in purchase_order_line:
|
||||||
|
purchase_order = self.env['purchase.order'].search(
|
||||||
|
[('state', '=', 'draft'), ('origin', 'ilike', production.name),
|
||||||
|
('id', '=', item.order_id.id)])
|
||||||
|
if not purchase_order:
|
||||||
|
is_exist = False
|
||||||
|
server_product_process.append((0, 0, {
|
||||||
|
'product_id': server_product.product_variant_id.id,
|
||||||
|
'product_qty': len(production_process),
|
||||||
|
'product_uom': server_product.uom_id.id
|
||||||
|
}))
|
||||||
|
if is_exist is False:
|
||||||
|
purchase_order = self.env['purchase.order'].search(
|
||||||
|
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process))])
|
||||||
|
if not purchase_order:
|
||||||
|
self.env['purchase.order'].sudo().create({
|
||||||
|
'partner_id': server_product.seller_ids.partner_id.id,
|
||||||
|
'origin': ','.join(production_process),
|
||||||
|
'state': 'draft',
|
||||||
|
'order_line': server_product_process})
|
||||||
|
|
||||||
@api.onchange('order_line')
|
@api.onchange('order_line')
|
||||||
def _onchange_order_line(self):
|
def _onchange_order_line(self):
|
||||||
for order in self:
|
for order in self:
|
||||||
@@ -238,6 +279,14 @@ class RePurchaseOrder(models.Model):
|
|||||||
if picking_id.move_ids:
|
if picking_id.move_ids:
|
||||||
for move_id in picking_id.move_ids:
|
for move_id in picking_id.move_ids:
|
||||||
move_id.put_move_line()
|
move_id.put_move_line()
|
||||||
|
for line in item.order_line:
|
||||||
|
if line.product_id.categ_type == '表面工艺':
|
||||||
|
for production_name in item.origin.split(','):
|
||||||
|
production = self.env['mrp.production'].search([('name', '=', production_name)])
|
||||||
|
for workorder in production.workorder_ids.filtered(
|
||||||
|
lambda wd: wd.routing_type == '表面工艺' and wd.state == 'waiting' and line.product_id.server_product_process_parameters_id == wd.surface_technics_parameters_id):
|
||||||
|
workorder.state = 'ready'
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user