view(Purchase): Set price automatically based on product.
This commit is contained in:
		@@ -45,6 +45,7 @@
 | 
				
			|||||||
              <v-select
 | 
					              <v-select
 | 
				
			||||||
                v-model="line.product"
 | 
					                v-model="line.product"
 | 
				
			||||||
                :items="products"
 | 
					                :items="products"
 | 
				
			||||||
 | 
					                @update:modelValue="onProductChange(index)"
 | 
				
			||||||
                item-title="name"
 | 
					                item-title="name"
 | 
				
			||||||
                item-value="id"
 | 
					                item-value="id"
 | 
				
			||||||
                label="Producto"
 | 
					                label="Producto"
 | 
				
			||||||
@@ -138,6 +139,11 @@
 | 
				
			|||||||
      },
 | 
					      },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    methods: {
 | 
					    methods: {
 | 
				
			||||||
 | 
					      onProductChange(index) {
 | 
				
			||||||
 | 
					        const selectedProductId = this.purchase.saleline_set[index].product;
 | 
				
			||||||
 | 
					        const selectedProduct = this.products.find(p => p.id == selectedProductId);
 | 
				
			||||||
 | 
					        this.purchase.saleline_set[index].unit_price = selectedProduct.price;
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
      fetchClients() {
 | 
					      fetchClients() {
 | 
				
			||||||
        fetch('/don_confiao/api/customers/')
 | 
					        fetch('/don_confiao/api/customers/')
 | 
				
			||||||
          .then(response => response.json())
 | 
					          .then(response => response.json())
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user