diff --git a/addons/point_of_sale/models/pos_payment_method.py b/addons/point_of_sale/models/pos_payment_method.py index 87852afa5dc..f890b3a7f2c 100644 --- a/addons/point_of_sale/models/pos_payment_method.py +++ b/addons/point_of_sale/models/pos_payment_method.py @@ -19,6 +19,9 @@ class PosPaymentMethod(models.Model): _description = "Point of Sale Payment Methods" _order = "id asc" + def _get_payment_terminal_selection(self): + return [] + name = fields.Char(string="Payment Method", required=True) receivable_account_id = fields.Many2one('account.account', string='Intermediary Account', @@ -40,19 +43,25 @@ class PosPaymentMethod(models.Model): open_session_ids = fields.Many2many('pos.session', string='Pos Sessions', compute='_compute_open_session_ids', help='Open PoS sessions that are using this payment method.') config_ids = fields.Many2many('pos.config', string='Point of Sale Configurations') company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.company) - use_payment_terminal = fields.Selection([], 'Use a Payment Terminal', help='Record payments with a terminal on this journal.') + use_payment_terminal = fields.Selection(selection=lambda self: self._get_payment_terminal_selection(), string='Use a Payment Terminal', help='Record payments with a terminal on this journal.') hide_use_payment_terminal = fields.Boolean(compute='_compute_hide_use_payment_terminal', help='Technical field which is used to ' 'hide use_payment_terminal when no payment interfaces are installed.') + @api.depends('is_cash_count') def _compute_hide_use_payment_terminal(self): - no_terminals = not bool(self._fields['use_payment_terminal'].selection) + no_terminals = not bool(self._fields['use_payment_terminal'].selection(self)) for payment_method in self: - payment_method.hide_use_payment_terminal = no_terminals + payment_method.hide_use_payment_terminal = no_terminals or payment_method.is_cash_count + + @api.onchange('use_payment_terminal') + def _onchange_use_payment_terminal(self): + """Used by inheriting model to unset the value of the field related to the unselected payment terminal.""" + pass @api.depends('config_ids') def _compute_open_session_ids(self): for payment_method in self: - self.open_session_ids = self.env['pos.session'].search([('config_id', 'in', payment_method.config_ids.ids), ('state', '!=', 'closed')]) + payment_method.open_session_ids = self.env['pos.session'].search([('config_id', 'in', payment_method.config_ids.ids), ('state', '!=', 'closed')]) @api.onchange('is_cash_count') def _onchange_is_cash_count(self): diff --git a/addons/point_of_sale/models/res_config_settings.py b/addons/point_of_sale/models/res_config_settings.py index 2cfe0fc0a36..f1fcf4db6d4 100644 --- a/addons/point_of_sale/models/res_config_settings.py +++ b/addons/point_of_sale/models/res_config_settings.py @@ -7,4 +7,5 @@ class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' sale_tax_id = fields.Many2one('account.tax', string="Default Sale Tax", related='company_id.account_sale_tax_id', readonly=False) - module_pos_mercury = fields.Boolean(string="Integrated Card Payments", help="The transactions are processed by Vantiv. Set your Vantiv credentials on the related payment journal.") + module_pos_mercury = fields.Boolean(string="Vantiv Payment Terminal", help="The transactions are processed by Vantiv. Set your Vantiv credentials on the related payment method.") + module_pos_adyen = fields.Boolean(string="Adyen Payment Terminal", help="The transactions are processed by Adyen. Set your Adyen credentials on the related payment method.") diff --git a/addons/point_of_sale/views/pos_payment_method_views.xml b/addons/point_of_sale/views/pos_payment_method_views.xml index 7093c7c3da5..8e7ad9eefee 100644 --- a/addons/point_of_sale/views/pos_payment_method_views.xml +++ b/addons/point_of_sale/views/pos_payment_method_views.xml @@ -17,10 +17,10 @@ - + @@ -33,10 +33,12 @@ pos.payment.method + + diff --git a/addons/point_of_sale/views/res_config_settings_views.xml b/addons/point_of_sale/views/res_config_settings_views.xml index b5e2a4debdd..8963973427f 100644 --- a/addons/point_of_sale/views/res_config_settings_views.xml +++ b/addons/point_of_sale/views/res_config_settings_views.xml @@ -66,24 +66,34 @@ -

Payments

-
-
+

Payment Terminals

+
+
-
+
+
+ +
+
+
+
diff --git a/addons/pos_adyen/models/pos_payment_method.py b/addons/pos_adyen/models/pos_payment_method.py index c3489797173..6576485cebd 100644 --- a/addons/pos_adyen/models/pos_payment_method.py +++ b/addons/pos_adyen/models/pos_payment_method.py @@ -15,7 +15,9 @@ _logger = logging.getLogger(__name__) class PosPaymentMethod(models.Model): _inherit = 'pos.payment.method' - use_payment_terminal = fields.Selection(selection_add=[('adyen', 'Adyen')]) + def _get_payment_terminal_selection(self): + return super(PosPaymentMethod, self)._get_payment_terminal_selection() + [('adyen', 'Adyen')] + adyen_api_key = fields.Char(string="Adyen API key", help='Used when connecting to Adyen: https://docs.adyen.com/user-management/how-to-get-the-api-key/#description', copy=False) adyen_terminal_identifier = fields.Char(help='[Terminal model]-[Serial number], for example: P400Plus-123456789', copy=False) adyen_test_mode = fields.Boolean(help='Run transactions in the test environment.') @@ -116,3 +118,10 @@ class PosPaymentMethod(models.Model): return True return req.json() + + @api.onchange('use_payment_terminal') + def _onchange_use_payment_terminal(self): + super(PosPaymentMethod, self)._onchange_use_payment_terminal() + if self.use_payment_terminal != 'adyen': + self.adyen_api_key = False + self.adyen_terminal_identifier = False diff --git a/addons/pos_adyen/views/pos_payment_method_views.xml b/addons/pos_adyen/views/pos_payment_method_views.xml index 50aa6b39cb0..7c1d28597f0 100644 --- a/addons/pos_adyen/views/pos_payment_method_views.xml +++ b/addons/pos_adyen/views/pos_payment_method_views.xml @@ -5,14 +5,12 @@ pos.payment.method - - - - - - - + + + + + diff --git a/addons/pos_mercury/__manifest__.py b/addons/pos_mercury/__manifest__.py index 50778cac342..773f5e933b3 100644 --- a/addons/pos_mercury/__manifest__.py +++ b/addons/pos_mercury/__manifest__.py @@ -2,7 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. { - 'name': 'Mercury Payment Services', + 'name': 'Vantiv Payment Services', 'version': '1.0', 'category': 'Point of Sale', 'sequence': 6, @@ -12,8 +12,8 @@ Allow credit card POS payments ============================== This module allows customers to pay for their orders with credit -cards. The transactions are processed by Mercury (developed by Wells -Fargo Bank). A Mercury merchant account is necessary. It allows the +cards. The transactions are processed by Vantiv (developed by Wells +Fargo Bank). A Vantiv merchant account is necessary. It allows the following: * Fast payment by just swiping a credit card while on the payment screen diff --git a/addons/pos_mercury/data/pos_mercury_demo.xml b/addons/pos_mercury/data/pos_mercury_demo.xml index b242868f8df..e93579af19f 100644 --- a/addons/pos_mercury/data/pos_mercury_demo.xml +++ b/addons/pos_mercury/data/pos_mercury_demo.xml @@ -1,10 +1,10 @@ - + - Mercury Demo + Vantiv Demo 755847002 xyz diff --git a/addons/pos_mercury/models/pos_mercury.py b/addons/pos_mercury/models/pos_mercury.py index 35e0e63bf72..cfac776876c 100644 --- a/addons/pos_mercury/models/pos_mercury.py +++ b/addons/pos_mercury/models/pos_mercury.py @@ -19,9 +19,9 @@ class BarcodeRule(models.Model): class PosMercuryConfiguration(models.Model): _name = 'pos_mercury.configuration' - _description = 'Point of Sale Mercury Configuration' + _description = 'Point of Sale Vantiv Configuration' - name = fields.Char(required=True, help='Name of this Mercury configuration') + name = fields.Char(required=True, help='Name of this Vantiv configuration') merchant_id = fields.Char(string='Merchant ID', required=True, help='ID of the merchant to authenticate him on the payment provider server') merchant_pwd = fields.Char(string='Merchant Password', required=True, help='Password of the merchant to authenticate him on the payment provider server') @@ -33,9 +33,9 @@ class PoSPayment(models.Model): mercury_prefixed_card_number = fields.Char(string='Card Number Prefix', compute='_compute_prefixed_card_number', help='The card number used for the payment.') mercury_card_brand = fields.Char(string='Card Brand', help='The brand of the payment card (e.g. Visa, AMEX, ...)') mercury_card_owner_name = fields.Char(string='Card Owner Name', help='The name of the card owner') - mercury_ref_no = fields.Char(string='Mercury reference number', help='Payment reference number from Mercury Pay') - mercury_record_no = fields.Char(string='Mercury record number', help='Payment record number from Mercury Pay') - mercury_invoice_no = fields.Char(string='Mercury invoice number', help='Invoice number from Mercury Pay') + mercury_ref_no = fields.Char(string='Vantiv reference number', help='Payment reference number from Vantiv Pay') + mercury_record_no = fields.Char(string='Vantiv record number', help='Payment record number from Vantiv Pay') + mercury_invoice_no = fields.Char(string='Vantiv invoice number', help='Invoice number from Vantiv Pay') def _compute_prefixed_card_number(self): for line in self: @@ -48,8 +48,16 @@ class PoSPayment(models.Model): class PoSPaymentMethod(models.Model): _inherit = 'pos.payment.method' - pos_mercury_config_id = fields.Many2one('pos_mercury.configuration', string='Mercury Credentials', help='The configuration of Mercury used for this journal') + pos_mercury_config_id = fields.Many2one('pos_mercury.configuration', string='Vantiv Credentials', help='The configuration of Vantiv used for this journal') + def _get_payment_terminal_selection(self): + return super(PoSPaymentMethod, self)._get_payment_terminal_selection() + [('mercury', 'Vantiv')] + + @api.onchange('use_payment_terminal') + def _onchange_use_payment_terminal(self): + super(PoSPaymentMethod, self)._onchange_use_payment_terminal() + if self.use_payment_terminal != 'mercury': + self.pos_mercury_config_id = False class PosOrder(models.Model): _inherit = "pos.order" diff --git a/addons/pos_mercury/models/pos_mercury_transaction.py b/addons/pos_mercury/models/pos_mercury_transaction.py index 3b4473ee01c..48ff5e18560 100644 --- a/addons/pos_mercury/models/pos_mercury_transaction.py +++ b/addons/pos_mercury/models/pos_mercury_transaction.py @@ -14,7 +14,7 @@ from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT, misc class MercuryTransaction(models.Model): _name = 'pos_mercury.mercury_transaction' - _description = 'Point of Sale Mercury Transaction' + _description = 'Point of Sale Vantiv Transaction' def _get_pos_session(self): pos_session = self.env['pos.session'].search([('state', '=', 'opened'), ('user_id', '=', self.env.uid)], limit=1) @@ -31,7 +31,7 @@ class MercuryTransaction(models.Model): if payment_method and payment_method.pos_mercury_config_id: return payment_method.pos_mercury_config_id else: - raise UserError(_("No Mercury configuration associated with the payment method.")) + raise UserError(_("No Vantiv configuration associated with the payment method.")) def _setup_request(self, data): # todo: in master make the client include the pos.session id and use that @@ -112,7 +112,7 @@ class MercuryTransaction(models.Model): response = self._do_request('pos_mercury.mercury_return', data) return response - # One time (the ones we use) Mercury tokens are required to be + # One time (the ones we use) Vantiv tokens are required to be # deleted after 6 months @api.model def cleanup_old_tokens(self): diff --git a/addons/pos_mercury/static/src/js/pos_mercury.js b/addons/pos_mercury/static/src/js/pos_mercury.js index 3e561e724cb..eb473cdc593 100644 --- a/addons/pos_mercury/static/src/js/pos_mercury.js +++ b/addons/pos_mercury/static/src/js/pos_mercury.js @@ -255,10 +255,10 @@ ScreenWidget.include({ // On Payment screen, allow online payments PaymentScreenWidget.include({ // How long we wait for the odoo server to deliver the response of - // a Mercury transaction + // a Vantiv transaction server_timeout_in_ms: 95000, - // How many Mercury transactions we send without receiving a + // How many Vantiv transactions we send without receiving a // response server_retries: 3, @@ -313,7 +313,7 @@ PaymentScreenWidget.include({ message = "Error " + response.error + ": " + lookUpCodeTransaction["TimeoutError"][response.error] + "
" + response.message; } else { if (can_connect_to_server) { - message = _t("No response from Mercury (Mercury down?)"); + message = _t("No response from Vantiv (Vantiv down?)"); } else { message = _t("No response from server (connected to network?)"); } @@ -393,7 +393,7 @@ PaymentScreenWidget.include({ timeout: self.server_timeout_in_ms, }) .then(function (data) { - // if not receiving a response from Mercury, we should retry + // if not receiving a response from Vantiv, we should retry if (data === "timeout") { self.retry_mercury_transaction(def, null, retry_nr, true, self.credit_code_transaction, [parsed_result, def, retry_nr + 1]); return; @@ -401,7 +401,7 @@ PaymentScreenWidget.include({ if (data === "not setup") { def.resolve({ - message: _t("Please setup your Mercury merchant account.") + message: _t("Please setup your Vantiv merchant account.") }); return; } diff --git a/addons/pos_mercury/views/pos_mercury_transaction_templates.xml b/addons/pos_mercury/views/pos_mercury_transaction_templates.xml index 3573672acb4..41e268c9248 100644 --- a/addons/pos_mercury/views/pos_mercury_transaction_templates.xml +++ b/addons/pos_mercury/views/pos_mercury_transaction_templates.xml @@ -24,7 +24,7 @@ MagneSafe - + @@ -38,7 +38,7 @@ - + diff --git a/addons/pos_mercury/views/pos_mercury_views.xml b/addons/pos_mercury/views/pos_mercury_views.xml index fb1c5495382..2ba576e35f9 100644 --- a/addons/pos_mercury/views/pos_mercury_views.xml +++ b/addons/pos_mercury/views/pos_mercury_views.xml @@ -2,7 +2,7 @@ - Mercury Configurations + Vantiv Configurations pos_mercury.configuration
@@ -13,8 +13,8 @@

- Mercury Configurations define what Mercury account will be used when - processing credit card transactions in the Point Of Sale. Setting up a Mercury + Vantiv Configurations define what Vantiv account will be used when + processing credit card transactions in the Point Of Sale. Setting up a Vantiv configuration will enable you to allow payments with various credit cards (eg. Visa, MasterCard, Discovery, American Express, ...). After setting up this configuration you should associate it with a Point Of Sale payment method. @@ -22,7 +22,7 @@ We currently support the MagTek Dynamag card reader device. It can be connected directly to the Point Of Sale device or it can be connected to the IoTBox.

- Using the Mercury integration in the Point Of Sale is easy: just press the + Using the Vantiv integration in the Point Of Sale is easy: just press the associated payment method. After that the amount can be adjusted (eg. for cashback) just like on any other payment line. Whenever the payment line is set up, a card can be swiped through the card reader device. @@ -31,7 +31,7 @@ (without having pressed anything else) will charge the full amount of the order to the card.

- If you don't already have a Mercury account, contact Mercury at +1 (800) 846-4472 + If you don't already have a Vantiv account, contact Vantiv at +1 (800) 846-4472 to create one.

@@ -45,7 +45,7 @@ - Mercury Configurations + Vantiv Configurations pos_mercury.configuration @@ -56,7 +56,7 @@ - Mercury Configurations + Vantiv Configurations ir.actions.act_window pos_mercury.configuration tree,kanban,form @@ -72,8 +72,8 @@ pos.payment.method - - + +