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 1, 2024
1 parent d2e8012 commit f9ec324
Show file tree
Hide file tree
Showing 15 changed files with 280 additions and 280 deletions.
12 changes: 7 additions & 5 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 All @@ -43,6 +43,8 @@ To add a Cashdro payment terminal:

#. Go to *Point of Sale > Configuration > Payment Methods*
#. Choose a cash payment method or create a new one.
#. You need to change the type to bank in order to configure the terminal values.
#. Once you configure them, you can change it back to cash before saving.
#. Select *Cashdro* in the *Use a Payment Terminal* field.
#. Configure the Cashdro terminal hostname and credentials.
#. Configure the desired, Cashdro terminal in the proper PoS configurations.
Expand Down Expand Up @@ -84,7 +86,7 @@ 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 +122,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
14 changes: 8 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,12 @@ 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"""
if self.use_payment_terminal != "cashdro":
return super()._onchange_journal_id()
self.use_payment_terminal = "cashdro"

Check warning on line 24 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-L24

Added lines #L23 - L24 were not covered by tests
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
2 changes: 2 additions & 0 deletions pos_payment_method_cashdro/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ To add a Cashdro payment terminal:

#. Go to *Point of Sale > Configuration > Payment Methods*
#. Choose a cash payment method or create a new one.
#. You need to change the type to bank in order to configure the terminal values.
#. Once you configure them, you can change it back to cash before saving.
#. Select *Cashdro* in the *Use a Payment Terminal* field.
#. Configure the Cashdro terminal hostname and credentials.
#. Configure the desired, Cashdro terminal in the proper PoS configurations.
Expand Down
9 changes: 5 additions & 4 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 All @@ -393,6 +392,8 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<ol class="arabic simple">
<li>Go to <em>Point of Sale &gt; Configuration &gt; Payment Methods</em></li>
<li>Choose a cash payment method or create a new one.</li>
<li>You need to change the type to bank in order to configure the terminal values.</li>
<li>Once you configure them, you can change it back to cash before saving.</li>
<li>Select <em>Cashdro</em> in the <em>Use a Payment Terminal</em> field.</li>
<li>Configure the Cashdro terminal hostname and credentials.</li>
<li>Configure the desired, Cashdro terminal in the proper PoS configurations.</li>
Expand Down Expand Up @@ -435,7 +436,7 @@ <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 +467,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 f9ec324

Please sign in to comment.