Compare commits
12 Commits
feature/ma
...
feature/ne
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b23589b73d | ||
|
|
29864b8bb2 | ||
|
|
aa5294f110 | ||
|
|
4387d343b5 | ||
|
|
ff979aa34b | ||
|
|
21af368068 | ||
|
|
47d886ef6d | ||
|
|
a7d97f137b | ||
|
|
42fe08384a | ||
|
|
eff09e9b52 | ||
|
|
f6aa07fbe7 | ||
|
|
649dfe90d6 |
@@ -190,7 +190,7 @@ def _create(self, data_list):
|
|||||||
# 如果该用户组被限制创建或更新操作
|
# 如果该用户组被限制创建或更新操作
|
||||||
if rec['is_create_or_update']:
|
if rec['is_create_or_update']:
|
||||||
raise UserError(
|
raise UserError(
|
||||||
_("You are restricted from performing this operation. Please contact the administrator."))
|
_("您没有执行此操作的权限。请联系管理员"))
|
||||||
else:
|
else:
|
||||||
# 如果 'access.right' 模型不存在,可以在这里定义备选逻辑
|
# 如果 'access.right' 模型不存在,可以在这里定义备选逻辑
|
||||||
# 例如,记录日志、发送通知或者简单地跳过这部分逻辑
|
# 例如,记录日志、发送通知或者简单地跳过这部分逻辑
|
||||||
|
|||||||
@@ -729,13 +729,39 @@ class MrpProduction(models.Model):
|
|||||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
||||||
for i, workorder in enumerate(sorted_workorders):
|
for i, workorder in enumerate(sorted_workorders):
|
||||||
# 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
|
# 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
|
||||||
if not workorder.picking_ids:
|
if i == 0:
|
||||||
|
consecutive_workorders.append(workorder)
|
||||||
|
elif workorder.sequence == sorted_workorders[
|
||||||
|
i - 1].sequence + 1 and workorder.supplier_id.id == sorted_workorders[i - 1].supplier_id.id:
|
||||||
|
consecutive_workorders.append(workorder)
|
||||||
|
else:
|
||||||
|
# 处理连续组,如果它不为空
|
||||||
|
if consecutive_workorders:
|
||||||
|
# 创建外协出入库单和采购订单
|
||||||
|
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
||||||
|
self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
||||||
|
product_id_to_production_names)
|
||||||
|
if i < len(sorted_workorders) - 1:
|
||||||
|
# 重置连续组,并添加当前工作订单
|
||||||
|
consecutive_workorders = [workorder]
|
||||||
|
else:
|
||||||
|
# 判断最后一笔:
|
||||||
|
if workorder.sequence == sorted_workorders[
|
||||||
|
i - 1].sequence and workorder.supplier_id.id == sorted_workorders[
|
||||||
|
i - 1].supplier_id.id:
|
||||||
|
consecutive_workorders = [workorder]
|
||||||
|
else:
|
||||||
|
# 立即创建外协出入库单和采购订单
|
||||||
self.env['stock.picking'].create_outcontract_picking(workorder, production)
|
self.env['stock.picking'].create_outcontract_picking(workorder, production)
|
||||||
# if not workorder.
|
|
||||||
if not workorder.purchase_id:
|
|
||||||
self.env['purchase.order'].get_purchase_order(workorder, production,
|
self.env['purchase.order'].get_purchase_order(workorder, production,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
|
consecutive_workorders = []
|
||||||
|
|
||||||
|
# 处理最后一个组,即使它可能只有一个工作订单
|
||||||
|
if consecutive_workorders:
|
||||||
|
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
||||||
|
self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
||||||
|
product_id_to_production_names)
|
||||||
|
|
||||||
# 工单排序
|
# 工单排序
|
||||||
def _reset_work_order_sequence1(self, k):
|
def _reset_work_order_sequence1(self, k):
|
||||||
|
|||||||
@@ -23,15 +23,12 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
|
|
||||||
product_tmpl_name = fields.Char('坯料产品名称', related='production_bom_id.bom_line_ids.product_id.name')
|
product_tmpl_name = fields.Char('坯料产品名称', related='production_bom_id.bom_line_ids.product_id.name')
|
||||||
|
|
||||||
product_tmpl_id_length = fields.Float(string='坯料长度(mm)', related='material_length', readonly=True, store=False)
|
product_tmpl_id_length = fields.Float(related='production_id.product_tmpl_id.length', readonly=True, store=True,
|
||||||
product_tmpl_id_width = fields.Float(string='坯料宽度(mm)', related='material_width', readonly=True, store=False)
|
string="坯料长度(mm)")
|
||||||
product_tmpl_id_height = fields.Float(string='坯料高度(mm)', related='material_height', readonly=True, store=False)
|
product_tmpl_id_width = fields.Float(related='production_id.product_tmpl_id.width', readonly=True, store=True,
|
||||||
# product_tmpl_id_length = fields.Float(related='production_id.product_tmpl_id.length', readonly=True, store=True,
|
string="坯料宽度(mm)")
|
||||||
# string="坯料长度(mm)")
|
product_tmpl_id_height = fields.Float(related='production_id.product_tmpl_id.height', readonly=True, store=True,
|
||||||
# product_tmpl_id_width = fields.Float(related='production_id.product_tmpl_id.width', readonly=True, store=True,
|
string="坯料高度(mm)")
|
||||||
# string="坯料宽度(mm)")
|
|
||||||
# product_tmpl_id_height = fields.Float(related='production_id.product_tmpl_id.height', readonly=True, store=True,
|
|
||||||
# string="坯料高度(mm)")
|
|
||||||
product_tmpl_id_materials_id = fields.Many2one(related='production_id.product_tmpl_id.materials_id', readonly=True,
|
product_tmpl_id_materials_id = fields.Many2one(related='production_id.product_tmpl_id.materials_id', readonly=True,
|
||||||
store=True, check_company=True, string="材料")
|
store=True, check_company=True, string="材料")
|
||||||
product_tmpl_id_materials_type_id = fields.Many2one(related='production_id.product_tmpl_id.materials_type_id',
|
product_tmpl_id_materials_type_id = fields.Many2one(related='production_id.product_tmpl_id.materials_type_id',
|
||||||
@@ -138,7 +135,7 @@ 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.Many2many('purchase.order', 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')
|
surface_technics_purchase_count = fields.Integer("外协采购", compute='_compute_surface_technics_purchase_ids')
|
||||||
|
|
||||||
@@ -242,10 +239,12 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
previous_workorder = self.env['mrp.workorder'].search(
|
previous_workorder = self.env['mrp.workorder'].search(
|
||||||
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
||||||
('production_id', '=', workorder.production_id.id)])
|
('production_id', '=', workorder.production_id.id)])
|
||||||
# if previous_workorder:
|
if previous_workorder:
|
||||||
# if previous_workorder.supplier_id != workorder.supplier_id:
|
if previous_workorder.supplier_id != workorder.supplier_id:
|
||||||
# domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
|
# process_product = self.env['product.template']._get_process_parameters_product(
|
||||||
# else:
|
# previous_workorder.surface_technics_parameters_id)
|
||||||
|
domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
|
||||||
|
else:
|
||||||
domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
|
domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
|
||||||
picking_ids = self.env['stock.picking'].search(domain, order='id asc')
|
picking_ids = self.env['stock.picking'].search(domain, order='id asc')
|
||||||
workorder.surface_technics_picking_count = len(picking_ids)
|
workorder.surface_technics_picking_count = len(picking_ids)
|
||||||
|
|||||||
@@ -649,10 +649,10 @@ class StockPicking(models.Model):
|
|||||||
for mi in move_in:
|
for mi in move_in:
|
||||||
pick = self.env['stock.picking'].search([('id', '=', mi.picking_id.id), ('name', 'ilike', 'OCIN'),
|
pick = self.env['stock.picking'].search([('id', '=', mi.picking_id.id), ('name', 'ilike', 'OCIN'),
|
||||||
('partner_id', '=', self.partner_id.id)])
|
('partner_id', '=', self.partner_id.id)])
|
||||||
if pick:
|
# if pick:
|
||||||
if mi.state != 'done':
|
# if mi.state != 'done':
|
||||||
mi.write({'state': 'assigned'})
|
# mi.write({'state': 'assigned'})
|
||||||
self.env['stock.move.line'].create(mi.get_move_line(production, None))
|
# self.env['stock.move.line'].create(mi.get_move_line(production, None))
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@@ -671,6 +671,11 @@ class StockPicking(models.Model):
|
|||||||
if not sorted_workorders.picking_ids:
|
if not sorted_workorders.picking_ids:
|
||||||
# outcontract_stock_move = self.env['stock.move'].search([('production_id', '=', item.id)])
|
# outcontract_stock_move = self.env['stock.move'].search([('production_id', '=', item.id)])
|
||||||
# if not outcontract_stock_move:
|
# if not outcontract_stock_move:
|
||||||
|
# 创建一个新的补货组
|
||||||
|
procurement_group_id = self.env['procurement.group'].create({
|
||||||
|
'name': sorted_workorders.name,
|
||||||
|
'partner_id': self.partner_id.id,
|
||||||
|
})
|
||||||
new_picking = True
|
new_picking = True
|
||||||
location_id = self.env['stock.location'].search(
|
location_id = self.env['stock.location'].search(
|
||||||
[('barcode', 'ilike', 'VL-SPOC')]).id,
|
[('barcode', 'ilike', 'VL-SPOC')]).id,
|
||||||
@@ -680,24 +685,25 @@ class StockPicking(models.Model):
|
|||||||
'sf_manufacturing.outcontract_picking_in').id,
|
'sf_manufacturing.outcontract_picking_in').id,
|
||||||
outcontract_picking_type_out = self.env.ref(
|
outcontract_picking_type_out = self.env.ref(
|
||||||
'sf_manufacturing.outcontract_picking_out').id,
|
'sf_manufacturing.outcontract_picking_out').id,
|
||||||
moves_out = self.env['stock.move'].sudo().create(
|
|
||||||
self.env['stock.move']._get_stock_move_values_Res(item, location_dest_id, location_id,
|
|
||||||
outcontract_picking_type_out))
|
|
||||||
picking_out = self.create(
|
|
||||||
moves_out._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCOUT/'))
|
|
||||||
# pick_ids.append(picking_out.id)
|
|
||||||
moves_out.write(
|
|
||||||
{'picking_id': picking_out.id, 'state': 'waiting'})
|
|
||||||
moves_out._assign_picking_post_process(new=new_picking)
|
|
||||||
moves_in = self.env['stock.move'].sudo().create(
|
moves_in = self.env['stock.move'].sudo().create(
|
||||||
self.env['stock.move']._get_stock_move_values_Res(item, location_id, location_dest_id,
|
self.env['stock.move']._get_stock_move_values_Res(item, location_id, location_dest_id,
|
||||||
outcontract_picking_type_in))
|
outcontract_picking_type_in, procurement_group_id.id))
|
||||||
picking_in = self.create(
|
picking_in = self.create(
|
||||||
moves_in._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCIN/'))
|
moves_in._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCIN/'))
|
||||||
# pick_ids.append(picking_in.id)
|
# pick_ids.append(picking_in.id)
|
||||||
moves_in.write(
|
moves_in.write(
|
||||||
{'picking_id': picking_in.id, 'state': 'waiting'})
|
{'picking_id': picking_in.id, 'state': 'waiting'})
|
||||||
moves_in._assign_picking_post_process(new=new_picking)
|
moves_in._assign_picking_post_process(new=new_picking)
|
||||||
|
moves_out = self.env['stock.move'].sudo().create(
|
||||||
|
self.env['stock.move']._get_stock_move_values_Res(item, location_dest_id, location_id,
|
||||||
|
outcontract_picking_type_out, procurement_group_id.id, moves_in.id))
|
||||||
|
picking_out = self.create(
|
||||||
|
moves_out._get_new_picking_values_Res(item, sorted_workorders, 'WH/OCOUT/'))
|
||||||
|
# pick_ids.append(picking_out.id)
|
||||||
|
moves_out.write(
|
||||||
|
{'picking_id': picking_out.id, 'state': 'waiting'})
|
||||||
|
moves_out._assign_picking_post_process(new=new_picking)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ReStockMove(models.Model):
|
class ReStockMove(models.Model):
|
||||||
@@ -707,7 +713,7 @@ class ReStockMove(models.Model):
|
|||||||
materiel_width = fields.Float(string='物料宽度', digits=(16, 4))
|
materiel_width = fields.Float(string='物料宽度', digits=(16, 4))
|
||||||
materiel_height = 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):
|
def _get_stock_move_values_Res(self, item, location_src_id, location_dest_id, picking_type_id, group_id, move_dest_ids=False):
|
||||||
route = self.env['stock.route'].sudo().search([('name', '=', '表面工艺外协')])
|
route = self.env['stock.route'].sudo().search([('name', '=', '表面工艺外协')])
|
||||||
move_values = {
|
move_values = {
|
||||||
'name': '推',
|
'name': '推',
|
||||||
@@ -718,6 +724,8 @@ class ReStockMove(models.Model):
|
|||||||
'location_id': location_src_id,
|
'location_id': location_src_id,
|
||||||
'location_dest_id': location_dest_id,
|
'location_dest_id': location_dest_id,
|
||||||
'origin': item.name,
|
'origin': item.name,
|
||||||
|
'group_id': group_id,
|
||||||
|
'move_dest_ids': [(6, 0, [move_dest_ids])] if move_dest_ids else False,
|
||||||
# 'route_ids': False if not route else [(4, route.id)],
|
# 'route_ids': False if not route else [(4, route.id)],
|
||||||
'date_deadline': datetime.now(),
|
'date_deadline': datetime.now(),
|
||||||
'picking_type_id': picking_type_id,
|
'picking_type_id': picking_type_id,
|
||||||
@@ -980,7 +988,6 @@ class ReStockMove(models.Model):
|
|||||||
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
||||||
productions = self.env['mrp.production'].search(
|
productions = self.env['mrp.production'].search(
|
||||||
[('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
[('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
||||||
if productions.mapped('name'):
|
|
||||||
res['origin'] = ','.join(productions.mapped('name'))
|
res['origin'] = ','.join(productions.mapped('name'))
|
||||||
res['retrospect_ref'] = production.product_id.name
|
res['retrospect_ref'] = production.product_id.name
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -738,7 +738,7 @@
|
|||||||
<!-- parent="mrp.menu_mrp_manufacturing"-->
|
<!-- parent="mrp.menu_mrp_manufacturing"-->
|
||||||
<!-- sequence="1"/>-->
|
<!-- sequence="1"/>-->
|
||||||
|
|
||||||
<menuitem id="mrp.menu_mrp_production_action"
|
<menuitem id="menu_mrp_production_action"
|
||||||
name="制造订单"
|
name="制造订单"
|
||||||
parent="mrp.menu_mrp_manufacturing"
|
parent="mrp.menu_mrp_manufacturing"
|
||||||
action="mrp.mrp_production_action"
|
action="mrp.mrp_production_action"
|
||||||
|
|||||||
@@ -280,13 +280,12 @@ class RePurchaseOrder(models.Model):
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
if server_product_process:
|
if server_product_process:
|
||||||
purchase_order = self.env['purchase.order'].sudo().create({
|
self.env['purchase.order'].sudo().create({
|
||||||
'partner_id': server_template.seller_ids[0].partner_id.id,
|
'partner_id': server_template.seller_ids[0].partner_id.id,
|
||||||
'origin': production.name,
|
'origin': production.name,
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'purchase_type': 'consignment',
|
'purchase_type': 'consignment',
|
||||||
'order_line': server_product_process})
|
'order_line': server_product_process})
|
||||||
consecutive_process_parameters.purchase_id = [(6, 0, [purchase_order.id])]
|
|
||||||
# self.env.cr.commit()
|
# self.env.cr.commit()
|
||||||
|
|
||||||
@api.onchange('order_line')
|
@api.onchange('order_line')
|
||||||
|
|||||||
Reference in New Issue
Block a user