diff options
| author | tbe-odoo <tbe@odoo.com> | 2017-08-29 16:50:48 +0200 |
|---|---|---|
| committer | tbe-odoo <tbe@odoo.com> | 2017-08-29 17:16:42 +0200 |
| commit | be650c5979d6d427ad79bc23f0edc1d10290f881 (patch) | |
| tree | 8baecb371dbf39501d5cbd9825c09a7aa214449d | |
| parent | 2a2a1c7b2843fc6fe0c82583120ce100fa4068fa (diff) | |
[IMP] Fixing the code to fit the reviews
16 files changed, 35 insertions, 54 deletions
diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index e9c8c86c85b..d225dd8c801 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -404,34 +404,22 @@ class PaymentIcon(models.Model): image = fields.Binary( "Image", attachment=True, help="This field holds the image used for this payment icon, limited to 1024x1024px") - image_medium = fields.Binary( - "Medium-sized image", attachment=True, - help="Medium-sized image of this payment icon. It is automatically " - "resized as a 128x128px image, with aspect ratio preserved. " - "Use this field in form views or some kanban views.") - image_small = fields.Binary( - "Small-sized image", attachment=True, - help="Small-sized image of this payment icon. It is automatically " - "resized as a 64x64px image, with aspect ratio preserved. " - "Use this field anywhere a small image is required.") image_payment_form = fields.Binary( "Image displayed on the payment form", attachment=True) @api.model def create(self, vals): - image_resize_images(vals) - if 'image' in vals: vals['image_payment_form'] = image_resize_image(vals['image'], size=(45,30)) - + vals['image'] = image_resize_image(vals['image'], size=(64,64)) return super(PaymentIcon, self).create(vals) @api.multi def write(self, vals): - image_resize_images(vals) if 'image' in vals: vals['image_payment_form'] = image_resize_image(vals['image'], size=(45,30)) + vals['image'] = image_resize_image(vals['image'], size=(64,64)) return super(PaymentIcon, self).write(vals) class PaymentTransaction(models.Model): diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js index a7197ad1306..491cafcf00c 100644 --- a/addons/payment/static/src/js/payment_form.js +++ b/addons/payment/static/src/js/payment_form.js @@ -18,7 +18,6 @@ odoo.define('payment.payment_form', function (require){ }, payEvent: function(ev) { - // ev.stopPropagation(); ev.preventDefault(); var form = this.el; var checked_radio = this.$('input[type="radio"]:checked'); @@ -113,26 +112,23 @@ odoo.define('payment.payment_form', function (require){ // if there's a prepare tx url set if($tx_url.length == 1) { + // if the user wants to save his credit card info + form_save_token = $('input[name="o_payment_form_save_token"]').checked === true; // then we call the route to prepare the transaction ajax.jsonRpc($tx_url[0].value, 'call', { 'acquirer_id': parseInt(acquirer_id), 'save_token': form_save_token }).then(function(result){ if(result) { - // TBE: I really don't like how it is designed, but I can't do better with how e-commerce works/ - var ignored_inputs = ['data_set', 'o_payment_form_save_token']; - var html_form = '<form method="post" action="' - + ds.dataset.actionUrl + '" class="hidden">' - + result + '</form>'; - - // we append the form to the body - var form = $(html_form).appendTo("body"); - // we remove the "unused" inputs - for(var i = 0; i < ignored_inputs.length; i++) { - form.find('input[name="' + ignored_inputs[i] + '"]').remove(); - } - // we submit the form - form.submit(); + // if the server sent us the html form, we create a form element + var newForm = document.createElement('form'); + newForm.setAttribute("method", "post"); // set it to post + newForm.setAttribute("action", ds.dataset.actionUrl); // set the action url + newForm.hidden = true; // hide it + newForm.innerHTML = result; // put the html sent by the server inside the form + document.getElementsByTagName('body')[0].appendChild(newForm); // append the form to the body + $(newForm).find('input[data-remove-me]').remove(); // remove all the input that should be removed + newForm.submit(); // and finally submit the form } else { self.error(_t('Server Error'), @@ -146,7 +142,6 @@ odoo.define('payment.payment_form', function (require){ else { // we append the form to the body and send it. - // $(html_form).appendTo("body").submit(); this.error(_t("Cannot set-up the payment"), _t("<p>We're unable to process your payment.</p>")); } } @@ -366,11 +361,11 @@ odoo.define('payment.payment_form', function (require){ - $(document).ready(function (){ - if (!$('.o_payment_form').length) { - return $.Deferred().reject("DOM doesn't contain '.o_payment_form'"); - } - var form = new PaymentForm(); - form.attachTo($('.o_payment_form')); - }); + require('web.dom_ready'); // only start this when dom is ready + if (!$('.o_payment_form').length) { + return $.Deferred().reject("DOM doesn't contain '.o_payment_form'"); + } + var form = new PaymentForm(); + form.attachTo($('.o_payment_form')); + }); diff --git a/addons/payment/views/payment_templates.xml b/addons/payment/views/payment_templates.xml index 182a80bf8d7..81e73aa464b 100644 --- a/addons/payment/views/payment_templates.xml +++ b/addons/payment/views/payment_templates.xml @@ -74,7 +74,7 @@ </div> </div> </t> - <t tif="mode == 'payment'" t-foreach="form_acquirers" t-as="acq"> + <t t-if="mode == 'payment'" t-foreach="form_acquirers" t-as="acq"> <div class="panel-body"> <label> <input type="radio" t-att-data-acquirer-id="acq.id" @@ -102,7 +102,7 @@ </ul> </div> <div t-attf-id="o_payment_form_acq_{{acq.id}}" t-attf-class="hidden {{'panel-footer' if acq.save_token == 'ask' else ''}}"> - <label t-if="acq.save_token == 'ask'"><input type="checkbox" name="o_payment_form_save_token"/> Save my payment data</label> + <label t-if="acq.save_token == 'ask'"><input type="checkbox" name="o_payment_form_save_token" data-remove-me=""/> Save my payment data</label> <t t-raw="acq.form"/> </div> </t> diff --git a/addons/payment/views/payment_views.xml b/addons/payment/views/payment_views.xml index 365a57a7a01..29ab44d606b 100644 --- a/addons/payment/views/payment_views.xml +++ b/addons/payment/views/payment_views.xml @@ -416,6 +416,7 @@ <menuitem action="action_payment_icon" id="payment_icon_menu" - parent="root_payment_menu"/> + parent="root_payment_menu" + groups="base.group_no_one"/> </data> </odoo> diff --git a/addons/payment_adyen/views/payment_adyen_templates.xml b/addons/payment_adyen/views/payment_adyen_templates.xml index 9f0a32deb19..4f4d21811a2 100644 --- a/addons/payment_adyen/views/payment_adyen_templates.xml +++ b/addons/payment_adyen/views/payment_adyen_templates.xml @@ -2,7 +2,7 @@ <odoo> <data noupdate="1"> <template id="adyen_form"> - <input type="hidden" name="data_set" t-att-data-action-url="tx_url"/> + <input type="hidden" name="data_set" t-att-data-action-url="tx_url" data-remove-me=""/> <input type="hidden" name="merchantReference" t-att-value="merchantReference"/> <input type="hidden" name="paymentAmount" t-att-value="paymentAmount"/> <input type="hidden" name="currencyCode" t-att-value="currencyCode"/> diff --git a/addons/payment_authorize/views/payment_authorize_templates.xml b/addons/payment_authorize/views/payment_authorize_templates.xml index efef504dfec..1e56c309317 100644 --- a/addons/payment_authorize/views/payment_authorize_templates.xml +++ b/addons/payment_authorize/views/payment_authorize_templates.xml @@ -3,7 +3,7 @@ <data noupdate="1"> <template id="authorize_form"> <div> - <input type="hidden" name="data_set" t-att-data-action-url="tx_url"/> + <input type="hidden" name="data_set" t-att-data-action-url="tx_url" data-remove-me=""/> <input type='hidden' name='x_login' t-att-value='x_login'/> <input type='hidden' name='x_fp_hash' t-att-value='x_fp_hash'/> <input type='hidden' name='x_amount' t-att-value='x_amount'/> diff --git a/addons/payment_buckaroo/views/payment_buckaroo_templates.xml b/addons/payment_buckaroo/views/payment_buckaroo_templates.xml index da47b258ce3..e65700ee6e7 100644 --- a/addons/payment_buckaroo/views/payment_buckaroo_templates.xml +++ b/addons/payment_buckaroo/views/payment_buckaroo_templates.xml @@ -2,7 +2,7 @@ <odoo> <data noupdate="1"> <template id="buckaroo_form"> - <input type="hidden" name="data_set" t-att-data-action-url="tx_url"/> + <input type="hidden" name="data_set" t-att-data-action-url="tx_url" data-remove-me=""/> <input type="hidden" name="Brq_websitekey" t-att-value="Brq_websitekey"/> <input type="hidden" name="Brq_amount" t-att-value="Brq_amount"/> <input type="hidden" name="Brq_currency" t-att-value="Brq_currency"/> diff --git a/addons/payment_ogone/views/payment_ogone_templates.xml b/addons/payment_ogone/views/payment_ogone_templates.xml index 37e1daaa211..aec5274981d 100644 --- a/addons/payment_ogone/views/payment_ogone_templates.xml +++ b/addons/payment_ogone/views/payment_ogone_templates.xml @@ -2,7 +2,7 @@ <odoo> <data> <template id="ogone_form"> - <input type="hidden" name="data_set" t-att-data-action-url="tx_url"/> + <input type="hidden" name="data_set" t-att-data-action-url="tx_url" data-remove-me=""/> <!-- seller --> <input type='hidden' name='PSPID' t-att-value='PSPID'/> <input type='hidden' name='ORDERID' t-att-value='ORDERID'/> diff --git a/addons/payment_paypal/views/payment_paypal_templates.xml b/addons/payment_paypal/views/payment_paypal_templates.xml index e0ce37a584b..5678a460aac 100644 --- a/addons/payment_paypal/views/payment_paypal_templates.xml +++ b/addons/payment_paypal/views/payment_paypal_templates.xml @@ -3,7 +3,7 @@ <data noupdate="1"> <template id="paypal_form"> <div> - <input type="hidden" name="data_set" t-att-data-action-url="tx_url"/> + <input type="hidden" name="data_set" t-att-data-action-url="tx_url" data-remove-me=""/> <input type="hidden" name="cmd" t-att-value="cmd"/> <input type="hidden" name="business" t-att-value="business"/> <input type="hidden" name="item_name" t-att-value="item_name"/> diff --git a/addons/payment_payumoney/views/payment_payumoney_templates.xml b/addons/payment_payumoney/views/payment_payumoney_templates.xml index 377caaa21ed..70ec052fd0c 100644 --- a/addons/payment_payumoney/views/payment_payumoney_templates.xml +++ b/addons/payment_payumoney/views/payment_payumoney_templates.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <odoo> <template id="payumoney_form"> - <input type="hidden" name="data_set" t-att-data-action-url="tx_url"/> + <input type="hidden" name="data_set" t-att-data-action-url="tx_url" data-remove-me=""/> <input type="hidden" name="key" t-att-value='key' /> <input type="hidden" name="txnid" t-att-value='txnid' /> <input type="hidden" name="amount" t-att-value='amount' /> diff --git a/addons/payment_sips/views/payment_sips_templates.xml b/addons/payment_sips/views/payment_sips_templates.xml index 8143588158d..477bb964140 100644 --- a/addons/payment_sips/views/payment_sips_templates.xml +++ b/addons/payment_sips/views/payment_sips_templates.xml @@ -2,7 +2,7 @@ <odoo> <data noupdate="0"> <template id="sips_form"> - <input type="hidden" name="data_set" t-att-data-action-url="tx_url"/> + <input type="hidden" name="data_set" t-att-data-action-url="tx_url" data-remove-me=""/> <input type="hidden" name="Data" t-att-value="Data"/> <input type="hidden" name="InterfaceVersion" t-att-value="InterfaceVersion"/> <input type="hidden" name="Seal" t-att-value="Seal"/> diff --git a/addons/payment_stripe/static/src/js/stripe.js b/addons/payment_stripe/static/src/js/stripe.js index a4b50949860..c0b9ef3d5a8 100644 --- a/addons/payment_stripe/static/src/js/stripe.js +++ b/addons/payment_stripe/static/src/js/stripe.js @@ -112,7 +112,6 @@ odoo.define('payment_stripe.stripe', function(require) { } } - // TBE TODO: Pass 'so_id: so_id' and 'access_token: access_token' on the URL ajax.jsonRpc(url, 'call', { acquirer_id: acquirer_id }, {'async': false}).then(function (data) { diff --git a/addons/payment_stripe/views/payment_stripe_templates.xml b/addons/payment_stripe/views/payment_stripe_templates.xml index 3ebaef50729..64a7de11977 100644 --- a/addons/payment_stripe/views/payment_stripe_templates.xml +++ b/addons/payment_stripe/views/payment_stripe_templates.xml @@ -2,7 +2,7 @@ <odoo> <data> <template id="stripe_form"> - <input type="hidden" name="data_set" t-att-data-action-url="tx_url"/> + <input type="hidden" name="data_set" t-att-data-action-url="tx_url" data-remove-me=""/> <script src="https://checkout.stripe.com/checkout.js"></script> <input type='hidden' name='stripe_image' t-att-value="acquirer.stripe_image_url"/> <input type='hidden' name='merchant' t-att-value='acquirer.company_id.name'/> @@ -22,7 +22,6 @@ <input type='hidden' name='email' t-att-value='email'/> <input id="acquirer_stripe" type='hidden' name="acquirer" t-att-value="acquirer.id"/> <input type='hidden' name="stripe_key" t-att-value="acquirer.stripe_publishable_key"/> - <!-- TBE TODO: Seems like the JS does something with the submit button, I need to check this out --> <script type="text/javascript" src="/payment_stripe/static/src/js/stripe.js"></script> </template> diff --git a/addons/payment_transfer/views/payment_transfer_templates.xml b/addons/payment_transfer/views/payment_transfer_templates.xml index f21f05f1d0a..abd39cf681b 100644 --- a/addons/payment_transfer/views/payment_transfer_templates.xml +++ b/addons/payment_transfer/views/payment_transfer_templates.xml @@ -2,7 +2,7 @@ <odoo> <data noupdate="1"> <template id="transfer_form"> - <input type="hidden" name="data_set" t-att-data-action-url="tx_url"/> + <input type="hidden" name="data_set" t-att-data-action-url="tx_url" data-remove-me=""/> <t t-if="return_url"> <input type='hidden' name='return_url' t-att-value='return_url'/> </t> diff --git a/addons/website_payment/models/website.py b/addons/website_payment/models/website.py index b6b67e60708..ff2159f384d 100644 --- a/addons/website_payment/models/website.py +++ b/addons/website_payment/models/website.py @@ -11,5 +11,4 @@ class Website(models.Model): def payment_icons(self): """ This function returns the list of payment icons which are supported by payment acquirers that are published """ - icons = self.env['payment.icon'].sudo().search([('acquirer_ids', '!=', False)]) - return [icon for icon in icons if any(acq.website_published for acq in icon.acquirer_ids)] + return self.env['payment.icon'].sudo().search([('acquirer_ids.website_published', '=', True)]) diff --git a/addons/website_payment/views/website_payment_templates.xml b/addons/website_payment/views/website_payment_templates.xml index c7083c140e9..f81ab5e6e50 100644 --- a/addons/website_payment/views/website_payment_templates.xml +++ b/addons/website_payment/views/website_payment_templates.xml @@ -6,7 +6,7 @@ <ul class="payment_method_list list-inline"> <t t-foreach="request.website.payment_icons()" t-as="icon"> <li> - <span t-field="icon.image_small" t-options='{"widget": "image", "alt-field": "name"}' /> + <span t-field="icon.image" t-options='{"widget": "image", "alt-field": "name"}' /> </li> </t> </ul> |
