mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	improvements after code-review by @eeintech
This commit is contained in:
		@@ -257,8 +257,9 @@ class PurchaseOrder(Order):
 | 
				
			|||||||
                # update quantity and price
 | 
					                # update quantity and price
 | 
				
			||||||
                quantity_new = line.quantity + quantity
 | 
					                quantity_new = line.quantity + quantity
 | 
				
			||||||
                line.quantity = quantity_new
 | 
					                line.quantity = quantity_new
 | 
				
			||||||
                if line.purchase_price:
 | 
					                supplier_price = supplier_part.get_price(quantity_new)
 | 
				
			||||||
                    line.purchase_price = supplier_part.get_price(quantity_new) / quantity_new
 | 
					                if line.purchase_price and supplier_price:
 | 
				
			||||||
 | 
					                    line.purchase_price = supplier_price / quantity_new
 | 
				
			||||||
                line.save()
 | 
					                line.save()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -996,7 +996,14 @@ class OrderParts(AjaxView):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                part.order_supplier = supplier_part.id if supplier_part else None
 | 
					                part.order_supplier = supplier_part.id if supplier_part else None
 | 
				
			||||||
                part.order_quantity = quantity
 | 
					                part.order_quantity = quantity
 | 
				
			||||||
                part.purchase_price = supplier_part.get_price(quantity) / quantity if supplier_part else None
 | 
					
 | 
				
			||||||
 | 
					                # set supplier-price
 | 
				
			||||||
 | 
					                if supplier_part:
 | 
				
			||||||
 | 
					                    supplier_price = supplier_part.get_price(quantity)
 | 
				
			||||||
 | 
					                    if supplier_price:
 | 
				
			||||||
 | 
					                        part.purchase_price = supplier_price / quantity
 | 
				
			||||||
 | 
					                if not hasattr(part, 'purchase_price'):
 | 
				
			||||||
 | 
					                    part.purchase_price = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                self.parts.append(part)
 | 
					                self.parts.append(part)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1098,7 +1105,7 @@ class OrderParts(AjaxView):
 | 
				
			|||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                # get purchase price
 | 
					                # get purchase price
 | 
				
			||||||
                purchase_price = item.purchase_price if item.purchase_price else None
 | 
					                purchase_price = item.purchase_price
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                order.add_line_item(supplier_part, quantity, purchase_price=purchase_price)
 | 
					                order.add_line_item(supplier_part, quantity, purchase_price=purchase_price)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user