[MIG] pos_check_deposit to v18
This commit is contained in:
20
pos_check_deposit/README.rst
Normal file
20
pos_check_deposit/README.rst
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
POS Check Deposit
|
||||||
|
=================
|
||||||
|
|
||||||
|
On POS payment method, there is a boolean field named **split_transactions** which has a string **Identify Customer**. When this option is enabled, the payment move lines are split (which is required for the account_check_deposit module) and you must select a Customer on the POS order (which is not really needed for a payment by check).
|
||||||
|
|
||||||
|
The goal of this module is to have 2 different options on POS payment method:
|
||||||
|
|
||||||
|
* split_transactions (the current field), to split the payment move lines
|
||||||
|
* identify_customer (a new field), to require the selection of a customer on the POS order
|
||||||
|
|
||||||
|
That way, you can configure the **Check** payment method with split_transactions enabled and identify_customer disabled.
|
||||||
|
|
||||||
|
WARNING: this module requires a patch on the point_of_sale module. The patch is available in the root directory of the module under the name **odoo-pos_check_deposit.diff**.
|
||||||
|
|
||||||
|
Authors
|
||||||
|
-------
|
||||||
|
|
||||||
|
Akretion:
|
||||||
|
|
||||||
|
* Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
@@ -1,41 +1,16 @@
|
|||||||
# Copyright 2022 Akretion France (http://www.akretion.com/)
|
# Copyright 2022-2024 Akretion France (https://www.akretion.com/)
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "POS Check Deposit",
|
"name": "POS Check Deposit",
|
||||||
"version": "16.0.1.0.0",
|
"version": "18.0.1.0.0",
|
||||||
"category": "Point of sale",
|
"category": "Point of sale",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"summary": "Make POS and Check Deposit module work together",
|
"summary": "Make POS and Check Deposit modules work together",
|
||||||
"description": """
|
|
||||||
POS Check Deposit
|
|
||||||
=================
|
|
||||||
|
|
||||||
On POS payment method, there is a boolean field named 'split_transactions' which has a string "Identify Customer". When this option is enabled, the payment move lines are split (which is required for the account_check_deposit module) and you must select a Customer on the POS order (which is not really needed for a payment by check).
|
|
||||||
|
|
||||||
The goal of this module is to have 2 different options on POS payment method:
|
|
||||||
|
|
||||||
* split_transactions (the current field), to split the payment move lines
|
|
||||||
* identify_customer (a new field), to require the selection of a customer on the POS order
|
|
||||||
|
|
||||||
That way, you can configure the **Check** payment method with split_transactions enabled and identify_customer disabled.
|
|
||||||
|
|
||||||
WARNING: this module requires a patch on the point_of_sale module. The patch is available in the root directory of the module under the name **odoo-pos_check_deposit.diff**.
|
|
||||||
|
|
||||||
Authors
|
|
||||||
-------
|
|
||||||
|
|
||||||
Akretion:
|
|
||||||
|
|
||||||
* Alexis de Lattre <alexis.delattre@akretion.com>
|
|
||||||
|
|
||||||
""",
|
|
||||||
"author": "Akretion",
|
"author": "Akretion",
|
||||||
"website": "https://github.com/akretion/odoo-usability",
|
"website": "https://github.com/akretion/odoo-usability",
|
||||||
"depends": ["point_of_sale"],
|
"depends": ["point_of_sale"],
|
||||||
"data": [
|
"data": ["views/pos_payment_method.xml"],
|
||||||
"views/pos_payment_method.xml",
|
"installable": True,
|
||||||
],
|
|
||||||
"installable": False,
|
|
||||||
}
|
}
|
||||||
|
|||||||
50
pos_check_deposit/i18n/fr.po
Normal file
50
pos_check_deposit/i18n/fr.po
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * pos_check_deposit
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 18.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2024-12-24 10:27+0000\n"
|
||||||
|
"PO-Revision-Date: 2024-12-24 10:27+0000\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_check_deposit
|
||||||
|
#: model:ir.model.fields,field_description:pos_check_deposit.field_pos_payment_method__identify_customer
|
||||||
|
msgid "Identify Customer"
|
||||||
|
msgstr "Identifier le client"
|
||||||
|
|
||||||
|
#. module: pos_check_deposit
|
||||||
|
#. odoo-python
|
||||||
|
#: code:addons/pos_check_deposit/models/pos_payment_method.py:0
|
||||||
|
msgid ""
|
||||||
|
"On payment method '%s' the option 'Identify Customer' is enabled, so the "
|
||||||
|
"option 'Split Transactions' must be enabled too."
|
||||||
|
msgstr ""
|
||||||
|
"Pour le mode de paiement '%s', l'option 'Identifier le client' est activée, "
|
||||||
|
"l'option 'Fractionner les transactions' doit donc l'être également."
|
||||||
|
|
||||||
|
#. module: pos_check_deposit
|
||||||
|
#: model:ir.model,name:pos_check_deposit.model_pos_payment_method
|
||||||
|
msgid "Point of Sale Payment Methods"
|
||||||
|
msgstr "Modes de paiement du point de vente"
|
||||||
|
|
||||||
|
#. module: pos_check_deposit
|
||||||
|
#: model:ir.model.fields,field_description:pos_check_deposit.field_pos_payment_method__split_transactions
|
||||||
|
msgid "Split Transactions"
|
||||||
|
msgstr "Fractionner les transactions"
|
||||||
|
|
||||||
|
#. module: pos_check_deposit
|
||||||
|
#: model:ir.model.fields,help:pos_check_deposit.field_pos_payment_method__split_transactions
|
||||||
|
msgid ""
|
||||||
|
"Splits the journal entries for each transaction. It could slow down the "
|
||||||
|
"closing process."
|
||||||
|
msgstr ""
|
||||||
|
"Découpe les pièces comptables par transaction. Ceci peut ralentir le processus de "
|
||||||
|
"fermeture."
|
||||||
@@ -1,2 +1 @@
|
|||||||
from . import pos_payment_method
|
from . import pos_payment_method
|
||||||
from . import pos_session
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2022 Akretion France (http://www.akretion.com/)
|
# Copyright 2022-2024 Akretion France (http://www.akretion.com/)
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
@@ -9,8 +9,14 @@ from odoo.exceptions import ValidationError
|
|||||||
class PosPaymentMethod(models.Model):
|
class PosPaymentMethod(models.Model):
|
||||||
_inherit = "pos.payment.method"
|
_inherit = "pos.payment.method"
|
||||||
|
|
||||||
split_transactions = fields.Boolean(string="Split Transactions")
|
# native field, just change string (origin string is "Identify Customer")
|
||||||
identify_customer = fields.Boolean(string='Identify Customer')
|
split_transactions = fields.Boolean(
|
||||||
|
string="Split Transactions",
|
||||||
|
help="Splits the journal entries for each transaction. It could slow down the closing process.",
|
||||||
|
)
|
||||||
|
# new field
|
||||||
|
identify_customer = fields.Boolean(
|
||||||
|
compute='_compute_identify_customer', store=True, readonly=False, precompute=True)
|
||||||
|
|
||||||
@api.constrains('split_transactions', 'identify_customer')
|
@api.constrains('split_transactions', 'identify_customer')
|
||||||
def _check_split_transactions_identify_customer(self):
|
def _check_split_transactions_identify_customer(self):
|
||||||
@@ -21,7 +27,8 @@ class PosPaymentMethod(models.Model):
|
|||||||
"is enabled, so the option 'Split Transactions' must "
|
"is enabled, so the option 'Split Transactions' must "
|
||||||
"be enabled too.") % method.display_name)
|
"be enabled too.") % method.display_name)
|
||||||
|
|
||||||
@api.onchange('split_transactions')
|
@api.depends('split_transactions')
|
||||||
def split_transactions_change(self):
|
def _compute_identify_customer(self):
|
||||||
if not self.split_transactions and self.identify_customer:
|
for method in self:
|
||||||
self.identify_customer = False
|
if not method.split_transactions and method.identify_customer:
|
||||||
|
method.identify_customer = False
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
# Copyright 2022 Akretion France (http://www.akretion.com/)
|
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo import models
|
|
||||||
|
|
||||||
|
|
||||||
class PosSession(models.Model):
|
|
||||||
_inherit = "pos.session"
|
|
||||||
|
|
||||||
def _loader_params_pos_payment_method(self):
|
|
||||||
res = super()._loader_params_pos_payment_method()
|
|
||||||
res['search_params']['fields'].append('identify_customer')
|
|
||||||
return res
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py
|
diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py
|
||||||
index 31e39105612..fe74620369a 100644
|
index 546dbece6c4..0add2935f52 100644
|
||||||
--- a/addons/point_of_sale/models/pos_session.py
|
--- a/addons/point_of_sale/models/pos_session.py
|
||||||
+++ b/addons/point_of_sale/models/pos_session.py
|
+++ b/addons/point_of_sale/models/pos_session.py
|
||||||
@@ -928,8 +928,13 @@ class PosSession(models.Model):
|
@@ -1123,8 +1123,13 @@ class PosSession(models.Model):
|
||||||
if not payment_method.journal_id:
|
if not payment_method.journal_id:
|
||||||
return self.env['account.move.line']
|
return self.env['account.move.line']
|
||||||
outstanding_account = payment_method.outstanding_account_id or self.company_id.account_journal_payment_debit_account_id
|
outstanding_account = payment_method.outstanding_account_id
|
||||||
- accounting_partner = self.env["res.partner"]._find_accounting_partner(payment.partner_id)
|
- accounting_partner = self.env["res.partner"]._find_accounting_partner(payment.partner_id)
|
||||||
- destination_account = accounting_partner.property_account_receivable_id
|
- destination_account = accounting_partner.property_account_receivable_id
|
||||||
+ # HACK for pos_check_deposit
|
+ # HACK for pos_check_deposit
|
||||||
@@ -14,20 +14,31 @@ index 31e39105612..fe74620369a 100644
|
|||||||
+ destination_account = accounting_partner.property_account_receivable_id
|
+ destination_account = accounting_partner.property_account_receivable_id
|
||||||
+ else:
|
+ else:
|
||||||
+ accounting_partner = False
|
+ accounting_partner = False
|
||||||
+ destination_account = self._get_receivable_account(payment.payment_method_id)
|
+ destination_account = self._get_receivable_account(payment_method)
|
||||||
|
|
||||||
if float_compare(amounts['amount'], 0, precision_rounding=self.currency_id.rounding) < 0:
|
if float_compare(amounts['amount'], 0, precision_rounding=self.currency_id.rounding) < 0:
|
||||||
# revert the accounts because account.payment doesn't accept negative amount.
|
# revert the accounts because account.payment doesn't accept negative amount.
|
||||||
@@ -937,7 +942,7 @@ class PosSession(models.Model):
|
@@ -1132,7 +1137,8 @@ class PosSession(models.Model):
|
||||||
|
|
||||||
account_payment = self.env['account.payment'].create({
|
account_payment = self.env['account.payment'].create({
|
||||||
'amount': abs(amounts['amount']),
|
'amount': abs(amounts['amount']),
|
||||||
- 'partner_id': payment.partner_id.id,
|
- 'partner_id': payment.partner_id.id,
|
||||||
|
+ # HACK for pos_check_deposit
|
||||||
+ 'partner_id': accounting_partner and accounting_partner.id or False,
|
+ 'partner_id': accounting_partner and accounting_partner.id or False,
|
||||||
'journal_id': payment_method.journal_id.id,
|
'journal_id': payment_method.journal_id.id,
|
||||||
'force_outstanding_account_id': outstanding_account.id,
|
'force_outstanding_account_id': outstanding_account.id,
|
||||||
'destination_account_id': destination_account.id,
|
'destination_account_id': destination_account.id,
|
||||||
@@ -1097,8 +1102,8 @@ class PosSession(models.Model):
|
@@ -1141,7 +1147,8 @@ class PosSession(models.Model):
|
||||||
|
'pos_session_id': self.id,
|
||||||
|
})
|
||||||
|
account_payment.action_post()
|
||||||
|
- return account_payment.move_id.line_ids.filtered(lambda line: line.account_id == accounting_partner.property_account_receivable_id)
|
||||||
|
+ # HACK for pos_check_deposit
|
||||||
|
+ return account_payment.move_id.line_ids.filtered(lambda line: line.account_id == destination_account)
|
||||||
|
|
||||||
|
def _create_cash_statement_lines_and_cash_move_lines(self, data):
|
||||||
|
# Create the split and combine cash statement lines and account move lines.
|
||||||
|
@@ -1292,8 +1299,8 @@ class PosSession(models.Model):
|
||||||
lines.filtered(lambda line: not line.reconciled).reconcile()
|
lines.filtered(lambda line: not line.reconciled).reconcile()
|
||||||
|
|
||||||
for payment, lines in payment_to_receivable_lines.items():
|
for payment, lines in payment_to_receivable_lines.items():
|
||||||
@@ -38,15 +49,16 @@ index 31e39105612..fe74620369a 100644
|
|||||||
|
|
||||||
# Reconcile invoice payments' receivable lines. But we only do when the account is reconcilable.
|
# Reconcile invoice payments' receivable lines. But we only do when the account is reconcilable.
|
||||||
# Though `account_default_pos_receivable_account_id` should be of type receivable, there is currently
|
# Though `account_default_pos_receivable_account_id` should be of type receivable, there is currently
|
||||||
@@ -1176,15 +1181,17 @@ class PosSession(models.Model):
|
@@ -1333,16 +1340,17 @@ class PosSession(models.Model):
|
||||||
return self._credit_amounts(partial_args, amount, amount_converted)
|
return self._credit_amounts(partial_args, amount, amount_converted)
|
||||||
|
|
||||||
def _get_split_receivable_vals(self, payment, amount, amount_converted):
|
def _get_split_receivable_vals(self, payment, amount, amount_converted):
|
||||||
- accounting_partner = self.env["res.partner"]._find_accounting_partner(payment.partner_id)
|
- accounting_partner = self.env["res.partner"]._find_accounting_partner(payment.partner_id)
|
||||||
- if not accounting_partner:
|
- if not accounting_partner:
|
||||||
- raise UserError(_("You have enabled the \"Identify Customer\" option for %s payment method,"
|
- raise UserError(_("You have enabled the \"Identify Customer\" option for %(payment_method)s payment method,"
|
||||||
- "but the order %s does not contain a customer.") % (payment.payment_method_id.name,
|
- "but the order %(order)s does not contain a customer.",
|
||||||
- payment.pos_order_id.name))
|
- payment_method=payment.payment_method_id.name,
|
||||||
|
- order=payment.pos_order_id.name))
|
||||||
+ # HACK for pos_check_deposit
|
+ # HACK for pos_check_deposit
|
||||||
+ if payment.partner_id:
|
+ if payment.partner_id:
|
||||||
+ accounting_partner = self.env["res.partner"]._find_accounting_partner(payment.partner_id)
|
+ accounting_partner = self.env["res.partner"]._find_accounting_partner(payment.partner_id)
|
||||||
@@ -63,17 +75,18 @@ index 31e39105612..fe74620369a 100644
|
|||||||
'name': '%s - %s' % (self.name, payment.payment_method_id.name),
|
'name': '%s - %s' % (self.name, payment.payment_method_id.name),
|
||||||
}
|
}
|
||||||
return self._debit_amounts(partial_vals, amount, amount_converted)
|
return self._debit_amounts(partial_vals, amount, amount_converted)
|
||||||
diff --git a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js
|
diff --git a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js
|
||||||
index b9a237eb34c..62ad67e9517 100644
|
index c94484b8a26..39d3b66cc63 100644
|
||||||
--- a/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js
|
--- a/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js
|
||||||
+++ b/addons/point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreen.js
|
+++ b/addons/point_of_sale/static/src/app/screens/payment_screen/payment_screen.js
|
||||||
@@ -288,7 +288,8 @@ odoo.define('point_of_sale.PaymentScreen', function (require) {
|
@@ -407,8 +407,9 @@ export class PaymentScreen extends Component {
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
async _askForCustomerIfRequired() {
|
||||||
- const splitPayments = this.paymentLines.filter(payment => payment.payment_method.split_transactions)
|
+ // HACK for pos_check_deposit
|
||||||
+ // HACK for pos_check_deposit
|
const splitPayments = this.paymentLines.filter(
|
||||||
+ const splitPayments = this.paymentLines.filter(payment => payment.payment_method.identify_customer)
|
- (payment) => payment.payment_method_id.split_transactions
|
||||||
if (splitPayments.length && !this.currentOrder.get_partner()) {
|
+ (payment) => payment.payment_method_id.identify_customer
|
||||||
const paymentMethod = splitPayments[0].payment_method
|
);
|
||||||
const { confirmed } = await this.showPopup('ConfirmPopup', {
|
if (splitPayments.length && !this.currentOrder.get_partner()) {
|
||||||
|
const paymentMethod = splitPayments[0].payment_method_id;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright 2022 Akretion France (http://www.akretion.com/)
|
Copyright 2022-2024 Akretion France (https://www.akretion.com/)
|
||||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<field name="inherit_id" ref="point_of_sale.pos_payment_method_view_form"/>
|
<field name="inherit_id" ref="point_of_sale.pos_payment_method_view_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="split_transactions" position="after">
|
<field name="split_transactions" position="after">
|
||||||
<field name="identify_customer" attrs="{'invisible': [('split_transactions', '=', False)]}"/>
|
<field name="identify_customer" invisible="not split_transactions"/>
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<field name="inherit_id" ref="point_of_sale.pos_payment_method_view_tree"/>
|
<field name="inherit_id" ref="point_of_sale.pos_payment_method_view_tree"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="split_transactions" position="after">
|
<field name="split_transactions" position="after">
|
||||||
<field name="identify_customer" attrs="{'invisible': [('split_transactions', '=', False)]}" optional="hide"/>
|
<field name="identify_customer" invisible="not split_transactions" optional="hide"/>
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user