Skip to content

Commit

Permalink
[MIG] pos_cashback: Migration to 16.0 (from 12.0)
Browse files Browse the repository at this point in the history
- rename from pos_casback_warning, to allow to add new feature, such as charging a commission.
- Adapt to V16 PoS Framework
  • Loading branch information
legalsylvain committed Feb 21, 2025
1 parent 531edd9 commit 9c12599
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 110 deletions.
16 changes: 8 additions & 8 deletions pos_cashback_warning/README.rst → pos_cashback/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
================================
Point of Sale - Cashback Warning
================================
========================
Point of Sale - Cashback
========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -17,10 +17,10 @@ Point of Sale - Cashback Warning
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-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_cashback_warning
:target: https://github.com/OCA/pos/tree/16.0/pos_cashback
: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_cashback_warning
:target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_cashback
: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
Expand All @@ -39,7 +39,7 @@ transaction will generate a cashback.

This module simply add a message in such case.

.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_cashback_warning/static/description/pos_cashback_warning.png
.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_cashback/static/description/pos_cashback_warning.png


**Note** : The cashback is an operation that consists,
Expand All @@ -57,7 +57,7 @@ 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_cashback_warning%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_cashback%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.

Expand Down Expand Up @@ -95,6 +95,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-legalsylvain|

This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/16.0/pos_cashback_warning>`_ project on GitHub.
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/16.0/pos_cashback>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Point of Sale - Cashback Warning",
"version": "12.0.1.0.2",
"name": "Point of Sale - Cashback",
"version": "16.0.1.0.0",
"category": "Point of Sale",
"author": "GRAP, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"maintainers": ["legalsylvain"],
"depends": [
"point_of_sale",
],
"data": [
"views/templates.xml",
],
"qweb": [
"static/src/xml/pos.xml",
],
"depends": ["point_of_sale"],
"assets": {
"point_of_sale.assets": [
"pos_cashback/static/src/js/models.esm.js",
"pos_cashback/static/src/xml/pos.xml",
"pos_cashback/static/src/scss/pos_cashback.scss",
],
},
"installable": True,
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_cashback_warning
# * pos_cashback
#
msgid ""
msgstr ""
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Point of Sale - Cashback Warning</title>
<title>Point of Sale - Cashback</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,16 +360,16 @@
</style>
</head>
<body>
<div class="document" id="point-of-sale-cashback-warning">
<h1 class="title">Point of Sale - Cashback Warning</h1>
<div class="document" id="point-of-sale-cashback">
<h1 class="title">Point of Sale - Cashback</h1>

<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:d82fb9e5cd7890e4c0f84c83c1868e6fa55b8bab9a20599c98fd049887d19f1f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pos/tree/16.0/pos_cashback_warning"><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_cashback_warning"><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><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/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pos/tree/16.0/pos_cashback"><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_cashback"><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 modules extends the Point of sale functionnalies to add a warning
if confirming an order generate a cashback.</p>
<p>By default, if the payment lines of an Odoo PoS order generate Change,
Expand All @@ -378,7 +378,7 @@ <h1 class="title">Point of Sale - Cashback Warning</h1>
a payment by credit card, check, meal voucher, etc. confirming the
transaction will generate a cashback.</p>
<p>This module simply add a message in such case.</p>
<img alt="https://raw.githubusercontent.com/OCA/pos/16.0/pos_cashback_warning/static/description/pos_cashback_warning.png" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_cashback_warning/static/description/pos_cashback_warning.png" />
<img alt="https://raw.githubusercontent.com/OCA/pos/16.0/pos_cashback/static/description/pos_cashback_warning.png" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_cashback/static/description/pos_cashback_warning.png" />
<p><strong>Note</strong> : The cashback is an operation that consists,
for a merchant to collect more money in check, credit card, etc.
than the amount of the sale and give change in cash.</p>
Expand All @@ -399,7 +399,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">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_cashback_warning%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_cashback%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">
Expand Down Expand Up @@ -427,7 +427,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/legalsylvain"><img alt="legalsylvain" src="https://github.com/legalsylvain.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_cashback_warning">OCA/pos</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_cashback">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>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions pos_cashback/static/src/js/models.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** ***************************************************************************
Copyright (C) 2022 - Today: GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
******************************************************************************/

odoo.define("pos_cashback.Order", function (require) {
var {Order} = require("point_of_sale.models");
const Registries = require("point_of_sale.Registries");
var utils = require("web.utils");

var round_pr = utils.round_precision;

const OverloadOrder = (OriginalOrder) =>
class extends OriginalOrder {
get_extradue_cashback() {
var total_cash_received = 0.0;
var extradue = 0.0;
var due = this.get_due();
var lines = this.get_paymentlines();

if (due && lines.length) {
extradue = due;
}

_.each(lines, function (line) {
if (line.payment_method.type === "cash") {
total_cash_received += line.amount;
}
});

if (extradue < 0.0 && total_cash_received + extradue < 0.0) {
return round_pr(
-(total_cash_received + extradue),
this.pos.currency.rounding
);
}
return round_pr(0.0, this.pos.currency.rounding);
}
};
Registries.Model.extend(Order, OverloadOrder);
});
3 changes: 3 additions & 0 deletions pos_cashback/static/src/scss/pos_cashback.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.cashback-message-container {
font-size: 25px;
}
22 changes: 22 additions & 0 deletions pos_cashback/static/src/xml/PaymentScreen/PaymentScreenStatus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright 2022 - Today Sylvain LE GAL
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<templates id="template" xml:space="preserve">

<t t-inherit="point_of_sale.PaymentScreenStatus" t-inherit-mode="extension">
<xpath expr="//div[hasclass('payment-status-container')]" position="after">
<div
class="cashback-message-container"
t-if="props.order.get_extradue_cashback() > 0"
>
<i class='fa fa-warning' />
This will generate a cashback of <t
t-esc='env.pos.format_currency(props.order.get_extradue_cashback())'
/>
</div>
</xpath>
</t>

</templates>
Binary file not shown.
48 changes: 0 additions & 48 deletions pos_cashback_warning/static/src/js/screens.js

This file was deleted.

19 changes: 0 additions & 19 deletions pos_cashback_warning/static/src/xml/pos.xml

This file was deleted.

15 changes: 0 additions & 15 deletions pos_cashback_warning/views/templates.xml

This file was deleted.

1 change: 1 addition & 0 deletions setup/pos_cashback/odoo/addons/pos_cashback
File renamed without changes.

This file was deleted.

0 comments on commit 9c12599

Please sign in to comment.