Compare commits
7 Commits
feature/ne
...
feature/ma
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed6189a963 | ||
|
|
a6979b213b | ||
|
|
57fe68bae8 | ||
|
|
aa32fdcd07 | ||
|
|
27ec5b1b74 | ||
|
|
dc5c0b1d1e | ||
|
|
9a1cde6abc |
@@ -190,7 +190,7 @@ def _create(self, data_list):
|
||||
# 如果该用户组被限制创建或更新操作
|
||||
if rec['is_create_or_update']:
|
||||
raise UserError(
|
||||
_("您没有执行此操作的权限。请联系管理员"))
|
||||
_("You are restricted from performing this operation. Please contact the administrator."))
|
||||
else:
|
||||
# 如果 'access.right' 模型不存在,可以在这里定义备选逻辑
|
||||
# 例如,记录日志、发送通知或者简单地跳过这部分逻辑
|
||||
|
||||
@@ -729,40 +729,14 @@ class MrpProduction(models.Model):
|
||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
||||
for i, workorder in enumerate(sorted_workorders):
|
||||
# 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
|
||||
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['purchase.order'].get_purchase_order(workorder, production,
|
||||
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,
|
||||
if not workorder.picking_ids:
|
||||
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,
|
||||
product_id_to_production_names)
|
||||
|
||||
|
||||
# 工单排序
|
||||
def _reset_work_order_sequence1(self, k):
|
||||
for rec in self:
|
||||
|
||||
@@ -23,12 +23,15 @@ class ResMrpWorkOrder(models.Model):
|
||||
|
||||
product_tmpl_name = fields.Char('坯料产品名称', related='production_bom_id.bom_line_ids.product_id.name')
|
||||
|
||||
product_tmpl_id_length = fields.Float(related='production_id.product_tmpl_id.length', readonly=True, store=True,
|
||||
string="坯料长度(mm)")
|
||||
product_tmpl_id_width = fields.Float(related='production_id.product_tmpl_id.width', readonly=True, store=True,
|
||||
string="坯料宽度(mm)")
|
||||
product_tmpl_id_height = fields.Float(related='production_id.product_tmpl_id.height', readonly=True, store=True,
|
||||
string="坯料高度(mm)")
|
||||
product_tmpl_id_length = fields.Float(string='坯料长度(mm)', related='material_length', readonly=True, store=False)
|
||||
product_tmpl_id_width = fields.Float(string='坯料宽度(mm)', related='material_width', readonly=True, store=False)
|
||||
product_tmpl_id_height = fields.Float(string='坯料高度(mm)', related='material_height', readonly=True, store=False)
|
||||
# product_tmpl_id_length = fields.Float(related='production_id.product_tmpl_id.length', readonly=True, store=True,
|
||||
# string="坯料长度(mm)")
|
||||
# product_tmpl_id_width = fields.Float(related='production_id.product_tmpl_id.width', readonly=True, store=True,
|
||||
# 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,
|
||||
store=True, check_company=True, string="材料")
|
||||
product_tmpl_id_materials_type_id = fields.Many2one(related='production_id.product_tmpl_id.materials_type_id',
|
||||
@@ -135,7 +138,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
is_subcontract = fields.Boolean(string='是否外协')
|
||||
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
||||
picking_ids = fields.Many2many('stock.picking', string='外协出入库单')
|
||||
# purchase_id = fields.Many2one('purchase.order', string='外协采购单')
|
||||
purchase_id = fields.Many2many('purchase.order', string='外协采购单')
|
||||
surface_technics_picking_count = fields.Integer("外协出入库", compute='_compute_surface_technics_picking_ids')
|
||||
surface_technics_purchase_count = fields.Integer("外协采购", compute='_compute_surface_technics_purchase_ids')
|
||||
|
||||
@@ -239,13 +242,11 @@ class ResMrpWorkOrder(models.Model):
|
||||
previous_workorder = self.env['mrp.workorder'].search(
|
||||
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
||||
('production_id', '=', workorder.production_id.id)])
|
||||
if previous_workorder:
|
||||
if previous_workorder.supplier_id != workorder.supplier_id:
|
||||
# process_product = self.env['product.template']._get_process_parameters_product(
|
||||
# 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)]
|
||||
# if previous_workorder:
|
||||
# if previous_workorder.supplier_id != workorder.supplier_id:
|
||||
# domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
|
||||
# else:
|
||||
domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
|
||||
picking_ids = self.env['stock.picking'].search(domain, order='id asc')
|
||||
workorder.surface_technics_picking_count = len(picking_ids)
|
||||
workorder.picking_ids = picking_ids.ids
|
||||
|
||||
@@ -649,10 +649,10 @@ class StockPicking(models.Model):
|
||||
for mi in move_in:
|
||||
pick = self.env['stock.picking'].search([('id', '=', mi.picking_id.id), ('name', 'ilike', 'OCIN'),
|
||||
('partner_id', '=', self.partner_id.id)])
|
||||
# if pick:
|
||||
# if mi.state != 'done':
|
||||
# mi.write({'state': 'assigned'})
|
||||
# self.env['stock.move.line'].create(mi.get_move_line(production, None))
|
||||
if pick:
|
||||
if mi.state != 'done':
|
||||
mi.write({'state': 'assigned'})
|
||||
self.env['stock.move.line'].create(mi.get_move_line(production, None))
|
||||
|
||||
return res
|
||||
|
||||
@@ -671,11 +671,6 @@ class StockPicking(models.Model):
|
||||
if not sorted_workorders.picking_ids:
|
||||
# outcontract_stock_move = self.env['stock.move'].search([('production_id', '=', item.id)])
|
||||
# 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
|
||||
location_id = self.env['stock.location'].search(
|
||||
[('barcode', 'ilike', 'VL-SPOC')]).id,
|
||||
@@ -685,25 +680,24 @@ 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(
|
||||
self.env['stock.move']._get_stock_move_values_Res(item, location_id, location_dest_id,
|
||||
outcontract_picking_type_in, procurement_group_id.id))
|
||||
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'})
|
||||
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))
|
||||
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(
|
||||
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'})
|
||||
moves_in._assign_picking_post_process(new=new_picking)
|
||||
|
||||
|
||||
class ReStockMove(models.Model):
|
||||
@@ -713,7 +707,7 @@ 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, group_id, move_dest_ids=False):
|
||||
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': '推',
|
||||
@@ -724,8 +718,6 @@ class ReStockMove(models.Model):
|
||||
'location_id': location_src_id,
|
||||
'location_dest_id': location_dest_id,
|
||||
'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)],
|
||||
'date_deadline': datetime.now(),
|
||||
'picking_type_id': picking_type_id,
|
||||
@@ -988,7 +980,8 @@ class ReStockMove(models.Model):
|
||||
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
||||
productions = self.env['mrp.production'].search(
|
||||
[('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
||||
res['origin'] = ','.join(productions.mapped('name'))
|
||||
if productions.mapped('name'):
|
||||
res['origin'] = ','.join(productions.mapped('name'))
|
||||
res['retrospect_ref'] = production.product_id.name
|
||||
return res
|
||||
|
||||
|
||||
@@ -738,7 +738,7 @@
|
||||
<!-- parent="mrp.menu_mrp_manufacturing"-->
|
||||
<!-- sequence="1"/>-->
|
||||
|
||||
<menuitem id="menu_mrp_production_action"
|
||||
<menuitem id="mrp.menu_mrp_production_action"
|
||||
name="制造订单"
|
||||
parent="mrp.menu_mrp_manufacturing"
|
||||
action="mrp.mrp_production_action"
|
||||
|
||||
@@ -280,12 +280,13 @@ class RePurchaseOrder(models.Model):
|
||||
}))
|
||||
|
||||
if server_product_process:
|
||||
self.env['purchase.order'].sudo().create({
|
||||
purchase_order = self.env['purchase.order'].sudo().create({
|
||||
'partner_id': server_template.seller_ids[0].partner_id.id,
|
||||
'origin': production.name,
|
||||
'state': 'draft',
|
||||
'purchase_type': 'consignment',
|
||||
'order_line': server_product_process})
|
||||
consecutive_process_parameters.purchase_id = [(6, 0, [purchase_order.id])]
|
||||
# self.env.cr.commit()
|
||||
|
||||
@api.onchange('order_line')
|
||||
|
||||
Reference in New Issue
Block a user