summaryrefslogtreecommitdiff
path: root/addons/pos_adyen
diff options
context:
space:
mode:
authorAntoine Prieels <anp@odoo.com>2020-08-19 13:49:02 +0000
committerAntoine Prieels <anp@odoo.com>2020-08-21 12:41:10 +0000
commit379e4f0a72bc95798068735c0c7a8662d3a48b3b (patch)
tree62af60fad32801bdcf2b3a96cd6a5b80669eb232 /addons/pos_adyen
parent25d63db3f850b989b9d37e016ef1ba492452058b (diff)
[ADD] pos_restaurant_adyen: Tipping on the receipt
The amount is authorized when the customer scans its card, then the customer writes the tip on the receipt and the total amount is captured when the waiter manually inputs the tip, either right after or at the end of the day. closes odoo/odoo#56148 Taskid: 2321771 Related: odoo/upgrade#1661 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Diffstat (limited to 'addons/pos_adyen')
-rw-r--r--addons/pos_adyen/models/pos_config.py11
-rw-r--r--addons/pos_adyen/static/src/js/payment_adyen.js9
-rw-r--r--addons/pos_adyen/views/pos_config_views.xml18
3 files changed, 18 insertions, 20 deletions
diff --git a/addons/pos_adyen/models/pos_config.py b/addons/pos_adyen/models/pos_config.py
index 7578f844ed7..9e3882792e4 100644
--- a/addons/pos_adyen/models/pos_config.py
+++ b/addons/pos_adyen/models/pos_config.py
@@ -13,14 +13,13 @@ class PosConfig(models.Model):
adyen_ask_customer_for_tip = fields.Boolean('Ask Customers For Tip', help='Prompt the customer to tip.')
+ @api.onchange('iface_tipproduct')
+ def _onchange_iface_tipproduct_adyen(self):
+ if not self.iface_tipproduct:
+ self.adyen_ask_customer_for_tip = False
+
@api.constrains('adyen_ask_customer_for_tip', 'iface_tipproduct', 'tip_product_id')
def _check_adyen_ask_customer_for_tip(self):
for config in self:
if config.adyen_ask_customer_for_tip and (not config.tip_product_id or not config.iface_tipproduct):
raise ValidationError(_("Please configure a tip product for POS %s to support tipping with Adyen.", config.name))
-
- @api.onchange('adyen_ask_customer_for_tip')
- def _onchange_adyen_ask_customer_for_tip(self):
- for config in self:
- if config.adyen_ask_customer_for_tip:
- config.iface_tipproduct = True
diff --git a/addons/pos_adyen/static/src/js/payment_adyen.js b/addons/pos_adyen/static/src/js/payment_adyen.js
index 3cbc8be2c5c..f8eb63fb515 100644
--- a/addons/pos_adyen/static/src/js/payment_adyen.js
+++ b/addons/pos_adyen/static/src/js/payment_adyen.js
@@ -207,6 +207,15 @@ var PaymentAdyen = PaymentInterface.extend({
var config = self.pos.config;
var payment_response = notification.SaleToPOIResponse.PaymentResponse;
var payment_result = payment_response.PaymentResult;
+
+ var cashier_receipt = payment_response.PaymentReceipt.find(function (receipt) {
+ return receipt.DocumentQualifier == 'CashierReceipt';
+ });
+
+ if (cashier_receipt) {
+ line.set_cashier_receipt(self._convert_receipt_info(cashier_receipt.OutputContent.OutputText));
+ }
+
var customer_receipt = payment_response.PaymentReceipt.find(function (receipt) {
return receipt.DocumentQualifier == 'CustomerReceipt';
});
diff --git a/addons/pos_adyen/views/pos_config_views.xml b/addons/pos_adyen/views/pos_config_views.xml
index 72d6b395bda..51756d22030 100644
--- a/addons/pos_adyen/views/pos_config_views.xml
+++ b/addons/pos_adyen/views/pos_config_views.xml
@@ -5,20 +5,10 @@
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="arch" type="xml">
- <xpath expr="//div[@id='payment_methods_new']/.." position="after">
- <h2>Adyen</h2>
- <div class="row mt16 o_settings_container" id="adyen">
- <div class="col-12 col-lg-6 o_setting_box">
- <div class="o_setting_left_pane">
- <field name="adyen_ask_customer_for_tip"/>
- </div>
- <div class="o_setting_right_pane">
- <label for="adyen_ask_customer_for_tip"/>
- <div class="text-muted">
- Ask customers to tip before paying.
- </div>
- </div>
- </div>
+ <xpath expr="//div[@id='tip_product']" position="after">
+ <div attrs="{'invisible': [('iface_tipproduct', '=', False)]}">
+ <field name="adyen_ask_customer_for_tip" class="oe_inline"/>
+ <label class="font-weight-normal" for="adyen_ask_customer_for_tip" string="Add tip through payment terminal (Adyen)"/>
</div>
</xpath>
</field>