-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] pos_customer_wallet_partner_is_user: Migration to 16.0
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
- Loading branch information
1 parent
f4e22e2
commit 5b22f64
Showing
9 changed files
with
102 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from . import pos_session | ||
from . import res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
pos_customer_wallet_partner_is_user/static/src/js/Screens/PaymentScreen/PaymentScreen.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
pos_customer_wallet_partner_is_user/static/src/js/screens.js
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
pos_customer_wallet_partner_is_user/static/src/xml/Screens/ReceiptScreen/OrderReceipt.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
31 changes: 0 additions & 31 deletions
31
pos_customer_wallet_partner_is_user/static/src/xml/pos.xml
This file was deleted.
Oops, something went wrong.