Skip to content

Commit

Permalink
[FIX] do not hardcode test regarding if payment method is a terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Oct 15, 2024
1 parent f01d5bb commit 3acfeb1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
11 changes: 1 addition & 10 deletions pos_odoo_driver_payment/models/pos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models
from odoo import fields, models


class PosConfig(models.Model):
Expand All @@ -11,13 +11,4 @@ class PosConfig(models.Model):
iface_payment_terminal = fields.Boolean(
"Payment Terminal",
help="A payment terminal is available on the Proxy",
compute="_compute_iface_payment_terminal",
store=True,
)

@api.depends("payment_method_ids.is_payment_terminal")
def _compute_iface_payment_terminal(self):
for config in self:
config.iface_payment_terminal = any(
config.mapped("payment_method_ids.is_payment_terminal")
)
5 changes: 5 additions & 0 deletions pos_odoo_driver_payment/models/pos_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ def _get_pos_ui_pos_config(self, params):
config["is_posbox"] and config["iface_payment_terminal"]
)
return config

def _loader_params_pos_payment_method(self):
res = super()._loader_params_pos_payment_method()
res["search_params"]["fields"] += ["is_payment_terminal"]
return res
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
t-inherit="point_of_sale.PaymentScreenPaymentLines"
t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('payment-name')]" position="after">
<!-- TODO: FIXME, hardcoded value -->
<t t-if="line.payment_method.name == 'CB'">
<t t-if="line.payment_method.is_payment_terminal">
<div class="send-payment-terminal-button"
t-on-click="() => this.trigger('send-payment-terminal', { cid: line.cid })"
aria-label="Send to Payment Terminal"
Expand Down

0 comments on commit 3acfeb1

Please sign in to comment.