Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
cd987312
Unverified
Commit
cd987312
authored
8 years ago
by
Damien Bouvy
Browse files
Options
Downloads
Patches
Plain Diff
[IMP] payment: prevent 'authorize-only' transaction to settle invoice
parent
a2b9b3a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
addons/payment/models/account_payment.py
+7
-3
7 additions, 3 deletions
addons/payment/models/account_payment.py
with
7 additions
and
3 deletions
addons/payment/models/account_payment.py
+
7
−
3
View file @
cd987312
...
...
@@ -10,7 +10,8 @@ class AccountPayment(models.Model):
_inherit
=
'
account.payment
'
payment_transaction_id
=
fields
.
Many2one
(
'
payment.transaction
'
,
string
=
"
Payment Transaction
"
)
payment_token_id
=
fields
.
Many2one
(
'
payment.token
'
,
string
=
"
Saved payment token
"
)
payment_token_id
=
fields
.
Many2one
(
'
payment.token
'
,
string
=
"
Saved payment token
"
,
domain
=
[(
'
acquirer_id.auto_confirm
'
,
'
!=
'
,
'
authorize
'
)],
help
=
"
Note that tokens from acquirers set to only authorize transactions (instead of capturing the amount) are not available.
"
)
payment_type
=
fields
.
Selection
(
selection_add
=
[(
'
electronic
'
,
'
Electronically receive money
'
)])
payment_method_id_code
=
fields
.
Char
(
related
=
'
payment_method_id.code
'
)
...
...
@@ -18,14 +19,14 @@ class AccountPayment(models.Model):
def
_onchange_partner_id
(
self
):
res
=
{}
if
self
.
partner_id
:
res
[
'
domain
'
]
=
{
'
payment_token_id
'
:
[(
'
partner_id
'
,
'
=
'
,
self
.
partner_id
.
id
)]}
res
[
'
domain
'
]
=
{
'
payment_token_id
'
:
[(
'
partner_id
'
,
'
=
'
,
self
.
partner_id
.
id
)
,
(
'
acquirer_id.auto_confirm
'
,
'
!=
'
,
'
authorize
'
)
]}
return
res
@api.onchange
(
'
payment_method_id
'
,
'
journal_id
'
)
def
_onchange_payment_method
(
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
)
self
.
payment_token_id
=
self
.
env
[
'
payment.token
'
].
search
([(
'
partner_id
'
,
'
=
'
,
self
.
partner_id
.
id
)
,
(
'
acquirer_id.auto_confirm
'
,
'
!=
'
,
'
authorize
'
)
],
limit
=
1
)
else
:
self
.
payment_token_id
=
False
...
...
@@ -38,6 +39,9 @@ class AccountPayment(models.Model):
return
account_payment
def
_do_payment
(
self
):
if
self
.
payment_token_id
.
acquirer_id
.
auto_confirm
==
'
authorize
'
:
raise
ValidationError
(
'
This feature is not available for payment acquirers set to the
"
Authorize
"
mode.
\n
'
'
Please use a token from another provider than %s.
'
%
self
.
payment_token_id
.
acquirer_id
.
name
)
reference
=
"
PAYMENT-%s-%s
"
%
(
self
.
id
,
datetime
.
datetime
.
now
().
strftime
(
'
%y%m%d_%H%M%S
'
))
tx
=
self
.
env
[
'
payment.transaction
'
].
create
({
'
amount
'
:
self
.
amount
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment