Implementacion API Tryton Client
This commit is contained in:
parent
c257c253e1
commit
efb33ef011
8
package-lock.json
generated
8
package-lock.json
generated
@ -31,7 +31,7 @@
|
|||||||
"unplugin-fonts": "^1.1.1",
|
"unplugin-fonts": "^1.1.1",
|
||||||
"unplugin-vue-components": "^0.27.2",
|
"unplugin-vue-components": "^0.27.2",
|
||||||
"unplugin-vue-router": "^0.10.0",
|
"unplugin-vue-router": "^0.10.0",
|
||||||
"vite": "^5.3.3",
|
"vite": "^5.4.14",
|
||||||
"vite-plugin-vue-layouts": "^0.11.0",
|
"vite-plugin-vue-layouts": "^0.11.0",
|
||||||
"vite-plugin-vuetify": "^2.0.3",
|
"vite-plugin-vuetify": "^2.0.3",
|
||||||
"vue-router": "^4.4.0"
|
"vue-router": "^4.4.0"
|
||||||
@ -5229,9 +5229,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vite": {
|
"node_modules/vite": {
|
||||||
"version": "5.4.4",
|
"version": "5.4.14",
|
||||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.4.tgz",
|
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.14.tgz",
|
||||||
"integrity": "sha512-RHFCkULitycHVTtelJ6jQLd+KSAAzOgEYorV32R2q++M6COBjKJR6BxqClwp5sf0XaBDjVMuJ9wnNfyAJwjMkA==",
|
"integrity": "sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
"unplugin-fonts": "^1.1.1",
|
"unplugin-fonts": "^1.1.1",
|
||||||
"unplugin-vue-components": "^0.27.2",
|
"unplugin-vue-components": "^0.27.2",
|
||||||
"unplugin-vue-router": "^0.10.0",
|
"unplugin-vue-router": "^0.10.0",
|
||||||
"vite": "^5.3.3",
|
"vite": "^5.4.14",
|
||||||
"vite-plugin-vue-layouts": "^0.11.0",
|
"vite-plugin-vue-layouts": "^0.11.0",
|
||||||
"vite-plugin-vuetify": "^2.0.3",
|
"vite-plugin-vuetify": "^2.0.3",
|
||||||
"vue-router": "^4.4.0"
|
"vue-router": "^4.4.0"
|
||||||
|
@ -256,10 +256,10 @@
|
|||||||
},
|
},
|
||||||
onProductChange(index) {
|
onProductChange(index) {
|
||||||
const selectedProductId = this.purchase.saleline_set[index].product;
|
const selectedProductId = this.purchase.saleline_set[index].product;
|
||||||
const selectedProduct = this.products.find(p => p.id == selectedProductId);
|
const selectedProduct = this.products.find(p => p.id == selectedProductId);
|
||||||
this.purchase.saleline_set[index].unit_price = selectedProduct.price;
|
this.purchase.saleline_set[index].unit_price = selectedProduct.price;
|
||||||
this.purchase.saleline_set[index].measuring_unit = selectedProduct.measuring_unit;
|
this.purchase.saleline_set[index].measuring_unit = selectedProduct.measuring_unit;
|
||||||
},
|
},
|
||||||
fetchClients() {
|
fetchClients() {
|
||||||
this.api.getCustomers()
|
this.api.getCustomers()
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@ -276,7 +276,14 @@
|
|||||||
fetchProducts() {
|
fetchProducts() {
|
||||||
this.api.getProducts()
|
this.api.getProducts()
|
||||||
.then(data => {
|
.then(data => {
|
||||||
this.products = data;
|
const transformed_products = data.map(item => ({
|
||||||
|
id: item.id,
|
||||||
|
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);
|
||||||
@ -285,7 +292,7 @@
|
|||||||
fetchPaymentMethods() {
|
fetchPaymentMethods() {
|
||||||
this.api.getPaymentMethods()
|
this.api.getPaymentMethods()
|
||||||
.then(data => {
|
.then(data => {
|
||||||
this.payment_methods = data;
|
this.payment_methods = data[0]?.payment_methods;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -309,8 +316,21 @@
|
|||||||
},
|
},
|
||||||
async submit() {
|
async submit() {
|
||||||
this.$refs.purchase.validate();
|
this.$refs.purchase.validate();
|
||||||
|
const tryton_sale = {
|
||||||
|
party: this.purchase.customer,
|
||||||
|
company: "1",
|
||||||
|
currency: "31",
|
||||||
|
pickup_location: "on_site",
|
||||||
|
lines: [[
|
||||||
|
"create", this.purchase.saleline_set.map(item => ({
|
||||||
|
product: item.product,
|
||||||
|
quantity: item.quantity,
|
||||||
|
unitprice: item.unit_price
|
||||||
|
})
|
||||||
|
)]]};
|
||||||
|
|
||||||
if (this.valid) {
|
if (this.valid) {
|
||||||
this.api.createPurchase(this.purchase)
|
this.api.createPurchase(tryton_sale)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Compra enviada:', data);
|
console.log('Compra enviada:', data);
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
|
@ -14,7 +14,7 @@ import ApiImplementation from './services/api-implementation';
|
|||||||
// Composables
|
// Composables
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
|
|
||||||
process.env.API_IMPLEMENTATION = 'django';
|
process.env.API_IMPLEMENTATION = 'tryton';
|
||||||
let apiImplementation = new ApiImplementation();
|
let apiImplementation = new ApiImplementation();
|
||||||
const api = apiImplementation.getApi();
|
const api = apiImplementation.getApi();
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import DjangoApi from './django-api';
|
import DjangoApi from './django-api';
|
||||||
|
import TrytonApiClient from './tryton-api';
|
||||||
import Api from './api';
|
import Api from './api';
|
||||||
|
|
||||||
class ApiImplementation {
|
class ApiImplementation {
|
||||||
@ -7,6 +8,13 @@ class ApiImplementation {
|
|||||||
let apiImplementation;
|
let apiImplementation;
|
||||||
if (implementation === 'django') {
|
if (implementation === 'django') {
|
||||||
apiImplementation = new DjangoApi();
|
apiImplementation = new DjangoApi();
|
||||||
|
} else if (implementation === 'tryton'){
|
||||||
|
const url = 'http://192.168.85.45:18030';
|
||||||
|
const key = '9a9ffc430146447d81e6698240199a4be2b0e774cb18474999d0f60e33b5b1eb1cfff9d9141346a98844879b5a9e787489c891ddc8fb45cc903b7244cab64fb1';
|
||||||
|
const db = 'tryton';
|
||||||
|
const applicationName = 'sale_don_confiao';
|
||||||
|
apiImplementation = new TrytonApiClient(
|
||||||
|
url, key, db, applicationName);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("API implementation don't configured");
|
throw new Error("API implementation don't configured");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user