Remove dead payment.provider create() override
The override guarded on self.code, which is empty on the model-level recordset passed to create(), so the branch never ran. The private key is generated during pairing (in the onchange) instead, so the override is dead code; removing it also keeps copying a provider from regenerating (and thus invalidating) an already paired key.
This commit is contained in:
1 parent
9f3f702c9f
commit
023e4060c5
1 file changed
+2
-8
@@ -1,4 +1,4 @@
|
|||||||
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
|
||||||
|
|
||||||
@@ -21,15 +21,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_privkey()
|
|
||||||
|
|
||||||
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:
|
||||||
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)
|
||||||
token = client.pair_client(self.btcpay_pairingCode)
|
token = client.pair_client(self.btcpay_pairingCode)
|
||||||
|
|||||||