diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 0efa6c309..82e0bf078 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -10,8 +10,7 @@ module.exports = Self => { require('../methods/invoice-in/invoiceInEmail')(Self); require('../methods/invoice-in/getSerial')(Self); Self.rewriteDbError(function(err) { - console.log(err); - if (err.code === 'ER_ROW_IS_REFERENCED_2') + if (err.code === 'ER_ROW_IS_REFERENCED_2' && err.sqlMessage.includes('vehicleInvoiceIn')) return new UserError(`This invoice has a linked vehicle.`); return err; });