[IMP] crm, iap, sms, snailmail_account, partner_autocomplete: replace credit checker widget
Remove the check of the balance for the IAP accounts in the settings. Add a link to buy credits to all of the services in the settings. Task #1909302
This commit is contained in:
committed by
Pierre Masereel
parent
c299225020
commit
405705de2b
@@ -58,7 +58,7 @@
|
||||
<field name="module_crm_reveal"/>
|
||||
</div>
|
||||
|
||||
<div class="o_setting_right_pane crm_reveal_settings">
|
||||
<div class="o_setting_right_pane" id="crm_reveal_settings">
|
||||
<label string="Visits to Leads" for="module_crm_reveal"/>
|
||||
<div class="text-muted">
|
||||
Convert visitors of your website into leads and perform data enrichment based on their IP address.
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="res_config_settings_view_form" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.inherit.crm_reveal</field>
|
||||
<field name="name">res.config.settings.view.form.inherit.crm.reveal</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="priority" eval="5"/>
|
||||
<field name="inherit_id" ref="crm.res_config_settings_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[hasclass('crm_reveal_settings')]" position="inside">
|
||||
<div class="content-group">
|
||||
<widget name="iap_credit_checker" service_name="reveal"/>
|
||||
</div>
|
||||
</xpath>
|
||||
<div id="crm_reveal_settings" position="inside">
|
||||
<widget name="iap_buy_more_credits" service_name="reveal"/>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
odoo.define('iap.buy_more_credits', function (require) {
|
||||
'use strict';
|
||||
|
||||
var widgetRegistry = require('web.widget_registry');
|
||||
var Widget = require('web.Widget');
|
||||
|
||||
var core = require('web.core');
|
||||
var rpc = require('web.rpc');
|
||||
|
||||
var QWeb = core.qweb;
|
||||
|
||||
var IAPBuyMoreCreditsWidget = Widget.extend({
|
||||
className: 'o_field_iap_buy_more_credits',
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* Prepares the basic rendering of edit mode by setting the root to be a
|
||||
* div.dropdown.open.
|
||||
* @see FieldChar.init
|
||||
*/
|
||||
init: function (parent, data, options) {
|
||||
this._super.apply(this, arguments);
|
||||
this.service_name = options.attrs.service_name;
|
||||
},
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
start: function () {
|
||||
this.$widget = $(QWeb.render('iap.buy_more_credits'));
|
||||
this.$buyLink = this.$widget.find('.buy_credits');
|
||||
this.$widget.appendTo(this.$el);
|
||||
this.$buyLink.click(this._getLink.bind(this));
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
_getLink: function () {
|
||||
var self = this;
|
||||
return rpc.query({
|
||||
model: 'iap.account',
|
||||
method: 'get_credits_url',
|
||||
args: [this.service_name],
|
||||
}, {
|
||||
shadow: true,
|
||||
}).then(function (url) {
|
||||
return self.do_action({
|
||||
type: 'ir.actions.act_url',
|
||||
url: url,
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
widgetRegistry.add('iap_buy_more_credits', IAPBuyMoreCreditsWidget);
|
||||
|
||||
return IAPBuyMoreCreditsWidget;
|
||||
});
|
||||
@@ -1,110 +0,0 @@
|
||||
odoo.define('iap.credit.checker', function (require) {
|
||||
'use strict';
|
||||
|
||||
var widgetRegistry = require('web.widget_registry');
|
||||
var Widget = require('web.Widget');
|
||||
|
||||
var core = require('web.core');
|
||||
var rpc = require('web.rpc');
|
||||
|
||||
var QWeb = core.qweb;
|
||||
|
||||
var IAPCreditChecker = Widget.extend({
|
||||
className: 'o_field_iap_credit_checker',
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* Prepares the basic rendering of edit mode by setting the root to be a
|
||||
* div.dropdown.open.
|
||||
* @see FieldChar.init
|
||||
*/
|
||||
init: function (parent, data, options) {
|
||||
this._super.apply(this, arguments);
|
||||
this.service_name = options.attrs.service_name;
|
||||
},
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
start: function () {
|
||||
this.$widget = $(QWeb.render('iap.credit_checker'));
|
||||
this.$loading = this.$widget.find('.loading');
|
||||
this.$sufficient = this.$widget.find('.sufficient');
|
||||
this.$insufficient = this.$widget.find('.insufficient');
|
||||
this.$error = this.$widget.find('.error');
|
||||
this.$buyLink = this.$widget.find('.buy_credits');
|
||||
|
||||
this.$widget.appendTo(this.$el);
|
||||
|
||||
this.$buyLink.click(this._getLink.bind(this));
|
||||
|
||||
this._getCredits();
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
_getCredits: function () {
|
||||
var self = this;
|
||||
this._showLoading();
|
||||
|
||||
return rpc.query({
|
||||
model: 'iap.account',
|
||||
method: 'get_credits',
|
||||
args: [this.service_name],
|
||||
}, {
|
||||
shadow: true,
|
||||
}).then(function (credit) {
|
||||
if (credit > 0) self._showSufficient(credit);
|
||||
else if (credit < 0) self._showError();
|
||||
else self._showInsufficient();
|
||||
});
|
||||
},
|
||||
|
||||
_getLink: function () {
|
||||
console.log(true)
|
||||
var self = this;
|
||||
return rpc.query({
|
||||
model: 'iap.account',
|
||||
method: 'get_credits_url',
|
||||
args: [this.service_name],
|
||||
}, {
|
||||
shadow: true,
|
||||
}).then(function (url) {
|
||||
return self.do_action({
|
||||
type: 'ir.actions.act_url',
|
||||
url: url,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
_showLoading: function () {
|
||||
this.$loading.show();
|
||||
this.$sufficient.hide();
|
||||
this.$insufficient.hide();
|
||||
this.$error.hide();
|
||||
},
|
||||
_showSufficient: function (credits) {
|
||||
this.$loading.hide();
|
||||
this.$sufficient.show().find('.remaining_credits').text(credits);
|
||||
this.$insufficient.hide();
|
||||
this.$error.hide();
|
||||
},
|
||||
_showInsufficient: function () {
|
||||
this.$loading.hide();
|
||||
this.$sufficient.hide();
|
||||
this.$insufficient.show();
|
||||
this.$error.hide();
|
||||
},
|
||||
_showError: function () {
|
||||
this.$loading.hide();
|
||||
this.$sufficient.hide();
|
||||
this.$insufficient.hide();
|
||||
this.$error.show();
|
||||
},
|
||||
});
|
||||
|
||||
widgetRegistry.add('iap_credit_checker', IAPCreditChecker);
|
||||
|
||||
return IAPCreditChecker;
|
||||
});
|
||||
@@ -34,23 +34,9 @@
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<div t-name="iap.credit_checker" class="mt-2 row">
|
||||
<div class="col-sm">
|
||||
<div class="loading text-muted">
|
||||
<i class="fa fa-spinner fa-spin"/> Checking remaining credit ...
|
||||
</div>
|
||||
<div class="insufficient">
|
||||
<i class="fa fa-exclamation-triangle text-warning"/> Insufficient credit
|
||||
</div>
|
||||
<div class="sufficient">
|
||||
<i class="fa fa-check-circle text-success"/> Remaining : <b class="remaining_credits"/> credits
|
||||
</div>
|
||||
<div class="error">
|
||||
<i class="fa fa-question-circle text-muted"/> Temporarily unavailable
|
||||
</div>
|
||||
</div>
|
||||
<div t-name="iap.buy_more_credits" class="mt-2 row">
|
||||
<div class="col-sm text-right">
|
||||
<button class="btn btn-link buy_credits"><i class="fa fa-arrow-right"/> Buy more credits</button>
|
||||
<button class="btn btn-link buy_credits"><i class="fa fa-arrow-right"/> Buy credits</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<script type="text/javascript" src="/iap/static/src/js/iap_credit.js"></script>
|
||||
<script type="text/javascript" src="/iap/static/src/js/crash_manager.js"></script>
|
||||
<script type="text/javascript" src="/iap/static/src/js/dashboard.js"></script>
|
||||
<script type="text/javascript" src="/iap/static/src/js/iap_credit_checker_widget.js"></script>
|
||||
<script type="text/javascript" src="/iap/static/src/js/iap_buy_more_credits.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
|
||||
@@ -6,22 +6,8 @@
|
||||
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<div id="partner_autocomplete_settings" position="inside">
|
||||
<widget name="iap_credit_checker" service_name="partner_autocomplete"/>
|
||||
<widget name="iap_buy_more_credits" service_name="partner_autocomplete"/>
|
||||
</div>
|
||||
|
||||
<xpath expr="//div[hasclass('app_settings_block')][@data-key='general_settings']/div[1]" position="before">
|
||||
<div class="alert alert-info alert-dismissible fade show pt-2 pb-2" role="alert" attrs="{'invisible': [('partner_autocomplete_insufficient_credit', '=', False)]}" data-showfor="crm,general_settings">
|
||||
<field name="partner_autocomplete_insufficient_credit" invisible="1"/>
|
||||
<i class="fa fa-exclamation-triangle text-warning"></i> &nbsp; You don't have credits to auto-complete companies' data anymore.
|
||||
<button name="redirect_to_buy_autocomplete_credit" type="object" class="btn-link">
|
||||
<i class="fa fa-arrow-right"/>
|
||||
Buy more credits
|
||||
</button>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span>&times;</span>
|
||||
</button>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -13,6 +13,7 @@ The service is provided by the In App Purchase Odoo platform.
|
||||
'depends': ['base', 'iap', 'mail'],
|
||||
'data': [
|
||||
'wizard/send_sms_views.xml',
|
||||
'views/res_config_settings_views.xml',
|
||||
'views/res_partner_views.xml',
|
||||
'views/templates.xml',
|
||||
],
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="res_config_settings_view_form" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.inherit.sms</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<div id="sms_settings" position="inside">
|
||||
<widget name="iap_buy_more_credits" service_name="sms"/>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -7,26 +7,15 @@
|
||||
<field name="inherit_id" ref="account.res_config_settings_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@id='send_default']" position="inside">
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<div class="o_setting_left_pane">
|
||||
<field name="invoice_is_snailmail"/>
|
||||
</div>
|
||||
<div class="o_setting_right_pane">
|
||||
<label for="invoice_is_snailmail"/>
|
||||
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific."/>
|
||||
<div class="content-group" attrs="{'invisible': [('invoice_is_snailmail' ,'=', False)]}">
|
||||
<div class="mt16">
|
||||
<field name="snailmail_color" class="oe_inline"/>
|
||||
<label string="Print in Color" class="o_light_label" for="snailmail_color"/>
|
||||
</div>
|
||||
<div>
|
||||
<field name="snailmail_duplex" class="oe_inline"/>
|
||||
<label string="Print on Both Sides" class="o_light_label" for="snailmail_duplex"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<field name="invoice_is_snailmail" class="col-lg-1 ml16"/>
|
||||
<label for="invoice_is_snailmail"/>
|
||||
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific."/>
|
||||
</div>
|
||||
</xpath>
|
||||
<div id="snailmail_settings" position="inside">
|
||||
<widget name="iap_buy_more_credits" service_name="snailmail"/>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user