pos_cashdro_allow_manual: move config from paymet.method to res.config

This commit is contained in:
Luis 2026-04-28 10:47:43 +02:00
parent d994ab600e
commit 86101218e9
8 changed files with 48 additions and 38 deletions

View file

@ -11,7 +11,7 @@
"pos_payment_method_cashdro",
],
"data": [
"views/pos_payment_method_views.xml",
"views/pos_config_views.xml",
],
"assets": {
"point_of_sale.assets": [

View file

@ -1,4 +1,4 @@
# Copyright 2026 Criptomart
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import pos_payment_method
from . import pos_session
from . import pos_config
from . import res_config_settings

View file

@ -3,11 +3,11 @@
from odoo import fields, models
class PosPaymentMethod(models.Model):
_inherit = "pos.payment.method"
class PosConfig(models.Model):
_inherit = "pos.config"
cashdro_allow_manual_amount = fields.Boolean(
string="Permitir importe manual",
string="Permitir importe manual CashDro",
help=(
"Cuando está activado, aparece un botón 'Manual' en la pantalla de "
"pago del TPV que permite confirmar el importe de la línea sin pasar "

View file

@ -1,12 +0,0 @@
# Copyright 2026 Criptomart
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models
class PosSession(models.Model):
_inherit = "pos.session"
def _loader_params_pos_payment_method(self):
result = super()._loader_params_pos_payment_method()
result["search_params"]["fields"].append("cashdro_allow_manual_amount")
return result

View file

@ -0,0 +1,12 @@
# Copyright 2026 Criptomart
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
pos_cashdro_allow_manual_amount = fields.Boolean(
related="pos_config_id.cashdro_allow_manual_amount",
readonly=False,
)

View file

@ -7,7 +7,7 @@
The button is shown when:
- the payment method is of type "cashdro"
- cashdro_allow_manual_amount is True on that payment method
- cashdro_allow_manual_amount is True on the pos.config
- the line is in "pending" or "retry" state (the two states where
the numpad is already active and the cashier can edit the amount)
@ -32,7 +32,7 @@
<xpath expr="//div[hasclass('send_payment_request')]" position="before">
<t
t-if="line.payment_method.use_payment_terminal === 'cashdro'
and line.payment_method.cashdro_allow_manual_amount"
and env.pos.config.cashdro_allow_manual_amount"
>
<div
class="button cashdro-manual-button"

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2026 Criptomart
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="res_config_settings_cashdro_allow_manual_form" model="ir.ui.view">
<field name="name">res.config.settings.cashdro.allow.manual.form</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="point_of_sale.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='payment_methods_new']" position="after">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="pos_cashdro_allow_manual_amount"/>
</div>
<div class="o_setting_right_pane">
<label for="pos_cashdro_allow_manual_amount"
string="Permitir importe manual CashDro"/>
<div class="text-muted">
Muestra un botón "Manual" en la pantalla de pago para
confirmar el importe CashDro sin pasar por la máquina.
Útil ante fallos de comunicación o situaciones de emergencia.
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

View file

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2026 Criptomart
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="pos_payment_method_cashdro_allow_manual_form" model="ir.ui.view">
<field name="name">pos.payment.method.cashdro.allow.manual.form</field>
<field name="model">pos.payment.method</field>
<field name="inherit_id" ref="pos_payment_method_cashdro.pos_payment_method_view_form"/>
<field name="arch" type="xml">
<field name="cashdro_password" position="after">
<field
name="cashdro_allow_manual_amount"
attrs="{'invisible': [('use_payment_terminal', '!=', 'cashdro')]}"
/>
</field>
</field>
</record>
</odoo>