- New 'pending' status allows tasks to be created without a schedule, acting as a queue for unscheduled work that gets assigned later - Pending group appears in the Delivery Map sidebar with amber color - Other modules can create tasks in pending state for scheduling - scheduled_date no longer required (null for pending tasks) - New Pending Tasks menu item under Field Service - Pending filter added to search view Co-authored-by: Cursor <cursoragent@cursor.com>
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import logging
|
|
|
|
from odoo import _, fields, models
|
|
from odoo.exceptions import ValidationError
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class PaymentToken(models.Model):
|
|
_inherit = 'payment.token'
|
|
|
|
poynt_card_id = fields.Char(
|
|
string="Poynt Card ID",
|
|
help="The unique card identifier stored on the Poynt platform.",
|
|
readonly=True,
|
|
)
|
|
|
|
def _poynt_validate_stored_card(self):
|
|
"""Validate that the stored card is still usable on Poynt.
|
|
|
|
Fetches the card details from Poynt to confirm the card ID is valid
|
|
and the card is still active.
|
|
|
|
:return: True if the card is valid.
|
|
:rtype: bool
|
|
:raises ValidationError: If the card cannot be validated.
|
|
"""
|
|
self.ensure_one()
|
|
|
|
if not self.poynt_card_id:
|
|
raise ValidationError(
|
|
_("No Poynt card ID found on this payment token.")
|
|
)
|
|
|
|
try:
|
|
result = self.provider_id._poynt_make_request(
|
|
'GET',
|
|
f'cards/{self.poynt_card_id}',
|
|
)
|
|
status = result.get('status', '')
|
|
if status != 'ACTIVE':
|
|
raise ValidationError(
|
|
_("The stored card is no longer active on Poynt (status: %(status)s).",
|
|
status=status)
|
|
)
|
|
return True
|
|
except ValidationError:
|
|
raise
|
|
except Exception as e:
|
|
_logger.warning("Failed to validate Poynt card %s: %s", self.poynt_card_id, e)
|
|
raise ValidationError(
|
|
_("Unable to validate the stored card with Poynt.")
|
|
)
|