Skip to content

Commit 41dc27a

Browse files
committed
[FIX] pos_payment_method_cashdro: Use correct payment line retrieval method + Improve http
Allow to retrieve correctly the payment line at request sending Add http only option
1 parent 5431496 commit 41dc27a

5 files changed

Lines changed: 23 additions & 18 deletions

File tree

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
from . import pos_payment_method
2-
from . import pos_session

pos_payment_method_cashdro/models/pos_payment_method.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ def _get_payment_terminal_selection(self):
1515
)
1616
cashdro_user = fields.Char()
1717
cashdro_password = fields.Char()
18+
cashdro_http = fields.Boolean(
19+
string="Use HTTP connection",
20+
help="Check this to enable HTTP (not secure) connection. You should enable it"
21+
" also in Cashdro configuration interface.",
22+
)
1823

1924
def _onchange_journal_id(self):
2025
"""Cash payment method force the `use_payment_terminal` to `False` as
@@ -33,3 +38,11 @@ def _compute_hide_use_payment_terminal(self):
3338
return super(
3439
PosPaymentMethod, self - cash_payment_types
3540
)._compute_hide_use_payment_terminal()
41+
42+
def _load_pos_data_fields(self, config_id):
43+
return super()._load_pos_data_fields(config_id) + [
44+
"cashdro_host",
45+
"cashdro_user",
46+
"cashdro_password",
47+
"cashdro_http",
48+
]

pos_payment_method_cashdro/models/pos_session.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

pos_payment_method_cashdro/static/src/js/payment_cashdro.esm.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,15 @@ export class PaymentCashdro extends PaymentInterface {
107107
_cashdro_url() {
108108
// Cashdro machines don't support safe POST calls, so we're sending
109109
// all the data quite unsafely constantly...
110-
const method = this.pos.get_order().selected_paymentline.payment_method;
110+
const method = this.pos
111+
.get_order()
112+
.get_selected_paymentline().payment_method_id;
111113
const host = method && method.cashdro_host;
112114
if (!host) {
113115
return false;
114116
}
115-
let url = `${host}/Cashdro3WS/index.php`;
117+
const connection = method.cashdro_http ? `http://` : `https://`;
118+
let url = `${connection}${host}/Cashdro3WS/index.php`;
116119
url += `?name=${method.cashdro_user}`;
117120
url += `&password=${method.cashdro_password}`;
118121
return url;
@@ -125,7 +128,7 @@ export class PaymentCashdro extends PaymentInterface {
125128
const operationType = parameters.amount > 0 ? 4 : 3;
126129
parameters = {...parameters, amount: Math.abs(parameters.amount)};
127130
let url = `${this._cashdro_url()}&operation=startOperation&type=${operationType}`;
128-
url += `&posid=pos-${this.pos.pos_session.name}`;
131+
url += `&posid=pos-${this.pos.session.name}`;
129132
url += `&posuser=${user}`;
130133
url += `&parameters=${encodeURIComponent(JSON.stringify(parameters))}`;
131134
return url;

pos_payment_method_cashdro/views/pos_payment_method_views.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
invisible="use_payment_terminal != 'cashdro'"
1111
required="use_payment_terminal == 'cashdro'"
1212
/>
13+
<field
14+
name="cashdro_http"
15+
invisible="use_payment_terminal != 'cashdro'"
16+
/>
1317
<field
1418
name="cashdro_user"
1519
invisible="use_payment_terminal != 'cashdro'"

0 commit comments

Comments
 (0)