Compare commits
36 Commits
feature/72
...
feature/ba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e47a85167 | ||
|
|
2644df4fd5 | ||
|
|
e14aa35d90 | ||
|
|
9392819375 | ||
|
|
ea3d9e5375 | ||
|
|
7db0a44420 | ||
|
|
238840b647 | ||
|
|
51e25d8847 | ||
|
|
c6f06a4c32 | ||
|
|
5b61a801c5 | ||
|
|
2893524902 | ||
|
|
ed55e36f45 | ||
|
|
c811f26104 | ||
|
|
3763b60758 | ||
|
|
976907bd92 | ||
|
|
50c3b31ece | ||
|
|
8afc8bb3a6 | ||
|
|
a0427d424f | ||
|
|
3148ce5a15 | ||
|
|
8e726e1bf6 | ||
|
|
4c0f9cfb39 | ||
|
|
86d3bd38c5 | ||
|
|
a8e4c7d9a0 | ||
|
|
7501832637 | ||
|
|
ce0ead4da6 | ||
|
|
343e2f9f24 | ||
|
|
6d3793ee30 | ||
|
|
43f7e97c28 | ||
|
|
9e6f3fa864 | ||
|
|
ed50d7c9a7 | ||
|
|
89e23050e6 | ||
|
|
b7f912453f | ||
|
|
1040844b0a | ||
|
|
36a13c04de | ||
|
|
f4318bd997 | ||
|
|
d47a30977c |
@@ -20,7 +20,8 @@ class MrpProduction(models.Model):
|
||||
# 由于采购申请合并了所有销售订单行的采购,所以不区分产品
|
||||
first_mp = self.env['mrp.production'].search(
|
||||
[('origin', '=', item.origin)], limit=1, order='id asc')
|
||||
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', first_mp.name)])
|
||||
pr_ids = self.env['purchase.request'].sudo().search(
|
||||
[('origin', 'like', first_mp.name), ('is_subcontract', '!=', 'True')])
|
||||
item.pr_mp_count = len(pr_ids)
|
||||
# pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', item.name), ('is_subcontract', '!=', 'True')])
|
||||
|
||||
@@ -29,18 +30,10 @@ class MrpProduction(models.Model):
|
||||
采购请求
|
||||
"""
|
||||
self.ensure_one()
|
||||
# pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', self.name),('is_subcontract', '!=', True)])
|
||||
# if self.product_id.product_tmpl_id.single_manufacturing == True and not self.is_remanufacture:
|
||||
# first_order = self.env['mrp.production'].search(
|
||||
# [('origin', '=', self.origin), ('product_id', '=', self.product_id.id)], limit=1, order='id asc')
|
||||
# pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', first_order.name)])
|
||||
# else:
|
||||
# pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', self.name)])
|
||||
# 由于采购申请合并了所有销售订单行的采购,所以不区分产品
|
||||
first_mp = self.env['mrp.production'].search(
|
||||
[('origin', '=', self.origin)], limit=1, order='id asc')
|
||||
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', first_mp.name)])
|
||||
|
||||
pr_ids = self.env['purchase.request'].sudo().search(
|
||||
[('origin', 'like', first_mp.name), ('is_subcontract', '!=', 'True')])
|
||||
|
||||
action = {
|
||||
'res_model': 'purchase.request',
|
||||
@@ -54,7 +47,7 @@ class MrpProduction(models.Model):
|
||||
else:
|
||||
action.update({
|
||||
'name': _("从 %s生成采购请求单", self.name),
|
||||
'domain': [('id', 'in', pr_ids)],
|
||||
'domain': [('id', 'in', pr_ids.ids)],
|
||||
'view_mode': 'tree,form',
|
||||
})
|
||||
return action
|
||||
|
||||
@@ -24,6 +24,8 @@ class SfProductionProcessParameter(models.Model):
|
||||
obj = super(SfProductionProcessParameter, self).create(vals)
|
||||
return obj
|
||||
def create_service_product(self):
|
||||
if not self.active:
|
||||
return
|
||||
service_categ = self.env.ref(
|
||||
'sf_dlm.product_category_surface_technics_sf').sudo()
|
||||
|
||||
|
||||
@@ -41,7 +41,9 @@
|
||||
attrs="{'invisible': [('categ_type', 'not in', ['成品','坯料', '原材料'])],'readonly': [('id', '!=', False)]}"/>
|
||||
<field name="server_product_process_parameters_id" string="工艺参数"
|
||||
options="{'no_create': True}"
|
||||
attrs="{'invisible': ['|',('detailed_type', '!=', 'service'),('detailed_type', '=', False)]}"/>
|
||||
attrs="{'invisible': ['|',('detailed_type', '!=', 'service'),('detailed_type', '=', False)]}"
|
||||
domain="[('active', '=', 'True'),('outsourced_service_products', '!=', 'True')]"
|
||||
/>
|
||||
<field name="cutting_tool_material_id" class="custom_required"
|
||||
options="{'no_create': True}"
|
||||
attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}"
|
||||
|
||||
@@ -928,6 +928,8 @@ class MrpProduction(models.Model):
|
||||
'sf_stock.stock_route_process_outsourcing').id)]
|
||||
for product_id, request_line_list in grouped_purchase_request_line_sorted_list.items():
|
||||
cur_request_line = request_line_list[0]
|
||||
if cur_request_line['product_qty'] == 1:
|
||||
cur_request_line['product_qty'] = len(request_line_list)
|
||||
# cur_request_line['product_qty'] = cur_request_line['product_qty']
|
||||
cur_request_line['request_id'] = pr.id
|
||||
cur_request_line['origin'] = ", ".join({item['production_name'] for item in request_line_list if item.get('production_name')})
|
||||
|
||||
@@ -443,21 +443,11 @@ class ResMrpWorkOrder(models.Model):
|
||||
@api.depends('state', 'production_id.name')
|
||||
def _compute_surface_technics_purchase_ids(self):
|
||||
for order in self:
|
||||
if order.routing_type == '表面工艺' and order.state not in ['cancel']:
|
||||
# domain = [('group_id', '=', self.production_id.procurement_group_id.id),
|
||||
# ('purchase_type', '=', 'consignment'), ('state', '!=', 'cancel')]
|
||||
domain = [('purchase_type', '=', 'consignment'),
|
||||
('origin', 'like', '%' + self.production_id.name + '%'),
|
||||
('state', '!=', 'cancel')]
|
||||
purchase = self.env['purchase.order'].search(domain)
|
||||
order.surface_technics_purchase_count = 0
|
||||
if not purchase:
|
||||
order.surface_technics_purchase_count = 0
|
||||
for po in purchase:
|
||||
if any(
|
||||
line.product_id and line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id
|
||||
for line in po.order_line):
|
||||
order.surface_technics_purchase_count = 1
|
||||
pr_ids = self.env['purchase.request'].sudo().search(
|
||||
[('origin', 'like', self.production_id.name), ('is_subcontract', '=', 'True'),
|
||||
('state', '!=', 'rejected')])
|
||||
if pr_ids.purchase_count:
|
||||
order.surface_technics_purchase_count = pr_ids.purchase_count
|
||||
else:
|
||||
order.surface_technics_purchase_count = 0
|
||||
|
||||
@@ -502,16 +492,19 @@ class ResMrpWorkOrder(models.Model):
|
||||
# if technology_design.is_auto is False:
|
||||
# domain = [('origin', '=', self.production_id.name)]
|
||||
# else:
|
||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||
result = {
|
||||
"type": "ir.actions.act_window",
|
||||
"res_model": "purchase.order",
|
||||
"res_id": purchase_orders_id.id,
|
||||
# "domain": [['id', 'in', self.purchase_id]],
|
||||
"name": _("Purchase Orders"),
|
||||
'view_mode': 'form',
|
||||
}
|
||||
return result
|
||||
pr_ids = self.env['purchase.request'].sudo().search(
|
||||
[('origin', 'like', self.production_id.name), ('is_subcontract', '=', 'True'),
|
||||
('state', '!=', 'rejected')])
|
||||
# purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||
# result = {
|
||||
# "type": "ir.actions.act_window",
|
||||
# "res_model": "purchase.order",
|
||||
# "res_id": purchase_orders_id.id,
|
||||
# # "domain": [['id', 'in', self.purchase_id]],
|
||||
# "name": _("Purchase Orders"),
|
||||
# 'view_mode': 'form',
|
||||
# }
|
||||
return pr_ids.action_view_purchase_order()
|
||||
|
||||
def _get_surface_technics_purchase_ids(self):
|
||||
domain = [('origin', 'like', '%' + self.production_id.name + '%'), ('purchase_type', '=', 'consignment'),
|
||||
@@ -1283,20 +1276,27 @@ class ResMrpWorkOrder(models.Model):
|
||||
# for move_line in move.move_line_ids
|
||||
# )
|
||||
if (workorder.production_id.production_type == '人工线下加工'
|
||||
and workorder.production_id.schedule_state == '已排'):
|
||||
and workorder.production_id.programming_state == '已编程'):
|
||||
# and workorder.production_id.programming_state == '已编程'
|
||||
if workorder.is_subcontract is True:
|
||||
if workorder.production_id.state == 'rework':
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||
if purchase_orders_id.state == 'purchase':
|
||||
purchase_count = 0
|
||||
for purchase_order in purchase_orders_id:
|
||||
for purchase_order_line in purchase_order.order_line:
|
||||
if purchase_order_line.product_id.server_product_process_parameters_id.id == workorder.surface_technics_parameters_id.id:
|
||||
purchase_count = purchase_order_line.product_qty
|
||||
if purchase_orders_id.state == 'purchase' and purchase_count>=workorder.production_id.product_qty:
|
||||
workorder.state = 'ready'
|
||||
picking_id = workorder.production_id.picking_ids.filtered(
|
||||
lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
||||
move_out = picking_id.move_ids
|
||||
# move_out = workorder.move_subcontract_workorder_ids[1]
|
||||
for mo in move_out:
|
||||
if workorder.production_id.bom_id.bom_line_ids.product_id.id != mo.product_id.id:
|
||||
continue
|
||||
if mo.state != 'done':
|
||||
mo.write({'state': 'assigned', 'production_id': False})
|
||||
if not mo.move_line_ids:
|
||||
@@ -1312,6 +1312,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
else:
|
||||
workorder.state = 'ready'
|
||||
continue
|
||||
continue
|
||||
# ================= 如果制造订单刀具状态为[无效刀、缺刀] 或者 制造订单状态为[返工]==========================
|
||||
if (workorder.production_id.tool_state in ['1', '2'] or workorder.production_id.state == 'rework'
|
||||
or workorder.production_id.schedule_state != '已排'
|
||||
@@ -1327,9 +1328,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
if workorder.is_subcontract is False:
|
||||
workorder.state = 'ready'
|
||||
else:
|
||||
if len(workorder.production_id.picking_ids.filtered(
|
||||
lambda w: w.state not in ['done',
|
||||
'cancel'])) == 0 and workorder.production_id.programming_state == '已编程':
|
||||
if workorder.production_id.programming_state == '已编程':
|
||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||
if purchase_orders_id:
|
||||
if purchase_orders_id.state == 'purchase':
|
||||
@@ -1339,6 +1338,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
||||
move_out = picking_id.move_ids
|
||||
for mo in move_out:
|
||||
if workorder.production_id.bom_id.bom_line_ids.product_id.id != mo.product_id.id:
|
||||
continue
|
||||
if mo.state != 'done':
|
||||
mo.write({'state': 'assigned', 'production_id': False})
|
||||
if not mo.move_line_ids:
|
||||
@@ -1387,6 +1388,15 @@ class ResMrpWorkOrder(models.Model):
|
||||
boolean = True
|
||||
if not boolean:
|
||||
raise UserError('制造订单【%s】缺少组件的序列号信息!' % self.production_id.name)
|
||||
self.pro_code = False # 默认值
|
||||
if (
|
||||
self.production_id
|
||||
and self.production_id.move_raw_ids
|
||||
and len(self.production_id.move_raw_ids) > 0
|
||||
and self.production_id.move_raw_ids[0].move_line_ids
|
||||
and len(self.production_id.move_raw_ids[0].move_line_ids) > 0
|
||||
and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id
|
||||
):
|
||||
self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name
|
||||
# cnc校验
|
||||
if self.production_id.production_type == '自动化产线加工':
|
||||
@@ -1422,6 +1432,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
# [('barcode', 'ilike', 'VL-SPOC')]).id),
|
||||
# ('origin', '=', self.production_id.name), ('state', 'not in', ['cancel', 'done'])])
|
||||
for mo in move_out:
|
||||
if self.production_id.bom_id.bom_line_ids.product_id.id != mo.product_id.id:
|
||||
continue
|
||||
if mo.state != 'done':
|
||||
mo.write({'state': 'assigned', 'production_id': False})
|
||||
if not mo.move_line_ids:
|
||||
@@ -1554,6 +1566,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
lambda wo: wo.is_subcontract == True and wo.state != 'cancel').sorted('sequence')
|
||||
if self == subcontract_workorders[-1]:
|
||||
# 给下一个库存移动就绪
|
||||
if self.move_subcontract_workorder_ids:
|
||||
self.move_subcontract_workorder_ids[0].move_dest_ids._action_done()
|
||||
# self.production_id.button_mark_done()
|
||||
tem_date_planned_finished = record.date_planned_finished
|
||||
|
||||
@@ -126,11 +126,13 @@ class PurchaseOrder(models.Model):
|
||||
if not work_ids:
|
||||
continue
|
||||
min_sequence_wk = min(work_ids, key=lambda wk: wk.sequence)
|
||||
if min_sequence_wk.is_subcontract:
|
||||
if min_sequence_wk.is_subcontract and min_sequence_wk.state == 'ready':
|
||||
picking_id = production_id.picking_ids.filtered(
|
||||
lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
||||
move_out = picking_id.move_ids
|
||||
for mo in move_out:
|
||||
if production_id.bom_id.bom_line_ids.product_id.id != mo.product_id.id:
|
||||
continue
|
||||
if mo.state != 'done':
|
||||
mo.write({'state': 'assigned', 'production_id': False})
|
||||
if not mo.move_line_ids:
|
||||
@@ -152,6 +154,8 @@ class PurchaseOrder(models.Model):
|
||||
|
||||
for line in self.order_line:
|
||||
# 将产品不追踪序列号的行项目设置qty_done
|
||||
if not line.move_ids:
|
||||
continue
|
||||
if line.move_ids and line.move_ids[0].product_id.tracking == 'none':
|
||||
line.move_ids[0].quantity_done = line.move_ids[0].product_qty
|
||||
return res
|
||||
@@ -224,6 +228,24 @@ class PurchaseOrderLine(models.Model):
|
||||
)
|
||||
record.part_number = filtered_order_line.product_id.part_number
|
||||
record.part_name = filtered_order_line.product_id.part_name
|
||||
elif record.order_id.purchase_type == 'consignment':
|
||||
product_name = ''
|
||||
match = re.search(r'(S\d{5}-\d)', record.related_product.name)
|
||||
# 如果匹配成功,提取结果
|
||||
if match:
|
||||
product_name = match.group(0)
|
||||
sale_order_name = ''
|
||||
match_sale = re.search(r'S(\d+)', record.related_product.name)
|
||||
if match_sale:
|
||||
sale_order_name = match_sale.group(0)
|
||||
sale_order = self.env['sale.order'].sudo().search(
|
||||
[('name', '=', sale_order_name)])
|
||||
if sale_order:
|
||||
filtered_order_line = sale_order.order_line.filtered(
|
||||
lambda order_line: re.search(f'{product_name}$', order_line.product_id.name)
|
||||
)
|
||||
record.part_number = filtered_order_line.product_id.part_number
|
||||
record.part_name = filtered_order_line.product_id.part_name
|
||||
else:
|
||||
record.part_number = record.product_id.part_number
|
||||
record.part_name = record.product_id.part_name
|
||||
|
||||
@@ -20,13 +20,6 @@ class SfProductionProcessParameter(models.Model):
|
||||
is_product_button = fields.Boolean(compute='_compute_is_product_button',default=False)
|
||||
is_delete_button = fields.Boolean(compute='_compute_is_delete_button', default=False)
|
||||
routing_id = fields.Many2one('mrp.routing.workcenter', string="工序")
|
||||
|
||||
@api.depends('outsourced_service_products')
|
||||
def _compute_service_products(self):
|
||||
for record in self:
|
||||
# 假设取第一条作为主明细
|
||||
record.service_products = record.outsourced_service_products.ids if record.outsourced_service_products else False
|
||||
|
||||
def _inverse_service_products(self):
|
||||
for record in self:
|
||||
if record.service_products:
|
||||
@@ -34,6 +27,12 @@ class SfProductionProcessParameter(models.Model):
|
||||
record.outsourced_service_products = record.service_products.ids if record.service_products else False
|
||||
else:
|
||||
record.outsourced_service_products = False
|
||||
@api.depends('outsourced_service_products')
|
||||
def _compute_service_products(self):
|
||||
for record in self:
|
||||
# 假设取第一条作为主明细
|
||||
record.service_products = record.outsourced_service_products[0].id if record.outsourced_service_products else False
|
||||
|
||||
def name_get(self):
|
||||
result = []
|
||||
for record in self:
|
||||
|
||||
@@ -930,6 +930,8 @@ class ReStockMove(models.Model):
|
||||
}
|
||||
|
||||
def get_move_line(self, production_id, sorted_workorders):
|
||||
# if not self.move_ids[0].product_id.single_manufacturing and self.move_ids[0].product_id.tracking == 'none':
|
||||
qty = production_id.product_qty
|
||||
return {
|
||||
'move_id': self.id,
|
||||
'product_id': self.product_id.id,
|
||||
@@ -937,7 +939,7 @@ class ReStockMove(models.Model):
|
||||
'location_id': self.picking_id.location_id.id,
|
||||
'location_dest_id': self.picking_id.location_dest_id.id,
|
||||
'picking_id': self.picking_id.id,
|
||||
'reserved_uom_qty': 1.0,
|
||||
'reserved_uom_qty': qty,
|
||||
'lot_id': production_id.move_line_raw_ids.lot_id.id,
|
||||
'company_id': self.env.company.id,
|
||||
# 'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
|
||||
|
||||
@@ -3,6 +3,9 @@ import logging
|
||||
import os
|
||||
import json
|
||||
import base64
|
||||
import traceback
|
||||
|
||||
|
||||
from odoo import http, fields, models
|
||||
from odoo.http import request
|
||||
from odoo.addons.sf_base.controllers.controllers import MultiInheritController
|
||||
@@ -273,7 +276,8 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
except Exception as e:
|
||||
res = {'status': -1, 'message': '系统解析失败'}
|
||||
request.cr.rollback()
|
||||
logging.info('get_cnc_processing_create error:%s' % e)
|
||||
traceback_error = traceback.format_exc()
|
||||
logging.error("get_cnc_processing_create error:%s" % traceback_error)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user