Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] pos_customer_wallet_partner_is_user #307

Open
wants to merge 26 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5b97d84
[ADD] pos_customer_wallet_is_user
carmenbianca Jun 15, 2022
667eda7
[REM] pos_customer_wallet_partner_is_user: Don't compute the field
carmenbianca Jun 16, 2022
54e0aaa
[IMP] SCRLfs → SC
carmenbianca Jul 8, 2022
176224e
[UPD] Update pos_customer_wallet_partner_is_user.pot
Jul 8, 2022
3a16dde
[UPD] README.rst
github-grap-bot Jul 8, 2022
04990fd
pos_customer_wallet_partner_is_user 12.0.1.1.0
github-grap-bot Jul 8, 2022
908f151
[FIX] pos_customer_wallet_partner_is_user: Raise error when functiona…
carmenbianca Jun 19, 2023
16a6ccf
[IMP] pos_customer_wallet_partner_is_user: Add to roadmap
carmenbianca Jun 20, 2023
8094f1a
[FIX] pos_customer_wallet_partner_is_user: Use more robust method to …
carmenbianca Jun 26, 2023
011f530
[FIX] pos_customer_wallet[_partner_is_user]: Pass required argument
carmenbianca Jun 26, 2023
4fe15d3
[IMP] pos_customer_wallet_partner_is_user: Clarifying comment
carmenbianca Jun 29, 2023
78387c8
[UPD] Update pos_customer_wallet_partner_is_user.pot
Jun 29, 2023
7bee5f9
[UPD] README.rst
github-grap-bot Jun 29, 2023
70adb39
pos_customer_wallet_partner_is_user 12.0.1.2.0
github-grap-bot Jun 29, 2023
f0a06e3
[FIX] pos_customer_wallet[_*]: Rename foodprint class
carmenbianca Sep 9, 2022
1cbaf56
[FIX] pos_customer_wallet_[*]: Repair maintainer tags in manifest
carmenbianca Jun 30, 2023
0efb6a8
[UPD] Run prettier
carmenbianca Jun 30, 2023
30b8c3e
[UPD] README.rst
github-grap-bot Jun 30, 2023
f47fb38
pos_customer_wallet_partner_is_user 12.0.1.2.1
github-grap-bot Jun 30, 2023
ce6c633
[UPD] Update pos_customer_wallet_partner_is_user.pot
Jun 30, 2023
0d9a322
[IMP] pos_customer_wallet_partner_is_user: black, isort, prettier
carmenbianca Sep 18, 2023
b4517dd
[MIG] pos_customer_wallet_partner_is_user: Migration to 13.0
carmenbianca Sep 18, 2023
a471deb
[MIG] pos_customer_wallet_partner_is_user: Migration to 14.0
carmenbianca Sep 18, 2023
f4e22e2
[MIG] pos_customer_wallet_partner_is_user: Migration to 15.0
carmenbianca Sep 18, 2023
5b22f64
[MIG] pos_customer_wallet_partner_is_user: Migration to 16.0
carmenbianca Sep 18, 2023
9b3ed72
[IMP] pos_customer_wallet_partner_is_user: Hide payment method condit…
carmenbianca Jan 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions pos_customer_wallet_partner_is_user/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
=============================================
Point of Sale Customer Wallet Partner Is User
=============================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Faddons-lightgray.png?logo=github
:target: https://github.com/coopiteasy/addons/tree/12.0/pos_customer_wallet_partner_is_user
:alt: coopiteasy/addons

|badge1| |badge2| |badge3|


**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

- Create module ``account_customer_wallet_partner_is_user`` that forbids certain
accounting operations from happening if the partner is not a customer wallet
user.
- Hide the customer wallet payment method if the selected partner is not a user.
- Hide the customer wallet balance if the selected partner is not a user.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/addons/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/coopiteasy/addons/issues/new?body=module:%20pos_customer_wallet_partner_is_user%0Aversion:%2012.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
~~~~~~~

* Coop IT Easy SC

Contributors
~~~~~~~~~~~~

* `Coop IT Easy SC <https://coopiteasy.be>`_:

* Carmen Bianca Bakker

Maintainers
~~~~~~~~~~~

.. |maintainer-carmenbianca| image:: https://github.com/carmenbianca.png?size=40px
:target: https://github.com/carmenbianca
:alt: carmenbianca

Current maintainer:

|maintainer-carmenbianca|

This module is part of the `coopiteasy/addons <https://github.com/coopiteasy/addons/tree/12.0/pos_customer_wallet_partner_is_user>`_ project on GitHub.

You are welcome to contribute.
5 changes: 5 additions & 0 deletions pos_customer_wallet_partner_is_user/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2022 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from . import models
32 changes: 32 additions & 0 deletions pos_customer_wallet_partner_is_user/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-FileCopyrightText: 2022 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

{
"name": "Point of Sale Customer Wallet Partner Is User",
"summary": """
Add a field on partners that shows whether they have used customer wallet
functionality, and don't show some parts of customer wallet functionality
to partners who haven't already used it.""",
"version": "16.0.1.0.0",
"category": "Point of Sale",
"website": "https://github.com/coopiteasy/addons",
"author": "Coop IT Easy SC",
"maintainers": ["carmenbianca"],
"license": "AGPL-3",
"application": False,
"depends": [
"pos_customer_wallet",
],
"excludes": [],
"assets": {
"point_of_sale.assets": [
"pos_customer_wallet_partner_is_user/static/src/js/**/*.js",
"pos_customer_wallet_partner_is_user/static/src/xml/**/*.xml",
],
},
"data": [
"views/res_partner_views.xml",
],
"demo": [],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_customer_wallet_partner_is_user
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.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_customer_wallet_partner_is_user
#: model:ir.model,name:pos_customer_wallet_partner_is_user.model_res_partner
msgid "Contact"
msgstr ""

#. module: pos_customer_wallet_partner_is_user
#. openerp-web
#: code:addons/pos_customer_wallet_partner_is_user/static/src/js/screens.js:38
#, python-format
msgid "Customer cannot use customer wallet"
msgstr ""

#. module: pos_customer_wallet_partner_is_user
#. openerp-web
#: code:addons/pos_customer_wallet_partner_is_user/static/src/js/screens.js:39
#, python-format
msgid "Customer has not enabled the usage of a customer wallet. Before the user can use this payment method, they must enable it."
msgstr ""

#. module: pos_customer_wallet_partner_is_user
#: model:ir.model.fields,field_description:pos_customer_wallet_partner_is_user.field_res_partner__is_customer_wallet_user
#: model:ir.model.fields,field_description:pos_customer_wallet_partner_is_user.field_res_users__is_customer_wallet_user
#: model_terms:ir.ui.view,arch_db:pos_customer_wallet_partner_is_user.view_res_partner_filter
msgid "Is Customer Wallet User"
msgstr ""

#. module: pos_customer_wallet_partner_is_user
#. openerp-web
#: code:addons/pos_customer_wallet_partner_is_user/static/src/xml/pos.xml:17
#, python-format
msgid "order.pos.get_client() and order.pos.get_client().is_customer_wallet_user"
msgstr ""

#. module: pos_customer_wallet_partner_is_user
#. openerp-web
#: code:addons/pos_customer_wallet_partner_is_user/static/src/xml/pos.xml:27
#, python-format
msgid "receipt.is_customer_wallet_user !== null and receipt.is_customer_wallet_user"
msgstr ""

6 changes: 6 additions & 0 deletions pos_customer_wallet_partner_is_user/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2022 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from . import pos_session
from . import res_partner
14 changes: 14 additions & 0 deletions pos_customer_wallet_partner_is_user/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from odoo import models


class PosSession(models.Model):
_inherit = "pos.session"

def _loader_params_res_partner(self):
result = super()._loader_params_res_partner()
result["search_params"]["fields"].append("is_customer_wallet_user")
return result
11 changes: 11 additions & 0 deletions pos_customer_wallet_partner_is_user/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2022 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from odoo import fields, models


class Partner(models.Model):
_inherit = "res.partner"

is_customer_wallet_user = fields.Boolean(default=False)
3 changes: 3 additions & 0 deletions pos_customer_wallet_partner_is_user/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Coop IT Easy SC <https://coopiteasy.be>`_:

* Carmen Bianca Bakker
Empty file.
5 changes: 5 additions & 0 deletions pos_customer_wallet_partner_is_user/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Create module ``account_customer_wallet_partner_is_user`` that forbids certain
accounting operations from happening if the partner is not a customer wallet
user.
- Hide the customer wallet payment method if the selected partner is not a user.
- Hide the customer wallet balance if the selected partner is not a user.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
odoo.define("pos_customer_wallet_partner_is_user.PaymentScreen", function (require) {
"use strict";
const PaymentScreen = require("point_of_sale.PaymentScreen");

const Registries = require("point_of_sale.Registries");

const IsUserPaymentScreen = (PaymentScreen_) =>
class extends PaymentScreen_ {
/* eslint-disable no-unused-vars */
/**
* Overload function.
*
* - If partner hasn't enabled functionality, don't allow wallet payments.
*
* @param {Boolean} isForceValidate - Passed to super.
* @returns {Boolean} Whether the order is valid.
*/
async validateOrder(isForceValidate) {
var partner = this.currentOrder.get_partner();
var [payment_wallet_amount, payment_lines_qty] =
this.get_amount_debit_with_customer_wallet_journal();
var [product_wallet_amount, product_lines_qty] =
this.get_amount_credit_with_customer_wallet_product();
/* eslint-enable no-unused-vars */

// If the partner is not a customer wallet user, and if a customer
// wallet operation is being made (via the payment method or via the
// wallet product), display an error.
if (
(payment_lines_qty || product_lines_qty) &&
partner &&
!partner.is_customer_wallet_user
) {
this.showPopup("ErrorPopup", {
title: this.env._t("Customer cannot use customer wallet"),
body: this.env._t(
"Customer has not enabled the usage of a customer wallet. Before the user can use this payment method, they must enable it."
),
});
return;
}

await super.validateOrder(...arguments);
}
};

Registries.Component.extend(PaymentScreen, IsUserPaymentScreen);

return IsUserPaymentScreen;
});
22 changes: 22 additions & 0 deletions pos_customer_wallet_partner_is_user/static/src/js/models.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: 2022 Coop IT Easy SC
//
// SPDX-License-Identifier: AGPL-3.0-or-later
odoo.define("pos_customer_wallet_partner_is_user.models", function (require) {
"use strict";

const {Order} = require("point_of_sale.models");
const Registries = require("point_of_sale.Registries");

const WalletOrder = (Order_) =>
class extends Order_ {
export_for_printing() {
var json = super.export_for_printing(...arguments);
json.is_customer_wallet_user = this.partner.is_customer_wallet_user
? this.partner
: false;
return json;
}
};

Registries.Model.extend(Order, WalletOrder);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
SPDX-FileCopyrightText: 2022 Coop IT Easy SC

SPDX-License-Identifier: AGPL-3.0-or-later
-->
<templates id="template" xml:space="preserve">

<t
t-name="OrderReceipt"
t-inherit="point_of_sale.OrderReceipt"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//div[hasclass('customer-wallet-balance')]" position="attributes">
<attribute name="t-if">receipt.is_customer_wallet_user</attribute>
</xpath>
</t>

</templates>
41 changes: 41 additions & 0 deletions pos_customer_wallet_partner_is_user/views/res_partner_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
SPDX-FileCopyrightText: 2022 Coop IT Easy SC

SPDX-License-Identifier: AGPL-3.0-or-later
-->
<odoo>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">pos_customer_wallet_partner_is_user.view_partner_form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account_customer_wallet.view_partner_form" />
<field name="arch" type="xml">
<field name="customer_wallet_balance" position="before">
<field name="is_customer_wallet_user" />
</field>
</field>
</record>

<record id="view_res_partner_filter" model="ir.ui.view">
<field
name="name"
>pos_customer_wallet_partner_is_user.partner.search.form</field>
<field name="model">res.partner</field>
<field
name="inherit_id"
ref="account_customer_wallet.view_res_partner_filter"
/>
<field name="arch" type="xml">
<xpath
expr="filter[@name='customer_wallet_balance_nonzero']"
position="before"
>
<filter
name="is_customer_wallet_user"
string="Is Customer Wallet User"
domain="[('is_customer_wallet_user', '=', True)]"
/>
</xpath>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/pos_customer_wallet_partner_is_user/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)