Initial commit: OCA Technical packages (595 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:03 +02:00
commit 2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions

View file

@ -0,0 +1,46 @@
# Pos Loyalty Redeem Payment
Odoo addon: pos_loyalty_redeem_payment
## Installation
```bash
pip install odoo-bringout-oca-pos-pos_loyalty_redeem_payment
```
## Dependencies
This addon depends on:
- pos_loyalty
## Manifest Information
- **Name**: Pos Loyalty Redeem Payment
- **Version**: 16.0.1.0.2
- **Category**: Point Of Sale & Sales
- **License**: LGPL-3
- **Installable**: True
## Source
Based on [OCA/pos](https://github.com/OCA/pos) branch 16.0, addon `pos_loyalty_redeem_payment`.
## License
This package maintains the original LGPL-3 license from the upstream Odoo project.
## Documentation
- Overview: doc/OVERVIEW.md
- Architecture: doc/ARCHITECTURE.md
- Models: doc/MODELS.md
- Controllers: doc/CONTROLLERS.md
- Wizards: doc/WIZARDS.md
- Reports: doc/REPORTS.md
- Security: doc/SECURITY.md
- Install: doc/INSTALL.md
- Usage: doc/USAGE.md
- Configuration: doc/CONFIGURATION.md
- Dependencies: doc/DEPENDENCIES.md
- Troubleshooting: doc/TROUBLESHOOTING.md
- FAQ: doc/FAQ.md

View file

@ -0,0 +1,32 @@
# Architecture
```mermaid
flowchart TD
U[Users] -->|HTTP| V[Views and QWeb Templates]
V --> C[Controllers]
V --> W[Wizards Transient Models]
C --> M[Models and ORM]
W --> M
M --> R[Reports]
DX[Data XML] --> M
S[Security ACLs and Groups] -. enforces .-> M
subgraph Pos_loyalty_redeem_payment Module - pos_loyalty_redeem_payment
direction LR
M:::layer
W:::layer
C:::layer
V:::layer
R:::layer
S:::layer
DX:::layer
end
classDef layer fill:#eef8ff,stroke:#6ea8fe,stroke-width:1px
```
Notes
- Views include tree/form/kanban templates and report templates.
- Controllers provide website/portal routes when present.
- Wizards are UI flows implemented with `models.TransientModel`.
- Data XML loads data/demo records; Security defines groups and access.

View file

@ -0,0 +1,3 @@
# Configuration
Refer to Odoo settings for pos_loyalty_redeem_payment. Configure related models, access rights, and options as needed.

View file

@ -0,0 +1,3 @@
# Controllers
This module does not define custom HTTP controllers.

View file

@ -0,0 +1,5 @@
# Dependencies
This addon depends on:
- [pos_loyalty](../../odoo-bringout-oca-ocb-pos_loyalty)

View file

@ -0,0 +1,4 @@
# FAQ
- Q: Which Odoo version? A: 16.0 (OCA/OCB packaged).
- Q: How to enable? A: Start server with --addon pos_loyalty_redeem_payment or install in UI.

View file

@ -0,0 +1,7 @@
# Install
```bash
pip install odoo-bringout-oca-pos-pos_loyalty_redeem_payment"
# or
uv pip install odoo-bringout-oca-pos-pos_loyalty_redeem_payment"
```

View file

@ -0,0 +1,17 @@
# Models
Detected core models and extensions in pos_loyalty_redeem_payment.
```mermaid
classDiagram
class loyalty_program
class pos_config
class pos_order
class pos_payment
class pos_payment_method
class pos_session
```
Notes
- Classes show model technical names; fields omitted for brevity.
- Items listed under _inherit are extensions of existing models.

View file

@ -0,0 +1,6 @@
# Overview
Packaged Odoo addon: pos_loyalty_redeem_payment. Provides features documented in upstream Odoo 16 under this addon.
- Source: OCA/OCB 16.0, addon pos_loyalty_redeem_payment
- License: LGPL-3

View file

@ -0,0 +1,3 @@
# Reports
This module does not define custom reports.

View file

@ -0,0 +1,8 @@
# Security
This module does not define custom security rules or access controls beyond Odoo defaults.
Default Odoo security applies:
- Base user access through standard groups
- Model access inherited from dependencies
- No custom row-level security rules

View file

@ -0,0 +1,5 @@
# Troubleshooting
- Ensure Python and Odoo environment matches repo guidance.
- Check database connectivity and logs if startup fails.
- Validate that dependent addons listed in DEPENDENCIES.md are installed.

View file

@ -0,0 +1,7 @@
# Usage
Start Odoo including this addon (from repo root):
```bash
python3 scripts/nix_odoo_web_server.py --db-name mydb --addon pos_loyalty_redeem_payment
```

View file

@ -0,0 +1,3 @@
# Wizards
This module does not include UI wizards.

View file

@ -0,0 +1,135 @@
==========================
Pos Loyalty Redeem Payment
==========================
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a4c88b98735f3e452ef23d87528408015c2016b54798037fcdcfd1a026369681
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
:target: https://github.com/OCA/pos/tree/16.0/pos_loyalty_redeem_payment
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_loyalty_redeem_payment
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This module allows gift cards to be applied as a payment method when customer
uses it. Provides the necessary flexibility to accomplish with `European
Regulations <https://eur-lex.europa.eu/eli/dir/2016/1065/oj>`_ (Council
Directive (EU) 2016/1065 of 27 June 2016 amending Directive 2006/112/EC).
**Table of contents**
.. contents::
:local:
Configuration
=============
To allow a loyalty program of type *Gift Card* to be redeemed as a payment
method, first select *Payment Method* as *Redemption Method*:
.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/redeemMethod.png
:width: 300
:alt: Configure a loyalty program to be redeemed as payments
Then, choose those *POS Payment Methods* that will be used to redeem cards:
.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/paymentMethod.png
:width: 300
:alt: Select payment methods to be used for card redeeming
On selected payment methods, field *Used for loyalty program* has to be checked:
.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/paymentMethodCheck.png
:width: 300
:alt: Payment method used for loyalty program
Usage
=====
In the payment screen of PoS interface, after selecting configured payment
method a popup requests loyalty card code:
.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/usage_1_code_popup.png
:width: 300
:alt: config
After entering card code, a new popup asks user to introduce amount to redeem:
.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/usage_2_amount_popup.png
:width: 300
:alt: config
A new payment line is added with selected amount:
.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/usage_3_payment_line.png
:width: 300
:alt: config
After order is completed, loyalty card report is downloaded with updated
points.
Known issues / Roadmap
======================
* Make popup used for redeeming compatible with Mozilla Firefox. Currently CSS
rules are not applied correctly to it with this navigator
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_loyalty_redeem_payment%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* FactorLibre
Contributors
~~~~~~~~~~~~
* Juan Carlos Bonilla <juancarlos.bonilla@factorlibre.com>
* Pablo De Andrés <pablo.deandres@factorlibre.com>
* Daniel Duque <daniel.duque@factorlibre.com>
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/16.0/pos_loyalty_redeem_payment>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View file

@ -0,0 +1 @@
from . import models

View file

@ -0,0 +1,28 @@
{
"name": "Pos Loyalty Redeem Payment",
"summary": "Use vouchers as payment method in pos orders",
"category": "Point Of Sale & Sales",
"version": "16.0.1.0.2",
"website": "https://github.com/OCA/pos",
"author": "Odoo Community Association (OCA), FactorLibre",
"application": False,
"depends": [
"pos_loyalty",
],
"data": [
"views/pos_payment_method_views.xml",
"views/loyalty_program_views.xml",
],
"assets": {
"point_of_sale.assets": [
"pos_loyalty_redeem_payment/static/src/js/**/*",
"pos_loyalty_redeem_payment/static/src/xml/**/*",
"pos_loyalty_redeem_payment/static/src/scss/responsive_number_popup.scss",
],
"web.assets_tests": [
"pos_loyalty_redeem_payment/static/tests/tours/**/*",
],
},
"installable": True,
"license": "LGPL-3",
}

View file

@ -0,0 +1,160 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_loyalty_redeem_payment
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \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_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment__coupon_id
msgid "Coupon"
msgstr "Kupon"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields.selection,name:pos_loyalty_redeem_payment.selection__loyalty_program__redeem_method__discount
msgid "Discount"
msgstr "Popust"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Enter Code"
msgstr "Enter Code"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Error"
msgstr "Greška"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Gift Card"
msgstr "Gift Card"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_pos_payment_method__used_for_loyalty_program
msgid "In PoS interface, this method allows to redeem a gift card."
msgstr "In PoS interface, this method allows to redeem a gift card."
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_loyalty_program
msgid "Loyalty Program"
msgstr "Program lojalnosti"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_loyalty_program__pos_payment_method_ids
msgid "POS Payment Methods"
msgstr "POS Payment Methods"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields.selection,name:pos_loyalty_redeem_payment.selection__loyalty_program__redeem_method__payment_method
msgid "Payment Method"
msgstr "Metoda plaćanja"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_loyalty_program__redeem_method
msgid ""
"Payment Method: The Voucher/Gift Card is used as a payment method in PoS orders.\n"
"Discount: The Voucher/Gift Card is used as a discount."
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_loyalty_program__pos_payment_method_ids
msgid "Payment methods that can be used to redeem coupons of this program."
msgstr "Payment methods that can be used to redeem coupons of this program."
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Postavke prodajnog mjesta"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_order
msgid "Point of Sale Orders"
msgstr "Narudžbe POS-a"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_payment_method
msgid "Point of Sale Payment Methods"
msgstr "Načini plaćanja na prodajnom mjestu"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_payment
msgid "Point of Sale Payments"
msgstr "Plaćanja na prodajnom mjestu"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_session
msgid "Point of Sale Session"
msgstr "Sesija POS-a"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment_method__program_id
msgid "Program"
msgstr "Program"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_loyalty_program__redeem_method
msgid "Redemption Method"
msgstr "Redemption Method"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Set amount to redeem, up to %s"
msgstr "Set amount to redeem, up to %s"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid ""
"That coupon code has already been scanned and activated. Please, process "
"pending orders."
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_pos_payment__coupon_id
msgid "The coupon used as payment method."
msgstr "The coupon used as payment method."
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "There is already an electronic payment in progress."
msgstr "Već je u tijeku elektroničko plaćanje."
#. module: pos_loyalty_redeem_payment
#. odoo-python
#: code:addons/pos_loyalty_redeem_payment/models/pos_config.py:0
#, python-format
msgid "This coupon has to be redeemed from payment mode (%s)."
msgstr "This coupon has to be redeemed from payment mode (%s)."
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment_method__used_for_loyalty_program
msgid "Used for loyalty program"
msgstr "Used for loyalty program"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid ""
"You tried to redeem %s, but maximum for this gift card in this order is %s"
msgstr ""

View file

@ -0,0 +1,188 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_loyalty_redeem_payment
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-18 15:59+0000\n"
"PO-Revision-Date: 2023-08-22 18:15+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment__coupon_id
msgid "Coupon"
msgstr "Cupón"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields.selection,name:pos_loyalty_redeem_payment.selection__loyalty_program__redeem_method__discount
msgid "Discount"
msgstr "Descuento"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Enter Code"
msgstr "Ingresar código"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Error"
msgstr "Error"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Gift Card"
msgstr "Tarjeta regalo"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_pos_payment_method__used_for_loyalty_program
msgid "In PoS interface, this method allows to redeem a gift card."
msgstr "En la interfaz PoS, este método permite canjear una tarjeta regalo."
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_loyalty_program
msgid "Loyalty Program"
msgstr "Programa de Lealtad"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_loyalty_program__pos_payment_method_ids
msgid "POS Payment Methods"
msgstr "Métodos de pago"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields.selection,name:pos_loyalty_redeem_payment.selection__loyalty_program__redeem_method__payment_method
msgid "Payment Method"
msgstr "Método de pago"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_loyalty_program__redeem_method
msgid ""
"Payment Method: The Voucher/Gift Card is used as a payment method in PoS "
"orders.\n"
"Discount: The Voucher/Gift Card is used as a discount."
msgstr ""
"Método de pago: el vale o tarjeta regalo se usa como método de pago en "
"pedidos TPV.\n"
"Descuento: el vale o tarjeta regalo se usa como descuento en pedidos TPV."
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_loyalty_program__pos_payment_method_ids
msgid "Payment methods that can be used to redeem coupons of this program."
msgstr ""
"Métodos de pago que pueden ser utilizados para canjear cupones de este "
"programa."
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Configuración del TPV"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_order
msgid "Point of Sale Orders"
msgstr "Pedidos en el punto de venta"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_payment_method
msgid "Point of Sale Payment Methods"
msgstr "Métodos de pago en el punto de venta"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_payment
msgid "Point of Sale Payments"
msgstr "Pagos en el punto de venta"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_session
msgid "Point of Sale Session"
msgstr "Sesión TPV"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment_method__program_id
msgid "Program"
msgstr "Programa"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_loyalty_program__redeem_method
msgid "Redemption Method"
msgstr "Método de canje"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Set amount to redeem, up to %s"
msgstr "Establece el importe a redimir, hasta %s"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid ""
"That coupon code has already been scanned and activated. Please, process "
"pending orders."
msgstr ""
"El código ha sido escaneado y activado. Por favor, procese las órdenes "
"pendientes."
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_pos_payment__coupon_id
msgid "The coupon used as payment method."
msgstr "El cupón usado como método de pago."
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "There is already an electronic payment in progress."
msgstr "Hay un pago electrónico en progreso."
#. module: pos_loyalty_redeem_payment
#. odoo-python
#: code:addons/pos_loyalty_redeem_payment/models/pos_config.py:0
#, python-format
msgid "This coupon has to be redeemed from payment mode (%s)."
msgstr "Este cupón tiene que ser redimido desde modos de pago (%s)."
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment_method__used_for_loyalty_program
msgid "Used for loyalty program"
msgstr "Utilizado para programas de fidelización"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid ""
"You tried to redeem %s, but maximum for this gift card in this order is %s"
msgstr ""
"Has intentado redimir %s, pero el máximo para esta tarjeta regalo en este "
"pedido es %s"
#~ msgid "Coupon ({}) must be redeemed from 'Insert Code' of product screen."
#~ msgstr ""
#~ "El cupón ({}) debe ser canjeado desde 'Insertar Código' de la pantalla de "
#~ "productos."
#~ msgid "Voucher"
#~ msgstr "Vale"
#~ msgid "Voucher or Gift Card"
#~ msgstr "Vale o tarjeta regalo"
#~ msgid "Vouchers"
#~ msgstr "Vales"

View file

@ -0,0 +1,176 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_loyalty_redeem_payment
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-11-10 12:38+0000\n"
"Last-Translator: LESTRAT21 <elodie@comptoirdecampagne.fr>\n"
"Language-Team: none\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment__coupon_id
msgid "Coupon"
msgstr "Coupon"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields.selection,name:pos_loyalty_redeem_payment.selection__loyalty_program__redeem_method__discount
msgid "Discount"
msgstr "Réduction"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Enter Code"
msgstr "Saisir le code"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Error"
msgstr "Erreur"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Gift Card"
msgstr "Carte cadeau"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_pos_payment_method__used_for_loyalty_program
#, fuzzy
msgid "In PoS interface, this method allows to redeem a gift card."
msgstr "Cette méthode va permettre d'utiliser une carte cadeau en caisse."
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_loyalty_program
msgid "Loyalty Program"
msgstr "Programme de fidélité"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_loyalty_program__pos_payment_method_ids
msgid "POS Payment Methods"
msgstr "Moyens de paiement en caisse"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields.selection,name:pos_loyalty_redeem_payment.selection__loyalty_program__redeem_method__payment_method
msgid "Payment Method"
msgstr "Moyen de paiement"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_loyalty_program__redeem_method
msgid ""
"Payment Method: The Voucher/Gift Card is used as a payment method in PoS orders.\n"
"Discount: The Voucher/Gift Card is used as a discount."
msgstr ""
"Moyen de paiement : la carte cadeau (ou le coupon) sera utilisé(e) comme "
"moyen de paiement en caisse.\n"
"Réduction : la carte cadeau (ou le coupon) applique une réduction en caisse."
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_loyalty_program__pos_payment_method_ids
#, fuzzy
msgid "Payment methods that can be used to redeem coupons of this program."
msgstr ""
"Moyens de paiement pouvant être utilisés pour utiliser des coupons de ce "
"programme."
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Configuration de la caisse"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_order
msgid "Point of Sale Orders"
msgstr "Tickets de caisse"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_payment_method
msgid "Point of Sale Payment Methods"
msgstr "Moyens de paiement de la caisse"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_payment
msgid "Point of Sale Payments"
msgstr "Paiements en caisse"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_session
msgid "Point of Sale Session"
msgstr "Session de caisse"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment_method__program_id
msgid "Program"
msgstr "Programme"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_loyalty_program__redeem_method
#, fuzzy
msgid "Redemption Method"
msgstr "Méthode d'utilisation de la carte ou du coupon"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, fuzzy, python-format
msgid "Set amount to redeem, up to %s"
msgstr ""
"Saisir le montant à utiliser sur la carte ou le coupon, dans le maximum de "
"%s."
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, fuzzy, python-format
msgid ""
"That coupon code has already been scanned and activated. Please, process "
"pending orders."
msgstr ""
"Ce coupon a déjà été scanné et activé. Vous pouvez l'utiliser en caisse."
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_pos_payment__coupon_id
msgid "The coupon used as payment method."
msgstr "Ce coupon est un moyen de paiement."
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "There is already an electronic payment in progress."
msgstr "Un paiement électronique est déjà en cours."
#. module: pos_loyalty_redeem_payment
#. odoo-python
#: code:addons/pos_loyalty_redeem_payment/models/pos_config.py:0
#, fuzzy, python-format
msgid "This coupon has to be redeemed from payment mode (%s)."
msgstr "Ce coupon doit être échangé à partir du mode de paiement (%s)"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment_method__used_for_loyalty_program
msgid "Used for loyalty program"
msgstr "Utilisable avec un programme de fidélité"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, fuzzy, python-format
msgid ""
"You tried to redeem %s, but maximum for this gift card in this order is %s"
msgstr ""
"Vous essayez d'utiliser %s, mais le maximum utilisable sur cette carte "
"cadeau est %s."

View file

@ -0,0 +1,174 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_loyalty_redeem_payment
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-07-03 16:08+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment__coupon_id
msgid "Coupon"
msgstr "Buono sconto"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields.selection,name:pos_loyalty_redeem_payment.selection__loyalty_program__redeem_method__discount
msgid "Discount"
msgstr "Sconto"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Enter Code"
msgstr "Inserire codice"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Error"
msgstr "Errore"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Gift Card"
msgstr "Buono regalo"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_pos_payment_method__used_for_loyalty_program
msgid "In PoS interface, this method allows to redeem a gift card."
msgstr ""
"Nell'interfaccia POS, questo metodo consente di utilizzare una buono regalo."
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_loyalty_program
msgid "Loyalty Program"
msgstr "Programma fedeltà"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_loyalty_program__pos_payment_method_ids
msgid "POS Payment Methods"
msgstr "Metodi di pagamento POS"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields.selection,name:pos_loyalty_redeem_payment.selection__loyalty_program__redeem_method__payment_method
msgid "Payment Method"
msgstr "Metodo di pagamento"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_loyalty_program__redeem_method
msgid ""
"Payment Method: The Voucher/Gift Card is used as a payment method in PoS "
"orders.\n"
"Discount: The Voucher/Gift Card is used as a discount."
msgstr ""
"Metodo di pagamento: il voucher/buono regalo è utilizzato come pagamento "
"negli ordini POS.\n"
"Sconto: il voucher/bono regalo è utilizzato come sconto."
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_loyalty_program__pos_payment_method_ids
msgid "Payment methods that can be used to redeem coupons of this program."
msgstr ""
"Metodi di pagamento che possono essere usati per utilizzare i buoni di "
"questo programma."
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Configurazione punto vendita"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_order
msgid "Point of Sale Orders"
msgstr "Ordini punto vendita"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_payment_method
msgid "Point of Sale Payment Methods"
msgstr "Metodi di pagamento punto vendita"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_payment
msgid "Point of Sale Payments"
msgstr "Pagamenti punto vendita"
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_session
msgid "Point of Sale Session"
msgstr "Sessione punto vendita"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment_method__program_id
msgid "Program"
msgstr "Programma"
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_loyalty_program__redeem_method
msgid "Redemption Method"
msgstr "Metodo riscatto"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Set amount to redeem, up to %s"
msgstr "Impostare valore da riscattare, fino a %s"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid ""
"That coupon code has already been scanned and activated. Please, process "
"pending orders."
msgstr ""
"Questo codice sconto è già stato letto e attivato. Elaborare gli ordini in "
"attesa."
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_pos_payment__coupon_id
msgid "The coupon used as payment method."
msgstr "Il buono utilizzato come metodo di pagamento."
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "There is already an electronic payment in progress."
msgstr "Esiste già un pagamento elettronico in corso."
#. module: pos_loyalty_redeem_payment
#. odoo-python
#: code:addons/pos_loyalty_redeem_payment/models/pos_config.py:0
#, python-format
msgid "This coupon has to be redeemed from payment mode (%s)."
msgstr "Questo buono deve essere riscosso dal metodo di pagamento (%s)."
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment_method__used_for_loyalty_program
msgid "Used for loyalty program"
msgstr "Utilizzato per il programma fedeltà"
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid ""
"You tried to redeem %s, but maximum for this gift card in this order is %s"
msgstr ""
"Si è cercato di riscattare %s, ma il massimo per questo buono regalo in "
"questo ordine è %s"

View file

@ -0,0 +1,160 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_loyalty_redeem_payment
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \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_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment__coupon_id
msgid "Coupon"
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields.selection,name:pos_loyalty_redeem_payment.selection__loyalty_program__redeem_method__discount
msgid "Discount"
msgstr ""
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Enter Code"
msgstr ""
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Error"
msgstr ""
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Gift Card"
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_pos_payment_method__used_for_loyalty_program
msgid "In PoS interface, this method allows to redeem a gift card."
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_loyalty_program
msgid "Loyalty Program"
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_loyalty_program__pos_payment_method_ids
msgid "POS Payment Methods"
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields.selection,name:pos_loyalty_redeem_payment.selection__loyalty_program__redeem_method__payment_method
msgid "Payment Method"
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_loyalty_program__redeem_method
msgid ""
"Payment Method: The Voucher/Gift Card is used as a payment method in PoS orders.\n"
"Discount: The Voucher/Gift Card is used as a discount."
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_loyalty_program__pos_payment_method_ids
msgid "Payment methods that can be used to redeem coupons of this program."
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_config
msgid "Point of Sale Configuration"
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_order
msgid "Point of Sale Orders"
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_payment_method
msgid "Point of Sale Payment Methods"
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_payment
msgid "Point of Sale Payments"
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model,name:pos_loyalty_redeem_payment.model_pos_session
msgid "Point of Sale Session"
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment_method__program_id
msgid "Program"
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_loyalty_program__redeem_method
msgid "Redemption Method"
msgstr ""
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "Set amount to redeem, up to %s"
msgstr ""
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid ""
"That coupon code has already been scanned and activated. Please, process "
"pending orders."
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,help:pos_loyalty_redeem_payment.field_pos_payment__coupon_id
msgid "The coupon used as payment method."
msgstr ""
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid "There is already an electronic payment in progress."
msgstr ""
#. module: pos_loyalty_redeem_payment
#. odoo-python
#: code:addons/pos_loyalty_redeem_payment/models/pos_config.py:0
#, python-format
msgid "This coupon has to be redeemed from payment mode (%s)."
msgstr ""
#. module: pos_loyalty_redeem_payment
#: model:ir.model.fields,field_description:pos_loyalty_redeem_payment.field_pos_payment_method__used_for_loyalty_program
msgid "Used for loyalty program"
msgstr ""
#. module: pos_loyalty_redeem_payment
#. odoo-javascript
#: code:addons/pos_loyalty_redeem_payment/static/src/js/PaymentScreen.esm.js:0
#, python-format
msgid ""
"You tried to redeem %s, but maximum for this gift card in this order is %s"
msgstr ""

View file

@ -0,0 +1,6 @@
from . import pos_payment_method
from . import pos_config
from . import pos_session
from . import pos_order
from . import loyalty_program
from . import pos_payment

View file

@ -0,0 +1,26 @@
from odoo import Command, fields, models
class LoyaltyProgram(models.Model):
_inherit = "loyalty.program"
redeem_method = fields.Selection(
[("discount", "Discount"), ("payment_method", "Payment Method")],
"Redemption Method",
required=True,
default="discount",
help=""
"Payment Method: The Voucher/Gift Card is used as a payment method in PoS orders.\n"
"Discount: The Voucher/Gift Card is used as a discount.",
)
pos_payment_method_ids = fields.One2many(
"pos.payment.method",
"program_id",
"POS Payment Methods",
help="Payment methods that can be used to redeem coupons of this program.",
)
def write(self, vals):
if vals.get("redeem_method") == "discount":
vals["pos_payment_method_ids"] = [Command.set([])]
return super().write(vals)

View file

@ -0,0 +1,44 @@
from odoo import _, models
class PosConfig(models.Model):
_inherit = "pos.config"
def _get_program_ids(self):
ret = super()._get_program_ids()
if self.env.context.get("payment_method_id"):
return self.env["loyalty.program"].search(
[
("id", "in", ret.ids),
("program_type", "=", "gift_card"),
("redeem_method", "=", "payment_method"),
(
"pos_payment_method_ids",
"in",
self.env.context.get("payment_method_id"),
),
]
)
return ret
def use_coupon_code(self, code, *args):
ret = super().use_coupon_code(code, *args)
if self.env.context.get("payment_method_id"):
return ret
program_id = ret.get("payload", {}).get("program_id")
if not program_id:
return ret
program = self.env["loyalty.program"].browse(program_id)
if (
program.program_type == "gift_card"
and program.redeem_method == "payment_method"
):
return {
"successful": False,
"payload": {
"error_message": _(
"This coupon has to be redeemed from payment mode (%s).", code
),
},
}
return ret

View file

@ -0,0 +1,72 @@
from collections import defaultdict
from odoo import api, models
class PosOrder(models.Model):
_inherit = "pos.order"
@api.model
def _payment_fields(self, order, ui_paymentline):
fields = super()._payment_fields(order, ui_paymentline)
if not ui_paymentline.get("coupon_data"):
return fields
coupon_id = ui_paymentline.get("coupon_data").get("coupon", {}).get("coupon_id")
fields.update({"coupon_id": coupon_id})
return fields
def apply_redeem_amount(self, coupons_data):
for coupon_id, amount in coupons_data.items():
card = self.env["loyalty.card"].browse(coupon_id)
if card:
card.points -= amount
def retrieve_coupon_data(self, order):
payments = [
payment[2] for payment in order.get("data", {}).get("statement_ids", {})
]
coupons_data = {
e.get("coupon").get("coupon_id"): e.get("amount")
for e in list(map(lambda x: x.get("coupon_data"), payments))
if e
}
return coupons_data
@api.model
def _process_order(self, order, draft, existing_order):
order_id = super()._process_order(order, draft, existing_order)
order_db = self.browse(order_id)
is_loyalty = order_db.payment_ids.filtered(
lambda x: x.payment_method_id.used_for_loyalty_program
)
if order and order_db.amount_total > 0 and is_loyalty:
data = self.retrieve_coupon_data(order)
self.apply_redeem_amount(data)
return order_id
@api.model
def get_loy_card_reports_from_order(self, order_ids):
coupons = (
self.env["pos.order"].browse(order_ids).mapped("payment_ids.coupon_id")
)
if not coupons:
return False
report_per_program = {}
coupon_per_report = defaultdict(list)
for coupon in coupons:
trigger = "create"
if coupon.points == 0:
trigger = "points_reach"
if (
coupon.program_id not in report_per_program
or not report_per_program[coupon.program_id]
):
report_per_program[
coupon.program_id
] = coupon.program_id.communication_plan_ids.filtered(
lambda c, trig=trigger: c.trigger == trig
).pos_report_print_id
for report in report_per_program[coupon.program_id]:
coupon_per_report[report.id].append(coupon.id)
return {"coupon_report": coupon_per_report}

View file

@ -0,0 +1,17 @@
from odoo import fields, models
class PosPayment(models.Model):
_inherit = "pos.payment"
coupon_id = fields.Many2one(
"loyalty.card",
"Coupon",
ondelete="restrict",
help="The coupon used as payment method.",
)
def _export_for_ui(self, payment):
result = super()._export_for_ui(payment)
result["code"] = payment.coupon_id.code
return result

View file

@ -0,0 +1,11 @@
from odoo import fields, models
class PosPaymentMethod(models.Model):
_inherit = "pos.payment.method"
used_for_loyalty_program = fields.Boolean(
string="Used for loyalty program",
help="In PoS interface, this method allows to redeem a gift card.",
)
program_id = fields.Many2one("loyalty.program")

View file

@ -0,0 +1,10 @@
from odoo import models
class PosPaymentMethod(models.Model):
_inherit = "pos.session"
def _loader_params_pos_payment_method(self):
result = super()._loader_params_pos_payment_method()
result["search_params"]["fields"].extend(["used_for_loyalty_program"])
return result

View file

@ -0,0 +1,18 @@
To allow a loyalty program of type *Gift Card* to be redeemed as a payment
method, first select *Payment Method* as *Redemption Method*:
.. image:: ../static/img/redeemMethod.png
:width: 300
:alt: Configure a loyalty program to be redeemed as payments
Then, choose those *POS Payment Methods* that will be used to redeem cards:
.. image:: ../static/img/paymentMethod.png
:width: 300
:alt: Select payment methods to be used for card redeeming
On selected payment methods, field *Used for loyalty program* has to be checked:
.. image:: ../static/img/paymentMethodCheck.png
:width: 300
:alt: Payment method used for loyalty program

View file

@ -0,0 +1,3 @@
* Juan Carlos Bonilla <juancarlos.bonilla@factorlibre.com>
* Pablo De Andrés <pablo.deandres@factorlibre.com>
* Daniel Duque <daniel.duque@factorlibre.com>

View file

@ -0,0 +1,4 @@
This module allows gift cards to be applied as a payment method when customer
uses it. Provides the necessary flexibility to accomplish with `European
Regulations <https://eur-lex.europa.eu/eli/dir/2016/1065/oj>`_ (Council
Directive (EU) 2016/1065 of 27 June 2016 amending Directive 2006/112/EC).

View file

@ -0,0 +1,2 @@
* Make popup used for redeeming compatible with Mozilla Firefox. Currently CSS
rules are not applied correctly to it with this navigator

View file

@ -0,0 +1,22 @@
In the payment screen of PoS interface, after selecting configured payment
method a popup requests loyalty card code:
.. image:: ../static/img/usage_1_code_popup.png
:width: 300
:alt: config
After entering card code, a new popup asks user to introduce amount to redeem:
.. image:: ../static/img/usage_2_amount_popup.png
:width: 300
:alt: config
A new payment line is added with selected amount:
.. image:: ../static/img/usage_3_payment_line.png
:width: 300
:alt: config
After order is completed, loyalty card report is downloaded with updated
points.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -0,0 +1,457 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Pos Loyalty Redeem Payment</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="pos-loyalty-redeem-payment">
<h1 class="title">Pos Loyalty Redeem Payment</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a4c88b98735f3e452ef23d87528408015c2016b54798037fcdcfd1a026369681
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pos/tree/16.0/pos_loyalty_redeem_payment"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_loyalty_redeem_payment"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pos&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows gift cards to be applied as a payment method when customer
uses it. Provides the necessary flexibility to accomplish with <a class="reference external" href="https://eur-lex.europa.eu/eli/dir/2016/1065/oj">European
Regulations</a> (Council
Directive (EU) 2016/1065 of 27 June 2016 amending Directive 2006/112/EC).</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>To allow a loyalty program of type <em>Gift Card</em> to be redeemed as a payment
method, first select <em>Payment Method</em> as <em>Redemption Method</em>:</p>
<img alt="Configure a loyalty program to be redeemed as payments" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/redeemMethod.png" style="width: 300px;" />
<p>Then, choose those <em>POS Payment Methods</em> that will be used to redeem cards:</p>
<img alt="Select payment methods to be used for card redeeming" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/paymentMethod.png" style="width: 300px;" />
<p>On selected payment methods, field <em>Used for loyalty program</em> has to be checked:</p>
<img alt="Payment method used for loyalty program" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/paymentMethodCheck.png" style="width: 300px;" />
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<p>In the payment screen of PoS interface, after selecting configured payment
method a popup requests loyalty card code:</p>
<img alt="config" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/usage_1_code_popup.png" style="width: 300px;" />
<p>After entering card code, a new popup asks user to introduce amount to redeem:</p>
<img alt="config" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/usage_2_amount_popup.png" style="width: 300px;" />
<p>A new payment line is added with selected amount:</p>
<img alt="config" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_loyalty_redeem_payment/static/img/usage_3_payment_line.png" style="width: 300px;" />
<p>After order is completed, loyalty card report is downloaded with updated
points.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Make popup used for redeeming compatible with Mozilla Firefox. Currently CSS
rules are not applied correctly to it with this navigator</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_loyalty_redeem_payment%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<ul class="simple">
<li>FactorLibre</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li>Juan Carlos Bonilla &lt;<a class="reference external" href="mailto:juancarlos.bonilla&#64;factorlibre.com">juancarlos.bonilla&#64;factorlibre.com</a>&gt;</li>
<li>Pablo De Andrés &lt;<a class="reference external" href="mailto:pablo.deandres&#64;factorlibre.com">pablo.deandres&#64;factorlibre.com</a>&gt;</li>
<li>Daniel Duque &lt;<a class="reference external" href="mailto:daniel.duque&#64;factorlibre.com">daniel.duque&#64;factorlibre.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_loyalty_redeem_payment">OCA/pos</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -0,0 +1,183 @@
/** @odoo-module **/
import NumberBuffer from "point_of_sale.NumberBuffer";
import PaymentScreen from "point_of_sale.PaymentScreen";
import Registries from "point_of_sale.Registries";
import session from "web.session";
export const CouponPosPaymentScreen = (OriginalPaymentScreen) =>
class extends OriginalPaymentScreen {
_updateSelectedPaymentline() {
// Disallow payment line editing
if (this.selectedPaymentLine && this.selectedPaymentLine.coupon_data)
return;
super._updateSelectedPaymentline();
}
async isValidCode(code, paymentMethod) {
const order = this.env.pos.get_order();
const customer = order.get_partner();
return await this.env.services.rpc({
model: "pos.config",
method: "use_coupon_code",
args: [
[this.env.pos.config.id],
code,
order.creation_date,
customer ? customer.id : false,
],
kwargs: {
context: {
from_payment_screen: true,
payment_method_id: paymentMethod.id,
},
},
});
}
// If voucher code has already been activated,
// we cannot used twice in same or different orders without being processed.
// First we have to process the order and then use it again.
codeIsDuplicated(orders, code) {
return orders.some((order) =>
order.paymentlines.some(
(line) => line.coupon_data && line.coupon_data.code === code
)
);
}
hasBeenScanned(code) {
const pending_orders = this.env.pos.get_order_list();
if (this.codeIsDuplicated(pending_orders, code)) {
this.showNotification(
this.env._t(
"That coupon code has already been scanned and activated. Please, process pending orders."
),
5000
);
return false;
}
return true;
}
async insertAndValidateCode(paymentMethod) {
const {confirmed, payload: code} = await this.showPopup("TextInputPopup", {
title: this.env._t("Enter Code"),
startingValue: "",
placeholder: this.env._t("Gift Card"),
});
if (!confirmed || !this.hasBeenScanned(code)) return 0;
const trimmedCode = code.trim();
if (trimmedCode) {
const {successful, payload} = await this.isValidCode(
trimmedCode,
paymentMethod
);
if (successful) {
return {payload, code};
}
this.showNotification(payload.error_message, 5000);
}
return 0;
}
async insertAmountToRedeem(maxVoucherAmount) {
const to_paid = Math.min(maxVoucherAmount, this.currentOrder.get_due());
const {confirmed, payload: amount} = await this.showPopup(
"ResponsiveNumberPopup",
{
startingValue: 0,
title: _.str.sprintf(
this.env._t("Set amount to redeem, up to %s"),
this.env.pos.format_currency(to_paid)
),
}
);
if (confirmed) {
const new_amount = parseFloat(amount.replace(",", "."));
if (new_amount <= maxVoucherAmount) {
return new_amount;
}
this.showPopup("ErrorPopup", {
body: _.str.sprintf(
this.env._t(
"You tried to redeem %s, but maximum for this gift card in this order is %s"
),
this.env.pos.format_currency(new_amount),
this.env.pos.format_currency(maxVoucherAmount)
),
});
}
return 0;
}
// Only valid for voucher and gift card programs
async applyProgramAsPaymentMethod(paymentMethod) {
const {payload, code} = await this.insertAndValidateCode(paymentMethod);
if (payload) {
const maxCouponValue = Math.min(
this.currentOrder.get_total_with_tax(),
payload.points
);
const amount = await this.insertAmountToRedeem(maxCouponValue);
if (amount) {
const newPaymentLine =
this.currentOrder.add_paymentline(paymentMethod);
newPaymentLine.set_amount(amount);
// Amount = amount to redeem
newPaymentLine.coupon_data = {coupon: payload, amount, code};
newPaymentLine.coupon_id = payload.coupon_id;
if (newPaymentLine) {
NumberBuffer.reset();
} else {
this.showPopup("ErrorPopup", {
title: this.env._t("Error"),
body: this.env._t(
"There is already an electronic payment in progress."
),
});
}
}
}
}
addNewPaymentLine({detail: paymentMethod}) {
const order = this.currentOrder;
if (
order.get_due() &&
order.get_subtotal() > 0 &&
paymentMethod.used_for_loyalty_program
) {
this.applyProgramAsPaymentMethod(paymentMethod);
return;
}
super.addNewPaymentLine(...arguments);
}
async _postPushOrderResolve(order, order_server_ids) {
if (order.has_redeem_payment_lines()) {
const payload = await this.rpc({
model: "pos.order",
method: "get_loy_card_reports_from_order",
args: [order_server_ids],
kwargs: {context: session.user_context},
});
if (payload.coupon_report) {
for (const report_entry of Object.entries(payload.coupon_report)) {
await this.env.legacyActionManager.do_action(report_entry[0], {
additional_context: {
active_ids: report_entry[1],
},
});
}
}
if (payload.new_coupon_info) {
order.new_coupon_info = payload.new_coupon_info;
}
}
return super._postPushOrderResolve(...arguments);
}
};
Registries.Component.extend(PaymentScreen, CouponPosPaymentScreen);

View file

@ -0,0 +1,11 @@
odoo.define("pos_loyalty_partial_redeem.ResponsiveNumberPopup", function (require) {
const NumberPopup = require("point_of_sale.NumberPopup");
const Registries = require("point_of_sale.Registries");
class ResponsiveNumberPopup extends NumberPopup {}
ResponsiveNumberPopup.template = "ResponsiveNumberPopup";
Registries.Component.add(ResponsiveNumberPopup);
return ResponsiveNumberPopup;
});

View file

@ -0,0 +1,42 @@
/** @odoo-module **/
import {Order, Payment} from "point_of_sale.models";
import Registries from "point_of_sale.Registries";
export const RedeemPaymentOrder = (OriginalOrder) =>
class extends OriginalOrder {
has_redeem_payment_lines() {
return this.paymentlines.some(
(pl) => pl.payment_method.used_for_loyalty_program
);
}
wait_for_push_order() {
let result = super.wait_for_push_order(...arguments);
result = Boolean(result || this.has_redeem_payment_lines());
return result;
}
};
Registries.Model.extend(Order, RedeemPaymentOrder);
export const PosVoucherRedeemPayment = (OriginalPayment) =>
class extends OriginalPayment {
constructor(obj, options) {
super(obj, options);
this.coupon_data = this.coupon_data || null;
}
export_as_JSON() {
const json = super.export_as_JSON(...arguments);
json.coupon_data = this.coupon_data;
return json;
}
init_from_JSON(json) {
super.init_from_JSON(...arguments);
this.coupon_data = json.coupon_data;
}
};
Registries.Model.extend(Payment, PosVoucherRedeemPayment);

View file

@ -0,0 +1,3 @@
.popup.popup-number:has(.popup-number-responsive) {
height: auto !important;
}

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t
t-name="ChromeInherit"
t-inherit="point_of_sale.Chrome"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//Notification" position="attributes">
<attribute
name="duration"
>state.notification.duration == 2000 ? 5000 : state.notification.duration</attribute>
</xpath>
</t>
</templates>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t
t-inherit="point_of_sale.NumberPopup"
t-name="ResponsiveNumberPopup"
t-inherit-mode="primary"
owl="1"
>
<!-- Expected thing would be adding a new class to popup-number, but this makes events crash -->
<xpath expr="//div[hasclass('popup-numpad')]" position="after">
<div class="oe_hidden popup-number-responsive" />
</xpath>
</t>
</templates>

View file

@ -0,0 +1,115 @@
/** @odoo-module **/
import {getSteps, startSteps} from "point_of_sale.tour.utils";
import {Chrome} from "point_of_sale.tour.ChromeTourMethods";
import {ErrorPopup} from "point_of_sale.tour.ErrorPopupTourMethods";
import {NumberPopup} from "point_of_sale.tour.NumberPopupTourMethods";
import {PaymentScreen} from "point_of_sale.tour.PaymentScreenTourMethods";
import {ProductScreen} from "point_of_sale.tour.ProductScreenTourMethods";
import {ReceiptScreen} from "point_of_sale.tour.ReceiptScreenTourMethods";
import {TextInputPopup} from "point_of_sale.tour.TextInputPopupTourMethods";
import {TicketScreen} from "point_of_sale.tour.TicketScreenTourMethods";
import Tour from "web_tour.tour";
startSteps();
ProductScreen.do.confirmOpeningPopup();
ProductScreen.do.clickHomeCategory();
// TEST: Order creation with a single gift card voucher paid as payment method. Remaining amount is paid on "Cash".
// steps:
// 1) Create a new order and redirect to payment screen
// 2) Create a new paymentline with "Voucher" name.
// 3) Set a valid voucher's code
// 4) Set a valid voucher's amount
// 5) Pay remaining amount in order to validate the order.
// 6) Finish order
ProductScreen.exec.addOrderline("Letter Tray", "1");
ProductScreen.check.selectedOrderlineHas("Letter Tray", "1.0");
ProductScreen.do.clickPayButton();
PaymentScreen.check.isShown();
PaymentScreen.do.clickPaymentMethod("Voucher");
TextInputPopup.check.isShown();
TextInputPopup.do.inputText("044123456");
TextInputPopup.do.clickConfirm();
NumberPopup.check.isShown();
NumberPopup.do.pressNumpad("1");
NumberPopup.do.clickConfirm();
PaymentScreen.check.selectedPaymentlineHas("Voucher", "1.00");
PaymentScreen.do.clickPaymentMethod("Cash");
PaymentScreen.check.validateButtonIsHighlighted(true);
PaymentScreen.do.clickValidate();
ReceiptScreen.check.totalAmountContains("5.28");
Chrome.do.clickTicketButton();
TicketScreen.do.clickNewTicket();
Tour.register(
"GiftCardProgramAsRedeemPayment",
{test: true, url: "/pos/web"},
getSteps()
);
// TEST: Display error on redeeming an amount greater that allowed by total amount and code points.
startSteps();
ProductScreen.check.isShown();
ProductScreen.do.clickHomeCategory();
ProductScreen.exec.addOrderline("Letter Tray", "1");
ProductScreen.check.selectedOrderlineHas("Letter Tray", "1.0");
ProductScreen.do.clickPayButton();
PaymentScreen.do.clickPaymentMethod("Voucher");
TextInputPopup.check.isShown();
TextInputPopup.do.inputText("044123456");
TextInputPopup.do.clickConfirm();
NumberPopup.check.isShown();
NumberPopup.do.pressNumpad("1");
NumberPopup.do.pressNumpad("0");
NumberPopup.do.pressNumpad("0");
NumberPopup.do.clickConfirm();
ErrorPopup.check.isShown();
ErrorPopup.do.clickConfirm();
Chrome.do.clickTicketButton();
TicketScreen.do.clickNewTicket();
Tour.register(
"GiftCardProgramAsRedeemPayment2",
{test: true, url: "/pos/web"},
getSteps()
);
// TEST: Order creation with multiple gift cards vouchers paid as payment method.
startSteps();
ProductScreen.check.isShown();
ProductScreen.do.clickHomeCategory();
ProductScreen.exec.addOrderline("Letter Tray", "1");
ProductScreen.check.selectedOrderlineHas("Letter Tray", "1.0");
ProductScreen.do.clickPayButton();
PaymentScreen.check.isShown();
PaymentScreen.do.clickPaymentMethod("Voucher");
TextInputPopup.check.isShown();
TextInputPopup.do.inputText("044123456");
TextInputPopup.do.clickConfirm();
NumberPopup.check.isShown();
NumberPopup.do.pressNumpad("1");
NumberPopup.do.clickConfirm();
PaymentScreen.check.selectedPaymentlineHas("Voucher", "1.00");
PaymentScreen.do.clickPaymentMethod("Voucher");
TextInputPopup.check.isShown();
TextInputPopup.do.inputText("044123457");
TextInputPopup.do.clickConfirm();
NumberPopup.check.isShown();
NumberPopup.do.pressNumpad("4 , 2 8");
NumberPopup.do.clickConfirm();
PaymentScreen.check.validateButtonIsHighlighted(true);
PaymentScreen.do.clickValidate();
ReceiptScreen.check.totalAmountContains("5.28");
Tour.register(
"MultipleGiftCardsAsRedeemPayment",
{test: true, url: "/pos/web"},
getSteps()
);

View file

@ -0,0 +1,25 @@
odoo.define(
"pos_loyalty_redeem_payment.tour.ReceiptScreenTourMethods",
function (require) {
"use strict";
const {createTourMethods} = require("point_of_sale.tour.utils");
const {
Do,
Check,
Execute,
} = require("point_of_sale.tour.ReceiptScreenTourMethods");
class CheckExt extends Check {
couponCodeIsShown(code) {
return [
{
content: `coupon code is '${code}'`,
trigger: `.receipt-screen span.payment-code:contains("${code}")`,
},
];
}
}
return createTourMethods("ReceiptScreen", Do, CheckExt, Execute);
}
);

View file

@ -0,0 +1 @@
from . import test_frontend

View file

@ -0,0 +1,108 @@
from odoo.tests import tagged
from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon
@tagged("post_install", "-at_install")
class TestUi(TestPointOfSaleHttpCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.voucher_payment_method = cls.env["pos.payment.method"].create(
{
"name": "Voucher",
"receivable_account_id": cls.company_data[
"default_account_receivable"
].id,
"journal_id": cls.company_data["default_journal_cash"].id,
"company_id": cls.env.company.id,
"used_for_loyalty_program": True,
}
)
cls.main_pos_config.write(
{"payment_method_ids": [(4, cls.voucher_payment_method.id)]}
)
def setUp(self):
super().setUp()
self.main_pos_config.write(
{
"tax_regime_selection": False,
"use_pricelist": False,
"gift_card_settings": "scan_use",
}
)
self.program1 = self.configure_program()
self.main_pos_config.open_ui()
def create_programs(self, details):
LoyaltyProgram = self.env["loyalty.program"]
programs = {} # map: name -> program
for (name, program_type) in details:
program_id = LoyaltyProgram.create_from_template(program_type)["res_id"]
program = LoyaltyProgram.browse(program_id)
program.write({"name": name})
programs[name] = program
return programs
def configure_program(self):
program_obj = self.env["loyalty.program"]
(program_obj.search([])).write({"pos_ok": False})
self.env.ref("loyalty.gift_card_product_50").write({"active": True})
gift_card_program = self.create_programs([("Gift Card Program", "gift_card")])[
"Gift Card Program"
]
self.env["loyalty.generate.wizard"].with_context(
active_id=gift_card_program.id
).create({"coupon_qty": 1, "points_granted": 50.00}).generate_coupons()
gift_card_program.coupon_ids.code = "044123456"
gift_card_program.redeem_method = "payment_method"
gift_card_program.write(
{"pos_payment_method_ids": [(4, self.voucher_payment_method.id)]}
)
return gift_card_program
def test_gift_card_as_redeem_payment(self):
"""
1º Tour: Check that we have generate a new pos order
paid with a gift card as payment method.
2º Tour: Display error on redeeming an amount greater
that allowed by total amount and code points.
"""
self.start_tour(
"/pos/web?config_id=%d" % self.main_pos_config.id,
"GiftCardProgramAsRedeemPayment",
login="accountman",
)
# check order has been created and coupon points substracted
pos_order = self.env["pos.order"].search([], limit=1)
voucher_payment = pos_order.payment_ids.filtered(
lambda x: x.payment_method_id.name == "Voucher"
)
self.assertEqual(voucher_payment.payment_method_id.name, "Voucher")
self.assertEqual(voucher_payment.amount, 1.00)
coupon_id = self.program1.coupon_ids[0]
self.assertEqual(coupon_id.points, 49.00)
self.start_tour(
"/pos/web?config_id=%d" % self.main_pos_config.id,
"GiftCardProgramAsRedeemPayment2",
login="accountman",
)
def test_multiple_gift_cards_as_redeem_payment(self):
"""
Check multiples gift card vouchers used as redeem payment in the same payment method.
"""
self.env["loyalty.generate.wizard"].with_context(
active_id=self.program1.id
).create({"coupon_qty": 1, "points_granted": 30.00}).generate_coupons()
coupon = self.program1.coupon_ids.filtered(lambda x: x.code != "044123456")
coupon.code = "044123457"
self.start_tour(
"/pos/web?config_id=%d" % self.main_pos_config.id,
"MultipleGiftCardsAsRedeemPayment",
login="accountman",
)

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="loyalty_program_view_form_inherit" model="ir.ui.view">
<field name="name">loyalty.program.view.form.inherit</field>
<field name="model">loyalty.program</field>
<field name="inherit_id" ref="loyalty.loyalty_program_view_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='mail_template_id']" position="after">
<field
name="redeem_method"
attrs="{'invisible': [('program_type', '!=', 'gift_card')]}"
/>
</xpath>
<xpath
expr="//form/sheet/group/group[last()]/field[@name='portal_point_name']"
position="after"
>
<field
name="pos_payment_method_ids"
widget="many2many_tags"
attrs="{'invisible': ['|', ('program_type', '!=', 'gift_card'), ('redeem_method', '=', 'discount')], 'required': [('redeem_method', '=', 'payment_method')]}"
/>
</xpath>
</field>
</record>
</odoo>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="pos_payment_method_view_form_inherit" model="ir.ui.view">
<field name="name">pos.payment.method.form</field>
<field name="model">pos.payment.method</field>
<field name="inherit_id" ref="point_of_sale.pos_payment_method_view_form" />
<field name="arch" type="xml">
<field name="split_transactions" position="after">
<field name="used_for_loyalty_program" />
</field>
</field>
</record>
</odoo>

View file

@ -0,0 +1,42 @@
[project]
name = "odoo-bringout-oca-pos-pos_loyalty_redeem_payment"
version = "16.0.0"
description = "Pos Loyalty Redeem Payment - Use vouchers as payment method in pos orders"
authors = [
{ name = "Ernad Husremovic", email = "hernad@bring.out.ba" }
]
dependencies = [
"odoo-bringout-oca-pos-pos_loyalty>=16.0.0",
"requests>=2.25.1"
]
readme = "README.md"
requires-python = ">= 3.11"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Office/Business",
]
[project.urls]
homepage = "https://github.com/bringout/0"
repository = "https://github.com/bringout/0"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.metadata]
allow-direct-references = true
[tool.hatch.build.targets.wheel]
packages = ["pos_loyalty_redeem_payment"]
[tool.rye]
managed = true
dev-dependencies = [
"pytest>=8.4.1",
]