I'm trying to implement the loyal program in odoo 10.
this functionality works in odoo 8 as same trying to develop in 10 Tried with this below code
I have 3 model classs . im getting the all data from model.load_modelsthough im not getting the button in pos screen under addto cart screen
**loyal.xml** <templates id="template" xml:space="preserve"> <t t-name="LoyaltyPoints"> <div class='loyalty-points'> <div class='loyalty-points-title'>Points</div> <t t-if='points_won'> <div class="loyalty-points-won"> <span class='value'>+<t t-esc='widget.format_pr(points_won,1)'/></span> </div> </t> <t t-if='points_spent'> <div class="loyalty-points-spent"> <span class='value'>-<t t-esc='widget.format_pr(points_spent,1)'/></span> </div> </t> <div class='loyalty-points-total'> <span class='value'><t t-esc='widget.format_pr(points_total,1)' /></span> </div> </div> </t>
<t t-name="LoyaltyButton"> <div class='control-button'> <i class='fa fa-tag' /> Rewards </div> </t> </templates>
**loyal.js**
odoo.define('pos_loyalty_program.pos_loyalty_program', function (require) { "use strict";
var models = require('point_of_sale.models');
var screens = require('point_of_sale.screens');
var core = require('web.core');
var utils = require('web.utils');
var gui = require('point_of_sale.gui');
var _t = core._t;
var round_pr = utils.round_precision;
var QWeb = core.qweb;
models.load_fields('res.partner','loyalty_points');
models.load_models([ { model: 'loyal.program', condition: function(self){ return !!self.config; }, fields: ['name'], domain: function(self){ return [['id','=',self.config.related_loyal_program_id[0]]]; }, loaded: function(self,loyalties){ self.loyalty = loyalties[0]; }, { model: 'loyal.rule',} { model: 'loyal.award',} }, ],{'after': 'product.product'});
var LoyaltyButton = screens.ActionButtonWidget.extend({ template: 'LoyaltyButton', button_click: function(){ var order = this.pos.get_order();
var client = order.get_client(); if (!client) { this.gui.show_screen('clientlist');
return;
}
var rewards = order.get_available_rewards();
if (rewards.length === 0) { this.gui.show_popup('alert',{ 'title': 'No Rewards Available', 'body': 'There are no rewards available for this customer as part of the loyalty program', });
return;
} else if (rewards.length === 1 && this.pos.loyalty.rewards.length === 1) { order.apply_reward(rewards[0]);
return;
} else { var list = [];
for (var i = 0; i < rewards.length; i++) { list.push({ label: rewards[i].name, item: rewards[i], });
} this.gui.show_popup('selection',{ 'title': 'Please select a reward', 'list': list, 'confirm': function(reward){ order.apply_reward(reward);
}, });
} }, });
screens.define_action_button({ 'name': 'loyalty', 'widget': LoyaltyButton, 'condition': function(){ return this.pos.loyalty && this.pos.loyalty.rewards.length;
}, });
Could anyone please help me to resolve this .
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Apskaita
- Atsarga
- PoS
- Project
- MRP
This question has been flagged
3102
Rodiniai
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
RegistracijaRelated Posts | Replies | Rodiniai | Veikla | |
---|---|---|---|---|
|
1
gruod. 17
|
3896 | ||
|
0
lapkr. 17
|
3017 | ||
|
1
liep. 17
|
5376 | ||
|
0
kov. 17
|
2904 | ||
|
3
gruod. 22
|
5710 |