Initial commit: Pos packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:50 +02:00
commit 95dfb9edb0
1301 changed files with 264148 additions and 0 deletions

View file

@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import pos_order
from . import pos_payment
from . import pos_payment_method
from . import pos_session

View file

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class PosOrder(models.Model):
_inherit = 'pos.order'
def action_pos_order_paid(self):
res = super(PosOrder, self).action_pos_order_paid()
if not self.config_id.set_tip_after_payment:
payment_lines = self.payment_ids.filtered(lambda line: line.payment_method_id.use_payment_terminal == 'adyen')
for payment_line in payment_lines:
payment_line._adyen_capture()
return res

View file

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import json
import requests
from odoo import models
TIMEOUT = 10
class PosPayment(models.Model):
_inherit = 'pos.payment'
def _update_payment_line_for_tip(self, tip_amount):
"""Capture the payment when a tip is set."""
res = super(PosPayment, self)._update_payment_line_for_tip(tip_amount)
if self.payment_method_id.use_payment_terminal == 'adyen':
self._adyen_capture()
return res
def _adyen_capture(self):
data = {
'originalReference': self.transaction_id,
'modificationAmount': {
'value': int(self.amount * 10**self.currency_id.decimal_places),
'currency': self.currency_id.name,
},
'merchantAccount': self.payment_method_id.adyen_merchant_account,
}
return self.payment_method_id.proxy_adyen_request(data, 'capture')

View file

@ -0,0 +1,17 @@
# coding: utf-8
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class PosPaymentMethod(models.Model):
_inherit = 'pos.payment.method'
adyen_merchant_account = fields.Char(help='The POS merchant account code used in Adyen')
def _get_adyen_endpoints(self):
return {
**super(PosPaymentMethod, self)._get_adyen_endpoints(),
'adjust': 'https://pal-%s.adyen.com/pal/servlet/Payment/v52/adjustAuthorisation',
'capture': 'https://pal-%s.adyen.com/pal/servlet/Payment/v52/capture',
}

View file

@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class PosSession(models.Model):
_inherit = 'pos.session'
def _loader_params_pos_payment_method(self):
result = super()._loader_params_pos_payment_method()
result['search_params']['fields'].append('adyen_merchant_account')
return result