Accept Merge Request #2112: (feature/tool_standard_library_process -> 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/2112
This commit is contained in:
@@ -19,8 +19,9 @@ class MrpProduction(models.Model):
|
|||||||
# item.pr_mp_count = len(pr_ids)
|
# item.pr_mp_count = len(pr_ids)
|
||||||
# 由于采购申请合并了所有销售订单行的采购,所以不区分产品
|
# 由于采购申请合并了所有销售订单行的采购,所以不区分产品
|
||||||
first_mp = self.env['mrp.production'].search(
|
first_mp = self.env['mrp.production'].search(
|
||||||
[('origin', '=', item.origin)], limit=1, order='id asc')
|
[('origin', '=', item.origin)], limit=1, order='id asc')
|
||||||
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', first_mp.name)])
|
pr_ids = self.env['purchase.request'].sudo().search(
|
||||||
|
[('origin', 'like', first_mp.name), ('is_subcontract', '!=', 'True')])
|
||||||
item.pr_mp_count = len(pr_ids)
|
item.pr_mp_count = len(pr_ids)
|
||||||
# pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', item.name), ('is_subcontract', '!=', 'True')])
|
# pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', item.name), ('is_subcontract', '!=', 'True')])
|
||||||
|
|
||||||
@@ -31,8 +32,8 @@ class MrpProduction(models.Model):
|
|||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
first_mp = self.env['mrp.production'].search(
|
first_mp = self.env['mrp.production'].search(
|
||||||
[('origin', '=', self.origin)], limit=1, order='id asc')
|
[('origin', '=', self.origin)], limit=1, order='id asc')
|
||||||
pr_ids = self.env['purchase.request'].sudo().search([('origin', 'like', first_mp.name)])
|
pr_ids = self.env['purchase.request'].sudo().search(
|
||||||
|
[('origin', 'like', first_mp.name), ('is_subcontract', '!=', 'True')])
|
||||||
|
|
||||||
action = {
|
action = {
|
||||||
'res_model': 'purchase.request',
|
'res_model': 'purchase.request',
|
||||||
|
|||||||
@@ -443,21 +443,11 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
@api.depends('state', 'production_id.name')
|
@api.depends('state', 'production_id.name')
|
||||||
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']:
|
pr_ids = self.env['purchase.request'].sudo().search(
|
||||||
# domain = [('group_id', '=', self.production_id.procurement_group_id.id),
|
[('origin', 'like', self.production_id.name), ('is_subcontract', '=', 'True'),
|
||||||
# ('purchase_type', '=', 'consignment'), ('state', '!=', 'cancel')]
|
('state', '!=', 'rejected')])
|
||||||
domain = [('purchase_type', '=', 'consignment'),
|
if pr_ids.purchase_count:
|
||||||
('origin', 'like', '%' + self.production_id.name + '%'),
|
order.surface_technics_purchase_count = pr_ids.purchase_count
|
||||||
('state', '!=', 'cancel')]
|
|
||||||
purchase = self.env['purchase.order'].search(domain)
|
|
||||||
order.surface_technics_purchase_count = 0
|
|
||||||
if not purchase:
|
|
||||||
order.surface_technics_purchase_count = 0
|
|
||||||
for po in purchase:
|
|
||||||
if any(
|
|
||||||
line.product_id and line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id
|
|
||||||
for line in po.order_line):
|
|
||||||
order.surface_technics_purchase_count = 1
|
|
||||||
else:
|
else:
|
||||||
order.surface_technics_purchase_count = 0
|
order.surface_technics_purchase_count = 0
|
||||||
|
|
||||||
@@ -502,17 +492,19 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# if technology_design.is_auto is False:
|
# if technology_design.is_auto is False:
|
||||||
# domain = [('origin', '=', self.production_id.name)]
|
# domain = [('origin', '=', self.production_id.name)]
|
||||||
# else:
|
# else:
|
||||||
|
pr_ids = self.env['purchase.request'].sudo().search(
|
||||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
[('origin', 'like', self.production_id.name), ('is_subcontract', '=', 'True'),
|
||||||
result = {
|
('state', '!=', 'rejected')])
|
||||||
"type": "ir.actions.act_window",
|
# purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||||
"res_model": "purchase.order",
|
# result = {
|
||||||
"res_id": purchase_orders_id.id,
|
# "type": "ir.actions.act_window",
|
||||||
# "domain": [['id', 'in', self.purchase_id]],
|
# "res_model": "purchase.order",
|
||||||
"name": _("Purchase Orders"),
|
# "res_id": purchase_orders_id.id,
|
||||||
'view_mode': 'form',
|
# # "domain": [['id', 'in', self.purchase_id]],
|
||||||
}
|
# "name": _("Purchase Orders"),
|
||||||
return result
|
# 'view_mode': 'form',
|
||||||
|
# }
|
||||||
|
return pr_ids.action_view_purchase_order()
|
||||||
|
|
||||||
def _get_surface_technics_purchase_ids(self):
|
def _get_surface_technics_purchase_ids(self):
|
||||||
domain = [('origin', 'like', '%' + self.production_id.name + '%'), ('purchase_type', '=', 'consignment'),
|
domain = [('origin', 'like', '%' + self.production_id.name + '%'), ('purchase_type', '=', 'consignment'),
|
||||||
@@ -1284,7 +1276,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# for move_line in move.move_line_ids
|
# for move_line in move.move_line_ids
|
||||||
# )
|
# )
|
||||||
if (workorder.production_id.production_type == '人工线下加工'
|
if (workorder.production_id.production_type == '人工线下加工'
|
||||||
and workorder.production_id.schedule_state == '已排'):
|
and workorder.production_id.programming_state == '已编程'):
|
||||||
# and workorder.production_id.programming_state == '已编程'
|
# and workorder.production_id.programming_state == '已编程'
|
||||||
if workorder.is_subcontract is True:
|
if workorder.is_subcontract is True:
|
||||||
if workorder.production_id.state == 'rework':
|
if workorder.production_id.state == 'rework':
|
||||||
@@ -1298,7 +1290,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
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 workorder.production_id.bom_id.bom_line_ids.product_id.id != move_out.product_id:
|
if workorder.production_id.bom_id.bom_line_ids.product_id.id != mo.product_id.id:
|
||||||
continue
|
continue
|
||||||
if mo.state != 'done':
|
if mo.state != 'done':
|
||||||
mo.write({'state': 'assigned', 'production_id': False})
|
mo.write({'state': 'assigned', 'production_id': False})
|
||||||
@@ -1341,7 +1333,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区')
|
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 workorder.production_id.bom_id.bom_line_ids.product_id.id != move_out.product_id:
|
if workorder.production_id.bom_id.bom_line_ids.product_id.id != mo.product_id.id:
|
||||||
continue
|
continue
|
||||||
if mo.state != 'done':
|
if mo.state != 'done':
|
||||||
mo.write({'state': 'assigned', 'production_id': False})
|
mo.write({'state': 'assigned', 'production_id': False})
|
||||||
@@ -1426,7 +1418,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# [('barcode', 'ilike', 'VL-SPOC')]).id),
|
# [('barcode', 'ilike', 'VL-SPOC')]).id),
|
||||||
# ('origin', '=', self.production_id.name), ('state', 'not in', ['cancel', 'done'])])
|
# ('origin', '=', self.production_id.name), ('state', 'not in', ['cancel', 'done'])])
|
||||||
for mo in move_out:
|
for mo in move_out:
|
||||||
if self.production_id.bom_id.bom_line_ids.product_id.id != move_out.product_id:
|
if self.production_id.bom_id.bom_line_ids.product_id.id != mo.product_id.id:
|
||||||
continue
|
continue
|
||||||
if mo.state != 'done':
|
if mo.state != 'done':
|
||||||
mo.write({'state': 'assigned', 'production_id': False})
|
mo.write({'state': 'assigned', 'production_id': False})
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class PurchaseOrder(models.Model):
|
|||||||
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 production_id.bom_id.bom_line_ids.product_id.id != move_out.product_id:
|
if production_id.bom_id.bom_line_ids.product_id.id != mo.product_id.id:
|
||||||
continue
|
continue
|
||||||
if mo.state != 'done':
|
if mo.state != 'done':
|
||||||
mo.write({'state': 'assigned', 'production_id': False})
|
mo.write({'state': 'assigned', 'production_id': False})
|
||||||
|
|||||||
Reference in New Issue
Block a user