@ -0,0 +1,45 @@ |
|||
.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg |
|||
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html |
|||
:alt: License: LGPL-3 |
|||
|
|||
POS Customer Wallet Management |
|||
============================== |
|||
This module helps to manage each customer wallet in pos |
|||
|
|||
Configuration |
|||
============= |
|||
- Install our custom addon |
|||
|
|||
Company |
|||
------- |
|||
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
|||
|
|||
License |
|||
------- |
|||
Lesser General Public License, Version 3 (LGPL v3). |
|||
(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) |
|||
|
|||
Credits |
|||
------- |
|||
* Developer: (v17) Nivedhya T, Contact: odoo@cybrosys.com, (v18) Henna Mehjabin, Contact: odoo@cybrosys.com |
|||
|
|||
Contacts |
|||
-------- |
|||
* Mail Contact : odoo@cybrosys.com |
|||
|
|||
Bug Tracker |
|||
----------- |
|||
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
|||
|
|||
Maintainer |
|||
========== |
|||
.. image:: https://cybrosys.com/images/logo.png |
|||
:target: https://cybrosys.com |
|||
|
|||
This module is maintained by Cybrosys Technologies. |
|||
|
|||
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
|||
|
|||
Further information |
|||
=================== |
|||
HTML Description: `<static/description/index.html>`__ |
|||
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import models |
|||
from . import wizard |
|||
@ -0,0 +1,60 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
{ |
|||
'name': 'POS Customer Wallet Management', |
|||
'version': '18.0.1.0.0', |
|||
'category': 'Point of Sale', |
|||
'summary': 'This Module Helps to Manage Customer Wallet in POS.', |
|||
'description': """This Module Helps to Manage Customer Wallet in POS.""", |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': 'https://www.cybrosys.com', |
|||
'depends': ['base', 'contacts', 'account', 'point_of_sale'], |
|||
'data': [ |
|||
'security/ir.model.access.csv', |
|||
'data/ir_sequence_data.xml', |
|||
'data/account_journal_data.xml', |
|||
'data/pos_payment_method_data.xml', |
|||
'views/res_partner_views.xml', |
|||
'views/wallet_transaction_views.xml', |
|||
'views/account_journal_views.xml', |
|||
'views/pos_payment_method_views.xml', |
|||
'wizard/recharge_wallet_views.xml' |
|||
], |
|||
'assets': { |
|||
'point_of_sale._assets_pos': [ |
|||
'pos_customer_wallet_management/static/src/xml/wallet_templates.xml', |
|||
'pos_customer_wallet_management/static/src/js/wallet_recharge.js', |
|||
'pos_customer_wallet_management/static/src/js/customerListScreen.js', |
|||
'pos_customer_wallet_management/static/src/js/payment_method.js', |
|||
'pos_customer_wallet_management/static/src/xml/balance_templates.xml', |
|||
'pos_customer_wallet_management/static/src/xml/partner_templates.xml', |
|||
|
|||
], |
|||
}, |
|||
'images': ['static/description/banner.jpg'], |
|||
'license': 'LGPL-3', |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False, |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<data noupdate="1"> |
|||
<record id="pos_wallet_journal" model="account.journal"> |
|||
<field name="name">POS Wallet</field> |
|||
<field name="code">WAL</field> |
|||
<field name="type">cash</field> |
|||
<field name="sequence">100</field> |
|||
<field name="alias_name">pos_wallet</field> |
|||
<field name="wallet_journal" eval="True"/> |
|||
<field name="company_id" ref="base.main_company"/> |
|||
</record> |
|||
</data> |
|||
</odoo> |
|||
@ -0,0 +1,13 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Sequence creation for wallet --> |
|||
<data noupdate="1"> |
|||
<record id="seq_wallet_transaction" model="ir.sequence"> |
|||
<field name="name">Wallet Transaction</field> |
|||
<field name="code">wallet.transaction</field> |
|||
<field name="prefix">WT</field> |
|||
<field name="padding">3</field> |
|||
<field name="number_next">1</field> |
|||
</record> |
|||
</data> |
|||
</odoo> |
|||
@ -0,0 +1,10 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<data noupdate="1"> |
|||
<record id="pos_wallet_payment_method" model="pos.payment.method"> |
|||
<field name="name">Wallet</field> |
|||
<field name="journal_id" ref="pos_customer_wallet_management.pos_wallet_journal"/> |
|||
</record> |
|||
</data> |
|||
</odoo> |
|||
|
|||
@ -0,0 +1,6 @@ |
|||
## Module <pos_customer_wallet_management> |
|||
|
|||
#### 16.01.2025 |
|||
#### Version 18.0.1.0.0 |
|||
#### ADD |
|||
- Initial Commit for POS Customer Wallet Management |
|||
@ -0,0 +1,26 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import pos_payment_method |
|||
from . import pos_session |
|||
from . import account_journal |
|||
from . import res_partner |
|||
from . import wallet_transaction |
|||
@ -0,0 +1,45 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import api,fields, models |
|||
|
|||
class AccountJournal(models.Model): |
|||
"""Adding fields to account journal""" |
|||
_inherit = "account.journal" |
|||
|
|||
wallet_journal = fields.Boolean(string="Wallet Journal", |
|||
help="Journal for wallet") |
|||
|
|||
@api.model |
|||
def _load_pos_data_fields(self, config_id): |
|||
return ['id', 'name', 'type'] |
|||
|
|||
@api.model |
|||
def _load_pos_data_domain(self, data): |
|||
pass |
|||
|
|||
def _load_pos_data(self, data): |
|||
domain = [] |
|||
fields = self._load_pos_data_fields(data['pos.config']['data'][0]['id']) |
|||
return { |
|||
'data': self.search_read([], fields, load=False), |
|||
'fields': self._load_pos_data_fields(data['pos.config']['data'][0]['id']), |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import fields, models, api |
|||
|
|||
|
|||
class PosPaymentMethod(models.Model): |
|||
"""Adding fields to pos payment method""" |
|||
_inherit = "pos.payment.method" |
|||
|
|||
wallet_journal = fields.Boolean(related="journal_id.wallet_journal", |
|||
string="Wallet Journal", |
|||
help="Journal for wallet") |
|||
|
|||
@api.model |
|||
def _load_pos_data_fields(self, config_id): |
|||
"""The list of field to be loaded for POS data.""" |
|||
fields = super()._load_pos_data_fields(config_id) |
|||
fields += ['wallet_journal'] |
|||
return fields |
|||
@ -0,0 +1,32 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import models |
|||
|
|||
|
|||
class PosSession(models.Model): |
|||
"""Class to load models in to pos session""" |
|||
_inherit = "pos.session" |
|||
|
|||
def _load_pos_data_models(self, config_id): |
|||
res = super(PosSession, self)._load_pos_data_models(config_id) |
|||
res += ['account.journal'] |
|||
return res |
|||
@ -0,0 +1,98 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import api, fields, models |
|||
from odoo.exceptions import ValidationError |
|||
|
|||
|
|||
class ResPartner(models.Model): |
|||
"""Add field into res partner""" |
|||
_inherit = 'res.partner' |
|||
|
|||
wallet_balance = fields.Float(string="Wallet Balance", |
|||
help="Wallet balance of each employee") |
|||
wallet_count = fields.Integer(string="Wallet", |
|||
compute='_compute_wallet_count', |
|||
help="Count of each wallet recharge") |
|||
|
|||
@api.model |
|||
def _load_pos_data_fields(self, config_id): |
|||
fields = super()._load_pos_data_fields(config_id) |
|||
fields.append('wallet_balance') |
|||
return fields |
|||
|
|||
def action_recharge(self): |
|||
"""Open wizard for wallet recharge and user |
|||
can use this wizard to recharge the wallet balance.""" |
|||
return { |
|||
'name': 'Wallet Recharge', |
|||
'type': 'ir.actions.act_window', |
|||
'res_model': 'recharge.wallet', |
|||
'view_mode': 'form', |
|||
'view_type': 'form', |
|||
'target': 'new', |
|||
} |
|||
|
|||
def action_number_of_wallet(self): |
|||
"""Wallet balance tree view""" |
|||
self.ensure_one() |
|||
return { |
|||
'type': 'ir.actions.act_window', |
|||
'name': 'Wallet', |
|||
'view_mode': 'list', |
|||
'res_model': 'wallet.transaction', |
|||
'domain': [('customer', '=', self.name)], |
|||
'context': "{'create': False}" |
|||
} |
|||
|
|||
def _compute_wallet_count(self): |
|||
"""This computed method calculates the number of wallet |
|||
transactions associated with each partner and updates the `wallet_count` field accordingly.""" |
|||
for record in self: |
|||
record.wallet_count = self.env['wallet.transaction'].search_count( |
|||
[('customer', '=', self.name)]) |
|||
|
|||
@api.model |
|||
def write_value(self, wallet_balance, partner_id, session, price, currency_id): |
|||
partner = self.env['res.partner'].browse(partner_id) |
|||
if not partner.exists(): |
|||
raise ValidationError("Partner not found") |
|||
|
|||
existing_transaction = self.env['wallet.transaction'].search([ |
|||
('customer', '=', partner.name), |
|||
('amount', '=', price), |
|||
('pos_order', '=', str(session)), |
|||
('type', '=', 'Debit') |
|||
], limit=1) |
|||
|
|||
if existing_transaction: |
|||
return |
|||
partner.wallet_balance = wallet_balance |
|||
current_session = self.env['pos.session'].search([('state', '=', 'opened')], limit=1) |
|||
session_name = current_session.name if current_session else f"Session-{session}" |
|||
|
|||
self.env['wallet.transaction'].create({ |
|||
'type': "Debit", |
|||
'customer': partner.name, |
|||
'amount': price, |
|||
'pos_order': session_name, |
|||
'currency': currency_id, |
|||
}) |
|||
@ -0,0 +1,46 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import api, fields, models |
|||
|
|||
|
|||
class WalletTransaction(models.Model): |
|||
"""Adding wallet transaction fields""" |
|||
_name = 'wallet.transaction' |
|||
_description = "Wallet Transaction" |
|||
|
|||
name = fields.Char(string="Name", help="Sequence of wallet transaction") |
|||
type = fields.Char(string="Type", help="Type of wallet transaction") |
|||
customer = fields.Char(string="Customer", |
|||
help="Customer of wallet transaction") |
|||
pos_order = fields.Char(string="POS Order", |
|||
help="Order reference of wallet transaction") |
|||
amount = fields.Float(string="Amount", |
|||
help="Amount of wallet transaction") |
|||
currency = fields.Char(string="Currency", |
|||
help="Currency of wallet transaction") |
|||
|
|||
@api.model |
|||
def create(self, vals): |
|||
"""Create sequence for wallet transaction""" |
|||
vals['name'] = self.env['ir.sequence'].next_by_code( |
|||
'wallet.transaction') |
|||
return super(WalletTransaction, self).create(vals) |
|||
|
|
After Width: | Height: | Size: 600 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 495 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 624 B |
|
After Width: | Height: | Size: 136 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 310 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 576 B |
|
After Width: | Height: | Size: 733 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 911 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 600 B |
|
After Width: | Height: | Size: 673 B |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 926 B |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 878 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 653 B |
|
After Width: | Height: | Size: 905 B |
|
After Width: | Height: | Size: 839 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 427 B |
|
After Width: | Height: | Size: 627 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 988 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 875 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 589 B |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 967 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 767 KiB |
|
After Width: | Height: | Size: 138 KiB |
|
After Width: | Height: | Size: 760 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 697 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 222 KiB |
|
After Width: | Height: | Size: 180 KiB |
|
After Width: | Height: | Size: 457 KiB |
|
After Width: | Height: | Size: 127 KiB |
|
After Width: | Height: | Size: 320 KiB |
|
After Width: | Height: | Size: 168 KiB |
|
After Width: | Height: | Size: 412 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 125 KiB |
|
After Width: | Height: | Size: 129 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 122 KiB |
|
After Width: | Height: | Size: 787 KiB |
|
After Width: | Height: | Size: 41 KiB |
@ -0,0 +1,52 @@ |
|||
/** @odoo-module */ |
|||
import { PartnerLine } from "@point_of_sale/app/screens/partner_list/partner_line/partner_line"; |
|||
import { patch } from "@web/core/utils/patch"; |
|||
import { PosStore } from "@point_of_sale/app/store/pos_store"; |
|||
import { _t } from "@web/core/l10n/translation"; |
|||
import { RechargeScreen } from "./wallet_recharge"; |
|||
import { useService } from "@web/core/utils/hooks"; |
|||
|
|||
patch(PosStore.prototype, { |
|||
async setup() { |
|||
await super.setup(...arguments); |
|||
this.loadServer() |
|||
this["account_journal"] = []; |
|||
}, |
|||
|
|||
async loadServer() { |
|||
const model_data = this.data['account.journal']; |
|||
if (model_data && model_data.data) { |
|||
this.account_journal = model_data.data; |
|||
} else { |
|||
this.account_journal = []; |
|||
} |
|||
} |
|||
}); |
|||
|
|||
patch(PartnerLine.prototype, { |
|||
setup() { |
|||
super.setup(...arguments); |
|||
this.dialog = useService("dialog"); |
|||
this.pos = useService("pos"); |
|||
}, |
|||
|
|||
onClickWallet(ev) { |
|||
if (ev) { |
|||
ev.stopPropagation(); |
|||
} |
|||
|
|||
const partner = this.props.partner; |
|||
if (!partner) { |
|||
console.error("Partner is not defined"); |
|||
return; |
|||
} |
|||
const data = this.pos.account_journal || []; |
|||
|
|||
this.dialog.add(RechargeScreen, { |
|||
title: _t("Wallet Recharge"), |
|||
partner: partner, |
|||
data: data, |
|||
}); |
|||
|
|||
} |
|||
}); |
|||
@ -0,0 +1,85 @@ |
|||
/** @odoo-module */ |
|||
import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen"; |
|||
import { browser } from "@web/core/browser/browser"; |
|||
import { patch } from "@web/core/utils/patch"; |
|||
import { _t } from "@web/core/l10n/translation"; |
|||
|
|||
|
|||
patch(PaymentScreen.prototype, { |
|||
setup() { |
|||
super.setup(...arguments); |
|||
}, |
|||
|
|||
async addNewPaymentLine(paymentMethod) { |
|||
var partner = this.currentOrder.get_partner(); |
|||
var selected_orderline = this.currentOrder.get_selected_orderline(); |
|||
|
|||
if (!partner) { |
|||
this.env.services.notification.add(_t("Choose Customer First"), { type: 'danger' }); |
|||
return; |
|||
} |
|||
else if (!selected_orderline) { |
|||
this.env.services.notification.add(_t("Choose Product First"), { type: 'danger' }); |
|||
return; |
|||
} |
|||
else { |
|||
return super.addNewPaymentLine(paymentMethod); |
|||
} |
|||
}, |
|||
|
|||
async validateOrder(isForceValidate) { |
|||
try { |
|||
if (this.currentOrder._walletProcessed) { |
|||
return super.validateOrder(isForceValidate); |
|||
} |
|||
|
|||
const paymentLines = this.currentOrder.paymentlines || this.currentOrder.payment_ids || []; |
|||
let hasWalletPayment = false; |
|||
|
|||
for (const paymentLine of paymentLines) { |
|||
const paymentMethod = paymentLine.payment_method || paymentLine.payment_method_id; |
|||
|
|||
console.log("paymentMethod--->>", paymentMethod); |
|||
debugger |
|||
|
|||
if (paymentMethod && paymentMethod.wallet_journal) { |
|||
hasWalletPayment = true; |
|||
|
|||
this.currentOrder._walletProcessed = true; |
|||
var price = paymentLine.amount; |
|||
var session = this.pos.config.current_session_id[1]; |
|||
var currency_id = this.pos.company.currency_id[1]; |
|||
var partner = this.currentOrder.get_partner(); |
|||
var wallet_balance = partner.wallet_balance; |
|||
|
|||
if (wallet_balance < price) { |
|||
this.currentOrder._walletProcessed = false; |
|||
this.env.services.notification.add(_t("Not enough wallet balance"), { type: 'danger' }); |
|||
return; |
|||
} else { |
|||
try { |
|||
var balance = wallet_balance - price; |
|||
var currency_name = this.pos.currency.name; |
|||
await this.env.services.orm.call("res.partner", "write_value", [balance, partner.id, session, price, currency_name]); |
|||
|
|||
partner.wallet_balance = balance; |
|||
|
|||
break; |
|||
} catch (error) { |
|||
this.currentOrder._walletProcessed = false; |
|||
this.env.services.notification.add(_t("Failed to update wallet balance"), { type: 'danger' }); |
|||
return; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return super.validateOrder(isForceValidate); |
|||
|
|||
} catch (error) { |
|||
if (this.currentOrder) { |
|||
this.currentOrder._walletProcessed = false; |
|||
} |
|||
this.env.services.notification.add(_t("An error occurred during order validation"), { type: 'danger' }); |
|||
} |
|||
} |
|||
}); |
|||
@ -0,0 +1,102 @@ |
|||
/** @odoo-module */ |
|||
import { Component } from "@odoo/owl"; |
|||
import { browser } from "@web/core/browser/browser"; |
|||
import { useRef, onMounted,onWillStart } from "@odoo/owl"; |
|||
import { useService } from "@web/core/utils/hooks"; |
|||
import { _t } from "@web/core/l10n/translation"; |
|||
import { Dialog } from "@web/core/dialog/dialog"; |
|||
|
|||
|
|||
export class RechargeScreen extends Component { |
|||
static template = "pos_customer_wallet_management.RechargeScreen"; |
|||
|
|||
static props = { |
|||
confirmText: { type: String, optional: true }, |
|||
cancelText: { type: String, optional: true }, |
|||
title: { type: String, optional: true }, |
|||
partner: { type: Object }, |
|||
data: { type: Array }, |
|||
close: { type: Function } |
|||
}; |
|||
|
|||
static components = { |
|||
Dialog |
|||
} |
|||
|
|||
static defaultProps = { |
|||
confirmText: 'Add', |
|||
cancelText: 'Cancel', |
|||
title: 'Wallet Recharge' |
|||
}; |
|||
|
|||
setup() { |
|||
this.amount_input = useRef("amountInput"); |
|||
this.journalInput = useRef("journalInput"); |
|||
this.orm = useService('orm'); |
|||
this.notification = useService('notification'); |
|||
|
|||
// Ensure journals is always an array
|
|||
this.journals = []; |
|||
|
|||
onWillStart(async () => { |
|||
this.journals = await this.orm.searchRead( |
|||
"account.journal", |
|||
[],["id", "name"]) |
|||
}); |
|||
|
|||
onMounted(() => { |
|||
if (this.amount_input.el) { |
|||
this.amount_input.el.focus(); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
async confirm() { |
|||
const journalId = parseInt(this.journalInput.el.value); |
|||
|
|||
if (!this.amount_input.el || !this.journalInput.el) { |
|||
return; |
|||
} |
|||
|
|||
const partner = this.props.partner; |
|||
const amount_input = this.amount_input.el.value; |
|||
const journalInput = this.journalInput.el.value; |
|||
|
|||
if (amount_input.trim() === '' || journalInput.trim() === '') { |
|||
this._showErrorMsg(_t("Please fill all fields")); |
|||
return; |
|||
} |
|||
|
|||
try { |
|||
const pos = this.env.services.pos; |
|||
const currency = this.env.services.pos.currency.name; |
|||
const session = this.env.services.pos.config.current_session_id.id; |
|||
|
|||
const rpc = await this.orm.call("recharge.wallet", "frontend_recharge", [ |
|||
partner.id, |
|||
parseFloat(amount_input), |
|||
currency, |
|||
session, |
|||
journalId |
|||
]); |
|||
|
|||
this.notification.add(_t('Successfully Recharged Your Wallet'), { |
|||
type: 'success', |
|||
}); |
|||
this.props.close(); |
|||
browser.location.reload(); |
|||
} catch (error) { |
|||
this._showErrorMsg(_t("Failed to recharge wallet")); |
|||
} |
|||
} |
|||
|
|||
cancel() { |
|||
this.props.close(); |
|||
} |
|||
|
|||
_showErrorMsg(msg) { |
|||
this.notification.add(msg, { |
|||
type: 'danger', |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!--Wallet balance of customer in set partner button--> |
|||
<templates id="template_id" xml:space="preserve"> |
|||
<t t-name="pos_customer_wallet_management.ActionpadWidget" t-inherit="point_of_sale.SelectPartnerButton" |
|||
t-inherit-mode="extension" owl="1"> |
|||
<xpath expr="//button[hasclass('set-partner')]" position="inside"> |
|||
<div t-if="props.partner"> |
|||
<b>WALLET[<t t-esc="props.partner.wallet_balance !== undefined ? props.partner.wallet_balance.toFixed(2) : '0.00'"/>]</b> |
|||
</div> |
|||
</xpath> |
|||
</t> |
|||
<t t-name="pos_customer_wallet_management.PaymentScreen" t-inherit="point_of_sale.PaymentScreenButtons" |
|||
t-inherit-mode="extension" owl="1"> |
|||
<xpath expr="//button[hasclass('partner-button')]" position="inside"> |
|||
<div> |
|||
<t t-set="partner" t-value="currentOrder.get_partner()"/> |
|||
<span> |
|||
<t t-if="partner"> |
|||
<br/>WALLET[<t t-esc="partner.wallet_balance !== undefined ? partner.wallet_balance.toFixed(2) : '0.00'"/>] |
|||
</t> |
|||
</span> |
|||
</div> |
|||
</xpath> |
|||
</t> |
|||
</templates> |
|||