diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index 6db429ff0..af4a7e672 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -580,6 +580,10 @@ export default {
searchButton: 'vn-order-index vn-searchbar vn-icon[icon="search"]',
createOrderButton: `${components.vnFloatButton}`,
},
+ orderDescriptor: {
+ returnToModuleIndexButton: 'vn-order-descriptor a[ui-sref="order.index"]',
+ acceptNavigationButton: 'vn-order-basic-data vn-confirm button[response=ACCEPT]'
+ },
createOrderView: {
clientAutocomplete: 'vn-autocomplete[label="Client"]',
addressAutocomplete: 'vn-autocomplete[label="Address"]',
diff --git a/e2e/paths/07-order-module/01_edit_basic_data.spec.js b/e2e/paths/07-order-module/01_edit_basic_data.spec.js
index 973697e9c..8c54bd06a 100644
--- a/e2e/paths/07-order-module/01_edit_basic_data.spec.js
+++ b/e2e/paths/07-order-module/01_edit_basic_data.spec.js
@@ -28,8 +28,8 @@ describe('Order edit basic data path', () => {
it('should now navigate to order index', async() => {
const orderId = 16;
const url = await nightmare
- .waitToClick(selectors.globalItems.returnToModuleIndexButton)
- .waitToClick(selectors.globalItems.acceptButton)
+ .waitToClick(selectors.orderDescriptor.returnToModuleIndexButton)
+ .waitToClick(selectors.orderDescriptor.acceptNavigationButton)
.wait(selectors.ordersIndex.createOrderButton)
.accessToSearchResult(orderId)
.accessToSection('order.card.basicData')
diff --git a/loopback/locale/en.json b/loopback/locale/en.json
index c4a1526aa..cfcb5bbdb 100644
--- a/loopback/locale/en.json
+++ b/loopback/locale/en.json
@@ -52,5 +52,6 @@
"Concept cannot be blank": "Concept cannot be blank",
"Ticket id cannot be blank": "Ticket id cannot be blank",
"Weekday cannot be blank": "Weekday cannot be blank",
- "This ticket can not be modified": "This ticket can not be modified"
+ "This ticket can not be modified": "This ticket can not be modified",
+ "You can't delete a confirmed order": "You can't delete a confirmed order"
}
\ No newline at end of file
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 1b91254e7..dfa637260 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -100,5 +100,6 @@
"You don't have privileges to change the zone": "No tienes permisos para cambiar la zona",
"This ticket is already on weekly tickets": "Este ticket ya está en tickets programados",
"Ticket id cannot be blank": "El id de ticket no puede quedar en blanco",
- "Weekday cannot be blank": "El día de la semana no puede quedar en blanco"
+ "Weekday cannot be blank": "El día de la semana no puede quedar en blanco",
+ "You can't delete a confirmed order": "No puedes borrar un pedido confirmado"
}
\ No newline at end of file
diff --git a/modules/order/back/models/order.js b/modules/order/back/models/order.js
index b2f9da85e..330019941 100644
--- a/modules/order/back/models/order.js
+++ b/modules/order/back/models/order.js
@@ -1,3 +1,5 @@
+const UserError = require('vn-loopback/util/user-error');
+
module.exports = Self => {
require('../methods/order/new')(Self);
require('../methods/order/getTotalVolume')(Self);
@@ -14,4 +16,11 @@ module.exports = Self => {
require('../methods/order/confirm')(Self);
require('../methods/order/filter')(Self);
require('../methods/order/getItemTypeAvailable')(Self);
+
+ Self.beforeRemote('deleteById', async function(ctx) {
+ const targetOrder = await Self.findById(ctx.args.id);
+
+ if (targetOrder.isConfirmed === 1)
+ throw new UserError(`You can't delete a confirmed order`);
+ });
};
diff --git a/modules/order/front/descriptor/index.html b/modules/order/front/descriptor/index.html
index 9ea8d01fb..dcc9b16de 100644
--- a/modules/order/front/descriptor/index.html
+++ b/modules/order/front/descriptor/index.html
@@ -6,7 +6,15 @@