diff --git a/back/models/image.js b/back/models/image.js
index f646543fcc..d736e924f8 100644
--- a/back/models/image.js
+++ b/back/models/image.js
@@ -145,13 +145,6 @@ module.exports = Self => {
fileName,
myOptions
);
- if (item.isPhotoRequested) {
- await item.updateAttribute(
- 'isPhotoRequested',
- false,
- myOptions
- );
- }
}
if (fs.existsSync(srcFilePath))
diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js
index b8baa97ea7..03a6fb7212 100644
--- a/modules/item/back/models/item.js
+++ b/modules/item/back/models/item.js
@@ -21,6 +21,15 @@ module.exports = Self => {
Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});
Self.observe('before save', async function(ctx) {
+ let currentInstance = ctx.currentInstance;
+ let oldInstance;
+ let newInstance;
+ ctx.hookState.oldInstance === undefined ? oldInstance = false : oldInstance = ctx.hookState.oldInstance;
+ ctx.hookState.newInstance === undefined ? newInstance = false : newInstance = ctx.hookState.newInstance;
+ if (oldInstance.image && newInstance.image) {
+ let query = `UPDATE vn.item SET doPhoto = 0 WHERE id = ${currentInstance.id}`;
+ await Self.rawSql(query);
+ }
await Self.availableId(ctx);
});
diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html
index 801a82ee0b..8f958bd3b8 100644
--- a/modules/item/front/summary/index.html
+++ b/modules/item/front/summary/index.html
@@ -65,6 +65,26 @@
{{$ctrl.summary.item.itemType.worker.user.name}}
+
+
+
+
+
+
+
+