Remove dead payment.provider create() override
The override guarded on self.code inside create(), which is empty on the model-level recordset, so the branch never ran; it also called a misspelled helper (generate_privakey). Removing it lets the private key be generated during pairing as intended, and keeps copying a provider from regenerating (and thus invalidating) an already paired key.
This commit is contained in:
1 parent
dc6b7a5758
commit
9705023233
1 file changed
+2
-8
@@ -1,6 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import api, fields, models
|
||||||
from .libs.client import BTCPayClient
|
from .libs.client import BTCPayClient
|
||||||
from .libs import crypto
|
from .libs import crypto
|
||||||
|
|
||||||
@@ -20,15 +20,9 @@ class PaymentProvider(models.Model):
|
|||||||
btcpay_privateKey = fields.Text(string='Private Key', help='Private Key for BTCPay Client. Leave empty, will be autogenerated during pairing.')
|
btcpay_privateKey = fields.Text(string='Private Key', help='Private Key for BTCPay Client. Leave empty, will be autogenerated during pairing.')
|
||||||
btcpay_facade = fields.Char(string='Facade', help='Token facade type: merchant/pos/payroll. Keep merchant', default='merchant')
|
btcpay_facade = fields.Char(string='Facade', help='Token facade type: merchant/pos/payroll. Keep merchant', default='merchant')
|
||||||
|
|
||||||
def create(self, values_list):
|
|
||||||
if self.code == 'btcpayserver':
|
|
||||||
values_list['btcpay_privateKey'] = crypto.generate_privakey()
|
|
||||||
|
|
||||||
return super(PaymentProvider, self).create(values_list)
|
|
||||||
|
|
||||||
@api.onchange('btcpay_pairingCode')
|
@api.onchange('btcpay_pairingCode')
|
||||||
def _onchange_pairingCode(self):
|
def _onchange_pairingCode(self):
|
||||||
if not self.btcpay_token and self.code == 'btcpayserver' and not self.btcpay_pairingCode == '':
|
if not self.btcpay_token and self.code == 'btcpayserver' and self.btcpay_pairingCode:
|
||||||
#_logger.info("ONCHANGE PAIRING CODE***SELF: %s %s %s", self.btcpay_location, self.btcpay_privateKey, self.btcpay_pairingCode)
|
#_logger.info("ONCHANGE PAIRING CODE***SELF: %s %s %s", self.btcpay_location, self.btcpay_privateKey, self.btcpay_pairingCode)
|
||||||
self.btcpay_privateKey = crypto.generate_privkey()
|
self.btcpay_privateKey = crypto.generate_privkey()
|
||||||
client = BTCPayClient(host=self.btcpay_location, pem=self.btcpay_privateKey)
|
client = BTCPayClient(host=self.btcpay_location, pem=self.btcpay_privateKey)
|
||||||
|
|||||||