summaryrefslogtreecommitdiff
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
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>
-rw-r--r--addons/point_of_sale/static/src/js/models.js12
-rw-r--r--addons/point_of_sale/views/pos_config_view.xml2
-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
-rw-r--r--addons/pos_restaurant/__manifest__.py1
-rw-r--r--addons/pos_restaurant/models/pos_config.py2
-rw-r--r--addons/pos_restaurant/static/src/js/Screens/TipScreen.js27
-rw-r--r--addons/pos_restaurant/static/src/xml/Screens/TipScreen.xml5
-rw-r--r--addons/pos_restaurant/static/src/xml/TipReceipt.xml79
-rw-r--r--addons/pos_restaurant/views/pos_config_views.xml20
-rw-r--r--addons/pos_restaurant_adyen/__init__.py5
-rw-r--r--addons/pos_restaurant_adyen/__manifest__.py17
-rw-r--r--addons/pos_restaurant_adyen/controllers/__init__.py4
-rw-r--r--addons/pos_restaurant_adyen/controllers/main.py24
-rw-r--r--addons/pos_restaurant_adyen/models/__init__.py6
-rw-r--r--addons/pos_restaurant_adyen/models/pos_order.py16
-rw-r--r--addons/pos_restaurant_adyen/models/pos_payment.py52
-rw-r--r--addons/pos_restaurant_adyen/models/pos_payment_method.py10
-rw-r--r--addons/pos_restaurant_adyen/static/src/js/payment_adyen.js28
-rw-r--r--addons/pos_restaurant_adyen/views/point_of_sale_assets.xml8
-rw-r--r--addons/pos_restaurant_adyen/views/pos_payment_method_views.xml13
22 files changed, 332 insertions, 37 deletions
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js
index 5e1cbd108a4..15a534d6d4f 100644
--- a/addons/point_of_sale/static/src/js/models.js
+++ b/addons/point_of_sale/static/src/js/models.js
@@ -2385,6 +2385,7 @@ exports.Paymentline = Backbone.Model.extend({
this.order = options.order;
this.amount = 0;
this.selected = false;
+ this.cashier_receipt = '';
this.ticket = '';
this.payment_status = '';
this.card_type = '';
@@ -2456,6 +2457,17 @@ exports.Paymentline = Backbone.Model.extend({
},
/**
+ * Set info to be printed on the cashier receipt. value should
+ * be compatible with both the QWeb and ESC/POS receipts.
+ *
+ * @param {string} value - receipt info
+ */
+ set_cashier_receipt: function (value) {
+ this.cashier_receipt = value;
+ this.trigger('change', this);
+ },
+
+ /**
* Set additional info to be printed on the receipts. value should
* be compatible with both the QWeb and ESC/POS receipts.
*
diff --git a/addons/point_of_sale/views/pos_config_view.xml b/addons/point_of_sale/views/pos_config_view.xml
index 918b27b7b97..e69a92381fb 100644
--- a/addons/point_of_sale/views/pos_config_view.xml
+++ b/addons/point_of_sale/views/pos_config_view.xml
@@ -427,7 +427,7 @@
Accept customer tips or convert their change to a tip
</div>
<div class="content-group" attrs="{'invisible': [('iface_tipproduct', '=', False)]}">
- <div class="mt16">
+ <div class="mt16" id="tip_product">
<label string="Tip Product" for="tip_product_id" class="o_light_label"/>
<field name="tip_product_id"/>
</div>
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>
diff --git a/addons/pos_restaurant/__manifest__.py b/addons/pos_restaurant/__manifest__.py
index 6d7ac74b47b..dc1a6149235 100644
--- a/addons/pos_restaurant/__manifest__.py
+++ b/addons/pos_restaurant/__manifest__.py
@@ -49,6 +49,7 @@ This module adds several features to the Point of Sale that are specific to rest
'static/src/xml/Screens/TipScreen.xml',
'static/src/xml/ChromeWidgets/BackToFloorButton.xml',
'static/src/xml/multiprint.xml',
+ 'static/src/xml/TipReceipt.xml',
],
'demo': [
'data/pos_restaurant_demo.xml',
diff --git a/addons/pos_restaurant/models/pos_config.py b/addons/pos_restaurant/models/pos_config.py
index 04002463778..3609f476586 100644
--- a/addons/pos_restaurant/models/pos_config.py
+++ b/addons/pos_restaurant/models/pos_config.py
@@ -14,7 +14,7 @@ class PosConfig(models.Model):
printer_ids = fields.Many2many('restaurant.printer', 'pos_config_printer_rel', 'config_id', 'printer_id', string='Order Printers')
is_table_management = fields.Boolean('Floors & Tables')
is_order_printer = fields.Boolean('Order Printer')
- set_tip_after_payment = fields.Boolean('Set Tip After Payment')
+ set_tip_after_payment = fields.Boolean('Set Tip After Payment', help="Adjust the amount authorized by payment terminals to add a tip after the customers left or at the end of the day.")
module_pos_restaurant = fields.Boolean(default=True)
@api.onchange('module_pos_restaurant')
diff --git a/addons/pos_restaurant/static/src/js/Screens/TipScreen.js b/addons/pos_restaurant/static/src/js/Screens/TipScreen.js
index e17ad6f1470..84091103542 100644
--- a/addons/pos_restaurant/static/src/js/Screens/TipScreen.js
+++ b/addons/pos_restaurant/static/src/js/Screens/TipScreen.js
@@ -12,6 +12,11 @@ odoo.define('pos_restaurant.TipScreen', function (require) {
this.state = useContext(this.currentOrder.uiState.TipScreen);
this._totalAmount = this.currentOrder.get_total_with_tax();
}
+ mounted () {
+ if (this.env.pos.proxy.printer) {
+ this.printTipReceipt();
+ }
+ }
get overallAmountStr() {
const tipAmount = parse.float(this.state.inputTipAmount || '0');
const original = this.env.pos.format_currency(this.totalAmount);
@@ -92,6 +97,28 @@ odoo.define('pos_restaurant.TipScreen', function (require) {
return { name: 'ProductScreen' };
}
}
+ async printTipReceipt() {
+ const receipts = [
+ this.currentOrder.selected_paymentline.ticket,
+ this.currentOrder.selected_paymentline.cashier_receipt
+ ];
+
+ for (let i = 0; i < receipts.length; i++) {
+ const data = receipts[i];
+ var receipt = this.env.qweb.renderToString('TipReceipt', {
+ receipt: this.currentOrder.getOrderReceiptEnv().receipt,
+ data: data,
+ total: this.env.pos.format_currency(this.totalAmount),
+ });
+ const printResult = await this.env.pos.proxy.printer.print_receipt(receipt);
+ if (!printResult.successful) {
+ await this.showPopup('ErrorPopup', {
+ title: printResult.message.title,
+ body: printResult.message.body,
+ });
+ }
+ }
+ }
}
TipScreen.template = 'pos_restaurant.TipScreen';
diff --git a/addons/pos_restaurant/static/src/xml/Screens/TipScreen.xml b/addons/pos_restaurant/static/src/xml/Screens/TipScreen.xml
index 1ddab966f3c..a6d52581f70 100644
--- a/addons/pos_restaurant/static/src/xml/Screens/TipScreen.xml
+++ b/addons/pos_restaurant/static/src/xml/Screens/TipScreen.xml
@@ -10,6 +10,11 @@
<span> </span>
<span>Back</span>
</span>
+ <span class="button" t-if="env.pos.proxy.printer" t-on-click="printTipReceipt()">
+ <i class="fa fa-print"></i>
+ <span> </span>
+ <span>Reprint receipts</span>
+ </span>
<div class="top-content-center">
<h1>Add a tip</h1>
</div>
diff --git a/addons/pos_restaurant/static/src/xml/TipReceipt.xml b/addons/pos_restaurant/static/src/xml/TipReceipt.xml
new file mode 100644
index 00000000000..2a82356e822
--- /dev/null
+++ b/addons/pos_restaurant/static/src/xml/TipReceipt.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates id="template" xml:space="preserve">
+
+ <t t-name="TipReceipt" owl="1">
+ <div class="pos-receipt">
+ <t t-if="receipt.company.logo">
+ <img class="pos-receipt-logo" t-att-src="receipt.company.logo" alt="Logo"/>
+ <br/>
+ </t>
+ <t t-if="!receipt.company.logo">
+ <h2 class="pos-receipt-center-align">
+ <t t-esc="receipt.company.name" />
+ </h2>
+ <br/>
+ </t>
+ <div class="pos-receipt-contact">
+ <t t-if="receipt.company.contact_address">
+ <div><t t-esc="receipt.company.contact_address" /></div>
+ </t>
+ <t t-if="receipt.company.phone">
+ <div>Tel:<t t-esc="receipt.company.phone" /></div>
+ </t>
+ <t t-if="receipt.company.vat">
+ <div>VAT:<t t-esc="receipt.company.vat" /></div>
+ </t>
+ <t t-if="receipt.company.email">
+ <div><t t-esc="receipt.company.email" /></div>
+ </t>
+ <t t-if="receipt.company.website">
+ <div><t t-esc="receipt.company.website" /></div>
+ </t>
+ <t t-if="receipt.header_html">
+ <t t-raw="receipt.header_html" />
+ </t>
+ <t t-if="!receipt.header_html and receipt.header">
+ <div><t t-esc="receipt.header" /></div>
+ </t>
+ <t t-if="receipt.cashier">
+ <div class="cashier">
+ <div>--------------------------------</div>
+ <div>Served by <t t-esc="receipt.cashier" /></div>
+ </div>
+ </t>
+ </div>
+ <br/>
+
+ <div class="pos-payment-terminal-receipt">
+ <t t-raw="data"/>
+ </div>
+ <br/>
+
+
+ <div class="subtotal">
+ <span>Subtotal</span>
+ <div class="pos-receipt-right-align"><t t-esc="total"/></div>
+ </div>
+ <br/>
+
+ <div class="tip">
+ <span>Tip:</span>
+ <div class="pos-receipt-right-align">________________________</div>
+ </div>
+ <br/>
+
+ <div class="total">
+ <span>Total:</span>
+ <div class="pos-receipt-right-align">________________________</div>
+ </div>
+ <br/>
+ <br/>
+
+ <div class="signature">
+ <div>______________________________________________</div>
+ <div>Signature</div>
+ </div>
+ </div>
+ </t>
+
+</templates>
diff --git a/addons/pos_restaurant/views/pos_config_views.xml b/addons/pos_restaurant/views/pos_config_views.xml
index b9c32ef0322..4bf03185ba4 100644
--- a/addons/pos_restaurant/views/pos_config_views.xml
+++ b/addons/pos_restaurant/views/pos_config_views.xml
@@ -62,21 +62,11 @@
</div>
</div>
</div>
- <div id="iface_tipproduct" position="after">
- <div class="col-12 col-lg-6 o_setting_box"
- id="set_tip_after_payment"
- title="Activate to add tip form in bill and set tip on order after payment."
- attrs="{'invisible': ['|', ('module_pos_restaurant', '=', False), ('iface_tipproduct', '=', False)]}">
- <div class="o_setting_left_pane">
- <field name="set_tip_after_payment" attrs="{'readonly': [('has_active_session','=', True)]}"/>
- </div>
- <div class="o_setting_right_pane">
- <label for="set_tip_after_payment"/>
- <span class="fa fa-lg fa-cutlery" title="Ask tips on bill" role="img" aria-label="Ask tips on bill"/>
- <div class="text-muted">
- Ask tips on bill and set tip on order after payment.
- </div>
- </div>
+ <div id="tip_product" position="after">
+ <div attrs="{'invisible': ['|', ('module_pos_restaurant', '=', False), ('iface_tipproduct', '=', False)]}">
+ <field name="set_tip_after_payment" class="oe_inline"/>
+ <label class="font-weight-normal" for="set_tip_after_payment" string="Add tip after payment (North America specific)"/>
+ <span class="fa fa-lg fa-cutlery" title="For bars and restaurants" role="img" aria-label="For bars and restaurants"/>
</div>
</div>
<div id="category_reference" position="before">
diff --git a/addons/pos_restaurant_adyen/__init__.py b/addons/pos_restaurant_adyen/__init__.py
new file mode 100644
index 00000000000..7d34c7c054a
--- /dev/null
+++ b/addons/pos_restaurant_adyen/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import controllers
+from . import models
diff --git a/addons/pos_restaurant_adyen/__manifest__.py b/addons/pos_restaurant_adyen/__manifest__.py
new file mode 100644
index 00000000000..bb6a31f592f
--- /dev/null
+++ b/addons/pos_restaurant_adyen/__manifest__.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+{
+ 'name': 'POS Restaurant Adyen',
+ 'version': '1.0',
+ 'category': 'Point of Sale',
+ 'sequence': 6,
+ 'summary': 'Adds American style tipping to Adyen',
+ 'description': '',
+ 'depends': ['pos_adyen', 'pos_restaurant', 'payment_adyen'],
+ 'data': [
+ 'views/pos_payment_method_views.xml',
+ 'views/point_of_sale_assets.xml',
+ ],
+ 'auto-install': True,
+}
diff --git a/addons/pos_restaurant_adyen/controllers/__init__.py b/addons/pos_restaurant_adyen/controllers/__init__.py
new file mode 100644
index 00000000000..5d4b25db9c0
--- /dev/null
+++ b/addons/pos_restaurant_adyen/controllers/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import main
diff --git a/addons/pos_restaurant_adyen/controllers/main.py b/addons/pos_restaurant_adyen/controllers/main.py
new file mode 100644
index 00000000000..5eef4aa18a0
--- /dev/null
+++ b/addons/pos_restaurant_adyen/controllers/main.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+import logging
+
+from odoo import http
+from odoo.http import request
+from odoo.addons.payment_adyen.controllers.main import AdyenController
+
+_logger = logging.getLogger(__name__)
+
+
+class PosRestaurantAdyenController(AdyenController):
+
+ @http.route()
+ def adyen_notification(self, **post):
+ if post.get('eventCode') == 'AUTHORISATION_ADJUSTMENT':
+ ref = post.get('originalReference')
+ payment = request.env['pos.payment'].sudo().search([('transaction_id', '=', ref)], limit=1)
+ if payment and post.get('success') == 'true':
+ payment._adyen_capture_tip()
+ else:
+ _logger.warning('Authorisation adjustment for transaction_id %s failed', ref)
+ return super(PosRestaurantAdyenController, self).adyen_notification(**post)
diff --git a/addons/pos_restaurant_adyen/models/__init__.py b/addons/pos_restaurant_adyen/models/__init__.py
new file mode 100644
index 00000000000..71dd1190116
--- /dev/null
+++ b/addons/pos_restaurant_adyen/models/__init__.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import pos_order
+from . import pos_payment
+from . import pos_payment_method
diff --git a/addons/pos_restaurant_adyen/models/pos_order.py b/addons/pos_restaurant_adyen/models/pos_order.py
new file mode 100644
index 00000000000..f32a1af7418
--- /dev/null
+++ b/addons/pos_restaurant_adyen/models/pos_order.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import models
+
+
+class PosOrder(models.Model):
+ _inherit = 'pos.order'
+
+ def set_no_tip(self):
+ """Capture the Adyen payment when no tip is set."""
+ self.ensure_one()
+ payment_line = self.payment_ids.filtered(lambda line: not line.is_change)[0]
+ if payment_line.payment_method_id.use_payment_terminal == 'adyen':
+ payment_line._adyen_capture_tip()
+ return super(PosOrder, self).set_no_tip()
diff --git a/addons/pos_restaurant_adyen/models/pos_payment.py b/addons/pos_restaurant_adyen/models/pos_payment.py
new file mode 100644
index 00000000000..8a067022b3e
--- /dev/null
+++ b/addons/pos_restaurant_adyen/models/pos_payment.py
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+import json
+import requests
+
+from odoo import models
+
+TIMEOUT = 10
+
+
+class PosPayment(models.Model):
+ _inherit = 'pos.payment'
+
+ def _update_payment_line_for_tip(self, tip_amount):
+ """Capture the correct amount when a tip is set."""
+ res = super(PosPayment, self)._update_payment_line_for_tip(tip_amount)
+ if self.payment_method_id.use_payment_terminal == 'adyen':
+ self._adyen_capture_tip(True)
+ return res
+
+ def _adyen_capture_tip(self, adjust_authorisation=False):
+ endpoint = 'https://pal-live.adyen.com/pal/servlet/Payment/v52/'
+ if self.payment_method_id.adyen_test_mode:
+ endpoint = 'https://pal-test.adyen.com/pal/servlet/Payment/v52/'
+
+ headers = {
+ 'x-api-key': self.payment_method_id.adyen_api_key,
+ 'Content-Type': 'application/json'
+ }
+
+ data = {
+ 'originalReference': self.transaction_id,
+ 'modificationAmount': {
+ 'value': int(self.amount * 10**self.currency_id.decimal_places),
+ 'currency': self.currency_id.name,
+ },
+ 'merchantAccount': self.payment_method_id.adyen_merchant_account,
+ }
+
+ if adjust_authorisation:
+ endpoint += 'adjustAuthorisation'
+ data['additionalData'] = {
+ 'industryUsage':'DelayedCharge'
+ }
+ else:
+ endpoint += 'capture'
+
+ req = requests.post(endpoint, data=json.dumps(data), headers=headers, timeout=TIMEOUT)
+
+ if not req.ok:
+ raise Exception('An error occured while capturing the payment')
diff --git a/addons/pos_restaurant_adyen/models/pos_payment_method.py b/addons/pos_restaurant_adyen/models/pos_payment_method.py
new file mode 100644
index 00000000000..9f928363379
--- /dev/null
+++ b/addons/pos_restaurant_adyen/models/pos_payment_method.py
@@ -0,0 +1,10 @@
+# coding: utf-8
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models
+
+
+class PosPaymentMethod(models.Model):
+ _inherit = 'pos.payment.method'
+
+ adyen_merchant_account = fields.Char(help='The POS merchant account code used in Adyen')
diff --git a/addons/pos_restaurant_adyen/static/src/js/payment_adyen.js b/addons/pos_restaurant_adyen/static/src/js/payment_adyen.js
new file mode 100644
index 00000000000..531311b09cb
--- /dev/null
+++ b/addons/pos_restaurant_adyen/static/src/js/payment_adyen.js
@@ -0,0 +1,28 @@
+odoo.define('pos_restaurant_adyen.payment', function (require) {
+ "use strict";
+
+ var PaymentAdyen = require('pos_adyen.payment');
+ var models = require('point_of_sale.models');
+
+ PaymentAdyen.include({
+ _adyen_pay_data: function () {
+ var data = this._super();
+
+ if (this.pos.config.set_tip_after_payment) {
+ data.SaleToPOIRequest.PaymentRequest.SaleData.SaleToAcquirerData = "authorisationType=PreAuth";
+ }
+
+ return data;
+ },
+ });
+
+ var paymentline_super = models.Paymentline.prototype;
+ models.Paymentline = models.Paymentline.extend({
+ canBeTipped: function () {
+ if (this.payment_method.use_payment_terminal === 'adyen') {
+ return ['mc', 'visa', 'amex', 'discover'].includes(this.card_type);
+ }
+ return paymentline_super.canBeTipped.apply(this);
+ },
+ });
+});
diff --git a/addons/pos_restaurant_adyen/views/point_of_sale_assets.xml b/addons/pos_restaurant_adyen/views/point_of_sale_assets.xml
new file mode 100644
index 00000000000..69462495b5b
--- /dev/null
+++ b/addons/pos_restaurant_adyen/views/point_of_sale_assets.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <template id="assets" inherit_id="point_of_sale.assets">
+ <xpath expr="." position="inside">
+ <script type="text/javascript" src="/pos_restaurant_adyen/static/src/js/payment_adyen.js"></script>
+ </xpath>
+ </template>
+</odoo>
diff --git a/addons/pos_restaurant_adyen/views/pos_payment_method_views.xml b/addons/pos_restaurant_adyen/views/pos_payment_method_views.xml
new file mode 100644
index 00000000000..1ffa2e01a21
--- /dev/null
+++ b/addons/pos_restaurant_adyen/views/pos_payment_method_views.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <record id="pos_payment_method_view_form_inherit_pos_restaurant_adyen" model="ir.ui.view">
+ <field name="name">pos.payment.method.form.inherit.restaurant.adyen</field>
+ <field name="model">pos.payment.method</field>
+ <field name="inherit_id" ref="pos_adyen.pos_payment_method_view_form_inherit_pos_adyen"/>
+ <field name="arch" type="xml">
+ <xpath expr="//field[@name='adyen_terminal_identifier']" position="after">
+ <field name="adyen_merchant_account" attrs="{'invisible': [('use_payment_terminal', '!=', 'adyen')], 'required': [('use_payment_terminal', '=', 'adyen')]}"/>
+ </xpath>
+ </field>
+ </record>
+</odoo>