mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[FIX] sale_payment_deposit: confirmation of orders stopped because transaction now validates amount
This commit is contained in:
committed by
Cedric Collins
parent
c821debd35
commit
d643b0abb1
@@ -1,3 +1,4 @@
|
|||||||
from . import account
|
from . import account
|
||||||
|
from . import payment
|
||||||
from . import sale
|
from . import sale
|
||||||
from . import sale_patch
|
from . import sale_patch
|
||||||
|
|||||||
33
sale_payment_deposit/models/payment.py
Normal file
33
sale_payment_deposit/models/payment.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
from odoo import models, _
|
||||||
|
|
||||||
|
import logging
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentTransaction(models.Model):
|
||||||
|
_inherit = 'payment.transaction'
|
||||||
|
|
||||||
|
# Override to confirm payments totaling the amount_total_deposit
|
||||||
|
def _check_amount_and_confirm_order(self):
|
||||||
|
self.ensure_one()
|
||||||
|
for order in self.sale_order_ids.filtered(lambda so: so.state in ('draft', 'sent')):
|
||||||
|
# default amount as originally calculated
|
||||||
|
amount = order.amount_total
|
||||||
|
if order.amount_total_deposit:
|
||||||
|
amount = order.amount_total_deposit
|
||||||
|
if order.currency_id.compare_amounts(self.amount, amount) == 0:
|
||||||
|
order.with_context(send_email=True).action_confirm()
|
||||||
|
else:
|
||||||
|
_logger.warning(
|
||||||
|
'<%s> transaction AMOUNT MISMATCH for order %s (ID %s): expected %r, got %r',
|
||||||
|
self.acquirer_id.provider,order.name, order.id,
|
||||||
|
amount, self.amount,
|
||||||
|
)
|
||||||
|
order.message_post(
|
||||||
|
subject=_("Amount Mismatch (%s)") % self.acquirer_id.provider,
|
||||||
|
body=_("The order was not confirmed despite response from the acquirer (%s): order total is %r but acquirer replied with %r.") % (
|
||||||
|
self.acquirer_id.provider,
|
||||||
|
amount,
|
||||||
|
self.amount,
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -7,7 +7,7 @@ class SaleOrder(models.Model):
|
|||||||
|
|
||||||
amount_total_deposit = fields.Monetary(string='Deposit', compute='_amount_total_deposit')
|
amount_total_deposit = fields.Monetary(string='Deposit', compute='_amount_total_deposit')
|
||||||
|
|
||||||
@api.depends('amount_total', 'payment_term_id.deposit_percentage')
|
@api.depends('amount_total', 'payment_term_id.deposit_percentage', 'payment_term_id.deposit_flat')
|
||||||
def _amount_total_deposit(self):
|
def _amount_total_deposit(self):
|
||||||
for order in self:
|
for order in self:
|
||||||
percent_deposit = order.amount_total * float(order.payment_term_id.deposit_percentage) / 100.0
|
percent_deposit = order.amount_total * float(order.payment_term_id.deposit_percentage) / 100.0
|
||||||
|
|||||||
Reference in New Issue
Block a user