Tryton Api Client Endpoints Tryton
This commit is contained in:
parent
a097bf7141
commit
03d38f0b64
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mdi/font": "7.4.47",
|
"@mdi/font": "7.4.47",
|
||||||
"core-js": "^3.37.1",
|
"core-js": "^3.37.1",
|
||||||
|
"cors": "^2.8.5",
|
||||||
"roboto-fontface": "*",
|
"roboto-fontface": "*",
|
||||||
"vee-validate": "^4.14.6",
|
"vee-validate": "^4.14.6",
|
||||||
"vue": "^3.4.31",
|
"vue": "^3.4.31",
|
||||||
|
@ -276,7 +276,14 @@
|
|||||||
fetchProducts() {
|
fetchProducts() {
|
||||||
this.api.getProducts()
|
this.api.getProducts()
|
||||||
.then(data => {
|
.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 => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -13,6 +13,9 @@ import ApiImplementation from './services/api-implementation';
|
|||||||
|
|
||||||
// Composables
|
// Composables
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
|
import cors from 'cors';
|
||||||
|
|
||||||
|
// const cors = require('cors');
|
||||||
|
|
||||||
process.env.API_IMPLEMENTATION = 'tryton';
|
process.env.API_IMPLEMENTATION = 'tryton';
|
||||||
// process.env.API_IMPLEMENTATION = 'django';
|
// process.env.API_IMPLEMENTATION = 'django';
|
||||||
@ -20,6 +23,10 @@ let apiImplementation = new ApiImplementation();
|
|||||||
const api = apiImplementation.getApi();
|
const api = apiImplementation.getApi();
|
||||||
|
|
||||||
const app = createApp(App);
|
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);
|
app.provide('api', api);
|
||||||
|
|
||||||
registerPlugins(app)
|
registerPlugins(app)
|
||||||
|
@ -9,7 +9,7 @@ class ApiImplementation {
|
|||||||
if (implementation === 'django') {
|
if (implementation === 'django') {
|
||||||
apiImplementation = new DjangoApi();
|
apiImplementation = new DjangoApi();
|
||||||
} else if (implementation === 'tryton'){
|
} else if (implementation === 'tryton'){
|
||||||
const url = 'http://localhost:8000';
|
const url = 'http://192.168.0.114:18030';
|
||||||
const key = '9a9ffc430146447d81e6698240199a4be2b0e774cb18474999d0f60e33b5b1eb1cfff9d9141346a98844879b5a9e787489c891ddc8fb45cc903b7244cab64fb1';
|
const key = '9a9ffc430146447d81e6698240199a4be2b0e774cb18474999d0f60e33b5b1eb1cfff9d9141346a98844879b5a9e787489c891ddc8fb45cc903b7244cab64fb1';
|
||||||
const db = 'tryton';
|
const db = 'tryton';
|
||||||
const applicationName = 'sale_don_confiao';
|
const applicationName = 'sale_don_confiao';
|
||||||
|
@ -11,6 +11,7 @@ class Api {
|
|||||||
return this.apiImplementation.getProducts();
|
return this.apiImplementation.getProducts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getPaymentMethods() {
|
getPaymentMethods() {
|
||||||
return this.apiImplementation.getPaymentMethods();
|
return this.apiImplementation.getPaymentMethods();
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,20 @@ class TrytonApiClient {
|
|||||||
this.headers = {
|
this.headers = {
|
||||||
'Authorization': `Bearer ${key}`,
|
'Authorization': `Bearer ${key}`,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
mode: 'cors'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
getCustomers() {
|
getCustomers() {
|
||||||
// const url = '/don_confiao/api/customers/';
|
|
||||||
const url = this.baseUrl + '/parties';
|
const url = this.baseUrl + '/parties';
|
||||||
const customers = this.getRequest(url);
|
const customers = this.getRequest(url);
|
||||||
return customers;
|
return customers;
|
||||||
}
|
}
|
||||||
|
|
||||||
getProducts() {
|
getProducts() {
|
||||||
const url = '/don_confiao/api/products/';
|
const url = this.baseUrl + '/products'
|
||||||
return this.getRequest(url);
|
const products = this.getRequest(url);
|
||||||
|
return products;
|
||||||
}
|
}
|
||||||
|
|
||||||
getPaymentMethods() {
|
getPaymentMethods() {
|
||||||
@ -94,16 +95,4 @@ class TrytonApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// export default 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)))
|
|
||||||
|
@ -65,11 +65,17 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
|
cors: {
|
||||||
|
origin: '*',
|
||||||
|
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
||||||
|
allowedHeaders: ['Content-Type', 'Authorization'],
|
||||||
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
'/sale_don_confiao': {
|
'/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,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/sale_don_confiao/, '/tryton/sale_don_confiao'), // Opcional: reescribe la ruta
|
rewrite: (path) => path.replace(/^\/sale_don_confiao/, '/tryton/sale_don_confiao'), // Opcional: reescribe la ruta
|
||||||
|
ws: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user