[IMP] payment: create and use an electronic account.payment.method
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
'depends': ['account'],
|
||||
'data': [
|
||||
'data/payment_acquirer.xml',
|
||||
'data/account.xml',
|
||||
'views/payment_acquirer.xml',
|
||||
'views/assets.xml',
|
||||
'views/res_config_view.xml',
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="account_payment_method_electronic_in" model="account.payment.method">
|
||||
<field name="name">Electronic</field>
|
||||
<field name="code">electronic</field>
|
||||
<field name="payment_type">inbound</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -15,8 +15,17 @@ class AccountPayment(models.Model):
|
||||
|
||||
return res
|
||||
|
||||
@api.onchange('payment_method_id', 'journal_id')
|
||||
def _clear_electronic_payment_token(self):
|
||||
if self.payment_method_id.code == 'electronic':
|
||||
self.payment_token_id = self.env['payment.token'].search([('partner_id', '=', self.partner_id.id)], limit=1)
|
||||
else:
|
||||
self.payment_token_id = False
|
||||
|
||||
payment_transaction_id = fields.Many2one('payment.transaction', string="Payment Transaction")
|
||||
payment_token_id = fields.Many2one('payment.token', string="Saved payment token")
|
||||
payment_type = fields.Selection(selection_add=[('electronic', 'Electronically receive money')])
|
||||
payment_method_id_code = fields.Char(related='payment_method_id.code')
|
||||
|
||||
def _do_payment(self):
|
||||
tx_obj = self.env['payment.transaction']
|
||||
@@ -37,7 +46,7 @@ class AccountPayment(models.Model):
|
||||
|
||||
s2s_result = tx.s2s_do_transaction()
|
||||
|
||||
if not s2s_result or tx.state != 'done': # todo jov: what about pending transactions
|
||||
if not s2s_result or tx.state != 'done':
|
||||
raise ValidationError(_("Payment transaction failed (%s)") % tx.state_message)
|
||||
|
||||
self.payment_transaction_id = tx
|
||||
@@ -50,4 +59,3 @@ class AccountPayment(models.Model):
|
||||
res._do_payment()
|
||||
|
||||
return res
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
<field name="inherit_id" ref="account.view_account_payment_invoice_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="payment_method_id" position="after">
|
||||
<field name="payment_token_id"/>
|
||||
<field name="payment_method_id_code" invisible="1"/>
|
||||
<field name="payment_token_id" attrs="{'invisible': [('payment_method_id_code', '!=', 'electronic')],
|
||||
'required': [('payment_method_id_code', '=', 'electronic')]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user