|
|
@ -17,20 +17,31 @@ odoo.define('pos_loyalty.loyalty_program', function (require){ |
|
|
|
|
|
|
|
models.load_fields('res.partner', 'loyalty_points'); |
|
|
|
|
|
|
|
models.load_models([ |
|
|
|
{ |
|
|
|
models.load_models([{ |
|
|
|
model: 'loyalty.program', |
|
|
|
condition: function(self){ return !!self.config.loyalty_id[0]; }, |
|
|
|
condition: function(self) { |
|
|
|
return !!self.config.loyalty_id[0]; |
|
|
|
}, |
|
|
|
fields: ['name', 'pp_currency', 'pp_product', 'pp_order', 'rounding'], |
|
|
|
domain: function(self){ return [['id','=',self.config.loyalty_id[0]]]; }, |
|
|
|
domain: function(self) { |
|
|
|
return [ |
|
|
|
['id', '=', self.config.loyalty_id[0]] |
|
|
|
]; |
|
|
|
}, |
|
|
|
loaded: function(self, loyalties) { |
|
|
|
self.loyalty = loyalties[0]; |
|
|
|
}, |
|
|
|
}, { |
|
|
|
model: 'loyalty.rule', |
|
|
|
condition: function(self){ return !!self.loyalty; }, |
|
|
|
condition: function(self) { |
|
|
|
return !!self.loyalty; |
|
|
|
}, |
|
|
|
fields: ['name', 'type', 'product_id', 'category_id', 'cumulative', 'pp_product', 'pp_currency'], |
|
|
|
domain: function(self){ return [['loyalty_program_id','=',self.loyalty.id]]; }, |
|
|
|
domain: function(self) { |
|
|
|
return [ |
|
|
|
['loyalty_program_id', '=', self.loyalty.id] |
|
|
|
]; |
|
|
|
}, |
|
|
|
loaded: function(self, rules) { |
|
|
|
|
|
|
|
self.loyalty.rules = rules; |
|
|
@ -56,9 +67,15 @@ odoo.define('pos_loyalty.loyalty_program', function (require){ |
|
|
|
}, |
|
|
|
}, { |
|
|
|
model: 'loyalty.reward', |
|
|
|
condition: function(self){ return !!self.loyalty; }, |
|
|
|
condition: function(self) { |
|
|
|
return !!self.loyalty; |
|
|
|
}, |
|
|
|
fields: ['name', 'type', 'minimum_points', 'gift_product_id', 'point_cost', 'discount_product_id', 'discount', 'discount_max', 'point_product_id'], |
|
|
|
domain: function(self){ return [['loyalty_program_id','=',self.loyalty.id]]; }, |
|
|
|
domain: function(self) { |
|
|
|
return [ |
|
|
|
['loyalty_program_id', '=', self.loyalty.id] |
|
|
|
]; |
|
|
|
}, |
|
|
|
loaded: function(self, rewards) { |
|
|
|
self.loyalty.rewards = rewards; |
|
|
|
self.loyalty.rewards_by_id = {}; |
|
|
@ -66,8 +83,9 @@ odoo.define('pos_loyalty.loyalty_program', function (require){ |
|
|
|
self.loyalty.rewards_by_id[rewards[i].id] = rewards[i]; |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
],{'after': 'product.product'}); |
|
|
|
}, ], { |
|
|
|
'after': 'product.product' |
|
|
|
}); |
|
|
|
|
|
|
|
var _orderline_super = models.Orderline.prototype; |
|
|
|
models.Orderline = models.Orderline.extend({ |
|
|
@ -275,7 +293,9 @@ odoo.define('pos_loyalty.loyalty_program', function (require){ |
|
|
|
price: 0, |
|
|
|
quantity: 1, |
|
|
|
merge: false, |
|
|
|
extras: { reward_id: reward.id }, |
|
|
|
extras: { |
|
|
|
reward_id: reward.id |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
} else if (reward.type === 'discount') { |
|
|
@ -299,7 +319,9 @@ odoo.define('pos_loyalty.loyalty_program', function (require){ |
|
|
|
price: -discount, |
|
|
|
quantity: 1, |
|
|
|
merge: false, |
|
|
|
extras: { reward_id: reward.id }, |
|
|
|
extras: { |
|
|
|
reward_id: reward.id |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
} else if (reward.type === 'resale') { |
|
|
@ -326,7 +348,9 @@ odoo.define('pos_loyalty.loyalty_program', function (require){ |
|
|
|
this.add_product(product, { |
|
|
|
quantity: -spendable, |
|
|
|
merge: false, |
|
|
|
extras: { reward_id: reward.id }, |
|
|
|
extras: { |
|
|
|
reward_id: reward.id |
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|