addons-cm/pos_payment_method_cashdro_fix
GitHub Copilot fbd43bb459
Some checks failed
CI / lint (pull_request) Successful in 33s
CI / test (pull_request) Failing after 9m29s
CI / review (pull_request) Has been skipped
[REF] all: pass pre-commit on the whole repo
Needed for the lint job of the CI to go green. Mostly automatic hook
fixes (black, isort, prettier, pyupgrade, autoflake, whitespace). By hand:

- flake8: two unused imports, an ambiguous variable name `l`.
- pylint-odoo mandatory: manifest keys equal to their default value
  (installable, application, data, external_dependencies).
- end-of-file-fixer skips *.patch too, like trailing-whitespace: the
  upstream patches stay as git format-patch wrote them.

No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 14:34:58 +02:00
..
models [ADD] pos_payment_method_cashdro_fix: 17.0 API leftovers in the OCA base module 2026-08-11 13:31:11 +02:00
readme [DOC] pos_payment_method_cashdro_fix: the console check it describes is not possible 2026-08-31 17:43:40 +02:00
static/src/js [ADD] pos_payment_method_cashdro_fix: 17.0 API leftovers in the OCA base module 2026-08-11 13:31:11 +02:00
tests [ADD] pos_payment_method_cashdro_fix: 17.0 API leftovers in the OCA base module 2026-08-11 13:31:11 +02:00
upstream [ADD] pos_payment_method_cashdro_fix: 17.0 API leftovers in the OCA base module 2026-08-11 13:31:11 +02:00
__init__.py [ADD] pos_payment_method_cashdro_fix: 17.0 API leftovers in the OCA base module 2026-08-11 13:31:11 +02:00
__manifest__.py [REF] all: pass pre-commit on the whole repo 2026-10-04 14:34:58 +02:00
README.rst [DOC] pos_payment_method_cashdro_fix: the console check it describes is not possible 2026-08-31 17:43:40 +02:00

======================
POS CashDro 18.0 Fixes
======================

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
    :target: https://odoo-community.org/page/development-status
    :alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
    :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
    :alt: License: AGPL-3

|badge1| |badge2|

The 18.0 migration of ``pos_payment_method_cashdro``
(`OCA/pos@6a4c251d <https://github.com/OCA/pos/commit/6a4c251d>`_) left three
uses of the 17.0 API that stop the CashDro integration from working. The module
has no tests nor tours and needs a physical drawer to be exercised, so nothing
in the OCA CI catches them.

This module patches the three of them from the outside, without touching the
OCA sources:

#. ``_cashdro_url()`` reads ``order.selected_paymentline``, replaced in 18.0 by
   ``order.get_selected_paymentline()``. Reading ``.payment_method`` on the
   resulting ``undefined`` raises a ``TypeError`` on every payment, which the
   caller swallows into a generic *"An error occurred while connecting to the
   cashdro"* message.
#. The ``add_paymentline`` patch checks ``line.payment_method``, renamed to
   ``line.payment_method_id`` in 18.0. The condition is never true, so the
   payment line keeps the default due amount instead of waiting for the amount
   the customer inserts in the drawer.
#. ``pos.session._loader_params_pos_payment_method`` is the 17.0 loading API,
   replaced in 18.0 by ``_load_pos_data_fields`` on each model. The override is
   dead code, so ``cashdro_host``, ``cashdro_user`` and ``cashdro_password``
   never reach the front end.

**Table of contents**

.. contents::
   :local:

Usage
=====

There is nothing to configure: installing the module is enough.

To check the three fixes on a PoS with a CashDro terminal:

#. Open a PoS session, add a product and go to the payment screen.
#. Select the CashDro payment method. The payment line must show **0**, not the
   due amount (fix 2).
#. The drawer must start the operation and ask for the amount, instead of the
   *"An error occurred while connecting to the cashdro"* dialog (fixes 1 and 3).

These three fixes are not enough on their own: the payment flow of the base
module is broken on 18.0 for reasons of its own, and it hides every failure —
these ones included — behind that same dialog, without logging anything.
Install ``pos_payment_method_cashdro_flow_fix`` as well; its ``USAGE`` explains
how to read what actually went wrong.

The Python side is covered by the tests. The base module lives outside this
repo, so the OCA sources have to be on the addons path (mounted by
``docker-compose.yml`` from ``ODOO_SRC``, set in your local ``.env``)::

  docker-compose run --rm odoo odoo -c /etc/odoo/odoo.conf \
      --addons-path=/mnt/extra-addons,/mnt/oca/pos,/usr/lib/python3/dist-packages/odoo/addons \
      -d odoo -u pos_payment_method_cashdro_fix --test-enable --stop-after-init

Known issues / Roadmap
======================

This module is meant to be temporary. The fixes are proposed upstream in
``upstream/pos_payment_method_cashdro-18.0-fixes.patch``; once they are merged
in ``OCA/pos`` this module can be uninstalled and removed.

It is written to stay harmless in the meantime: the Python override only adds
the credential fields that are missing from the loader, and the JavaScript
patches are idempotent with respect to the fixed upstream code.

The JavaScript side can't be covered by automated tests, as it needs a CashDro
terminal answering on the network. See ``USAGE`` for the manual check.

Contributors
============

* `Criptomart <https://criptomart.net>`_:

  * Criptomart