外协采购单使用采购申请创建出来的采购单
This commit is contained in:
@@ -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'),
|
||||||
|
|||||||
Reference in New Issue
Block a user