回退工艺外协代码
This commit is contained in:
@@ -48,7 +48,7 @@
|
|||||||
'views/mrp_workorder_batch_replan.xml',
|
'views/mrp_workorder_batch_replan.xml',
|
||||||
'views/purchase_order_view.xml',
|
'views/purchase_order_view.xml',
|
||||||
'views/product_template_views.xml',
|
'views/product_template_views.xml',
|
||||||
'views/stock_warehouse_orderpoint.xml',
|
# 'views/stock_warehouse_orderpoint.xml',
|
||||||
],
|
],
|
||||||
'assets': {
|
'assets': {
|
||||||
|
|
||||||
|
|||||||
@@ -18,4 +18,4 @@ from . import quick_easy_order
|
|||||||
from . import purchase_order
|
from . import purchase_order
|
||||||
from . import quality_check
|
from . import quality_check
|
||||||
from . import purchase_request_line
|
from . import purchase_request_line
|
||||||
from . import stock_warehouse_orderpoint
|
# from . import stock_warehouse_orderpoint
|
||||||
@@ -900,41 +900,41 @@ class MrpProduction(models.Model):
|
|||||||
for workorder in production.workorder_ids:
|
for workorder in production.workorder_ids:
|
||||||
workorder.duration_expected = workorder._get_duration_expected()
|
workorder.duration_expected = workorder._get_duration_expected()
|
||||||
|
|
||||||
def _create_subcontract_purchase_request(self, purchase_request_line):
|
# def _create_subcontract_purchase_request(self, purchase_request_line):
|
||||||
sorted_list = sorted(purchase_request_line, key=itemgetter('name'))
|
# sorted_list = sorted(purchase_request_line, key=itemgetter('name'))
|
||||||
grouped_purchase_request_line = {
|
# grouped_purchase_request_line = {
|
||||||
k: list(g)
|
# k: list(g)
|
||||||
for k, g in groupby(sorted_list, key=itemgetter('name'))
|
# for k, g in groupby(sorted_list, key=itemgetter('name'))
|
||||||
}
|
# }
|
||||||
for name, request_line in grouped_purchase_request_line.items():
|
# for name, request_line in grouped_purchase_request_line.items():
|
||||||
request_line_sorted_list = sorted(request_line, key=itemgetter('product_id'))
|
# request_line_sorted_list = sorted(request_line, key=itemgetter('product_id'))
|
||||||
grouped_purchase_request_line_sorted_list = {
|
# grouped_purchase_request_line_sorted_list = {
|
||||||
k: list(g)
|
# k: list(g)
|
||||||
for k, g in groupby(request_line_sorted_list, key=itemgetter('product_id'))
|
# for k, g in groupby(request_line_sorted_list, key=itemgetter('product_id'))
|
||||||
}
|
# }
|
||||||
purchase_request_model = self.env["purchase.request"]
|
# purchase_request_model = self.env["purchase.request"]
|
||||||
origin = ", ".join({item['production_name'] for item in request_line_sorted_list if item.get('production_name')})
|
# origin = ", ".join({item['production_name'] for item in request_line_sorted_list if item.get('production_name')})
|
||||||
pr = purchase_request_model.create({
|
# pr = purchase_request_model.create({
|
||||||
"origin": origin,
|
# "origin": origin,
|
||||||
"company_id": self.company_id.id,
|
# "company_id": self.company_id.id,
|
||||||
"picking_type_id": self.env.ref('stock.picking_type_in').id,
|
# "picking_type_id": self.env.ref('stock.picking_type_in').id,
|
||||||
"group_id": request_line[0].get('group_id'),
|
# "group_id": request_line[0].get('group_id'),
|
||||||
"requested_by": self.env.context.get("uid", self.env.uid),
|
# "requested_by": self.env.context.get("uid", self.env.uid),
|
||||||
"assigned_to": False,
|
# "assigned_to": False,
|
||||||
"bom_id": self[0].bom_id.id,
|
# "bom_id": self[0].bom_id.id,
|
||||||
"is_subcontract":True,
|
# "is_subcontract":True,
|
||||||
})
|
# })
|
||||||
self[0].bom_id.bom_line_ids.product_id.route_ids = [(4,self.env.ref(
|
# self[0].bom_id.bom_line_ids.product_id.route_ids = [(4,self.env.ref(
|
||||||
'sf_stock.stock_route_process_outsourcing').id)]
|
# 'sf_stock.stock_route_process_outsourcing').id)]
|
||||||
for product_id, request_line_list in grouped_purchase_request_line_sorted_list.items():
|
# for product_id, request_line_list in grouped_purchase_request_line_sorted_list.items():
|
||||||
cur_request_line = request_line_list[0]
|
# cur_request_line = request_line_list[0]
|
||||||
# cur_request_line['product_qty'] = cur_request_line['product_qty']
|
# # cur_request_line['product_qty'] = cur_request_line['product_qty']
|
||||||
cur_request_line['request_id'] = pr.id
|
# 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')})
|
# cur_request_line['origin'] = ", ".join({item['production_name'] for item in request_line_list if item.get('production_name')})
|
||||||
cur_request_line.pop('group_id', None)
|
# cur_request_line.pop('group_id', None)
|
||||||
cur_request_line.pop('production_name', None)
|
# cur_request_line.pop('production_name', None)
|
||||||
self.env["purchase.request.line"].create(cur_request_line)
|
# self.env["purchase.request.line"].create(cur_request_line)
|
||||||
pr.button_approved()
|
# pr.button_approved()
|
||||||
|
|
||||||
# 外协出入库单处理
|
# 外协出入库单处理
|
||||||
def get_subcontract_pick_purchase(self):
|
def get_subcontract_pick_purchase(self):
|
||||||
@@ -962,14 +962,14 @@ class MrpProduction(models.Model):
|
|||||||
if not sorted_workorders:
|
if not sorted_workorders:
|
||||||
return
|
return
|
||||||
for workorders in reversed(sorted_workorders):
|
for workorders in reversed(sorted_workorders):
|
||||||
# self.env['stock.picking'].create_outcontract_picking(workorders, production, sorted_workorders)
|
self.env['stock.picking'].create_outcontract_picking(workorders, production, sorted_workorders)
|
||||||
# self.env['purchase.order'].get_purchase_order(workorders, production, product_id_to_production_names)
|
self.env['purchase.order'].get_purchase_order(workorders, production, product_id_to_production_names)
|
||||||
purchase_request_line = purchase_request_line + self.env['purchase.order'].get_purchase_request(
|
# purchase_request_line = purchase_request_line + self.env['purchase.order'].get_purchase_request(
|
||||||
workorders, production)
|
# workorders, production)
|
||||||
all_workorders += workorders
|
# all_workorders += workorders
|
||||||
self._create_subcontract_purchase_request(purchase_request_line)
|
# self._create_subcontract_purchase_request(purchase_request_line)
|
||||||
for workorder in all_workorders:
|
# for workorder in all_workorders:
|
||||||
workorder._compute_pr_mp_count()
|
# workorder._compute_pr_mp_count()
|
||||||
# 工单排序
|
# 工单排序
|
||||||
def _reset_work_order_sequence1(self, k):
|
def _reset_work_order_sequence1(self, k):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
from odoo import fields, models, api
|
from odoo import fields, models, api
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
from odoo.tools import str2bool
|
# from odoo.tools import str2bool
|
||||||
|
|
||||||
|
|
||||||
class ResMrpRoutingWorkcenter(models.Model):
|
class ResMrpRoutingWorkcenter(models.Model):
|
||||||
@@ -25,20 +25,20 @@ class ResMrpRoutingWorkcenter(models.Model):
|
|||||||
workcenter_ids = fields.Many2many('mrp.workcenter', 'rel_workcenter_route', required=True)
|
workcenter_ids = fields.Many2many('mrp.workcenter', 'rel_workcenter_route', required=True)
|
||||||
bom_id = fields.Many2one('mrp.bom', required=False)
|
bom_id = fields.Many2one('mrp.bom', required=False)
|
||||||
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
|
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
|
||||||
optional_process_parameters = fields.One2many('sf.production.process.parameter','routing_id',string='可选工艺参数')
|
# optional_process_parameters = fields.One2many('sf.production.process.parameter','routing_id',string='可选工艺参数')
|
||||||
reserved_duration = fields.Float('预留时长', default=30, tracking=True)
|
reserved_duration = fields.Float('预留时长', default=30, tracking=True)
|
||||||
is_outsource = fields.Boolean('外协', default=False)
|
is_outsource = fields.Boolean('外协', default=False)
|
||||||
individuation_page_ids = fields.Many2many('sf.work.individuation.page', string='个性化记录')
|
individuation_page_ids = fields.Many2many('sf.work.individuation.page', string='个性化记录')
|
||||||
|
|
||||||
@api.onchange('surface_technics_id')
|
# @api.onchange('surface_technics_id')
|
||||||
def optional_process_parameters_date(self):
|
# def optional_process_parameters_date(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
if not record.surface_technics_id:
|
# if not record.surface_technics_id:
|
||||||
continue
|
# continue
|
||||||
parameter_ids = self.env['sf.production.process.parameter'].search([
|
# parameter_ids = self.env['sf.production.process.parameter'].search([
|
||||||
('process_id', '=', record.surface_technics_id.id),
|
# ('process_id', '=', record.surface_technics_id.id),
|
||||||
])
|
# ])
|
||||||
record.optional_process_parameters = parameter_ids.ids
|
# record.optional_process_parameters = parameter_ids.ids
|
||||||
|
|
||||||
# @api.model
|
# @api.model
|
||||||
# def _auto_init(self):
|
# def _auto_init(self):
|
||||||
|
|||||||
@@ -21,16 +21,16 @@ class ResWorkcenter(models.Model):
|
|||||||
related='equipment_id.production_line_id', store=True)
|
related='equipment_id.production_line_id', store=True)
|
||||||
is_process_outsourcing = fields.Boolean('工艺外协')
|
is_process_outsourcing = fields.Boolean('工艺外协')
|
||||||
users_ids = fields.Many2many("res.users", 'users_workcenter', tracking=True)
|
users_ids = fields.Many2many("res.users", 'users_workcenter', tracking=True)
|
||||||
@api.constrains('name')
|
# @api.constrains('name')
|
||||||
def _check_unique_name_code(self):
|
# def _check_unique_name_code(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
# 检查是否已经存在相同的 name 和 code 组合
|
# # 检查是否已经存在相同的 name 和 code 组合
|
||||||
existing = self.search([
|
# existing = self.search([
|
||||||
('name', '=', record.name),
|
# ('name', '=', record.name),
|
||||||
('id', '!=', record.id) # 排除当前记录
|
# ('id', '!=', record.id) # 排除当前记录
|
||||||
])
|
# ])
|
||||||
if existing:
|
# if existing:
|
||||||
raise ValueError('记录已存在')
|
# raise ValueError('记录已存在')
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
if 'users_ids' in vals:
|
if 'users_ids' in vals:
|
||||||
old_users = self.users_ids
|
old_users = self.users_ids
|
||||||
|
|||||||
@@ -70,21 +70,21 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '告警'), ('overdue', '逾期')], string='时效',
|
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '告警'), ('overdue', '逾期')], string='时效',
|
||||||
tracking=True)
|
tracking=True)
|
||||||
back_button_display = fields.Boolean(default=False, compute='_compute_back_button_display', store=True)
|
back_button_display = fields.Boolean(default=False, compute='_compute_back_button_display', store=True)
|
||||||
pr_mp_count = fields.Integer('采购申请单数量', compute='_compute_pr_mp_count', store=True)
|
# pr_mp_count = fields.Integer('采购申请单数量', compute='_compute_pr_mp_count', store=True)
|
||||||
|
|
||||||
@api.depends('state')
|
# @api.depends('state')
|
||||||
def _compute_pr_mp_count(self):
|
# def _compute_pr_mp_count(self):
|
||||||
for item in self:
|
# for item in self:
|
||||||
if not item.is_subcontract:
|
# if not item.is_subcontract:
|
||||||
item.pr_mp_count = 0
|
# item.pr_mp_count = 0
|
||||||
continue
|
# continue
|
||||||
pr_ids = self.env['purchase.request'].sudo().search(
|
# pr_ids = self.env['purchase.request'].sudo().search(
|
||||||
[('origin', 'like', item.production_id.name), ('is_subcontract', '=', 'True'),
|
# [('origin', 'like', item.production_id.name), ('is_subcontract', '=', 'True'),
|
||||||
('state', '!=', 'rejected')])
|
# ('state', '!=', 'rejected')])
|
||||||
if pr_ids:
|
# if pr_ids:
|
||||||
item.pr_mp_count = len(pr_ids)
|
# item.pr_mp_count = len(pr_ids)
|
||||||
else:
|
# else:
|
||||||
item.pr_mp_count = 0
|
# item.pr_mp_count = 0
|
||||||
|
|
||||||
@api.depends('state')
|
@api.depends('state')
|
||||||
def _compute_back_button_display(self):
|
def _compute_back_button_display(self):
|
||||||
@@ -444,11 +444,11 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
def _compute_surface_technics_purchase_ids(self):
|
def _compute_surface_technics_purchase_ids(self):
|
||||||
for order in self:
|
for order in self:
|
||||||
if order.routing_type == '表面工艺' and order.state not in ['cancel']:
|
if order.routing_type == '表面工艺' and order.state not in ['cancel']:
|
||||||
# domain = [('group_id', '=', self.production_id.procurement_group_id.id),
|
domain = [('group_id', '=', self.production_id.procurement_group_id.id),
|
||||||
# ('purchase_type', '=', 'consignment'), ('state', '!=', 'cancel')]
|
('purchase_type', '=', 'consignment'), ('state', '!=', 'cancel')]
|
||||||
domain = [('purchase_type', '=', 'consignment'),
|
# domain = [('purchase_type', '=', 'consignment'),
|
||||||
('origin', 'like', '%' + self.production_id.name + '%'),
|
# ('origin', 'like', '%' + self.production_id.name + '%'),
|
||||||
('state', '!=', 'cancel')]
|
# ('state', '!=', 'cancel')]
|
||||||
purchase = self.env['purchase.order'].search(domain)
|
purchase = self.env['purchase.order'].search(domain)
|
||||||
order.surface_technics_purchase_count = 0
|
order.surface_technics_purchase_count = 0
|
||||||
if not purchase:
|
if not purchase:
|
||||||
@@ -461,30 +461,30 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
else:
|
else:
|
||||||
order.surface_technics_purchase_count = 0
|
order.surface_technics_purchase_count = 0
|
||||||
|
|
||||||
def action_view_pr_mrp_workorder(self):
|
# def action_view_pr_mrp_workorder(self):
|
||||||
"""
|
# """
|
||||||
采购请求
|
# 采购请求
|
||||||
"""
|
# """
|
||||||
self.ensure_one()
|
# self.ensure_one()
|
||||||
pr_ids = self.env['purchase.request'].sudo().search(
|
# pr_ids = self.env['purchase.request'].sudo().search(
|
||||||
[('origin', 'like', self.production_id.name), ('is_subcontract', '=', 'True'),
|
# [('origin', 'like', self.production_id.name), ('is_subcontract', '=', 'True'),
|
||||||
('state', '!=', 'rejected')])
|
# ('state', '!=', 'rejected')])
|
||||||
action = {
|
# action = {
|
||||||
'res_model': 'purchase.request',
|
# 'res_model': 'purchase.request',
|
||||||
'type': 'ir.actions.act_window',
|
# 'type': 'ir.actions.act_window',
|
||||||
}
|
# }
|
||||||
if len(pr_ids) == 1:
|
# if len(pr_ids) == 1:
|
||||||
action.update({
|
# action.update({
|
||||||
'view_mode': 'form',
|
# 'view_mode': 'form',
|
||||||
'res_id': pr_ids[0].id,
|
# 'res_id': pr_ids[0].id,
|
||||||
})
|
# })
|
||||||
else:
|
# else:
|
||||||
action.update({
|
# action.update({
|
||||||
'name': _("从 %s生成采购请求单", self.name),
|
# 'name': _("从 %s生成采购请求单", self.name),
|
||||||
'domain': [('id', 'in', pr_ids)],
|
# 'domain': [('id', 'in', pr_ids)],
|
||||||
'view_mode': 'tree,form',
|
# 'view_mode': 'tree,form',
|
||||||
})
|
# })
|
||||||
return action
|
# return action
|
||||||
|
|
||||||
def action_view_surface_technics_purchase(self):
|
def action_view_surface_technics_purchase(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
@@ -1245,12 +1245,12 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
}]
|
}]
|
||||||
return workorders_values_str
|
return workorders_values_str
|
||||||
|
|
||||||
def check_lot_exists(self, picking_id, lot_id):
|
# def check_lot_exists(self, picking_id, lot_id):
|
||||||
return bool(
|
# return bool(
|
||||||
picking_id.move_ids.move_line_ids.filtered(
|
# picking_id.move_ids.move_line_ids.filtered(
|
||||||
lambda line: line.lot_id.id == lot_id
|
# lambda line: line.lot_id.id == lot_id
|
||||||
)
|
# )
|
||||||
)
|
# )
|
||||||
|
|
||||||
def _process_compute_state(self):
|
def _process_compute_state(self):
|
||||||
sorted_workorders = sorted(self, key=lambda x: x.sequence)
|
sorted_workorders = sorted(self, key=lambda x: x.sequence)
|
||||||
@@ -1292,10 +1292,10 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||||
if purchase_orders_id.state == 'purchase':
|
if purchase_orders_id.state == 'purchase':
|
||||||
workorder.state = 'ready'
|
workorder.state = 'ready'
|
||||||
picking_id = workorder.production_id.picking_ids.filtered(
|
# picking_id = workorder.production_id.picking_ids.filtered(
|
||||||
lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
# lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
||||||
move_out = picking_id.move_ids
|
# move_out = picking_id.move_ids
|
||||||
# move_out = workorder.move_subcontract_workorder_ids[1]
|
move_out = workorder.move_subcontract_workorder_ids[1]
|
||||||
for mo in move_out:
|
for mo in move_out:
|
||||||
if mo.state != 'done':
|
if mo.state != 'done':
|
||||||
mo.write({'state': 'assigned', 'production_id': False})
|
mo.write({'state': 'assigned', 'production_id': False})
|
||||||
@@ -1334,10 +1334,11 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
if purchase_orders_id:
|
if purchase_orders_id:
|
||||||
if purchase_orders_id.state == 'purchase':
|
if purchase_orders_id.state == 'purchase':
|
||||||
workorder.state = 'ready'
|
workorder.state = 'ready'
|
||||||
picking_id = workorder.production_id.picking_ids.filtered(
|
move_out = workorder.move_subcontract_workorder_ids[1]
|
||||||
lambda
|
# picking_id = workorder.production_id.picking_ids.filtered(
|
||||||
wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
# lambda
|
||||||
move_out = picking_id.move_ids
|
# wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
||||||
|
# move_out = picking_id.move_ids
|
||||||
for mo in move_out:
|
for mo in move_out:
|
||||||
if mo.state != 'done':
|
if mo.state != 'done':
|
||||||
mo.write({'state': 'assigned', 'production_id': False})
|
mo.write({'state': 'assigned', 'production_id': False})
|
||||||
@@ -1411,9 +1412,10 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# 表面工艺外协出库单
|
# 表面工艺外协出库单
|
||||||
if self.routing_type == '表面工艺':
|
if self.routing_type == '表面工艺':
|
||||||
if self.is_subcontract is True:
|
if self.is_subcontract is True:
|
||||||
picking_id = self.production_id.picking_ids.filtered(
|
move_out = self.move_subcontract_workorder_ids[1]
|
||||||
lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
# picking_id = self.production_id.picking_ids.filtered(
|
||||||
move_out = picking_id.move_ids
|
# lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
||||||
|
# move_out = picking_id.move_ids
|
||||||
# move_out = self.move_subcontract_workorder_ids[1]
|
# move_out = self.move_subcontract_workorder_ids[1]
|
||||||
# move_out = self.env['stock.move'].search(
|
# move_out = self.env['stock.move'].search(
|
||||||
# [('location_id', '=', self.env['stock.location'].search(
|
# [('location_id', '=', self.env['stock.location'].search(
|
||||||
|
|||||||
@@ -59,83 +59,83 @@ class PurchaseOrder(models.Model):
|
|||||||
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
||||||
purchase.production_count = len(production_id)
|
purchase.production_count = len(production_id)
|
||||||
|
|
||||||
def process_replenish(self,production,total_qty):
|
# def process_replenish(self,production,total_qty):
|
||||||
record = self
|
# record = self
|
||||||
bom_line_id = production.bom_id.bom_line_ids
|
# bom_line_id = production.bom_id.bom_line_ids
|
||||||
replenish = self.env['stock.warehouse.orderpoint'].search([
|
# replenish = self.env['stock.warehouse.orderpoint'].search([
|
||||||
('product_id', '=', bom_line_id.product_id.id),
|
# ('product_id', '=', bom_line_id.product_id.id),
|
||||||
(
|
# (
|
||||||
'location_id', '=', self.env.ref('sf_stock.stock_location_outsourcing_material_receiving_area').id),
|
# 'location_id', '=', self.env.ref('sf_stock.stock_location_outsourcing_material_receiving_area').id),
|
||||||
# ('state', 'in', ['draft', 'confirmed'])
|
# # ('state', 'in', ['draft', 'confirmed'])
|
||||||
], limit=1)
|
# ], limit=1)
|
||||||
if not replenish:
|
# if not replenish:
|
||||||
replenish_model = self.env['stock.warehouse.orderpoint']
|
# replenish_model = self.env['stock.warehouse.orderpoint']
|
||||||
replenish = replenish_model.create({
|
# replenish = replenish_model.create({
|
||||||
'product_id': bom_line_id.product_id.id,
|
# 'product_id': bom_line_id.product_id.id,
|
||||||
'location_id': self.env.ref(
|
# 'location_id': self.env.ref(
|
||||||
'sf_stock.stock_location_outsourcing_material_receiving_area').id,
|
# 'sf_stock.stock_location_outsourcing_material_receiving_area').id,
|
||||||
'route_id': self.env.ref('sf_stock.stock_route_process_outsourcing').id,
|
# 'route_id': self.env.ref('sf_stock.stock_route_process_outsourcing').id,
|
||||||
'group_id': record.group_id.id,
|
# 'group_id': record.group_id.id,
|
||||||
'qty_to_order': total_qty,
|
# 'qty_to_order': total_qty,
|
||||||
'origin': record.name,
|
# 'origin': record.name,
|
||||||
})
|
# })
|
||||||
else:
|
# else:
|
||||||
replenish.write({
|
# replenish.write({
|
||||||
'product_id': bom_line_id.product_id.id,
|
# 'product_id': bom_line_id.product_id.id,
|
||||||
'location_id': self.env.ref(
|
# 'location_id': self.env.ref(
|
||||||
'sf_stock.stock_location_outsourcing_material_receiving_area').id,
|
# 'sf_stock.stock_location_outsourcing_material_receiving_area').id,
|
||||||
'route_id': self.env.ref('sf_stock.stock_route_process_outsourcing').id,
|
# 'route_id': self.env.ref('sf_stock.stock_route_process_outsourcing').id,
|
||||||
'group_id': record.group_id.id,
|
# 'group_id': record.group_id.id,
|
||||||
'qty_to_order': total_qty + replenish.qty_to_order,
|
# 'qty_to_order': total_qty + replenish.qty_to_order,
|
||||||
'origin': record.name + ',' + replenish.origin,
|
# 'origin': record.name + ',' + replenish.origin,
|
||||||
})
|
# })
|
||||||
replenish.action_replenish()
|
# replenish.action_replenish()
|
||||||
|
|
||||||
def outsourcing_service_replenishment(self):
|
# def outsourcing_service_replenishment(self):
|
||||||
record = self
|
# record = self
|
||||||
if record.purchase_type != 'consignment':
|
# if record.purchase_type != 'consignment':
|
||||||
return
|
# return
|
||||||
grouped_lines = {}
|
# grouped_lines = {}
|
||||||
for line in record.order_line:
|
# for line in record.order_line:
|
||||||
if line.related_product.id not in grouped_lines:
|
# if line.related_product.id not in grouped_lines:
|
||||||
grouped_lines[line.related_product.id] = []
|
# grouped_lines[line.related_product.id] = []
|
||||||
grouped_lines[line.related_product.id].append(line)
|
# grouped_lines[line.related_product.id].append(line)
|
||||||
for product_id,lines in grouped_lines.items():
|
# for product_id,lines in grouped_lines.items():
|
||||||
production = self.env['mrp.production'].search([('product_id', '=', product_id)], limit=1)
|
# production = self.env['mrp.production'].search([('product_id', '=', product_id)], limit=1)
|
||||||
if not production:
|
# if not production:
|
||||||
continue
|
# continue
|
||||||
total_qty = sum(line.product_qty for line in lines)
|
# total_qty = sum(line.product_qty for line in lines)
|
||||||
record.process_replenish(production,total_qty)
|
# record.process_replenish(production,total_qty)
|
||||||
for product_id,lines in grouped_lines.items():
|
# for product_id,lines in grouped_lines.items():
|
||||||
productions = self.env['mrp.production'].search([('product_id', '=', product_id)], limit=1)
|
# productions = self.env['mrp.production'].search([('product_id', '=', product_id)], limit=1)
|
||||||
if not productions:
|
# if not productions:
|
||||||
continue
|
# continue
|
||||||
# production.bom_id.bom_line_ids.product_id
|
# # production.bom_id.bom_line_ids.product_id
|
||||||
location_id = self.env['stock.location'].search([('name', '=', '制造前')])
|
# location_id = self.env['stock.location'].search([('name', '=', '制造前')])
|
||||||
quants = self.env['stock.quant'].search([
|
# quants = self.env['stock.quant'].search([
|
||||||
('product_id', '=', productions.bom_id.bom_line_ids.product_id.id),
|
# ('product_id', '=', productions.bom_id.bom_line_ids.product_id.id),
|
||||||
('location_id', '=', location_id.id)
|
# ('location_id', '=', location_id.id)
|
||||||
])
|
# ])
|
||||||
total_qty = sum(quants.mapped('quantity')) # 计算该位置的总库存量
|
# total_qty = sum(quants.mapped('quantity')) # 计算该位置的总库存量
|
||||||
is_available = total_qty > 0
|
# is_available = total_qty > 0
|
||||||
if not is_available:
|
# if not is_available:
|
||||||
raise UserError('请先完成坯料入库')
|
# raise UserError('请先完成坯料入库')
|
||||||
for production_id in productions:
|
# for production_id in productions:
|
||||||
work_ids = production_id.workorder_ids.filtered(
|
# work_ids = production_id.workorder_ids.filtered(
|
||||||
lambda wk: wk.state not in ['done', 'rework', 'cancel'])
|
# lambda wk: wk.state not in ['done', 'rework', 'cancel'])
|
||||||
if not work_ids:
|
# if not work_ids:
|
||||||
continue
|
# continue
|
||||||
min_sequence_wk = min(work_ids, key=lambda wk: wk.sequence)
|
# min_sequence_wk = min(work_ids, key=lambda wk: wk.sequence)
|
||||||
if min_sequence_wk.is_subcontract:
|
# if min_sequence_wk.is_subcontract:
|
||||||
picking_id = production_id.picking_ids.filtered(
|
# picking_id = production_id.picking_ids.filtered(
|
||||||
lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
# lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
||||||
move_out = picking_id.move_ids
|
# move_out = picking_id.move_ids
|
||||||
for mo in move_out:
|
# for mo in move_out:
|
||||||
if mo.state != 'done':
|
# if mo.state != 'done':
|
||||||
mo.write({'state': 'assigned', 'production_id': False})
|
# mo.write({'state': 'assigned', 'production_id': False})
|
||||||
if not mo.move_line_ids:
|
# if not mo.move_line_ids:
|
||||||
self.env['stock.move.line'].create(
|
# self.env['stock.move.line'].create(
|
||||||
mo.get_move_line(production_id, min_sequence_wk))
|
# mo.get_move_line(production_id, min_sequence_wk))
|
||||||
# product = self.env['mrp.production'].search([('product_id', '=', product_id)], limit=1)
|
# product = self.env['mrp.production'].search([('product_id', '=', product_id)], limit=1)
|
||||||
# match = re.search(r'(S\d{5}-\d)',product.name)
|
# match = re.search(r'(S\d{5}-\d)',product.name)
|
||||||
# pass
|
# pass
|
||||||
@@ -146,7 +146,7 @@ class PurchaseOrder(models.Model):
|
|||||||
raise UserError('请对【产品】中的【数量】进行输入')
|
raise UserError('请对【产品】中的【数量】进行输入')
|
||||||
if line.price_unit <= 0:
|
if line.price_unit <= 0:
|
||||||
raise UserError('请对【产品】中的【单价】进行输入')
|
raise UserError('请对【产品】中的【单价】进行输入')
|
||||||
record.outsourcing_service_replenishment()
|
# record.outsourcing_service_replenishment()
|
||||||
|
|
||||||
res = super(PurchaseOrder, self).button_confirm()
|
res = super(PurchaseOrder, self).button_confirm()
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import base64
|
# import base64
|
||||||
import datetime
|
# import datetime
|
||||||
import logging
|
# import logging
|
||||||
import json
|
# import json
|
||||||
import os
|
# import os
|
||||||
import re
|
# import re
|
||||||
import traceback
|
# import traceback
|
||||||
from operator import itemgetter
|
# from operator import itemgetter
|
||||||
|
|
||||||
import requests
|
# import requests
|
||||||
from itertools import groupby
|
# from itertools import groupby
|
||||||
from collections import defaultdict, namedtuple
|
# from collections import defaultdict, namedtuple
|
||||||
|
|
||||||
from odoo import api, fields, models, SUPERUSER_ID, _
|
# from odoo import api, fields, models, SUPERUSER_ID, _
|
||||||
from odoo.exceptions import UserError, ValidationError
|
# from odoo.exceptions import UserError, ValidationError
|
||||||
from odoo.tools import float_compare, float_round, float_is_zero, format_datetime
|
# from odoo.tools import float_compare, float_round, float_is_zero, format_datetime
|
||||||
|
|
||||||
|
|
||||||
class PurchaseRequestLine(models.Model):
|
# class PurchaseRequestLine(models.Model):
|
||||||
_inherit = 'purchase.request'
|
# _inherit = 'purchase.request'
|
||||||
is_subcontract = fields.Boolean(string='是否外协',default=False)
|
# is_subcontract = fields.Boolean(string='是否外协',default=False)
|
||||||
class PurchaseRequestLine(models.Model):
|
# class PurchaseRequestLine(models.Model):
|
||||||
_inherit = 'purchase.request.line'
|
# _inherit = 'purchase.request.line'
|
||||||
is_subcontract = fields.Boolean(string='是否外协')
|
# is_subcontract = fields.Boolean(string='是否外协')
|
||||||
|
|
||||||
|
|
||||||
class PurchaseRequest(models.Model):
|
# class PurchaseRequest(models.Model):
|
||||||
_inherit = 'purchase.request'
|
# _inherit = 'purchase.request'
|
||||||
bom_id = fields.Many2one('mrp.bom')
|
# bom_id = fields.Many2one('mrp.bom')
|
||||||
|
|||||||
@@ -7,74 +7,74 @@ from odoo.exceptions import UserError, ValidationError
|
|||||||
|
|
||||||
class SfProductionProcessParameter(models.Model):
|
class SfProductionProcessParameter(models.Model):
|
||||||
_inherit = 'sf.production.process.parameter'
|
_inherit = 'sf.production.process.parameter'
|
||||||
service_products = fields.Many2one(
|
# service_products = fields.Many2one(
|
||||||
'product.template',
|
# 'product.template',
|
||||||
string='外协服务产品',compute='_compute_service_products',inverse='_inverse_service_products',
|
# string='外协服务产品',compute='_compute_service_products',inverse='_inverse_service_products',
|
||||||
store=True
|
# store=True
|
||||||
)
|
# )
|
||||||
outsourced_service_products = fields.One2many(
|
# outsourced_service_products = fields.One2many(
|
||||||
'product.template', # 另一个模型的名称
|
# 'product.template', # 另一个模型的名称
|
||||||
'server_product_process_parameters_id', # 对应的 Many2one 字段名称
|
# 'server_product_process_parameters_id', # 对应的 Many2one 字段名称
|
||||||
string='外协服务产品'
|
# string='外协服务产品'
|
||||||
)
|
# )
|
||||||
is_product_button = fields.Boolean(compute='_compute_is_product_button',default=False)
|
# is_product_button = fields.Boolean(compute='_compute_is_product_button',default=False)
|
||||||
is_delete_button = fields.Boolean(compute='_compute_is_delete_button', default=False)
|
# is_delete_button = fields.Boolean(compute='_compute_is_delete_button', default=False)
|
||||||
routing_id = fields.Many2one('mrp.routing.workcenter', string="工序")
|
# routing_id = fields.Many2one('mrp.routing.workcenter', string="工序")
|
||||||
|
|
||||||
@api.depends('outsourced_service_products')
|
# @api.depends('outsourced_service_products')
|
||||||
def _compute_service_products(self):
|
# def _compute_service_products(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
# 假设取第一条作为主明细
|
# # 假设取第一条作为主明细
|
||||||
record.service_products = record.outsourced_service_products.ids if record.outsourced_service_products else False
|
# record.service_products = record.outsourced_service_products.ids if record.outsourced_service_products else False
|
||||||
|
|
||||||
def _inverse_service_products(self):
|
# def _inverse_service_products(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
if record.service_products:
|
# if record.service_products:
|
||||||
# 确保关联关系正确
|
# # 确保关联关系正确
|
||||||
record.outsourced_service_products = record.service_products.ids if record.service_products else False
|
# record.outsourced_service_products = record.service_products.ids if record.service_products else False
|
||||||
else:
|
# else:
|
||||||
record.outsourced_service_products = False
|
# record.outsourced_service_products = False
|
||||||
def name_get(self):
|
# def name_get(self):
|
||||||
result = []
|
# result = []
|
||||||
for record in self:
|
# for record in self:
|
||||||
name = f"{record.process_id.name} - {record.name}" # 自定义显示格式
|
# name = f"{record.process_id.name} - {record.name}" # 自定义显示格式
|
||||||
result.append((record.id, name))
|
# result.append((record.id, name))
|
||||||
return result
|
# return result
|
||||||
@api.constrains('outsourced_service_products')
|
# @api.constrains('outsourced_service_products')
|
||||||
def _validate_partner_limit(self):
|
# def _validate_partner_limit(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
if len(record.outsourced_service_products) > 1:
|
# if len(record.outsourced_service_products) > 1:
|
||||||
raise ValidationError("工艺参数不能与多个产品关联")
|
# raise ValidationError("工艺参数不能与多个产品关联")
|
||||||
|
|
||||||
@api.onchange('outsourced_service_products')
|
# @api.onchange('outsourced_service_products')
|
||||||
def _onchange_validate_partner_limit(self):
|
# def _onchange_validate_partner_limit(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
if len(record.outsourced_service_products) > 1:
|
# if len(record.outsourced_service_products) > 1:
|
||||||
raise ValidationError("工艺参数不能与多个产品关联")
|
# raise ValidationError("工艺参数不能与多个产品关联")
|
||||||
@api.depends('outsourced_service_products')
|
# @api.depends('outsourced_service_products')
|
||||||
def _compute_is_product_button(self):
|
# def _compute_is_product_button(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
if record.outsourced_service_products:
|
# if record.outsourced_service_products:
|
||||||
record.is_product_button = True
|
# record.is_product_button = True
|
||||||
else:
|
# else:
|
||||||
record.is_product_button = False
|
# record.is_product_button = False
|
||||||
|
|
||||||
def has_wksp_prefix(self):
|
# def has_wksp_prefix(self):
|
||||||
"""
|
# """
|
||||||
判断字符串是否以WKSP开头(不区分大小写)
|
# 判断字符串是否以WKSP开头(不区分大小写)
|
||||||
:param text: 要检查的字符串
|
# :param text: 要检查的字符串
|
||||||
:return: True/False
|
# :return: True/False
|
||||||
"""
|
# """
|
||||||
return self.code.upper().startswith('101'+self.routing_id.code)
|
# return self.code.upper().startswith('101'+self.routing_id.code)
|
||||||
@api.depends('outsourced_service_products','code')
|
# @api.depends('outsourced_service_products','code')
|
||||||
def _compute_is_delete_button(self):
|
# def _compute_is_delete_button(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
if record.outsourced_service_products and record.has_wksp_prefix():
|
# if record.outsourced_service_products and record.has_wksp_prefix():
|
||||||
record.is_delete_button = False
|
# record.is_delete_button = False
|
||||||
elif record.outsourced_service_products:
|
# elif record.outsourced_service_products:
|
||||||
record.is_delete_button = True
|
# record.is_delete_button = True
|
||||||
else:
|
# else:
|
||||||
record.is_delete_button = True
|
# record.is_delete_button = True
|
||||||
@api.model
|
@api.model
|
||||||
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
|
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
|
||||||
if self._context.get('route_id'):
|
if self._context.get('route_id'):
|
||||||
@@ -90,19 +90,19 @@ class SfProductionProcessParameter(models.Model):
|
|||||||
return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
|
return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
|
||||||
return super()._name_search(name, args, operator, limit, name_get_uid)
|
return super()._name_search(name, args, operator, limit, name_get_uid)
|
||||||
|
|
||||||
def action_create_service_product(self):
|
# def action_create_service_product(self):
|
||||||
if self.id: # 如果是已存在的记录
|
# if self.id: # 如果是已存在的记录
|
||||||
self.write({}) # 空写入会触发保存
|
# self.write({}) # 空写入会触发保存
|
||||||
else: # 如果是新记录
|
# else: # 如果是新记录
|
||||||
self = self.create(self._convert_to_write(self.read()[0]))
|
# self = self.create(self._convert_to_write(self.read()[0]))
|
||||||
return {
|
# return {
|
||||||
'type': 'ir.actions.act_window',
|
# 'type': 'ir.actions.act_window',
|
||||||
'name': '向导名称',
|
# 'name': '向导名称',
|
||||||
'res_model': 'product.creation.wizard',
|
# 'res_model': 'product.creation.wizard',
|
||||||
'view_mode': 'form',
|
# 'view_mode': 'form',
|
||||||
'target': 'new',
|
# 'target': 'new',
|
||||||
'context': {'default_process_parameter_id': self.id}, # 传递当前记录ID
|
# 'context': {'default_process_parameter_id': self.id}, # 传递当前记录ID
|
||||||
}
|
# }
|
||||||
#
|
#
|
||||||
# return {
|
# return {
|
||||||
# 'name': '创建服务产品',
|
# 'name': '创建服务产品',
|
||||||
@@ -116,6 +116,6 @@ class SfProductionProcessParameter(models.Model):
|
|||||||
# },
|
# },
|
||||||
# }
|
# }
|
||||||
|
|
||||||
def action_hide_service_products(self):
|
# def action_hide_service_products(self):
|
||||||
# self.outsourced_service_products.active = False
|
# # self.outsourced_service_products.active = False
|
||||||
self.active = False
|
# self.active = False
|
||||||
|
|||||||
@@ -631,62 +631,84 @@ class StockPicking(models.Model):
|
|||||||
move.action_clear_lines_show_details()
|
move.action_clear_lines_show_details()
|
||||||
move.action_show_details()
|
move.action_show_details()
|
||||||
res = super().button_validate()
|
res = super().button_validate()
|
||||||
lot_ids = None
|
# lot_ids = None
|
||||||
product_ids = self.move_ids.mapped('product_id')
|
# product_ids = self.move_ids.mapped('product_id')
|
||||||
if not self.move_ids[0].product_id.single_manufacturing and self.move_ids[0].product_id.tracking == 'none':
|
# if not self.move_ids[0].product_id.single_manufacturing and self.move_ids[0].product_id.tracking == 'none':
|
||||||
lot_ids = self.move_ids.move_line_ids.mapped('lot_id')
|
# lot_ids = self.move_ids.move_line_ids.mapped('lot_id')
|
||||||
production_ids = self.sale_order_id.mrp_production_ids if self.sale_order_id else self.env['mrp.production']
|
# production_ids = self.sale_order_id.mrp_production_ids if self.sale_order_id else self.env['mrp.production']
|
||||||
if res and self.location_id.name == '外协收料区' and self.location_dest_id.name == '制造前':
|
# if res and self.location_id.name == '外协收料区' and self.location_dest_id.name == '制造前':
|
||||||
# 如果是最后一张外协入库单,则设置库存位置的预留数量
|
# # 如果是最后一张外协入库单,则设置库存位置的预留数量
|
||||||
for production_id in production_ids:
|
# for production_id in production_ids:
|
||||||
if lot_ids:
|
# if lot_ids:
|
||||||
lot_id = production_id.move_raw_ids.move_line_ids.lot_id
|
# lot_id = production_id.move_raw_ids.move_line_ids.lot_id
|
||||||
# picking_ids = production_id.picking_ids.filtered(
|
# # picking_ids = production_id.picking_ids.filtered(
|
||||||
# lambda wk: wk.location_id.name == '外协收料区' and wk.location_dest_id.name == '制造前')
|
# # lambda wk: wk.location_id.name == '外协收料区' and wk.location_dest_id.name == '制造前')
|
||||||
if lot_id in lot_ids:
|
# if lot_id in lot_ids:
|
||||||
workorder_id = production_id.workorder_ids.filtered(
|
# workorder_id = production_id.workorder_ids.filtered(
|
||||||
lambda a: a.state == 'progress' and a.is_subcontract)
|
# lambda a: a.state == 'progress' and a.is_subcontract)
|
||||||
if not workorder_id:
|
# if not workorder_id:
|
||||||
continue
|
# continue
|
||||||
workorder_id.button_finish()
|
# workorder_id.button_finish()
|
||||||
else:
|
# else:
|
||||||
workorder_id = production_id.workorder_ids.filtered(lambda a: a.state == 'progress' and a.is_subcontract)
|
# workorder_id = production_id.workorder_ids.filtered(lambda a: a.state == 'progress' and a.is_subcontract)
|
||||||
if not workorder_id:
|
# if not workorder_id:
|
||||||
continue
|
# continue
|
||||||
workorder_id.button_finish()
|
# workorder_id.button_finish()
|
||||||
# lot_id = workorder.production_id.move_raw_ids.move_line_ids.lot_id
|
# # lot_id = workorder.production_id.move_raw_ids.move_line_ids.lot_id
|
||||||
# picking_ids = workorder.production_id.picking_ids.filtered(
|
# # picking_ids = workorder.production_id.picking_ids.filtered(
|
||||||
# lambda wk: wk.location_id.name == '外协收料区' and wk.location_dest_id.name == '制造前')
|
# # lambda wk: wk.location_id.name == '外协收料区' and wk.location_dest_id.name == '制造前')
|
||||||
|
|
||||||
# if move_in:
|
# # if move_in:
|
||||||
# workorder = move_in.subcontract_workorder_id
|
# # workorder = move_in.subcontract_workorder_id
|
||||||
# workorders = workorder.production_id.workorder_ids
|
# # workorders = workorder.production_id.workorder_ids
|
||||||
# subcontract_workorders = workorders.filtered(
|
# # subcontract_workorders = workorders.filtered(
|
||||||
# lambda wo: wo.is_subcontract == True and wo.state != 'cancel').sorted('sequence')
|
# # lambda wo: wo.is_subcontract == True and wo.state != 'cancel').sorted('sequence')
|
||||||
# # if workorder == subcontract_workorders[-1]:
|
# # # if workorder == subcontract_workorders[-1]:
|
||||||
# # self.env['stock.quant']._update_reserved_quantity(
|
# # # self.env['stock.quant']._update_reserved_quantity(
|
||||||
# # move_in.product_id, move_in.location_dest_id, move_in.product_uom_qty,
|
# # # move_in.product_id, move_in.location_dest_id, move_in.product_uom_qty,
|
||||||
# # lot_id=move_in.move_line_ids.lot_id,
|
# # # lot_id=move_in.move_line_ids.lot_id,
|
||||||
# # package_id=False, owner_id=False, strict=False
|
# # # package_id=False, owner_id=False, strict=False
|
||||||
# # )
|
# # # )
|
||||||
# workorder.button_finish()
|
# # workorder.button_finish()
|
||||||
if res and self.location_id.name == '制造前' and self.location_dest_id.name == '外协加工区':
|
# if res and self.location_id.name == '制造前' and self.location_dest_id.name == '外协加工区':
|
||||||
for production_id in production_ids:
|
# for production_id in production_ids:
|
||||||
if lot_ids:
|
# if lot_ids:
|
||||||
lot_id = production_id.move_raw_ids.move_line_ids.lot_id
|
# lot_id = production_id.move_raw_ids.move_line_ids.lot_id
|
||||||
# picking_ids = production_id.picking_ids.filtered(
|
# # picking_ids = production_id.picking_ids.filtered(
|
||||||
# lambda wk: wk.location_id.name == '外协收料区' and wk.location_dest_id.name == '制造前')
|
# # lambda wk: wk.location_id.name == '外协收料区' and wk.location_dest_id.name == '制造前')
|
||||||
if lot_id in lot_ids:
|
# if lot_id in lot_ids:
|
||||||
workorder_id = production_id.workorder_ids.filtered(
|
# workorder_id = production_id.workorder_ids.filtered(
|
||||||
lambda a: a.state == 'progress' and a.is_subcontract)
|
# lambda a: a.state == 'progress' and a.is_subcontract)
|
||||||
if not workorder_id:
|
# if not workorder_id:
|
||||||
continue
|
# continue
|
||||||
workorder_id.button_finish()
|
# workorder_id.button_finish()
|
||||||
else:
|
# else:
|
||||||
workorder_id = production_id.workorder_ids.filtered(lambda a: a.state == 'ready' and a.is_subcontract)
|
# workorder_id = production_id.workorder_ids.filtered(lambda a: a.state == 'ready' and a.is_subcontract)
|
||||||
if not workorder_id:
|
# if not workorder_id:
|
||||||
continue
|
# continue
|
||||||
workorder_id.button_start()
|
# workorder_id.button_start()
|
||||||
|
picking_type_in = self.env.ref('sf_manufacturing.outcontract_picking_in').id
|
||||||
|
if res is True and self.picking_type_id.id == picking_type_in:
|
||||||
|
# 如果是最后一张外协入库单,则设置库存位置的预留数量
|
||||||
|
move_in = self.move_ids
|
||||||
|
if move_in:
|
||||||
|
workorder = move_in.subcontract_workorder_id
|
||||||
|
workorders = workorder.production_id.workorder_ids
|
||||||
|
subcontract_workorders = workorders.filtered(
|
||||||
|
lambda wo: wo.is_subcontract == True and wo.state != 'cancel').sorted('sequence')
|
||||||
|
# if workorder == subcontract_workorders[-1]:
|
||||||
|
# self.env['stock.quant']._update_reserved_quantity(
|
||||||
|
# move_in.product_id, move_in.location_dest_id, move_in.product_uom_qty,
|
||||||
|
# lot_id=move_in.move_line_ids.lot_id,
|
||||||
|
# package_id=False, owner_id=False, strict=False
|
||||||
|
# )
|
||||||
|
workorder.button_finish()
|
||||||
|
picking_type_out = self.env.ref('sf_manufacturing.outcontract_picking_out').id
|
||||||
|
if res and self.picking_type_id.id == picking_type_out:
|
||||||
|
move_out = self.move_ids
|
||||||
|
if move_out:
|
||||||
|
workorder = move_out.subcontract_workorder_id
|
||||||
|
workorder.button_start()
|
||||||
if self.location_id.name == '成品存货区' and self.location_dest_id.name == '客户':
|
if self.location_id.name == '成品存货区' and self.location_dest_id.name == '客户':
|
||||||
sale_id = self.env['sale.order'].sudo().search(
|
sale_id = self.env['sale.order'].sudo().search(
|
||||||
[('name', '=', self.origin)])
|
[('name', '=', self.origin)])
|
||||||
|
|||||||
@@ -383,7 +383,7 @@
|
|||||||
<field name="process_parameters_id"
|
<field name="process_parameters_id"
|
||||||
attrs="{'readonly': [('id', '!=', False),('routing_tag', '=', 'standard')]}"
|
attrs="{'readonly': [('id', '!=', False),('routing_tag', '=', 'standard')]}"
|
||||||
string="参数" context="{'route_id':route_id,'production_id': production_id}"
|
string="参数" context="{'route_id':route_id,'production_id': production_id}"
|
||||||
options="{'no_create': True}" domain="[('routing_id', '=', 'route_id')]"/>
|
options="{'no_create': True}"/>
|
||||||
<field name="panel" readonly="1"/>
|
<field name="panel" readonly="1"/>
|
||||||
<field name="routing_tag" readonly="1" widget="badge"
|
<field name="routing_tag" readonly="1" widget="badge"
|
||||||
decoration-success="routing_tag == 'standard'"
|
decoration-success="routing_tag == 'standard'"
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<field name="is_repeat"/>
|
<field name="is_repeat"/>
|
||||||
<field name="reserved_duration"/>
|
<field name="reserved_duration"/>
|
||||||
</field>
|
</field>
|
||||||
<xpath expr="//notebook/page[1]" position="before">
|
<!-- <xpath expr="//notebook/page[1]" position="before">
|
||||||
<page string="可选工艺参数">
|
<page string="可选工艺参数">
|
||||||
<field name="optional_process_parameters">
|
<field name="optional_process_parameters">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
@@ -30,9 +30,9 @@
|
|||||||
<field name="is_delete_button" invisible="1"/>
|
<field name="is_delete_button" invisible="1"/>
|
||||||
<field name="code" attrs="{'readonly': True}"/>
|
<field name="code" attrs="{'readonly': True}"/>
|
||||||
<field name="name" required="1"/>
|
<field name="name" required="1"/>
|
||||||
<field name="service_products" domain="[('detailed_type', '=', 'service'),('server_product_process_parameters_id', '=', False)]"/>
|
<field name="service_products" domain="[('detailed_type', '=', 'service'),('server_product_process_parameters_id', '=', False)]"/> -->
|
||||||
<!-- 按钮列 -->
|
<!-- 按钮列 -->
|
||||||
<button name="action_create_service_product" string="创建服务产品" type="object"
|
<!-- <button name="action_create_service_product" string="创建服务产品" type="object"
|
||||||
class="btn-primary"
|
class="btn-primary"
|
||||||
attrs="{'invisible': [('is_product_button', '=', True)]}" context="{'default_process_parameter_id':id}"/>
|
attrs="{'invisible': [('is_product_button', '=', True)]}" context="{'default_process_parameter_id':id}"/>
|
||||||
<button name="action_hide_service_products" string="删除" type="object"
|
<button name="action_hide_service_products" string="删除" type="object"
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath> -->
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
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_pr_mrp_workorder" class="oe_stat_button"
|
<!-- <button type="object" name="action_view_pr_mrp_workorder" class="oe_stat_button"
|
||||||
icon="fa-credit-card"
|
icon="fa-credit-card"
|
||||||
groups="base.group_user,sf_base.group_sf_order_user"
|
groups="base.group_user,sf_base.group_sf_order_user"
|
||||||
attrs="{'invisible': [('pr_mp_count', '=', 0)]}">
|
attrs="{'invisible': [('pr_mp_count', '=', 0)]}">
|
||||||
@@ -154,7 +154,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<span class="o_stat_text">采购申请</span>
|
<span class="o_stat_text">采购申请</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button> -->
|
||||||
<button type="object" name="action_view_surface_technics_purchase" class="oe_stat_button"
|
<button type="object" name="action_view_surface_technics_purchase" class="oe_stat_button"
|
||||||
icon="fa-credit-card"
|
icon="fa-credit-card"
|
||||||
groups="base.group_user,sf_base.group_sf_order_user"
|
groups="base.group_user,sf_base.group_sf_order_user"
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
if workorders[
|
if workorders[
|
||||||
0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
||||||
workorders[0].state = 'waiting'
|
workorders[0].state = 'waiting'
|
||||||
pr_ids = self.env['purchase.request'].sudo().search(
|
# pr_ids = self.env['purchase.request'].sudo().search(
|
||||||
[('origin', 'like', item.name), ('is_subcontract', '=', 'True'), ('state', '!=', 'rejected')])
|
# [('origin', 'like', item.name), ('is_subcontract', '=', 'True'), ('state', '!=', 'rejected')])
|
||||||
if not pr_ids:
|
# if not pr_ids:
|
||||||
continue
|
# continue
|
||||||
if not all(pr.state == 'draft' for pr in pr_ids):
|
# if not all(pr.state == 'draft' for pr in pr_ids):
|
||||||
# 如果发现有记录的 state 不是 'draft',抛出异常
|
# # 如果发现有记录的 state 不是 'draft',抛出异常
|
||||||
raise UserError("有采购申请的状态不是 '草稿'")
|
# raise UserError("有采购申请的状态不是 '草稿'")
|
||||||
pr_ids.state = 'rejected'
|
# pr_ids.state = 'rejected'
|
||||||
@@ -1149,7 +1149,7 @@ class sfProductionProcessParameter(models.Model):
|
|||||||
'processing_mm': item['processing_mm'],
|
'processing_mm': item['processing_mm'],
|
||||||
'gain_way':'外协',
|
'gain_way':'外协',
|
||||||
})
|
})
|
||||||
production_process_parameter.create_service_product()
|
# production_process_parameter.create_service_product()
|
||||||
else:
|
else:
|
||||||
production_process_parameter.gain_way = '外协'
|
production_process_parameter.gain_way = '外协'
|
||||||
production_process_parameter.name = item['name']
|
production_process_parameter.name = item['name']
|
||||||
@@ -1161,9 +1161,9 @@ class sfProductionProcessParameter(models.Model):
|
|||||||
[('materials_no', 'in', item['materials_model_ids_codes'])])
|
[('materials_no', 'in', item['materials_model_ids_codes'])])
|
||||||
production_process_parameter.active = item['active']
|
production_process_parameter.active = item['active']
|
||||||
production_process_parameter.processing_mm = item['processing_mm']
|
production_process_parameter.processing_mm = item['processing_mm']
|
||||||
if not production_process_parameter.outsourced_service_products:
|
# if not production_process_parameter.outsourced_service_products:
|
||||||
production_process_parameter.create_service_product()
|
# production_process_parameter.create_service_product()
|
||||||
production_process_parameter.create_work_center()
|
# production_process_parameter.create_work_center()
|
||||||
else:
|
else:
|
||||||
raise ValidationError("表面工艺可选参数认证未通过")
|
raise ValidationError("表面工艺可选参数认证未通过")
|
||||||
|
|
||||||
|
|||||||
@@ -346,10 +346,10 @@ class RePurchaseOrder(models.Model):
|
|||||||
if purchase.order_line[0].product_id.categ_id.name == '坯料':
|
if purchase.order_line[0].product_id.categ_id.name == '坯料':
|
||||||
if purchase.order_line[0].product_id.materials_type_id.gain_way == '外协':
|
if purchase.order_line[0].product_id.materials_type_id.gain_way == '外协':
|
||||||
purchase.purchase_type = 'outsourcing'
|
purchase.purchase_type = 'outsourcing'
|
||||||
request_lines = self.order_line.mapped('purchase_request_lines')
|
# request_lines = self.order_line.mapped('purchase_request_lines')
|
||||||
# 检查是否存在 is_subcontract 为 True 的行
|
# # 检查是否存在 is_subcontract 为 True 的行
|
||||||
if any(line.is_subcontract for line in request_lines):
|
# if any(line.is_subcontract for line in request_lines):
|
||||||
purchase.purchase_type = 'consignment'
|
# purchase.purchase_type = 'consignment'
|
||||||
|
|
||||||
|
|
||||||
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '预警'), ('overdue', '已逾期')],
|
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '预警'), ('overdue', '已逾期')],
|
||||||
@@ -384,28 +384,28 @@ class RePurchaseOrder(models.Model):
|
|||||||
if not line.taxes_id:
|
if not line.taxes_id:
|
||||||
raise UserError('请对【产品】中的【税】进行选择')
|
raise UserError('请对【产品】中的【税】进行选择')
|
||||||
|
|
||||||
def get_purchase_request(self, consecutive_process_parameters, production):
|
# def get_purchase_request(self, consecutive_process_parameters, production):
|
||||||
result = []
|
# result = []
|
||||||
for pp in consecutive_process_parameters:
|
# for pp in consecutive_process_parameters:
|
||||||
server_template = self.env['product.template'].search(
|
# server_template = self.env['product.template'].search(
|
||||||
[('server_product_process_parameters_id', '=', pp.surface_technics_parameters_id.id),
|
# [('server_product_process_parameters_id', '=', pp.surface_technics_parameters_id.id),
|
||||||
('detailed_type', '=', 'service')])
|
# ('detailed_type', '=', 'service')])
|
||||||
# route_ids
|
# # route_ids
|
||||||
result.append({
|
# result.append({
|
||||||
"product_id": server_template.product_variant_id.id,
|
# "product_id": server_template.product_variant_id.id,
|
||||||
'related_product': production.product_id.id,
|
# 'related_product': production.product_id.id,
|
||||||
"name": production.procurement_group_id.name,
|
# "name": production.procurement_group_id.name,
|
||||||
"date_required": fields.Datetime.now(),
|
# "date_required": fields.Datetime.now(),
|
||||||
"product_uom_id":server_template.uom_id.id,
|
# "product_uom_id":server_template.uom_id.id,
|
||||||
"product_qty": production.product_qty,
|
# "product_qty": production.product_qty,
|
||||||
"request_id": False,
|
# "request_id": False,
|
||||||
"move_dest_ids": False,
|
# "move_dest_ids": False,
|
||||||
"orderpoint_id": False,
|
# "orderpoint_id": False,
|
||||||
'is_subcontract':True,
|
# 'is_subcontract':True,
|
||||||
'group_id':production.procurement_group_id.id,
|
# 'group_id':production.procurement_group_id.id,
|
||||||
'production_name':pp.production_id.name,
|
# 'production_name':pp.production_id.name,
|
||||||
})
|
# })
|
||||||
return result
|
# return result
|
||||||
|
|
||||||
def get_purchase_order(self, consecutive_process_parameters, production, product_id_to_production_names):
|
def get_purchase_order(self, consecutive_process_parameters, production, product_id_to_production_names):
|
||||||
for pp in consecutive_process_parameters:
|
for pp in consecutive_process_parameters:
|
||||||
|
|||||||
Reference in New Issue
Block a user