[ADD] pos_payment_method_cashdro_fix: 17.0 API leftovers in the OCA base module
The 18.0 migration of `pos_payment_method_cashdro` (OCA/pos@6a4c251d) kept three uses of APIs removed in 18.0. The module has no tests nor tours and needs a physical drawer to be exercised, so the OCA CI can't catch them: * `_cashdro_url()` reads `order.selected_paymentline`, so `.payment_method` on the resulting `undefined` throws a TypeError on every payment, swallowed into a generic "An error occurred while connecting to the cashdro" dialog. * The `add_paymentline()` patch checks `line.payment_method`, renamed to `payment_method_id`, so the line keeps the default due amount instead of waiting for the amount the customer inserts. * `_loader_params_pos_payment_method()` is the 17.0 loading API, replaced by `_load_pos_data_fields()`. Dead code, so the CashDro credentials never reach the front end. Patched from the outside, as OCA sources are not to be modified. Written to stay harmless once fixed upstream: the Python override only adds the missing fields and the JS patches are idempotent against the fixed code. `upstream/pos_payment_method_cashdro-18.0-fixes.patch` holds the same fixes as a ready to send `git format-patch`, verified with `git apply --check`. This module is temporary and should be removed once that lands in OCA/pos. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
fb5b3d1f7e
commit
4615da6dae
14 changed files with 426 additions and 0 deletions
1
pos_payment_method_cashdro_fix/tests/__init__.py
Normal file
1
pos_payment_method_cashdro_fix/tests/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from . import test_load_pos_data_fields
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
# Copyright 2026 - Today Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests import tagged
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
from ..models.pos_payment_method import CASHDRO_FIELDS
|
||||
|
||||
|
||||
@tagged("post_install", "-at_install")
|
||||
class TestLoadPosDataFields(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.payment_method = cls.env["pos.payment.method"]
|
||||
# Nothing dereferences it, but we pass a real config when there's one
|
||||
cls.config_id = cls.env["pos.config"].search([], limit=1).id
|
||||
|
||||
def test_cashdro_credentials_are_loaded(self):
|
||||
"""The front end can't build the CashDro url without them."""
|
||||
fields = self.payment_method._load_pos_data_fields(self.config_id)
|
||||
for field in CASHDRO_FIELDS:
|
||||
self.assertIn(field, fields)
|
||||
|
||||
def test_no_duplicated_fields(self):
|
||||
"""Once the base module is fixed upstream we must not add them twice."""
|
||||
fields = self.payment_method._load_pos_data_fields(self.config_id)
|
||||
self.assertEqual(sorted(fields), sorted(set(fields)))
|
||||
|
||||
def test_fields_exist_on_the_model(self):
|
||||
"""Guard against a rename of the credentials in the base module."""
|
||||
for field in CASHDRO_FIELDS:
|
||||
self.assertIn(field, self.payment_method._fields)
|
||||
Loading…
Add table
Add a link
Reference in a new issue