Skip to content

Commit

Permalink
[MIG] pos_payment_method_cashdro: migration to 16.0
Browse files Browse the repository at this point in the history
TT45180
  • Loading branch information
chienandalu committed Mar 4, 2024
1 parent d2e8012 commit b77ae19
Show file tree
Hide file tree
Showing 15 changed files with 288 additions and 305 deletions.
19 changes: 6 additions & 13 deletions pos_payment_method_cashdro/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ PoS Payment Method CashDro
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
:target: https://github.com/OCA/pos/tree/14.0/pos_payment_method_cashdro
:target: https://github.com/OCA/pos/tree/16.0/pos_payment_method_cashdro
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-14-0/pos-14-0-pos_payment_method_cashdro
:target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_payment_method_cashdro
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -69,22 +69,15 @@ With the proper configuration made:
Known issues / Roadmap
======================

* Cashdro terminals are designed to communicate in the local network, so they can't
receive or transmit any request to a remote Odoo server. So in order to implement
further features, la cash control or cash ins/outs it would be necessary to either:

- Prepare the Cashdro terminal for a remote use (VPN, dns, etc.) and implement the
corresponding backend methods.
- Develope PoS frontend modules that allow to perform such operations and extend this
one making use of them.
* Integrate cash control (money inputs / outputs).

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_payment_method_cashdro%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_payment_method_cashdro%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -120,6 +113,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/14.0/pos_payment_method_cashdro>`_ project on GitHub.
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/16.0/pos_payment_method_cashdro>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
7 changes: 4 additions & 3 deletions pos_payment_method_cashdro/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "PoS Payment Method CashDro",
"summary": "Allows to pay with CashDro Terminals on the Point of Sale",
"version": "14.0.1.0.1",
"version": "16.0.1.0.0",
"category": "Point Of Sale",
"website": "https://github.com/OCA/pos",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand All @@ -12,8 +12,9 @@
"point_of_sale",
],
"data": [
"views/assets.xml",
"views/pos_payment_method_views.xml",
],
"installable": True,
"assets": {
"point_of_sale.assets": ["pos_payment_method_cashdro/static/src/js/*.js"],
},
}
34 changes: 0 additions & 34 deletions pos_payment_method_cashdro/migrations/14.0.1.0.0/pre-migration.py

This file was deleted.

1 change: 1 addition & 0 deletions pos_payment_method_cashdro/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import pos_payment_method
from . import pos_session
25 changes: 19 additions & 6 deletions pos_payment_method_cashdro/models/pos_payment_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,23 @@ def _get_payment_terminal_selection(self):
string="Cashdro Terminal Host Name or IP address",
help="It must be reachable by the PoS in the store",
)
cashdro_user = fields.Char(string="Cashdro User")
cashdro_password = fields.Char(string="Cashdro Password")
cashdro_user = fields.Char()
cashdro_password = fields.Char()

def _onchange_is_cash_count(self):
if self.use_payment_terminal == "cashdro":
return
return super()._onchange_is_cash_count()
def _onchange_journal_id(self):
"""Cash payment method force the `use_payment_terminal` to `False` as
it's assumed that a cash journal can't have a payment terminal. Let's keep
the method when it's needed"""
res = super()._onchange_journal_id()

Check warning on line 23 in pos_payment_method_cashdro/models/pos_payment_method.py

View check run for this annotation

Codecov / codecov/patch

pos_payment_method_cashdro/models/pos_payment_method.py#L23

Added line #L23 was not covered by tests
if self.use_payment_terminal != "cashdro" and not self.is_cash_count:
return res
self.use_payment_terminal = "cashdro"

Check warning on line 26 in pos_payment_method_cashdro/models/pos_payment_method.py

View check run for this annotation

Codecov / codecov/patch

pos_payment_method_cashdro/models/pos_payment_method.py#L25-L26

Added lines #L25 - L26 were not covered by tests

def _compute_hide_use_payment_terminal(self):
"""Now that we have the option to choose a payment terminal for the cashdro
payments, we can show the terminal options for cash payment types."""
cash_payment_types = self.filtered(lambda x: x.type == "cash")
cash_payment_types.hide_use_payment_terminal = False
return super(

Check warning on line 33 in pos_payment_method_cashdro/models/pos_payment_method.py

View check run for this annotation

Codecov / codecov/patch

pos_payment_method_cashdro/models/pos_payment_method.py#L32-L33

Added lines #L32 - L33 were not covered by tests
PosPaymentMethod, self - cash_payment_types
)._compute_hide_use_payment_terminal()
14 changes: 14 additions & 0 deletions pos_payment_method_cashdro/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Tecnativa - David Vidal
# 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"].extend(
["cashdro_host", "cashdro_user", "cashdro_password"]
)
return result
9 changes: 1 addition & 8 deletions pos_payment_method_cashdro/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
* Cashdro terminals are designed to communicate in the local network, so they can't
receive or transmit any request to a remote Odoo server. So in order to implement
further features, la cash control or cash ins/outs it would be necessary to either:

- Prepare the Cashdro terminal for a remote use (VPN, dns, etc.) and implement the
corresponding backend methods.
- Develope PoS frontend modules that allow to perform such operations and extend this
one making use of them.
* Integrate cash control (money inputs / outputs).
17 changes: 4 additions & 13 deletions pos_payment_method_cashdro/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -369,7 +368,7 @@ <h1 class="title">PoS Payment Method CashDro</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e4f16039547a5076c72bc8bac4fe707fc850c042c66e965d9b89a1aacb16b138
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pos/tree/14.0/pos_payment_method_cashdro"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pos-14-0/pos-14-0-pos_payment_method_cashdro"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pos&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pos/tree/16.0/pos_payment_method_cashdro"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_payment_method_cashdro"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pos&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to make payments with a Cashdro (<a class="reference external" href="https://www.cashdro.com">https://www.cashdro.com</a>) terminal
on the Point of Sale frontend.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -419,23 +418,15 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Cashdro terminals are designed to communicate in the local network, so they can’t
receive or transmit any request to a remote Odoo server. So in order to implement
further features, la cash control or cash ins/outs it would be necessary to either:<ul>
<li>Prepare the Cashdro terminal for a remote use (VPN, dns, etc.) and implement the
corresponding backend methods.</li>
<li>Develope PoS frontend modules that allow to perform such operations and extend this
one making use of them.</li>
</ul>
</li>
<li>Integrate cash control (money inputs / outputs).</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_payment_method_cashdro%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_payment_method_cashdro%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -466,7 +457,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/14.0/pos_payment_method_cashdro">OCA/pos</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_payment_method_cashdro">OCA/pos</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
35 changes: 35 additions & 0 deletions pos_payment_method_cashdro/static/src/js/models.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/** @odoo-module */
/* Copyright 2021 Tecnativa - David Vidal
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).*/
import {Order, register_payment_method} from "point_of_sale.models";
import {PaymentCashdro} from "./payment_cashdro.esm";
import Registries from "point_of_sale.Registries";

register_payment_method("cashdro", PaymentCashdro);

const PaymentCashdroOrder = (OriginalOrder) =>
class extends OriginalOrder {
constructor() {
super(...arguments);
this.in_cashdro_transaction = false;
}
/**
* @override
* Set the amount to 0 as it's going to be filled by the Cashdro response
*/
add_paymentline() {
const line = super.add_paymentline(...arguments);
if (!line) {
return line;
}
if (
line.payment_method &&
line.payment_method.use_payment_terminal === "cashdro"
) {
line.set_amount(0);
}
return line;
}
};

Registries.Model.extend(Order, PaymentCashdroOrder);
37 changes: 0 additions & 37 deletions pos_payment_method_cashdro/static/src/js/models.js

This file was deleted.

Loading

0 comments on commit b77ae19

Please sign in to comment.