Tryton Api Client Endpoints Tryton
This commit is contained in:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -11,6 +11,7 @@
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@mdi/font": "7.4.47",
 | 
			
		||||
    "core-js": "^3.37.1",
 | 
			
		||||
    "cors": "^2.8.5",
 | 
			
		||||
    "roboto-fontface": "*",
 | 
			
		||||
    "vee-validate": "^4.14.6",
 | 
			
		||||
    "vue": "^3.4.31",
 | 
			
		||||
 
 | 
			
		||||
@@ -276,7 +276,14 @@
 | 
			
		||||
     fetchProducts() {
 | 
			
		||||
       this.api.getProducts()
 | 
			
		||||
           .then(data => {
 | 
			
		||||
             this.products = data;
 | 
			
		||||
               console.log(data)
 | 
			
		||||
               const transformed_products = data.map(item => ({
 | 
			
		||||
                   name: item.name,
 | 
			
		||||
                   price: item["template."]?.list_price?.decimal,
 | 
			
		||||
                   measuring_unit: item["default_uom"]?.name,
 | 
			
		||||
                   categories: []
 | 
			
		||||
               }));
 | 
			
		||||
               this.products = transformed_products;
 | 
			
		||||
           })
 | 
			
		||||
           .catch(error => {
 | 
			
		||||
             console.error(error);
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,9 @@ import ApiImplementation from './services/api-implementation';
 | 
			
		||||
 | 
			
		||||
// Composables
 | 
			
		||||
import { createApp } from 'vue'
 | 
			
		||||
import cors from 'cors';
 | 
			
		||||
 | 
			
		||||
// const cors = require('cors');
 | 
			
		||||
 | 
			
		||||
process.env.API_IMPLEMENTATION = 'tryton';
 | 
			
		||||
// process.env.API_IMPLEMENTATION = 'django';
 | 
			
		||||
@@ -20,6 +23,10 @@ let apiImplementation = new ApiImplementation();
 | 
			
		||||
const api = apiImplementation.getApi();
 | 
			
		||||
 | 
			
		||||
const app = createApp(App);
 | 
			
		||||
// app.use(cors({
 | 
			
		||||
//   origin: '*', // Permitir todas las solicitudes de origen
 | 
			
		||||
//   exposedHeaders: ['X-Custom-Header', 'Content-Length'], // Exponer headers específicos
 | 
			
		||||
// }));
 | 
			
		||||
app.provide('api', api);
 | 
			
		||||
 | 
			
		||||
registerPlugins(app)
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ class ApiImplementation {
 | 
			
		||||
    if (implementation === 'django') {
 | 
			
		||||
      apiImplementation = new DjangoApi();
 | 
			
		||||
    } else if (implementation === 'tryton'){
 | 
			
		||||
      const url = 'http://localhost:8000';
 | 
			
		||||
      const url = 'http://192.168.0.114:18030';
 | 
			
		||||
      const key = '9a9ffc430146447d81e6698240199a4be2b0e774cb18474999d0f60e33b5b1eb1cfff9d9141346a98844879b5a9e787489c891ddc8fb45cc903b7244cab64fb1';
 | 
			
		||||
      const db = 'tryton';
 | 
			
		||||
      const applicationName = 'sale_don_confiao';
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,7 @@ class Api {
 | 
			
		||||
    return this.apiImplementation.getProducts();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  getPaymentMethods() {
 | 
			
		||||
    return this.apiImplementation.getPaymentMethods();
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -4,19 +4,20 @@ class TrytonApiClient {
 | 
			
		||||
    this.headers = {
 | 
			
		||||
      'Authorization': `Bearer ${key}`,
 | 
			
		||||
      'Content-Type': 'application/json',
 | 
			
		||||
      mode: 'cors'
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getCustomers() {
 | 
			
		||||
    // const url = '/don_confiao/api/customers/';
 | 
			
		||||
    const url = this.baseUrl + '/parties';
 | 
			
		||||
    const customers = this.getRequest(url);
 | 
			
		||||
    return customers;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getProducts() {
 | 
			
		||||
    const url = '/don_confiao/api/products/';
 | 
			
		||||
    return this.getRequest(url);
 | 
			
		||||
    const url = this.baseUrl + '/products'
 | 
			
		||||
    const products = this.getRequest(url);
 | 
			
		||||
    return products;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getPaymentMethods() {
 | 
			
		||||
@@ -94,16 +95,4 @@ class TrytonApiClient {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// export default TrytonApiClient;
 | 
			
		||||
 | 
			
		||||
// const url = 'http://localhost:8000';
 | 
			
		||||
// const key = '9a9ffc430146447d81e6698240199a4be2b0e774cb18474999d0f60e33b5b1eb1cfff9d9141346a98844879b5a9e787489c891ddc8fb45cc903b7244cab64fb1';
 | 
			
		||||
// const db = 'tryton';
 | 
			
		||||
// const applicationName = 'sale_don_confiao';
 | 
			
		||||
 | 
			
		||||
// const apiClient = new TrytonApiClient(url, key, db, applicationName);
 | 
			
		||||
 | 
			
		||||
// console.log(
 | 
			
		||||
//   apiClient.getCustomers()
 | 
			
		||||
//            .then(data => console.log(data))
 | 
			
		||||
//            .catch(error => console.error('Error:', error)))
 | 
			
		||||
export default TrytonApiClient;
 | 
			
		||||
 
 | 
			
		||||
@@ -65,11 +65,17 @@ export default defineConfig({
 | 
			
		||||
  },
 | 
			
		||||
  server: {
 | 
			
		||||
    port: 3000,
 | 
			
		||||
    cors: {
 | 
			
		||||
      origin: '*',
 | 
			
		||||
      methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
 | 
			
		||||
      allowedHeaders: ['Content-Type', 'Authorization'],
 | 
			
		||||
    },
 | 
			
		||||
    proxy: {
 | 
			
		||||
      '/sale_don_confiao': {
 | 
			
		||||
        target: "http://localhost:8000", // Cambia esto a la URL de tu API
 | 
			
		||||
        target: "http://127.0.0.1:8000/tryton/sale_don_confiao", // Cambia esto a la URL de tu API
 | 
			
		||||
        changeOrigin: true,
 | 
			
		||||
        rewrite: (path) => path.replace(/^\/sale_don_confiao/, '/tryton/sale_don_confiao'), // Opcional: reescribe la ruta
 | 
			
		||||
        ws: true
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user