Начальное наполнение

This commit is contained in:
parent 95f499c804
commit 8e6001b119
8 changed files with 139 additions and 0 deletions

4
__init__.py Normal file
View File

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models

18
__manifest__.py Normal file
View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'POS Restaurant Stripe',
'version': '1.0',
'category': 'Point of Sale',
'sequence': 6,
'summary': 'Adds American style tipping to Stripe',
'depends': ['pos_stripe', 'pos_restaurant', 'payment_stripe'],
'auto_install': True,
'assets': {
'point_of_sale._assets_pos': [
'pos_restaurant_stripe/static/**/*',
],
},
'license': 'LGPL-3',
}

View File

@ -0,0 +1,26 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_restaurant_stripe
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-26 21:55+0000\n"
"PO-Revision-Date: 2023-10-26 21:55+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_restaurant_stripe
#: model:ir.model,name:pos_restaurant_stripe.model_pos_order
msgid "Point of Sale Orders"
msgstr ""
#. module: pos_restaurant_stripe
#: model:ir.model,name:pos_restaurant_stripe.model_pos_payment
msgid "Point of Sale Payments"
msgstr ""

28
i18n/ru.po Normal file
View File

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_restaurant_stripe
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-26 21:55+0000\n"
"PO-Revision-Date: 2024-01-30 15:14+0400\n"
"Last-Translator: \n"
"Language-Team: Russian (https://app.transifex.com/odoo/teams/41243/ru/)\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"
#. module: pos_restaurant_stripe
#: model:ir.model,name:pos_restaurant_stripe.model_pos_order
msgid "Point of Sale Orders"
msgstr "Заказы в торговых точках"
#. module: pos_restaurant_stripe
#: model:ir.model,name:pos_restaurant_stripe.model_pos_payment
msgid "Point of Sale Payments"
msgstr "Платежи в точках продаж"

5
models/__init__.py Normal file
View File

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

17
models/pos_order.py Normal file
View File

@ -0,0 +1,17 @@
# 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 set_no_tip(self):
"""Capture the payment when no tip is set."""
res = super(PosOrder, self).set_no_tip()
for payment in self.payment_ids:
if payment.payment_method_id.use_payment_terminal == 'stripe':
payment.payment_method_id.stripe_capture_payment(payment.transaction_id)
return res

16
models/pos_payment.py Normal file
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 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 == 'stripe':
self.payment_method_id.stripe_capture_payment(self.transaction_id, amount=self.amount)
return res

View File

@ -0,0 +1,25 @@
/** @odoo-module */
import { PaymentStripe } from "@pos_stripe/app/payment_stripe";
import { patch } from "@web/core/utils/patch";
patch(PaymentStripe.prototype, {
async captureAfterPayment(processPayment, line) {
// Don't capture if the customer can tip, in that case we
// will capture later.
if (!this.canBeAdjusted(line.cid)) {
return super.captureAfterPayment(...arguments);
}
},
canBeAdjusted(cid) {
var order = this.pos.get_order();
var line = order.get_paymentline(cid);
return (
this.pos.config.set_tip_after_payment &&
line.payment_method.use_payment_terminal === "stripe" &&
line.card_type !== "interac" &&
!line.card_type.includes("eftpos")
);
},
});