diff --git a/services/client/common/models/address.js b/services/client/common/models/address.js index 995a7c0d6..6d74933a3 100644 --- a/services/client/common/models/address.js +++ b/services/client/common/models/address.js @@ -11,7 +11,7 @@ module.exports = function(Self) { function create(data, next) { if (data.isDefaultAddress) { - removeAllDefault({id: data.clientFk}, next); + removeAllDefault(data, next); } else { next(); } @@ -52,8 +52,8 @@ module.exports = function(Self) { } function removeAllDefault(client, next) { - if (client && client.id) - Self.updateAll({clientFk: client.id, isDefaultAddress: {neq: 0}}, {isDefaultAddress: false}, next); + if (client && client.clientFk) + Self.updateAll({clientFk: client.clientFk, isDefaultAddress: {neq: 0}}, {isDefaultAddress: false}, next); else next(); }