Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
103 changes: 103 additions & 0 deletions pos_check_accounting_settings/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
=========================================
Point of Sale - Check Accounting Settings
=========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:95ba837ae556e8ecb7af92cc67c3a0b664e5bc119051ebb1d5a73e01bcdf16ab
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-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_check_accounting_settings
: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_check_accounting_settings
: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
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionnality of Odoo PoS adding extra
checks, when opening session, to ensure that accounting configation
is correct.

Use case 1
~~~~~~~~~~

When we create a payment method and if:
- the field 'Outstanding Payment' is not set on payment method
- AND the field 'Outstanding Receipts Account' is not on company

if we use the payment method in the Point of sale, it is not
possible to close the session after.

.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_check_accounting_settings/static/img/error_oustanding_payment.png

As it not possible to change a payment method when a session
is not closed, this bad configuration has to be fixed by SQL.

This module adds a check when opening session, to avoid such situation.

**Table of contents**

.. contents::
:local:

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_check_accounting_settings%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.

Credits
=======

Authors
~~~~~~~

* GRAP

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

* Sylvain LE GAL (https://twitter.com/legalsylvain)

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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

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

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_check_accounting_settings>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions pos_check_accounting_settings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions pos_check_accounting_settings/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2024 - 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).
{
"name": "Point of Sale - Check Accounting Settings",
"version": "16.0.1.0.0",
"category": "Point of Sale",
"summary": "Prevent incorrect accounting configuration"
" when launching Point Of Sale",
"depends": ["point_of_sale"],
"website": "https://github.com/OCA/pos",
"author": "GRAP,Odoo Community Association (OCA)",
"maintainers": ["legalsylvain"],
"license": "LGPL-3",
}
35 changes: 35 additions & 0 deletions pos_check_accounting_settings/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_check_accounting_settings
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-29 22:22+0000\n"
"PO-Revision-Date: 2024-06-29 22:22+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_accounting_settings
#. odoo-python
#: code:addons/pos_check_accounting_settings/models/pos_config.py:0
#, python-format
msgid ""
"No outstanding payments/receipts account for the payment method "
"'%(payment_method_name)s'. Please set the field 'Outstanding Payment' on the"
" payment method or the field 'Outstanding Receipts Account' on the company "
"settings."
msgstr ""
"Pas de compte de paiements entrants/sortants en suspens pour la méthode de paiement "
"'%(payment_method_name)s'. Veuillez renseigner le champs 'Paiements sortants en suspens' sur la méthode de paiement, ou le champs 'Compte de paiements entrants en suspens'"
" dans les paramétrage de la société."

#. module: pos_check_accounting_settings
#: model:ir.model,name:pos_check_accounting_settings.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Configuration du point de vente"
1 change: 1 addition & 0 deletions pos_check_accounting_settings/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import pos_config
31 changes: 31 additions & 0 deletions pos_check_accounting_settings/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (C) 2024 - 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).

from odoo import _, models
from odoo.exceptions import UserError


class PosConfig(models.Model):
_inherit = "pos.config"

def _check_before_creating_new_session(self):
res = super()._check_before_creating_new_session()
for payment_method in self.payment_method_ids.filtered(
lambda x: x.journal_id and x.journal_id.type != "cash"
):
company = payment_method.journal_id.company_id
if (
not payment_method.outstanding_account_id
and not company.account_journal_payment_debit_account_id
):
raise UserError(
_(
"No outstanding payments/receipts account for the payment method"
" '%(payment_method_name)s'."
" Please set the field 'Outstanding Payment' on the payment method"
" or the field 'Outstanding Receipts Account' on the company settings.",
payment_method_name=payment_method.name,
)
)
return res
1 change: 1 addition & 0 deletions pos_check_accounting_settings/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Sylvain LE GAL (https://twitter.com/legalsylvain)
20 changes: 20 additions & 0 deletions pos_check_accounting_settings/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
This module extends the functionnality of Odoo PoS adding extra
checks, when opening session, to ensure that accounting configation
is correct.

Use case 1
~~~~~~~~~~

When we create a payment method and if:
- the field 'Outstanding Payment' is not set on payment method
- AND the field 'Outstanding Receipts Account' is not on company

if we use the payment method in the Point of sale, it is not
possible to close the session after.

.. image:: ../static/img/error_oustanding_payment.png

As it not possible to change a payment method when a session
is not closed, this bad configuration has to be fixed by SQL.

This module adds a check when opening session, to avoid such situation.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading