解决删除表面工艺,多增加了采购单的bug
This commit is contained in:
@@ -248,38 +248,19 @@ class RePurchaseOrder(models.Model):
|
||||
|
||||
def get_purchase_order(self, consecutive_process_parameters, production, product_id_to_production_names):
|
||||
server_product_process = []
|
||||
production_process = product_id_to_production_names.get(
|
||||
production.product_id.id)
|
||||
purchase_order = self.env['purchase.order'].search(
|
||||
[('state', '=', 'draft'), ('origin', '=', production.name),
|
||||
('purchase_type', '=', 'consignment')], order='name asc')
|
||||
for pp in consecutive_process_parameters:
|
||||
server_template = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', pp.surface_technics_parameters_id.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
if not purchase_order:
|
||||
purchase_order = pp._get_surface_technics_purchase_ids()
|
||||
if purchase_order:
|
||||
purchase_order.write({'state': 'draft'})
|
||||
else:
|
||||
server_template = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', pp.surface_technics_parameters_id.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
server_product_process.append((0, 0, {
|
||||
'product_id': server_template.product_variant_id.id,
|
||||
'product_qty': 1,
|
||||
'product_uom': server_template.uom_id.id
|
||||
}))
|
||||
for purchase in purchase_order:
|
||||
for po in purchase.order_line:
|
||||
if po.product_id == server_template.product_variant_id:
|
||||
continue
|
||||
if server_template.server_product_process_parameters_id != po.product_id.server_product_process_parameters_id:
|
||||
purchase_order_line = self.env['purchase.order.line'].search(
|
||||
[('product_id', '=', server_template.product_variant_id.id),
|
||||
('product_qty', '=', 1.0), ('id', '=', purchase.id)], limit=1,
|
||||
order='id desc')
|
||||
if not purchase_order_line:
|
||||
server_product_process.append((0, 0, {
|
||||
'product_id': server_template.product_variant_id.id,
|
||||
'product_qty': 1,
|
||||
'product_uom': server_template.uom_id.id
|
||||
}))
|
||||
|
||||
if server_product_process:
|
||||
purchase_order = self.env['purchase.order'].sudo().create({
|
||||
'partner_id': server_template.seller_ids[0].partner_id.id,
|
||||
'origin': production.name,
|
||||
|
||||
Reference in New Issue
Block a user