Accept Merge Request #1017: (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/1017?initial=true
This commit is contained in:
@@ -52,7 +52,7 @@ class Sf_Bf_Connect(http.Controller):
|
||||
self_machining_embryo = request.env['product.template'].sudo().no_bom_product_create(
|
||||
self_machining_id,
|
||||
item,
|
||||
order_id, 'self_machining', i)
|
||||
order_id, 'self_machining', i, product)
|
||||
# 创建坯料的bom
|
||||
self_machining_bom = request.env['mrp.bom'].with_user(
|
||||
request.env.ref("base.user_admin")).bom_create(
|
||||
@@ -78,7 +78,7 @@ class Sf_Bf_Connect(http.Controller):
|
||||
item,
|
||||
order_id,
|
||||
'subcontract',
|
||||
i)
|
||||
i, product)
|
||||
if outsource_embryo == -3:
|
||||
res['status'] = -3
|
||||
res['message'] = '该订单模型的材料型号在您分配的工厂里暂未设置获取方式和供应商,请先配置再进行分配'
|
||||
@@ -105,7 +105,8 @@ class Sf_Bf_Connect(http.Controller):
|
||||
purchase_embryo = request.env['product.template'].sudo().no_bom_product_create(purchase_id,
|
||||
item,
|
||||
order_id,
|
||||
'purchase', i)
|
||||
'purchase', i,
|
||||
product)
|
||||
if purchase_embryo == -3:
|
||||
res['status'] = -3
|
||||
res['message'] = '该订单模型的材料型号在您分配的工厂里暂未设置获取方式和供应商,请先配置再进行分配'
|
||||
|
||||
@@ -74,12 +74,23 @@
|
||||
<field name="active">True</field>
|
||||
<field name="sequence">11</field>
|
||||
</record>
|
||||
<!-- <record id="route_surface_technology_outsourcing" model="stock.rule">-->
|
||||
<!-- <record id="rule_surface_technology_in" model="stock.rule">-->
|
||||
<!-- <field name="name">外协出库单</field>-->
|
||||
<!-- <field name="action">push</field>-->
|
||||
<!-- <field name="pick_type_id" ref="outcontract_picking_out"></field>-->
|
||||
<!-- <field name="location_src_id" ref=""/>-->
|
||||
<!-- <field name="location_dest_id" ref="stock_location_locations_virtual_outcontract"/>-->
|
||||
<!-- <field name="route_id" ref="route_surface_technology_outsourcing"/>-->
|
||||
<!--<!– <field name="action">push</field>–>-->
|
||||
<!-- <field name="pick_type_id" ref="outcontract_picking_in"/>-->
|
||||
<!-- <!– <field name="location_src_id" search="[('barcode','=','WH-PREPRODUCTION')]"/>–>-->
|
||||
<!-- <!– <field name="location_dest_id" ref="stock_location_locations_virtual_outcontract"/>–>-->
|
||||
<!-- <!– <field name="active">True</field>–>-->
|
||||
<!-- <!– <field name="sequence">11</field>–>-->
|
||||
<!-- </record>-->
|
||||
<!-- <record id="rule_surface_technology_in" model="stock.rule">-->
|
||||
<!-- <field name="name">外协入库单</field>-->
|
||||
<!-- <field name="route_id" ref="route_surface_technology_outsourcing"/>-->
|
||||
<!-- <field name="action">pull</field>-->
|
||||
<!-- <field name="pick_type_id" ref="outcontract_picking_out"/>-->
|
||||
<!-- <field name="location_src_id" ref="stock_location_locations_virtual_outcontract"/>-->
|
||||
<!-- <field name="location_dest_id" search="[('barcode','=','WH-PREPRODUCTION')]"/>-->
|
||||
<!-- <field name="active">True</field>-->
|
||||
<!-- <field name="sequence">11</field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
@@ -305,8 +305,8 @@ class MrpProduction(models.Model):
|
||||
}]
|
||||
if production.product_id.categ_id.type == '成品':
|
||||
if production.product_id.id in product_id_to_production_names:
|
||||
# 同一个产品多个制造订单对应一个编程单和模型库
|
||||
# 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
||||
# # 同一个产品多个制造订单对应一个编程单和模型库
|
||||
# # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
||||
if not production.programming_no:
|
||||
production_programming = self.search(
|
||||
[('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)],
|
||||
@@ -318,7 +318,7 @@ class MrpProduction(models.Model):
|
||||
logging.info('production_programming2:%s' % production_programming.programming_no)
|
||||
production.write({'programming_no': production_programming.programming_no,
|
||||
'programming_state': '编程中'})
|
||||
# 根据加工面板的面数及对应的工序模板生成工单
|
||||
# # 根据加工面板的面数及对应的工序模板生成工单
|
||||
i = 0
|
||||
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
||||
for k in (production.product_id.model_processing_panel.split(',')):
|
||||
@@ -381,49 +381,6 @@ class MrpProduction(models.Model):
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
||||
production.workorder_ids = workorders_values
|
||||
process_parameter_workorder = self.env['mrp.workorder'].search(
|
||||
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
|
||||
('is_subcontract', '=', True)])
|
||||
if process_parameter_workorder:
|
||||
is_pick = False
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
|
||||
for i in range(len(sorted_workorders) - 1):
|
||||
if m == 0:
|
||||
is_pick = False
|
||||
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
|
||||
sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
|
||||
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
|
||||
if sorted_workorders[i] not in consecutive_workorders:
|
||||
consecutive_workorders.append(sorted_workorders[i])
|
||||
consecutive_workorders.append(sorted_workorders[i + 1])
|
||||
m += 1
|
||||
continue
|
||||
else:
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
||||
if sorted_workorders[i] in consecutive_workorders:
|
||||
is_pick = True
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
|
||||
if is_pick is False:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production)
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
||||
if sorted_workorders[i] in consecutive_workorders:
|
||||
is_pick = True
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
||||
if is_pick is False and m == 0:
|
||||
if len(sorted_workorders) == 1:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production)
|
||||
else:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production)
|
||||
|
||||
for workorder in production.workorder_ids:
|
||||
workorder.duration_expected = workorder._get_duration_expected()
|
||||
|
||||
@@ -449,20 +406,6 @@ class MrpProduction(models.Model):
|
||||
'user_id': production.user_id.id}
|
||||
return production_values_str
|
||||
|
||||
def _get_stock_move_values_Res(self, item, location_src_id, location_dest_id, picking_type_id):
|
||||
move_values = {
|
||||
'name': item.name if item.name else '/',
|
||||
'company_id': item.company_id.id,
|
||||
'product_id': item.bom_id.bom_line_ids.product_id.id,
|
||||
'product_uom': item.bom_id.bom_line_ids.product_uom_id.id,
|
||||
'product_uom_qty': 1.0,
|
||||
'location_id': location_src_id,
|
||||
'location_dest_id': location_dest_id,
|
||||
'origin': item.origin,
|
||||
'picking_type_id': picking_type_id,
|
||||
}
|
||||
return move_values
|
||||
|
||||
# 工单排序
|
||||
def _reset_work_order_sequence1(self, k):
|
||||
sequen = 0
|
||||
|
||||
@@ -109,8 +109,29 @@ class ResMrpWorkOrder(models.Model):
|
||||
glb_file = fields.Binary("glb模型文件", related='production_id.model_file')
|
||||
is_subcontract = fields.Boolean(string='是否外协')
|
||||
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
||||
picking_in_id = fields.Many2one('stock.picking', string='外协入库单')
|
||||
picking_out_id = fields.Many2one('stock.picking', string='外协出库单')
|
||||
picking_ids = fields.Many2many('stock.picking', string='外协出入库单')
|
||||
surface_technics_picking_count = fields.Integer("外协出入库", compute='_compute_surface_technics_picking_ids')
|
||||
|
||||
@api.depends('name', 'production_id.name')
|
||||
def _compute_surface_technics_picking_ids(self):
|
||||
for order in self:
|
||||
picking_ids = self.env['stock.picking'].search([('id', 'in', order.picking_ids.ids)])
|
||||
order.surface_technics_picking_count = len(picking_ids)
|
||||
|
||||
def action_view_surface_technics_picking(self):
|
||||
self.ensure_one()
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("stock.action_picking_tree_all")
|
||||
if len(self.picking_ids) > 1:
|
||||
action['domain'] = [('id', 'in', self.picking_ids.ids)]
|
||||
elif self.picking_ids:
|
||||
# action['name'] = '工艺外协'
|
||||
action['res_id'] = self.picking_ids.id
|
||||
action['views'] = [(self.env.ref('stock.view_picking_form').id, 'form')]
|
||||
if 'views' in action:
|
||||
action['views'] += [(state, view) for state, view in action['views'] if view != 'form']
|
||||
action['context'] = dict(self._context, default_origin=self.name)
|
||||
return action
|
||||
|
||||
supplier_id = fields.Many2one('res.partner', string='外协供应商')
|
||||
equipment_id = fields.Many2one('maintenance.equipment', string='加工设备')
|
||||
is_ok = fields.Boolean(string='是否合格')
|
||||
@@ -769,11 +790,21 @@ class ResMrpWorkOrder(models.Model):
|
||||
记录开始时间
|
||||
'''
|
||||
self.date_start = datetime.now()
|
||||
# 外协出库单,从“正在等待”变为“就绪”状态
|
||||
# 表面工艺外协出库单
|
||||
if self.routing_type == '表面工艺':
|
||||
if self.is_subcontract is True:
|
||||
picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)])
|
||||
if picking_out.state == 'confirmed':
|
||||
picking_out.write({'state': 'assigned'})
|
||||
move_out = self.env['stock.move'].search(
|
||||
[('location_id', '=', self.env['stock.location'].search(
|
||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
||||
('location_dest_id', '=', self.env.ref(
|
||||
'sf_manufacturing.stock_location_locations_virtual_outcontract').id),
|
||||
('origin', '=', self.production_id.name)])
|
||||
purchase = self.env['purchase.order'].search([('origin', '=', self.production_id.name)])
|
||||
if purchase and move_out:
|
||||
move_out.write({'state': 'assigned'})
|
||||
self.env['stock.move.line'].create(move_out.get_move_line(purchase, self))
|
||||
|
||||
# move_out._action_assign()
|
||||
if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress':
|
||||
self.move_raw_ids = self.production_id.move_raw_ids
|
||||
self.move_raw_ids[0].write({
|
||||
@@ -852,25 +883,28 @@ class ResMrpWorkOrder(models.Model):
|
||||
记录结束时间
|
||||
'''
|
||||
record.date_finished = datetime.now()
|
||||
|
||||
if record.picking_out_id:
|
||||
picking_out = record.env['stock.picking'].search([('id', '=', record.picking_out_id.id)])
|
||||
if picking_out.workorder_out_id:
|
||||
if record.routing_type == '表面工艺':
|
||||
if record.picking_ids[0]:
|
||||
picking_out = record.env['stock.move.line'].search(
|
||||
[('picking_id', '=', record.picking_ids[0].id), ('workorder_id', '=', record.id)])
|
||||
if picking_out:
|
||||
order_line_ids = []
|
||||
for item in picking_out.workorder_out_id:
|
||||
server_product = record.env['product.template'].search(
|
||||
for item in picking_out.workorder_id:
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
if server_product:
|
||||
order_line_ids.append((0, 0, {
|
||||
'product_id': server_product.product_variant_id.id,
|
||||
'product_qty': 1,
|
||||
'origin': record.production_id.name,
|
||||
'product_uom': server_product.uom_id.id
|
||||
}))
|
||||
else:
|
||||
raise UserError(
|
||||
'请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
|
||||
record.env['purchase.order'].create({
|
||||
if order_line_ids:
|
||||
self.env['purchase.order'].create({
|
||||
'partner_id': server_product.seller_ids.partner_id.id,
|
||||
'state': 'draft',
|
||||
'order_line': order_line_ids,
|
||||
|
||||
@@ -7,8 +7,6 @@ import os
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.modules import get_resource_path
|
||||
|
||||
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
|
||||
@@ -660,8 +658,12 @@ class ResProductMo(models.Model):
|
||||
return attachment
|
||||
|
||||
# 创建坯料
|
||||
def no_bom_product_create(self, product_id, item, order_id, route_type, i):
|
||||
def no_bom_product_create(self, product_id, item, order_id, route_type, i, finish_product):
|
||||
no_bom_copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
|
||||
# if finish_product.model_process_parameters_ids:
|
||||
# surface_technology = self.env['stock.route'].sudo().search([('name', '=', '表面工艺外协')])
|
||||
# if surface_technology:
|
||||
# no_bom_copy_product_id.route_ids |= surface_technology
|
||||
no_bom_copy_product_id.product_tmpl_id.active = True
|
||||
materials_id = self.env['sf.production.materials'].search(
|
||||
[('materials_no', '=', item['texture_code'])])
|
||||
|
||||
@@ -202,7 +202,7 @@ class StockRule(models.Model):
|
||||
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
|
||||
productions_values)
|
||||
|
||||
self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
'''
|
||||
创建工单
|
||||
@@ -213,6 +213,52 @@ class StockRule(models.Model):
|
||||
(
|
||||
p.move_dest_ids.procure_method != 'make_to_order' and not
|
||||
p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
||||
for production_item in productions:
|
||||
process_parameter_workorder = self.env['mrp.workorder'].search(
|
||||
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production_item.id),
|
||||
('is_subcontract', '=', True)])
|
||||
if process_parameter_workorder:
|
||||
is_pick = False
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
|
||||
for i in range(len(sorted_workorders) - 1):
|
||||
if m == 0:
|
||||
is_pick = False
|
||||
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
|
||||
sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
|
||||
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
|
||||
if sorted_workorders[i] not in consecutive_workorders:
|
||||
consecutive_workorders.append(sorted_workorders[i])
|
||||
consecutive_workorders.append(sorted_workorders[i + 1])
|
||||
m += 1
|
||||
continue
|
||||
else:
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
||||
production_item)
|
||||
if sorted_workorders[i] in consecutive_workorders:
|
||||
is_pick = True
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
|
||||
if is_pick is False:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
||||
production_item)
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
||||
production_item)
|
||||
if sorted_workorders[i] in consecutive_workorders:
|
||||
is_pick = True
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production_item)
|
||||
if is_pick is False and m == 0:
|
||||
if len(sorted_workorders) == 1:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production_item)
|
||||
else:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production_item)
|
||||
|
||||
for production in productions:
|
||||
'''
|
||||
@@ -441,8 +487,8 @@ class ProductionLot(models.Model):
|
||||
class StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
workorder_in_id = fields.One2many('mrp.workorder', 'picking_in_id')
|
||||
workorder_out_id = fields.One2many('mrp.workorder', 'picking_out_id')
|
||||
# workorder_in_id = fields.One2many('mrp.workorder', 'picking_in_id')
|
||||
# workorder_out_id = fields.One2many('mrp.workorder', 'picking_out_id')
|
||||
|
||||
# 设置外协出入单的名称
|
||||
def _get_name_Res(self, rescode):
|
||||
@@ -456,47 +502,56 @@ class StockPicking(models.Model):
|
||||
return '%s%s' % (rescode, num)
|
||||
|
||||
def button_validate(self):
|
||||
# 出库单验证
|
||||
if self.workorder_out_id:
|
||||
workorder_in = self.workorder_out_id.filtered(lambda p: p.state == 'progress' and p.is_subcontract is True)
|
||||
if workorder_in:
|
||||
picking_in = self.sudo().search([('id', '=', workorder_in.picking_in_id.id)])
|
||||
if picking_in:
|
||||
picking_in.write({'state': 'assigned'})
|
||||
else:
|
||||
workorder_subcontract = self.workorder_out_id.filtered(
|
||||
lambda p: p.state == 'pending' and p.is_subcontract is True)
|
||||
if workorder_subcontract:
|
||||
move_out = self.env['stock.move'].search(
|
||||
[('location_id', '=', self.env['stock.location'].search(
|
||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
||||
('location_dest_id', '=', self.env.ref(
|
||||
'sf_manufacturing.stock_location_locations_virtual_outcontract').id),
|
||||
('origin', '=', self.origin)])
|
||||
if self.id == move_out.picking_id.id:
|
||||
if move_out.move_line_ids.workorder_id.state not in ['progress']:
|
||||
raise UserError(
|
||||
_('该出库单里源单据内的单号为%s的工单还未开始,不能进行验证操作!' % workorder_subcontract[
|
||||
0].name))
|
||||
_('该出库单里源单据内的单号为%s的工单还未开始,不能进行验证操作!' % move_out.move_line_ids.workorder_id.name))
|
||||
# 入库单验证
|
||||
if self.workorder_in_id:
|
||||
workorder_out = self.workorder_in_id.filtered(lambda p: p.state == 'progress' and p.is_subcontract is True)
|
||||
if workorder_out:
|
||||
picking_out = self.sudo().search([('id', '=', workorder_out.picking_out_id.id)])
|
||||
if picking_out.state != 'done':
|
||||
move_in = self.env['stock.move'].search(
|
||||
[('location_dest_id', '=', self.env['stock.location'].search(
|
||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
||||
('location_id', '=', self.env.ref(
|
||||
'sf_manufacturing.stock_location_locations_virtual_outcontract').id),
|
||||
('origin', '=', self.origin)])
|
||||
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.picking_id.state != 'done':
|
||||
raise UserError(
|
||||
_('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % picking_out.name))
|
||||
|
||||
_('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % move_out.picking_id.name))
|
||||
res = super().button_validate()
|
||||
# 采购单验证(夹具)
|
||||
# for item in self.move_ids_without_package:
|
||||
# if item.quantity_done > 0:
|
||||
# if item.product_id.categ_type == '夹具':
|
||||
# item._register_fixture()
|
||||
# elif item.product_id.categ_type == '刀具':
|
||||
# item._register_cutting_tool()
|
||||
if res is True:
|
||||
if self.id == move_out.picking_id.id:
|
||||
if move_out.move_line_ids.workorder_id.state == 'progress':
|
||||
move_in = self.env['stock.move'].search(
|
||||
[('location_dest_id', '=', self.env['stock.location'].search(
|
||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
||||
('location_id', '=', self.env.ref(
|
||||
'sf_manufacturing.stock_location_locations_virtual_outcontract').id),
|
||||
('origin', '=', self.origin)])
|
||||
# purchase = self.env['purchase.order'].search([('origin', '=', self.origin)])
|
||||
if move_in:
|
||||
move_in.write({'state': 'assigned'})
|
||||
purchase = self.env['purchase.order'].search([('origin', '=', self.origin)])
|
||||
self.env['stock.move.line'].create(move_in.get_move_line(purchase, None))
|
||||
|
||||
return res
|
||||
|
||||
# 创建 外协出库入单
|
||||
def create_outcontract_picking(self, sorted_workorders_arr, item):
|
||||
m = 0
|
||||
for sorted_workorders in sorted_workorders_arr:
|
||||
pick_ids = []
|
||||
if m == 0:
|
||||
outcontract_stock_move = self.env['stock.move'].search(
|
||||
[('workorder_id', '=', sorted_workorders.id), ('production_id', '=', item.id)])
|
||||
if not outcontract_stock_move:
|
||||
new_picking = True
|
||||
location_id = self.env.ref(
|
||||
'sf_manufacturing.stock_location_locations_virtual_outcontract').id,
|
||||
location_dest_id = self.env['stock.location'].search(
|
||||
@@ -505,23 +560,26 @@ class StockPicking(models.Model):
|
||||
'sf_manufacturing.outcontract_picking_in').id,
|
||||
outcontract_picking_type_out = self.env.ref(
|
||||
'sf_manufacturing.outcontract_picking_out').id,
|
||||
moves_in = self.env['stock.move'].sudo().create(
|
||||
item._get_stock_move_values_Res(item, location_id, location_dest_id,
|
||||
outcontract_picking_type_in))
|
||||
moves_out = self.env['stock.move'].sudo().create(
|
||||
item._get_stock_move_values_Res(item, location_dest_id, location_id,
|
||||
self.env['stock.move']._get_stock_move_values_Res(item, location_dest_id, location_id,
|
||||
outcontract_picking_type_out))
|
||||
new_picking = True
|
||||
picking_in = self.create(
|
||||
moves_in._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCIN/'))
|
||||
picking_out = self.create(
|
||||
moves_out._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCOUT/'))
|
||||
moves_in.write({'picking_id': picking_in.id, 'state': 'confirmed'})
|
||||
moves_out.write({'picking_id': picking_out.id, 'state': 'confirmed'})
|
||||
moves_in._assign_picking_post_process(new=new_picking)
|
||||
pick_ids.append(picking_out.id)
|
||||
moves_out.write(
|
||||
{'picking_id': picking_out.id, 'state': 'waiting', 'workorder_id': sorted_workorders.id})
|
||||
moves_out._assign_picking_post_process(new=new_picking)
|
||||
moves_in = self.env['stock.move'].sudo().create(
|
||||
self.env['stock.move']._get_stock_move_values_Res(item, location_id, location_dest_id,
|
||||
outcontract_picking_type_in))
|
||||
picking_in = self.create(
|
||||
moves_in._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCIN/'))
|
||||
pick_ids.append(picking_in.id)
|
||||
moves_in.write(
|
||||
{'picking_id': picking_in.id, 'state': 'waiting', 'workorder_id': sorted_workorders.id})
|
||||
moves_in._assign_picking_post_process(new=new_picking)
|
||||
m += 1
|
||||
sorted_workorders.write({'picking_in_id': picking_in.id, 'picking_out_id': picking_out.id})
|
||||
sorted_workorders.write({'picking_ids': [(6, 0, pick_ids)]})
|
||||
|
||||
|
||||
class ReStockMove(models.Model):
|
||||
@@ -531,6 +589,23 @@ class ReStockMove(models.Model):
|
||||
materiel_width = fields.Float(string='物料宽度', digits=(16, 4))
|
||||
materiel_height = fields.Float(string='物料高度', digits=(16, 4))
|
||||
|
||||
def _get_stock_move_values_Res(self, item, location_src_id, location_dest_id, picking_type_id):
|
||||
route = self.env['stock.route'].sudo().search([('name', '=', '表面工艺外协')])
|
||||
move_values = {
|
||||
'name': '推',
|
||||
'company_id': item.company_id.id,
|
||||
'product_id': item.bom_id.bom_line_ids.product_id.id,
|
||||
'product_uom': item.bom_id.bom_line_ids.product_uom_id.id,
|
||||
'product_uom_qty': 1.0,
|
||||
'location_id': location_src_id,
|
||||
'location_dest_id': location_dest_id,
|
||||
'origin': item.name,
|
||||
# 'route_ids': False if not route else [(4, route.id)],
|
||||
'date_deadline': datetime.now(),
|
||||
'picking_type_id': picking_type_id,
|
||||
}
|
||||
return move_values
|
||||
|
||||
def _get_new_picking_values_Res(self, item, sorted_workorders, rescode):
|
||||
return {
|
||||
'name': self.env['stock.picking']._get_name_Res(rescode),
|
||||
@@ -545,6 +620,22 @@ class ReStockMove(models.Model):
|
||||
'state': 'confirmed',
|
||||
}
|
||||
|
||||
def get_move_line(self, purchase, sorted_workorders):
|
||||
return {
|
||||
'move_id': self.id,
|
||||
'product_id': self.product_id.id,
|
||||
'product_uom_id': self.product_uom.id,
|
||||
'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,
|
||||
'lot_id': purchase.picking_ids.move_line_ids.lot_id.id,
|
||||
'company_id': self.company_id.id,
|
||||
'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
|
||||
'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,
|
||||
'state': 'assigned',
|
||||
}
|
||||
|
||||
def print_serial_numbers(self):
|
||||
if not self.next_serial:
|
||||
raise UserError(_("请先分配序列号再进行打印"))
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
parent="sf_base.menu_sf_base"
|
||||
name="AGV站点"
|
||||
sequence="12"
|
||||
action="action_agv_site_form"/>
|
||||
action="action_agv_site_form"
|
||||
groups="sf_base.group_sf_order_user,sf_base.group_plan_dispatch,sf_base.group_plan_director,sf_base.group_sf_mrp_manager"/>
|
||||
|
||||
<!-- agv任务路线 -->
|
||||
<record id="view_agv_task_route_tree" model="ir.ui.view">
|
||||
|
||||
@@ -106,6 +106,13 @@
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<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"
|
||||
attrs="{'invisible': [('surface_technics_picking_count', '=', 0)]}">
|
||||
<field name="surface_technics_picking_count" widget="statinfo" string="工艺外协"/>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='state']" position="before">
|
||||
<field name='user_permissions' invisible="1"/>
|
||||
<field name='name' invisible="1"/>
|
||||
@@ -454,7 +461,7 @@
|
||||
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
||||
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
|
||||
<field name="is_cnc_program_down" readonly="1"/>
|
||||
<field name="production_line_id"/>
|
||||
<field name="production_line_id" readonly="1"/>
|
||||
<field name="task_delivery_time" readonly="1"/>
|
||||
<field name="task_completion_time" readonly="1"/>
|
||||
<field name="status" readonly="1"/>
|
||||
|
||||
@@ -67,7 +67,8 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
logging.info('cnc_processing_arr:%s' % cnc_processing_arr)
|
||||
cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||
cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
|
||||
{'cnc_ids': cnc_processing_arr})
|
||||
{'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
|
||||
lambda b: b.routing_type == 'CNC加工').cnc_worksheet})
|
||||
cnc_program_ids = [item.id for item in cnc_program]
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
[('production_id', 'in', cnc_program_ids)])
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
</xpath>
|
||||
<xpath expr="//form/header/button[@name='action_confirm']" position="after">
|
||||
<field name="check_status" invisible="1"/>
|
||||
<!-- <field name="schedule_status" invisible="1"/> -->
|
||||
<field name="schedule_status" invisible="1"/>
|
||||
<button name="sf_sale.action_sale_order_check_wizard" string="审核" type="action"
|
||||
context="{'default_order_id':active_id}" groups="sf_base.group_sale_director"
|
||||
attrs="{'invisible': ['|',('check_status','in', ['approved',False,'fail']),('state', 'in', ['cancel'])]}"
|
||||
@@ -84,7 +84,7 @@
|
||||
<xpath expr="//form/header/button[@name='action_confirm'][2]" position="replace">
|
||||
<button name="action_confirm" data-hotkey="v"
|
||||
string="确认" type="object" context="{'validate_analytic': True}"
|
||||
attrs="{'invisible': ['|','&',('check_status', '!=', 'approved'),('state', 'in', ['draft','cancel']),'&',('check_status', '=', 'approved'),('state', 'in', ['sale','cancel'])]}"/>
|
||||
attrs="{'invisible': ['|','&',('check_status', '!=', 'approved'),('state', 'in', ['draft','cancel']),'&','&',('check_status', '=', 'approved'),('state', 'in', ['sale','cancel']),('schedule_status', 'not in', False)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//form/header/button[@name='action_cancel']" position="attributes">
|
||||
<attribute name="attrs">{'invisible': ['|','&',('state', 'in',
|
||||
@@ -119,7 +119,7 @@
|
||||
string="模型文件" attrs="{'readonly': [('state', 'in', ['draft'])]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']/tree/field[@name='product_template_id']" position="attributes">
|
||||
<attribute name="options">{'no_create': True, 'no_quick_create': True}</attribute>
|
||||
<attribute name="options">{'no_create': True}</attribute>
|
||||
<attribute name="context">{'is_sale_order_line': True }</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']" position="attributes">
|
||||
@@ -198,7 +198,7 @@
|
||||
<field name="inherit_id" ref="sale.view_quotation_tree_with_onboarding"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree position="attributes">
|
||||
<attribute name="default_order">check_status desc,create_date asc</attribute>
|
||||
<attribute name="default_order">create_date desc</attribute>
|
||||
<attribute name="delete">False</attribute>
|
||||
</tree>
|
||||
<field name="name" position="attributes">
|
||||
|
||||
Reference in New Issue
Block a user