Commit Graph
387 Commits
Author SHA1 Message Date
Ivan Yelizariev d3867f48e7 [FIX] payment: handle reference with special regexp characters
Method `_compute_reference` computes unique reference for a transaction. If
reference from `account.move`'s `payment_reference` was never used, the method
just returns that reference. Othwerwise it adds a counter. The latter requires
to make a regular expression to count records with the same prefix. However, if
the prefix has special regexp characters (e.g. `+++INV/2020/666+++`), then we
have to escape the characters first. This is what this commit does.

opw-2994126

closes odoo/odoo#101201

X-original-commit: 6c513d43eba8c58171b0fb632d0ac82b28aa9e7d
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Ivan Elizaryev (iel) <iel@odoo.com>
2022-09-27 11:41:46 +02:00
Valentin Vallaeys (vava) 536a74b6b0 [CLN] payment(_*): remove useless refund parameter
*: adyen, authorize, demo, razorpay, stripe.

The param `create_refund_transaction` from `_send_refund_request` became
useless following this commit:
https://github.com/odoo/odoo/commit/e4c63126b45854b10f08ab14dee5eb1d4ed98bb0

It was only used for Authorize.net, which now works without calling this
param.

task-2869910

closes odoo/odoo#101105

X-original-commit: 6855d65df7a83037ee5e2202966fa4e67dae7d5a
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-09-26 13:41:47 +02:00
Valentin Vallaeys (vava) e6536f878e [IMP] payment: use ondelete to restrict deletion
Restrict deletion of token and express checkout inline forms when a payment provider is using it

Continuity of https://github.com/odoo/odoo/commit/efbf0c08382a9eddaa48bb386912e5c1925bbfc0

task-2883630

closes odoo/odoo#100466

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-09-19 12:23:13 +02:00
Valentin Vallaeys (vava) efbf0c0838 [IMP] payment: use ondelete instead of custom error
Use generic method on_delete instead of personalized one for the sake of
clarity and reproductibility.

task-2883630

closes odoo/odoo#99958

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-09-16 19:17:05 +02:00
Antoine Vandevenne (anv) 3bead2cbea [CLN] payment: code cleanup
This commit removes unused imports and renames some confusing variable
names and helper texts that were changed with commit f7b8f075 when
renaming the term "acquirer" to "provider".

closes odoo/odoo#100348

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-09-16 14:26:05 +02:00
Antoine Vandevenne (anv) e345204345 [FIX] payment: fix crash when uninstalling payment providers
Part-of: odoo/odoo#100348
2022-09-16 14:26:04 +02:00
Horacio Tellez f7b8f07501 [IMP] payment: rename of acquirer to provider
Changing the name of model payment.acquirer to payment.provider
and everything that it touches. It is technically incorrect to
use the term "acquirer" for systems that only provide a service
of payment.
After this commit the model payment.acquirer and all related to
it will be renamed to payment.provider.

Task - 2842088

closes odoo/odoo#90899

Related: odoo/upgrade#3542
Related: odoo/documentation#1981
Related: odoo/enterprise#27131
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-09-09 13:38:08 +02:00
Victor Feyens 61b8c0c1a2 [REF] (account_)payment: extract accounting logic from payment 2022-09-06 13:31:00 +02:00
Horacio Tellez 24f33c0282 [IMP] payment: rework the kanban view of acquirers
The present kanban view of acquirers is not the most appealing
one. It is full of useless information (e.g. "online payment") and the
combination of provider logos makes it look "old".

After this commit, the kanban view will hopefully have a "cool" and
concise look simular to the "Apps"'s kanban view.

Task - 284171

closes odoo/odoo#98345

Related: odoo/enterprise#30585
Related: odoo/upgrade#3803
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-09-05 14:50:11 +02:00
Valentin Chevalier c624ed5603 [IMP] payment(_stripe), website_sale(_delivery): support express checkout
This commit enables eCommerce customers to pay with the express payment
methods Apple Pay and Google Pay from the cart page.

For the moment, only Stripe supports this additional feature but it
was designed to make it easy to implement with a new provider.

task-2754209

closes odoo/odoo#88374

Related: odoo/enterprise#29915
Related: odoo/documentation#2392
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-09-05 14:49:33 +02:00
Alvaro Fuentes adf534f2bf [FIX] payment: compute related_partner_ids with sudo
`related_partner_ids` is used in the form view of account.payment
https://github.com/odoo/odoo/blob/43fccd7aaa83117c95babc52d60dd1c26b28335a/addons/payment/views/account_payment_views.xml#L14
It is only needed for electronic payments to display the payment token
ids (as part of its domain)
https://github.com/odoo/odoo/blob/45f5167b956521f0a183ff1b1cc75fa1b273866c/addons/payment/models/account_payment.py#L13-L21
and for draft payments only.
https://github.com/odoo/odoo/blob/43fccd7aaa83117c95babc52d60dd1c26b28335a/addons/payment/views/account_payment_views.xml#L16

Before this change the form view will fail when partner_id has a company
that is not in the context. This is not incorrect, but it is unexpected
as `related_partner_ids` is not needed to just show the form view. A way
to reproduce the issue is to confirm a payment, then change the partner
company to a company not accessible for current user.

This causes issues during migrations: the form view for the failing
payments is displayed just fine for versions <=13.0

closes odoo/odoo#98623

X-original-commit: a126f007573a41d22108d9d7887f92b6926ef3ec
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Alvaro Fuentes Suarez (afu) <afu@odoo.com>
2022-08-22 22:56:27 +02:00
Laura Schauer c1b41bcd08 [IMP] payment(_*): allow dynamic token name
Before this commit, tokens were prefixed with usually 12 X’s. To improve
readability, modernity and to shorten the length, this commit changes
token prefixes to a standard of •••• 1111.

task-2832669

closes odoo/odoo#94978

Related: odoo/upgrade#3738
Related: odoo/enterprise#29190
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-08-19 14:28:08 +02:00
Victor Feyens 4c185d4a3f [FIX] payment: correct message for validation transactions
The message returned by `_get_sent_message` for validation transaction
was wrong, refering to a token, but there is no token on validation transactions.

This doesn't have to be fixed in stable since validation transactions are not linked to
any specific document, so the wrong message was never posted anywhere.

Now that we improve the display logic of payment tokens and noticed the problem,
this commit fixes it (for code consistency, and if any custom code/... uses this
message as well.

Part-of: odoo/odoo#94978
2022-08-19 14:28:08 +02:00
Fabien Pinckaers 3363e55cac [IMP] cleanup of help messages in all modules
This commit aims at removing unuseful help message to:
1/ reduce translators work, to focus on more useful translations
2/ not sending unuseful information in load_views
3/ reduce help message to useful messages, so that we can mark
   fields having a tooltip in the future UI.
4/ some cleanup of existing messages too

The main use cases:
- REMOVED: help redundant with the field name, providing no extra info
- MOVED TO COMMENT: technical help messages, that should not be in UX

closes odoo/odoo#97279

Signed-off-by: Fabien Pinckaers <fp@odoo.com>
2022-08-02 00:26:53 +02:00
Horacio Tellez f8bebc407b [FIX] payment: do not add fee for validation transaction
When making transaction with 'validation' type and where fees
were active, fees were added to the amount.
This behaviour is problematic because
validation operations are used for tokenization for example where
no credit should charged to the customer.
Now validation operations have no fees even if fees are active
on the acquirer.

Task - 2784765

closes odoo/odoo#96712

X-original-commit: 69b04e753ab4e90e68b9d3e678ebea277586e7ac
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-07-29 14:31:49 +02:00
Horacio Tellez c1aa010af7 [IMP] payment: filter out acquirers based on the amount
This commit adds the possibility to define a maximum payment amount that
a given acquirer can process. If the payment amount exceeds the value,
the acquirer is filtered out of the available acquirers listed on the
payment forms.

While we're at it, the field `country_ids` is renamed to
`available_country_ids` to better depict that it is not a property of
the acquirer, but a configuration option. It will also be coherent with
the field `available_currency_ids` that is expected to be added soon.

Task - 2162165

closes odoo/odoo#82411

Related: odoo/enterprise#24412
Related: odoo/upgrade#3703
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-07-26 13:24:57 +02:00
Laura Schauer 6965066e9c [IMP] payment: allow (un)publishing of payment acquirers
Before this commit, it was impossible to migrate from one payment
acquirer to another as the only way to do so was to change a payment
acquirer’s state to ‘disabled’, subsequently disabling all tokens of that
acquirer (detrimental for eg. running subscriptions).

After this commit, payment acquirers have an additional boolean
‘Published’. With this functionality, users can safely migrate by
keeping an acquirer ‘enabled’, but invisible for customers.

There are five combined states an acquirer can take:

‘enabled’ & ‘published’: Visible to all users
‘enabled’ & ‘unpublished’: Visible only to internal users
‘disabled’ & ‘unpublished’: Same as previously ‘disabled’
‘test’ & ‘published’: Same as previously ‘test’
‘test’ & ‘unpublished’: visible only to internal users

task-2871459

closes odoo/odoo#94242

Related: odoo/upgrade#3688
Related: odoo/documentation#2308
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-07-19 20:12:58 +02:00
Laura Schauer 2ee4251d07 [IMP] payment(_adyen, _authorize): disable tokens of disabled acquirers
Before this commit, zombie payment tokens (= tokens linked to disabled
acquirers) could still
1) be used by internal users and
2) reactivated when the acquirer’s state changed to ‘test’ or ‘enabled’.
This is not desirable because zombie tokens should neither be used,
nor reactivated.

After this commit, all tokens related to an acquirer are unassigned
from linked documents and archived as soon as the acquirer’s state is
changed to ‘disabled’. Creating a payment with an archived token is
prohibited. In addition, archived tokens cannot be un-archived anymore.

task-2649806

closes odoo/odoo#93774

Related: odoo/enterprise#28661
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-07-12 03:09:44 +02:00
David Tran c779ee3f26 [FIX] payment: cron miss online payments of long verification
Sometime Paypal took 3 or 4 days for some payment verification due to
weekend. This raises the retry limit days for 4 days instead of 2 to
solve the issue

closes odoo/odoo#95522

X-original-commit: 5aaaaf8f072b3f8ab66a269bb3dba02714b593ad
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-07-07 16:07:04 +02:00
Antoine Vandevenne (anv) 889fbffb7f [FIX] payment: hide the tokenization input when required by the provider
Due to an oversight, the "Save my payment details" checkbox was shown on
the inline payment form of SEPA Direct Debit acquirers, which should
never happen because the transaction is *always* tokenized with those.

With this commit, the `_is_tokenization_required` method is slightly
refactored to read the provider from the current `payment.acquirer`
record rather than from the kwargs. This conveniently fixes the issue
and prevents it from happening again elsewhere.

closes odoo/odoo#95519

X-original-commit: ebeebd87ed6d687b96dda3006b81356dfa76d0a0
Related: odoo/enterprise#29237
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-07-07 14:44:48 +02:00
Valentin Chevalier b5dab9b119 [IMP] account_payment: hide pay button when paid
Hide the 'Pay Now' button for invoices which transactions total amount
equals their total amount.

When the total amount of all transactions related to the invoice is
equal to or greater than the total amount of said invoice, the 'Pay Now'
button should no longer be displayed.

task-2527323

closes odoo/odoo#95262

X-original-commit: de81225d39e7951ea9a63e24bab3a0138a6942e3
Signed-off-by: Achraf <abz@odoo.com>
2022-07-05 12:42:33 +02:00
Valentin Chevalierandxlu-odoo 2d81dffd23 [IMP] payment_test: support all additional features
After the payment apocalypse, `payment_test` was cleaned and stripped of
all useless parts. It was a very basic testing acquirer that allowed to
enter fake arbitrary payment details, choose whether they should be
tokenized, and then pay. It was intended to test the payment flow of
various applications (Sales, Subscriptions, Invoicing, ...) for a single
scenario: successful payments with immediate capture.

In order to extensively test an app's payment flow (explore other
scenarios), we need `payment_test` to have additional features.

Now, `payment_test` will allow profound testing of these features:
- separate authorization and capture
- customer fees computation
- tokenization
- refunds
- on the /pay page, users will be able to select the status of the
  payment
- on the payment transaction form view, users can change the status of
  a payment 'pending' to either succeed or fail
- on the payment token form view, users can change the state of future
  transactions made with that token

task-2512196

closes odoo/odoo#78083

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Co-authored-by: xlu-odoo <xlu@odoo.com>
2022-07-01 19:37:10 +02:00
Antoine Vandevenne (anv) 06084a8420 [FIX] payment: stop preventing non-admin users from deleting views
closes odoo/odoo#93532

X-original-commit: bc90dbb577c974c5b9c3a429ef8379e8af1a9ca7
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-06-17 14:14:19 +02:00
Antoine Vandevenne (anv) 33ae932413 [FIX] payment: fix broken call to ensure_one
closes odoo/odoo#93448

X-original-commit: f1be16ffe6a65aa85bc35443b09e517161244559
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-06-13 16:51:39 +02:00
Alvaro Fuentes d5f2fc2e37 [FIX] payment: fix misplaced sudo
On 02eba891cb8cd58985837090f2b60cf263bce065
we changed
https://github.com/odoo/odoo/blob/b5cf1ee3e21f2e60b8edd64f24c04c952fb7df3f/addons/payment/models/account_payment.py#L47
to
https://github.com/odoo/odoo/blob/02eba891cb8cd58985837090f2b60cf263bce065/addons/payment/models/account_payment.py#L47-L48
Effectively moving the place where `sudo` is called.

This causes issues during migration of some DBs
upg-328570

closes odoo/odoo#92651

X-original-commit: 90c321cc8bad04f7f094a221a39ca6f647944f5d
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-06-01 16:26:32 +02:00
Horacio Tellez e4c63126b4 [ADD] payment_authorize: add refund for Authorize.
Users can now ask for a refund from Odoo for their transactions done
through Authorize.net. A refund will be triggered from Odoo when
necessary.
Only full refunds are possible.
Note that unsettled transactions will be voided as they cannot be
refunded.

Task - 2678757

closes odoo/odoo#92279

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-06-01 13:13:55 +02:00
Raphael Collet 6cf8db906f [REF] *: adapt code to new flush API
closes odoo/odoo#87527

Related: odoo/upgrade#3497
Related: odoo/enterprise#26939
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-05-25 18:00:47 +02:00
Valentin Chevalier 930b6860d7 [IMP] payment_stripe: support refund
Allows users of Stripe to refund their customers directly from Odoo.

task-2678763

closes odoo/odoo#92235

Related: odoo/documentation#2086
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-05-25 12:46:08 +02:00
Demesmaeker 86ff8c6e8f [REF] payment(_*): compute feature fields
Computing the fields instead of storing them allows to implement the
feature for each provider more easily, without needing a migration
script.

task-2841744

closes odoo/odoo#91961

Related: odoo/enterprise#27618
Related: odoo/upgrade#3535
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-05-24 19:10:55 +02:00
Valentin Chevalier 7f6f6a545c [FIX] payment,sale: fix access error when using the capture or void buttons
Before this commit, users may saw the capture and void buttons but
couldn't use them.

As capture or void actions need to access acquirer-related fields,
these actions are now sudoed to allow any users that see the button
to use it.

The access rules and rights are also checked before executing the action
to avoid abusive RPC calls.

task-2785144

closes odoo/odoo#91923

X-original-commit: 2e351d6ff9b7f72b486e83c827ff6e15a05c3331
Signed-off-by: Valentin Chevalier <vcr@odoo.com>
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-05-20 15:25:46 +02:00
Horacio Tellez d67b7cf3d8 [FIX] payment: issue Authorize.net manual capture
When a 'manual capture' is set for Authorize.net and a client
make a payment in several partial payments the user can capture
all the authorized transactions without crashing now.

Task - 2676914

closes odoo/odoo#90212

X-original-commit: 68b354f7353e3b5fd1faaad1b762c3c73a286f0f
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Horacio Tellez Perez (hote) <hote@odoo.com>
2022-05-02 13:43:00 +02:00
Horacio Tellez f02cf4a195 [FIX] payment: hide the refund button on payments created from a refund
task-2685480

closes odoo/odoo#90085

X-original-commit: 02eba891cb8cd58985837090f2b60cf263bce065
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Horacio Tellez Perez (hote) <hote@odoo.com>
2022-04-29 12:06:15 +02:00
Antoine Vandevenne (anv) 5440a27550 [IMP] payment: allow the public user to tokenize payments
Before this commit, the public user would be prevented from creating,
reading, or using payment tokens entirely. This was put in place in an
effort to homogenize the way each application interacts with tokens,
and because it was considered more logical to only create tokens when
you can see actually them afterward. This however led to an undesirable
side effect in Subscriptions where customers would pay while being
logged out, thus preventing the token from being saved and failing the
automatic renewal of the subscription.

With this commit, we enable the public user to create tokens from any
payment flow. This also means that when a token is created, its owner
will not see it until they log in. This commit also reverts 2a084c48
which was intended to hide payments acquirers from the public user if
their payment would end up being tokenized.

opw-2789340

closes odoo/odoo#90061

X-original-commit: 4e03d4b6106f10522dd5f1839a0f941ca6b202fa
Related: odoo/enterprise#26741
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-04-29 12:05:55 +02:00
Nicolas (vin) 66e0e4086b [FIX] account_*: payment method journal filter
Fix two issues linked to payment methods and their journal link.

SEPA Credit Transfer was marked as only available on EUR journals, but
from what we have been told, and we have seen, it should also be made
available for other currencies (CHF/SEK).
So we are changing the rule used to determine if SEPA Credit Transfer
is available on a journal to allow to use it on journals using CHF or
SEK as a currency.

There is another issue, where the filtering is done differently at the
journal creation and when the user add the payment method manually in
the lists.
The filter rules were not respected at the journal creation, which
would lead to incorrect default inbound and outbound payment method list.
For example, a new journal would have the company currency (let's say,
USD) but still have SEPA Credit Transfer (EUR,CHF,SEK) added on it by
default while it should not be available there.

opw-2777522

X-original-commit: 0ad8faf3bfc7b28e5668c3445fcc06c24ad98354
[FIX] account_*: payment method journal filter

Fix two issues linked to payment methods and their journal link.

SEPA Credit Transfer was marked as only available on EUR journals, but
from what we have been told, and we have seen, it should also be made
available for other currencies (CHF/SEK).
So we are changing the rule used to determine if SEPA Credit Transfer
is available on a journal to allow to use it on journals using CHF or
SEK as a currency.

There is another issue, where the filtering is done differently at the
journal creation and when the user add the payment method manually in
the lists.
The filter rules were not respected at the journal creation, which
would lead to incorrect default inbound and outbound payment method list.
For example, a new journal would have the company currency (let's say,
USD) but still have SEPA Credit Transfer (EUR,CHF,SEK) added on it by
default while it should not be available there.

opw-2777522

closes odoo/odoo#88677

X-original-commit: e2cd91ad8339f73b2547bc839e675443528f3adf
Related: odoo/enterprise#26172
Signed-off-by: Florian Gilbert <flg@odoo.com>
2022-04-14 15:11:27 +02:00
Victor Feyens 00ed6aa042 [IMP] mail,* : uniformized API for chatter links
* Enforce html escaping of record title
* Avoid translating html content as much as possible, to reduce translation errors.
* Uniformize/Factorize link generation, easing future tasks, code maintenance, ...

Enterprise PR: https://github.com/odoo/enterprise/pull/25357

closes odoo/odoo#84866

Related: odoo/enterprise#25357
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-03-31 12:32:47 +02:00
Gorash 880954ebfc [IMP] *: remove _render from ir.ui.view and simplify report
There were inconsistencies in the calls to `_render`.
* the view context could contain information that misled developers.
Indeed, the context and value of the view are not supposed to be found
in the rendering. Thus by calling `ir.qweb` with the name of the
template, we ensure that there is no unwanted information and in
addition the cache key is that of the name of the template which saves
a query.
* the context used for rendering was modified by a method on
`ir.ui.view`, except this is not information used by this model. There
is now a `_prepare_environment` method residing on `ir.qweb`. This
method allows to modify the value dictionary as well as the context in
which the rendering will be done. This preparation of the data as well
as my security check is done only once per rendering. This also saves
some queries
* Freeze options for rendering were inconsistent. It could be that
options on which rendering depends were not part of the cache key. Thus,
depending on the user who generated the generation of the rendering
function, there was or was not information in the template. For example
for automatic branding. This is no longer possible, because it is the
context that is used. The options serving as a cache key are only
recorded for information (for the profiling system for example). A
simplification of the `ir.qweb.field` models could be made.

The report rendering and call `ir.qweb` instead of `ir.ui.view`.

Part-of: odoo/odoo#85110
2022-03-29 10:56:15 +02:00
Thibault Libioulle 2e7cc0d82f [IMP] payment{,_stripe},{,website_}sale: clean up stripe connect code
This commit removes deprecated actions and methods kept after the merge
of PR #79621 in stable.

Follow-up
task-2685160

closes odoo/odoo#84789

Related: odoo/upgrade#3256
Related: odoo/enterprise#25369
Signed-off-by: Thibault Libioulle (tle) <tle@odoo.com>
2022-03-29 08:57:43 +02:00
roen-odoo 7877c22a8d [FIX] payment: exclude acquirers requiring tokenization when logged out
Current behavior:
Public user have access to payment method that require tokenization wich leads to error when they use it.
We should not show those payment methos to the public users (e.g We shouldn't show sepa direct debit because this method uses tokenization)

Steps to reproduce:
- Activate SEPA Direct Debit in the payment acquierers
- Select Bank as payment journal
- In the bank payment journal create an account number (e.g BE71096123456769), and select a Bank (e.g BNP)
- Create a new customer (type : company, country : spain, and an email)
- Create a quotation with this new customer
- Click on the "action" icon and click on generate payment link
- Open the link in an incognito window (to make sure you'r not connected in Odoo)
- Try to use the sepa direct debit
- An access error appears because public user do not have access to payment.token.

opw-2754505

closes odoo/odoo#86415

X-original-commit: 2a084c4810c6d1af82901882d1588c8449ebdc78
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
2022-03-14 19:56:17 +00:00
Vincent Schippefilt 05fc9a6733 [IMP] *: use _read_group instead of read_group
This commit modifies most of the usages of read_group and uses
_read_group instead. _read_group doesn't join automatically on the
many2one fields when no order_by is specified, making it more performant
when the "name" of the many2one is not relevant, which is the case for
most back-end cases

closes odoo/odoo#84908

Task-id: 2479334
Related: odoo/enterprise#24877
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-03-02 17:10:48 +00:00
Horacio Tellez 3db051e7f5 [FIX] payment: link tokens to refund transactions
Whenever making a refund for a transaction with a saved token
the token will appear also on the refund transaction.
It is useful to keep track of which token was used in each
transaction, this remains true for refunds.
The token will also appear on the payments.

Task - 2694760

closes odoo/odoo#85484

X-original-commit: 351812a81ec29fe96bf3766c45ea3b51f4055066
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-02-28 12:01:48 +00:00
Thibault Libioulle c5198b0bab [IMP] payment{,_stripe},{,website_}sale: improve stripe onboarding
This commit lighten payment onboarding form in order to take advantage
of the Stripe Connect Onboarding Flow. It integrates the Stripe
Onboarding using the IAP proxy.

Purpose
=======
Help users easily onboard with Stripe by using the Stripe Connect API.

Specifications
==============
During the payment onboarding, if the user selects Stripe, they will
start the Stripe Onboarding. (NB: The process uses a proxy that handles
the Stripe Onboarding calls and signs them with the Stripe Connect key)
1) A call is made through the proxy to get the Stripe account token;
2) A call is made through the proxy to get the Stripe account link which
   contains the URL of the Onboarding;
3) The user is redirected to the Stripe Onboarding;
4) The user completes the Stripe Onboarding;
5) The user comes back to the acquirer form of Stripe and is able to get
   their keys.
6) The user can directly create their webhook after having copied/pasted
   their API keys.

During the website sale onboarding, the user doesn't go through the
onboarding wizard but is directly prompted to activate their account.

Note that the Onboarding status isn't stored in the database so there is
no call to Stripe API to validate the account status.

API Documentation :
- Connect Onboarding: https://stripe.com/docs/connect/standard-accounts
- Webhook creation: https://stripe.com/docs/api/webhook_endpoints/create

task-2685160
task-2691213

closes odoo/odoo#84639

X-original-commit: 085f4af4e57c43127413585a8df5b3aa47843339
Related: odoo/enterprise#24376
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Thibault Libioulle (tle) <tle@odoo.com>
2022-02-15 16:51:24 +00:00
Victor Feyens bbcac30342 [FIX] payment,sale(_*): typos
closes odoo/odoo#84094

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-02-07 16:22:54 +00:00
Antoine Vandevenne (anv) f4ca7290ac [IMP] payment(_*): search only once for the transaction
Before this commit, most acquirers needed to run several successive
searches for the transaction whose reference was received by a
controller in notification data. This is because the security checks
run on the notification data require access to the acquirer through the
transaction record which was immediately discarded.

Starting with this commit, all `*_feedback_data` method are no longer
decorated with `api.model` and can use the transaction record they're
called on if provided. They are also renamed to `*_notification_data`.

task-2737144

closes odoo/odoo#83850

Related: odoo/enterprise#23938
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-02-02 19:50:49 +00:00
Christophe Monniez dc0baf4948 [IMP] payment*: implement _neutralize method
An overridable model method was added in a previous commit in order to
neutralize a database.

This commit introduce the implementation of this method for the payment
modules.

Also, a `_neutralize_fields` helper method is added on the
PaymentAcquirer model to simplify the neutralization of the various
payment modules.

Part-of: odoo/odoo#67825
2022-02-01 09:54:07 +00:00
Wolfgang Taferner e85c2041fd [FIX] payment: Chatter will not convert to breaks
As the message is thought to be posted in chatter replacing returns with html break.

closes odoo/odoo#81937

X-original-commit: 6cb616d74f71951b3989880ae232702d2257d292
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Signed-off-by: Wolfgang Taferner <w.taferner@wtioit.at>
2021-12-28 10:39:01 +00:00
Horacio Tellez 5badb3fca8 [IMP] payment(_*): normalize logs across all acquirers
The logs for payments contain the transaction reference whenever possible.
Before logs for transactions contained the reference or the id of the
transaction in an inconsitent way. No transactions are identified by
reference whenever possible.

The logs for payments for the same function on different acquirers should
have the same format. Same flow step for different acquirers had
information passed in different formats. Now at each step of a transaction
flow log messages have the same format regardless of the acquirer.

Overall the payment logs should have an uniform format. Hopefully
understanding log messages related to transactions should be easier, as
now log format is independent of the acquirer and transaction are easily
identified by reference.

Task - 2545450

closes odoo/odoo#79547

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2021-11-29 15:40:54 +00:00
Demesmaeker 11433284cf [FIX] payment_(adyen, authorize): fix traceback and tune the refund
- This replaces the name of `refund_amount` to `amount_to_refund`
for a variable that was renamed elsewhere, which caused a traceback.
- Adyen and authorized `_send_refund_request` now have their return,
as their parent.
- When a refund is initiated from Adyen, it's now easier to change
the merchant reference, thus, we can't count on it anymore to get
the source transaction.
- Fix the automatic refund for authorize.net with the manual capture

task-2634184

closes odoo/odoo#77916

X-original-commit: 747dbf44f37407fd415af645dac652199ac7fa6b
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2021-10-05 18:05:46 +00:00
Denis Ledoux d979f5970d [FIX] payment: compute methods shouldn't write
`compute` shouldn't write things. This means `writes` can occur
just by reading records.

Instead, when you want to assign multiple compute fields at once,
`update` should be used.

```
2021-10-04 12:42:21,132 61 ERROR db_40421 odoo.upgrade.base.tests.test_mock_crawl: FAIL: TestCrawler.test_check
Traceback (most recent call last):
  File "/tmp/tmpn37k1zm_/migrations/testing.py", line 208, in test_check
    self.check(value)
  File "/tmp/tmpn37k1zm_/migrations/base/tests/test_mock_crawl.py", line 85, in check
    self.assertFalse(diff, msg)
AssertionError: [('payment.payment_acquirer_menu', 217, 'Accounting > Configuration > Payments > Payment Acquirers', 312)] is not false : At least one menu or view working before upgrade is not working after upgrade.

('payment.payment_acquirer_menu', 217, 'Accounting > Configuration > Payments > Payment Acquirers', 312):
 Traceback (most recent call last):
   File "/home/odoo/src/odoo/15.0/odoo/api.py", line 879, in get
    return field_cache[record._ids[0]]
 KeyError: 8

During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "/home/odoo/src/odoo/15.0/odoo/fields.py", line 1057, in __get__
    value = env.cache.get(record, self)
   File "/home/odoo/src/odoo/15.0/odoo/api.py", line 882, in get
    raise CacheMiss(record, field)
 odoo.exceptions.CacheMiss: 'payment.acquirer(8,).show_credentials_page'

During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "/tmp/tmpn37k1zm_/migrations/base/tests/test_mock_crawl.py", line 182, in crawl_menu
    self.mock_action(action_vals)
   File "/tmp/tmpn37k1zm_/migrations/base/tests/test_mock_crawl.py", line 293, in mock_action
    mock_method(model, view, fields_list, domain, group_by)
   File "/tmp/tmpn37k1zm_/migrations/base/tests/test_mock_crawl.py", line 319, in mock_view_form
    [data] = record.read(fields_list)
   File "/home/odoo/src/odoo/15.0/odoo/models.py", line 3227, in read
    return self._read_format(fnames=fields, load=load)
   File "/home/odoo/src/odoo/15.0/odoo/models.py", line 3247, in _read_format
    vals[name] = convert(record[name], record, use_name_get)
   File "/home/odoo/src/odoo/15.0/odoo/models.py", line 5867, in __getitem__
    return self._fields[key].__get__(self, type(self))
   File "/home/odoo/src/odoo/15.0/odoo/fields.py", line 1106, in __get__
    self.compute_value(recs)
   File "/home/odoo/src/odoo/15.0/odoo/fields.py", line 1265, in compute_value
    records._compute_field_value(self)
   File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4249, in _compute_field_value
    getattr(self, field.compute)()
   File "/home/odoo/src/odoo/15.0/addons/payment_transfer/models/payment_acquirer.py", line 21, in _compute_view_configuration_fields
    super()._compute_view_configuration_fields()
   File "/home/odoo/src/odoo/15.0/addons/payment/models/payment_acquirer.py", line 168, in _compute_view_configuration_fields
    'show_cancel_msg': True,
   File "/home/odoo/src/odoo/15.0/addons/payment_transfer/models/payment_acquirer.py", line 41, in write
    res = super().write(values)
   File "/home/odoo/src/odoo/15.0/addons/payment/models/payment_acquirer.py", line 234, in write
    self._check_required_if_provider()
   File "/home/odoo/src/odoo/15.0/addons/payment/models/payment_acquirer.py", line 260, in _check_required_if_provider
    _("The following fields must be filled: %s", ", ".join(field_names))
 odoo.exceptions.ValidationError: The following fields must be filled: Email
```

upg-40421

closes odoo/odoo#77752

closes odoo/odoo#77827

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2021-10-05 12:36:04 +00:00
Olivier Dony 2cf2b8cb6f [FIX] payment: fix access error in tx processing
The `callback_hash` and `callback_is_done` fields are not accessible
for non-admin users, so it will cause an access error whenever trying
to verify the hash inside `_execute_callback()`, and when marking the
callback execution successful.

Accessing it as `sudo` like other restricted transaction fields solves
the problem, and is safe, as the value is never leaked outside the
function.

Introduced in 573ed74c12.

closes odoo/odoo#77737

X-original-commit: 743031ed400b26f05775fc01c04ff63ef597a723
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2021-10-04 15:31:27 +00:00
Demesmaeker e0233a1010 [IMP] payment(_adyen): allow to refund confirmed transactions
Before this commit, it was not possible to refund a payment from Odoo.
Users had to go through the payment acquirer's backend and update the
payment accordingly in Odoo.

With this commit, refunds are made available in Odoo directly from the
payment form, for acquirers that support them. Acquirer can either only
support full refunds or also support partial refunds.

As of now, the only acquirer allowing refunds is Adyen, with partial
refund support.

task-2527891

closes odoo/odoo#70881

Related: odoo/upgrade#2689
Related: odoo/enterprise#19829
Signed-off-by: Antoine Vandevenne (anv) <AntoineVDV@users.noreply.github.com>
2021-08-23 10:54:17 +00:00