Browse Source
Merge pull request #325 from Tecnativa/11.0-mig-pos_payment_entries_globalization
Merge pull request #325 from Tecnativa/11.0-mig-pos_payment_entries_globalization
[MIG] pos_payment_entries_globalization: Migration to 11.0pull/341/head
Pedro M. Baeza
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 763 additions and 0 deletions
-
98pos_payment_entries_globalization/README.rst
-
1pos_payment_entries_globalization/__init__.py
-
19pos_payment_entries_globalization/__manifest__.py
-
59pos_payment_entries_globalization/i18n/es.po
-
60pos_payment_entries_globalization/i18n/pos_payment_entries_globalization.pot
-
2pos_payment_entries_globalization/models/__init__.py
-
14pos_payment_entries_globalization/models/account_journal.py
-
103pos_payment_entries_globalization/models/pos_session.py
-
7pos_payment_entries_globalization/readme/CONFIGURE.rst
-
6pos_payment_entries_globalization/readme/CONTRIBUTORS.rst
-
5pos_payment_entries_globalization/readme/DESCRIPTION.rst
-
1pos_payment_entries_globalization/readme/USAGE.rst
-
BINpos_payment_entries_globalization/static/description/icon.png
-
1pos_payment_entries_globalization/tests/__init__.py
-
366pos_payment_entries_globalization/tests/test_pos_payment_entries_globalization.py
-
21pos_payment_entries_globalization/views/account_journal_view.xml
@ -0,0 +1,98 @@ |
|||||
|
================================= |
||||
|
POS payment entries globalization |
||||
|
================================= |
||||
|
|
||||
|
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||||
|
!! 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-OCA%2Fpos-lightgray.png?logo=github |
||||
|
:target: https://github.com/OCA/pos/tree/11.0/pos_payment_entries_globalization |
||||
|
:alt: OCA/pos |
||||
|
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png |
||||
|
:target: https://translation.odoo-community.org/projects/pos-11-0/pos-11-0-pos_payment_entries_globalization |
||||
|
:alt: Translate me on Weblate |
||||
|
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png |
||||
|
:target: https://runbot.odoo-community.org/runbot/184/11.0 |
||||
|
:alt: Try me on Runbot |
||||
|
|
||||
|
|badge1| |badge2| |badge3| |badge4| |badge5| |
||||
|
|
||||
|
This module allows to globalize payment entries created by the POS. |
||||
|
|
||||
|
In some cases, all banking transactions are received in a single bank statement |
||||
|
line. With this module, it's possible to reconcile this one line with the |
||||
|
payment globalization line. |
||||
|
|
||||
|
**Table of contents** |
||||
|
|
||||
|
.. contents:: |
||||
|
:local: |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
|
||||
|
To configure this module, you need to: |
||||
|
|
||||
|
* Configure globalize account and journal on POS payment methods |
||||
|
(Account journal). |
||||
|
|
||||
|
A globalization entry is generated for each globalization journal and each |
||||
|
globalization account defined on payment methods. |
||||
|
|
||||
|
Usage |
||||
|
===== |
||||
|
|
||||
|
Now it's easier to reconcile bank transactions with PoS payments. |
||||
|
|
||||
|
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 smashing it by providing a detailed and welcomed |
||||
|
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_payment_entries_globalization%0Aversion:%2011.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 |
||||
|
~~~~~~~ |
||||
|
|
||||
|
* ACSONE SA/NV |
||||
|
|
||||
|
Contributors |
||||
|
~~~~~~~~~~~~ |
||||
|
|
||||
|
* Adrien Peiffer <adrien.peiffer@acsone.eu> |
||||
|
* Meyomesse Gilles <meyomesse.gilles@gmail.com> |
||||
|
* `Tecnativa <https://www.tecnativa.com>`_ |
||||
|
|
||||
|
* David Vidal <david.vidal@tecnativa.com> |
||||
|
* Rafael Blasco <rafael.blasco@tecnativa.com> |
||||
|
|
||||
|
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. |
||||
|
|
||||
|
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/11.0/pos_payment_entries_globalization>`_ project on GitHub. |
||||
|
|
||||
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
@ -0,0 +1 @@ |
|||||
|
from . import models |
@ -0,0 +1,19 @@ |
|||||
|
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>) |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
{ |
||||
|
'name': "POS payment entries globalization", |
||||
|
'summary': """Globalize POS Payment""", |
||||
|
'author': 'ACSONE SA/NV,' |
||||
|
'Odoo Community Association (OCA)', |
||||
|
'website': "http://github.com/OCA/pos", |
||||
|
'category': 'Point Of Sale', |
||||
|
'version': '11.0.1.0.0', |
||||
|
'license': 'AGPL-3', |
||||
|
'depends': [ |
||||
|
'point_of_sale', |
||||
|
], |
||||
|
'data': [ |
||||
|
'views/account_journal_view.xml', |
||||
|
], |
||||
|
'installable': True, |
||||
|
} |
@ -0,0 +1,59 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * pos_payment_entries_globalization |
||||
|
# |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 11.0\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2019-02-21 09:03+0000\n" |
||||
|
"PO-Revision-Date: 2019-02-21 09:03+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_payment_entries_globalization |
||||
|
#: model:ir.model,name:pos_payment_entries_globalization.model_account_journal |
||||
|
msgid "Journal" |
||||
|
msgstr "Diario" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: model:ir.ui.view,arch_db:pos_payment_entries_globalization.view_account_journal_pos_user_form |
||||
|
msgid "Payment Globalization" |
||||
|
msgstr "Globalización de pagos" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: code:addons/pos_payment_entries_globalization/models/pos_session.py:35 |
||||
|
#: code:addons/pos_payment_entries_globalization/models/pos_session.py:59 |
||||
|
#, python-format |
||||
|
msgid "Payment globalization" |
||||
|
msgstr "Globalización de pagos" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: code:addons/pos_payment_entries_globalization/models/pos_session.py:44 |
||||
|
#, python-format |
||||
|
msgid "Payment globalization counterpart" |
||||
|
msgstr "Contrapartida de globalización de pagos" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: model:ir.model.fields,field_description:pos_payment_entries_globalization.field_account_journal_pos_payment_globalization |
||||
|
msgid "Pos Payment Globalization" |
||||
|
msgstr "Globalización de pagos en Punto de Venta" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: model:ir.model.fields,field_description:pos_payment_entries_globalization.field_account_journal_pos_payment_globalization_account |
||||
|
msgid "Pos Payment Globalization Account" |
||||
|
msgstr "Cuenta para globalización de pagos en Punto de Venta" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: model:ir.model.fields,field_description:pos_payment_entries_globalization.field_account_journal_pos_payment_globalization_journal |
||||
|
msgid "Pos Payment Globalization Journal" |
||||
|
msgstr "Diario para globalización de pagos en Punto de Venta" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: model:ir.model,name:pos_payment_entries_globalization.model_pos_session |
||||
|
msgid "pos.session" |
||||
|
msgstr "pos.session" |
@ -0,0 +1,60 @@ |
|||||
|
# Translation of Odoo Server. |
||||
|
# This file contains the translation of the following modules: |
||||
|
# * pos_payment_entries_globalization |
||||
|
# |
||||
|
msgid "" |
||||
|
msgstr "" |
||||
|
"Project-Id-Version: Odoo Server 11.0\n" |
||||
|
"Report-Msgid-Bugs-To: \n" |
||||
|
"POT-Creation-Date: 2019-02-21 09:05+0000\n" |
||||
|
"PO-Revision-Date: 2019-02-21 09:05+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_payment_entries_globalization |
||||
|
#: model:ir.model,name:pos_payment_entries_globalization.model_account_journal |
||||
|
msgid "Journal" |
||||
|
msgstr "" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: model:ir.ui.view,arch_db:pos_payment_entries_globalization.view_account_journal_pos_user_form |
||||
|
msgid "Payment Globalization" |
||||
|
msgstr "" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: code:addons/pos_payment_entries_globalization/models/pos_session.py:35 |
||||
|
#: code:addons/pos_payment_entries_globalization/models/pos_session.py:59 |
||||
|
#, python-format |
||||
|
msgid "Payment globalization" |
||||
|
msgstr "" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: code:addons/pos_payment_entries_globalization/models/pos_session.py:44 |
||||
|
#, python-format |
||||
|
msgid "Payment globalization counterpart" |
||||
|
msgstr "" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: model:ir.model.fields,field_description:pos_payment_entries_globalization.field_account_journal_pos_payment_globalization |
||||
|
msgid "Pos Payment Globalization" |
||||
|
msgstr "" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: model:ir.model.fields,field_description:pos_payment_entries_globalization.field_account_journal_pos_payment_globalization_account |
||||
|
msgid "Pos Payment Globalization Account" |
||||
|
msgstr "" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: model:ir.model.fields,field_description:pos_payment_entries_globalization.field_account_journal_pos_payment_globalization_journal |
||||
|
msgid "Pos Payment Globalization Journal" |
||||
|
msgstr "" |
||||
|
|
||||
|
#. module: pos_payment_entries_globalization |
||||
|
#: model:ir.model,name:pos_payment_entries_globalization.model_pos_session |
||||
|
msgid "pos.session" |
||||
|
msgstr "" |
||||
|
|
@ -0,0 +1,2 @@ |
|||||
|
from . import account_journal |
||||
|
from . import pos_session |
@ -0,0 +1,14 @@ |
|||||
|
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>) |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from odoo import models, fields |
||||
|
|
||||
|
|
||||
|
class AccountJournal(models.Model): |
||||
|
_inherit = 'account.journal' |
||||
|
|
||||
|
pos_payment_globalization = fields.Boolean() |
||||
|
pos_payment_globalization_account = fields.Many2one( |
||||
|
comodel_name='account.account') |
||||
|
pos_payment_globalization_journal = fields.Many2one( |
||||
|
comodel_name='account.journal') |
@ -0,0 +1,103 @@ |
|||||
|
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>) |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from odoo import models, fields, api, _ |
||||
|
from collections import defaultdict |
||||
|
|
||||
|
|
||||
|
class PosSession(models.Model): |
||||
|
_inherit = 'pos.session' |
||||
|
|
||||
|
@api.multi |
||||
|
def _get_move_lines_for_globalization(self): |
||||
|
""" Get all move lines for globalization by journal-account""" |
||||
|
self.ensure_one() |
||||
|
grouped_move_lines = defaultdict(list) |
||||
|
for st in self.statement_ids: |
||||
|
if st.journal_id.pos_payment_globalization: |
||||
|
# One move per journal and account combination |
||||
|
key = (st.journal_id.pos_payment_globalization_account.id, |
||||
|
st.journal_id.pos_payment_globalization_journal.id) |
||||
|
debit_account_id =\ |
||||
|
st.journal_id.default_debit_account_id.id |
||||
|
lines = st.move_line_ids.filtered( |
||||
|
lambda r: r.account_id.id == debit_account_id) |
||||
|
grouped_move_lines[key].extend(lines) |
||||
|
return grouped_move_lines |
||||
|
|
||||
|
@api.model |
||||
|
def _prepare_globalization_move(self, journal_id): |
||||
|
"""Create the globalization move""" |
||||
|
entries_vals = { |
||||
|
'journal_id': journal_id, |
||||
|
'date': fields.Date.today(), |
||||
|
'name': "%s - %s" % ( |
||||
|
self.name, _("Payment globalization")), |
||||
|
} |
||||
|
return self.env['account.move'].create(entries_vals) |
||||
|
|
||||
|
@api.model |
||||
|
def _prepare_globalization_counterpart_line(self, debit, credit, |
||||
|
account_id, move): |
||||
|
"""Create the globalization counterpart line""" |
||||
|
item_vals = { |
||||
|
'name': _("Payment globalization counterpart"), |
||||
|
'credit': credit, |
||||
|
'debit': debit, |
||||
|
'account_id': account_id, |
||||
|
'move_id': move.id |
||||
|
} |
||||
|
return self.env['account.move.line'].with_context( |
||||
|
{'check_move_validity': False}).create(item_vals) |
||||
|
|
||||
|
@api.model |
||||
|
def _create_reverse_line(self, line_to_reverse, move): |
||||
|
"""Create move line the reverse payment line in entries |
||||
|
genereted by pos""" |
||||
|
item_vals = { |
||||
|
'name': "%s - %s" % ( |
||||
|
line_to_reverse.name, _("Payment globalization")), |
||||
|
'credit': line_to_reverse.debit, |
||||
|
'debit': line_to_reverse.credit, |
||||
|
'account_id': line_to_reverse.account_id.id, |
||||
|
'move_id': move.id |
||||
|
} |
||||
|
# case of reverse account move line don't check move validity |
||||
|
# because it will assert balanced move |
||||
|
# that need : sum(debit) - sum(credit) must be gt 0 |
||||
|
return self.env['account.move.line'].with_context( |
||||
|
{'check_move_validity': False}).create(item_vals) |
||||
|
|
||||
|
@api.multi |
||||
|
def _generate_globalization_entries(self): |
||||
|
"""Generate globalization moves""" |
||||
|
self.ensure_one() |
||||
|
grouped_move_lines = self._get_move_lines_for_globalization() |
||||
|
to_reconcile = [] |
||||
|
for key, lines in grouped_move_lines.items(): |
||||
|
global_account_id, global_journal_id = key |
||||
|
move = self._prepare_globalization_move(global_journal_id) |
||||
|
counterpart_debit = 0.0 |
||||
|
counterpart_credit = 0.0 |
||||
|
for line in lines: |
||||
|
counterpart_debit += line.debit |
||||
|
counterpart_credit += line.credit |
||||
|
new_line = self._create_reverse_line(line, move) |
||||
|
# Pair to reconcile : payment line and the reverse line |
||||
|
to_reconcile.append(line + new_line) |
||||
|
if counterpart_debit: |
||||
|
self._prepare_globalization_counterpart_line( |
||||
|
counterpart_debit, 0.0, global_account_id, move) |
||||
|
if counterpart_credit: |
||||
|
self._prepare_globalization_counterpart_line( |
||||
|
0.0, counterpart_credit, global_account_id, move) |
||||
|
move.post() |
||||
|
for lines in to_reconcile: |
||||
|
lines.reconcile() |
||||
|
|
||||
|
@api.multi |
||||
|
def action_pos_session_close(self): |
||||
|
super(PosSession, self).action_pos_session_close() |
||||
|
for record in self: |
||||
|
# Call the method to generate globalization entries |
||||
|
record._generate_globalization_entries() |
@ -0,0 +1,7 @@ |
|||||
|
To configure this module, you need to: |
||||
|
|
||||
|
* Configure globalize account and journal on POS payment methods |
||||
|
(Account journal). |
||||
|
|
||||
|
A globalization entry is generated for each globalization journal and each |
||||
|
globalization account defined on payment methods. |
@ -0,0 +1,6 @@ |
|||||
|
* Adrien Peiffer <adrien.peiffer@acsone.eu> |
||||
|
* Meyomesse Gilles <meyomesse.gilles@gmail.com> |
||||
|
* `Tecnativa <https://www.tecnativa.com>`_ |
||||
|
|
||||
|
* David Vidal <david.vidal@tecnativa.com> |
||||
|
* Rafael Blasco <rafael.blasco@tecnativa.com> |
@ -0,0 +1,5 @@ |
|||||
|
This module allows to globalize payment entries created by the POS. |
||||
|
|
||||
|
In some cases, all banking transactions are received in a single bank statement |
||||
|
line. With this module, it's possible to reconcile this one line with the |
||||
|
payment globalization line. |
@ -0,0 +1 @@ |
|||||
|
Now it's easier to reconcile bank transactions with PoS payments. |
After Width: 128 | Height: 128 | Size: 9.2 KiB |
@ -0,0 +1 @@ |
|||||
|
from . import test_pos_payment_entries_globalization |
@ -0,0 +1,366 @@ |
|||||
|
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>) |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from odoo.tests.common import SavepointCase |
||||
|
|
||||
|
|
||||
|
class TestPosPaymentEntriesGlobalization(SavepointCase): |
||||
|
|
||||
|
@classmethod |
||||
|
def setUpClass(cls): |
||||
|
super(TestPosPaymentEntriesGlobalization, cls).setUpClass() |
||||
|
|
||||
|
cls.move_line_obj = cls.env['account.move.line'] |
||||
|
cls.pos_order_obj = cls.env['pos.order'] |
||||
|
cls.main_config = cls.env.ref('point_of_sale.pos_config_main') |
||||
|
cls.account_type = cls.env['account.account.type'] |
||||
|
cls.account_account = cls.env['account.account'] |
||||
|
cls.payment_method = cls.env['account.journal'] |
||||
|
cls.product_01 = cls.env.ref( |
||||
|
'point_of_sale.product_product_consumable') |
||||
|
cls.pos_config = cls.env.ref('point_of_sale.pos_config_main') |
||||
|
cls.customer_01 = cls.env.ref('base.res_partner_2') |
||||
|
cls.pos_session_obj = cls.env['pos.session'] |
||||
|
|
||||
|
# MODELS |
||||
|
cls.account_type = cls.account_type.create({ |
||||
|
'name': 'Bank and Cash', |
||||
|
'type': 'liquidity', |
||||
|
'include_initial_balance': True |
||||
|
}) |
||||
|
cls.income_account = cls.account_account.create({ |
||||
|
'code': 'X11006', |
||||
|
'name': 'Other Income', |
||||
|
'user_type_id': cls.account_type.id, |
||||
|
}) |
||||
|
cls.income_account_02 = cls.income_account.copy() |
||||
|
cls.account_account = cls.account_account.create({ |
||||
|
'code': 'Test X1014', |
||||
|
'name': 'Bank Current Account - (test)', |
||||
|
'user_type_id': cls.account_type.id, |
||||
|
'reconcile': True |
||||
|
}) |
||||
|
|
||||
|
cls.payment_method_02 = cls.payment_method.create({ |
||||
|
'name': 'Bank - Test', |
||||
|
'code': 'TBNK', |
||||
|
'type': 'bank', |
||||
|
'default_debit_account_id': cls.account_account.id, |
||||
|
'default_credit_account_id': cls.account_account.id |
||||
|
}) |
||||
|
|
||||
|
# next line |
||||
|
cls.payment_method_03 = cls.payment_method.create({ |
||||
|
'name': 'Checks Journal - (test)', |
||||
|
'code': 'TBNK', |
||||
|
'type': 'bank', |
||||
|
'default_debit_account_id': cls.account_account.id, |
||||
|
'default_credit_account_id': cls.account_account.id |
||||
|
}) |
||||
|
|
||||
|
cls.misc_journal = cls.payment_method.create({ |
||||
|
'name': 'Miscellaneous Journal - (test)', |
||||
|
'code': 'TMIS', |
||||
|
'type': 'general' |
||||
|
}) |
||||
|
cls.misc_journal_02 = cls.misc_journal.copy() |
||||
|
|
||||
|
def create_order(self, amount, session): |
||||
|
# I create a new order |
||||
|
order_vals = { |
||||
|
'session_id': session.id, |
||||
|
'partner_id': self.customer_01.id, |
||||
|
'lines': [(0, 0, {'product_id': self.product_01.id, |
||||
|
'price_unit': amount})] |
||||
|
} |
||||
|
return self.pos_order_obj.create(order_vals) |
||||
|
|
||||
|
def test_globalization_0(self): |
||||
|
# add payment method |
||||
|
self.main_config.write( |
||||
|
{'journal_ids': [(6, 0, [self.payment_method_02.id])]}) |
||||
|
# Create and open a new session |
||||
|
self.session = self.pos_session_obj.create( |
||||
|
{'config_id': self.main_config.id}) |
||||
|
self.session.action_pos_session_open() |
||||
|
|
||||
|
# config pos payment globalization |
||||
|
self.payment_method_02.pos_payment_globalization = True |
||||
|
self.payment_method_02.pos_payment_globalization_account = \ |
||||
|
self.income_account |
||||
|
self.payment_method_02.pos_payment_globalization_journal = \ |
||||
|
self.misc_journal |
||||
|
|
||||
|
# I create a new orders |
||||
|
order_01 = self.create_order(100, self.session) |
||||
|
order_02 = self.create_order(100, self.session) |
||||
|
|
||||
|
# I pay the created order |
||||
|
payment_data1 = {'amount': 100, |
||||
|
'journal': self.payment_method_02.id, |
||||
|
'partner_id': order_01.partner_id.id} |
||||
|
payment_data2 = {'amount': 100, |
||||
|
'journal': self.payment_method_02.id, |
||||
|
'partner_id': order_02.partner_id.id} |
||||
|
|
||||
|
# add payment to orders and pay |
||||
|
order_01.add_payment(payment_data1) |
||||
|
if order_01.test_paid(): |
||||
|
order_01.action_pos_order_paid() |
||||
|
|
||||
|
order_02.add_payment(payment_data2) |
||||
|
if order_02.test_paid(): |
||||
|
order_02.action_pos_order_paid() |
||||
|
|
||||
|
# close session |
||||
|
self.session.action_pos_session_closing_control() |
||||
|
|
||||
|
move_line = self.move_line_obj.search( |
||||
|
[('account_id', '=', self.income_account.id), |
||||
|
('journal_id', '=', self.misc_journal.id)]) |
||||
|
|
||||
|
# I check that there is only one move line |
||||
|
self.assertEqual(len(move_line.ids), 1) |
||||
|
self.assertAlmostEqual(move_line.debit, 200, 2) |
||||
|
domain = [('move_id', '=', move_line.move_id.id), |
||||
|
('id', '!=', move_line.id)] |
||||
|
reverse_lines = self.move_line_obj.search(domain) |
||||
|
# I ensure that the move contains reverse lines |
||||
|
self.assertEqual(len(reverse_lines), 2) |
||||
|
# I ensure reverse lines are reconciled |
||||
|
not_reconcile_reverse_lines = reverse_lines.filtered( |
||||
|
lambda r: not r.reconciled) |
||||
|
self.assertEqual(len(not_reconcile_reverse_lines), 0) |
||||
|
|
||||
|
def test_globalization_1(self): |
||||
|
# add payment method |
||||
|
self.main_config.write( |
||||
|
{'journal_ids': [(6, 0, [self.payment_method_02.id, |
||||
|
self.payment_method_03.id])] |
||||
|
}) |
||||
|
# Create and open a new session |
||||
|
self.session = self.pos_session_obj.create( |
||||
|
{'config_id': self.main_config.id}) |
||||
|
self.session.action_pos_session_open() |
||||
|
|
||||
|
self.payment_method_02.pos_payment_globalization = True |
||||
|
self.payment_method_02.pos_payment_globalization_account = \ |
||||
|
self.income_account |
||||
|
self.payment_method_02.pos_payment_globalization_journal = \ |
||||
|
self.misc_journal |
||||
|
self.payment_method_03.pos_payment_globalization = True |
||||
|
self.payment_method_03.pos_payment_globalization_account = \ |
||||
|
self.income_account_02 |
||||
|
self.payment_method_03.pos_payment_globalization_journal = \ |
||||
|
self.misc_journal |
||||
|
|
||||
|
# I create a new order |
||||
|
order_01 = self.create_order(100, self.session) |
||||
|
order_02 = self.create_order(100, self.session) |
||||
|
|
||||
|
# I pay the created order |
||||
|
payment_data1 = {'amount': 100, |
||||
|
'journal': self.payment_method_02.id, |
||||
|
'partner_id': order_01.partner_id.id} |
||||
|
payment_data2 = {'amount': 100, |
||||
|
'journal': self.payment_method_03.id, |
||||
|
'partner_id': order_02.partner_id.id} |
||||
|
|
||||
|
# add payment to orders and pay |
||||
|
order_01.add_payment(payment_data1) |
||||
|
if order_01.test_paid(): |
||||
|
order_01.action_pos_order_paid() |
||||
|
|
||||
|
order_02.add_payment(payment_data2) |
||||
|
if order_02.test_paid(): |
||||
|
order_02.action_pos_order_paid() |
||||
|
|
||||
|
# close session |
||||
|
self.session.action_pos_session_closing_control() |
||||
|
|
||||
|
# I check the first globalization account |
||||
|
move_line = self.move_line_obj.search( |
||||
|
[('account_id', '=', self.income_account.id), |
||||
|
('journal_id', '=', self.misc_journal.id)]) |
||||
|
|
||||
|
# I check that there is only one move line |
||||
|
self.assertEqual(len(move_line.ids), 1) |
||||
|
self.assertAlmostEqual(move_line.debit, 100, 2) |
||||
|
domain = [('move_id', '=', move_line.move_id.id), |
||||
|
('id', '!=', move_line.id)] |
||||
|
reverse_lines = self.move_line_obj.search(domain) |
||||
|
# I ensure that the move contains reverse lines |
||||
|
self.assertEqual(len(reverse_lines), 1) |
||||
|
# I ensure reverse lines are reconciled |
||||
|
not_reconcile_reverse_lines = reverse_lines.filtered( |
||||
|
lambda r: not r.reconciled) |
||||
|
self.assertEqual(len(not_reconcile_reverse_lines), 0) |
||||
|
# I check the second globalization account |
||||
|
move_line = self.move_line_obj.search( |
||||
|
[('account_id', '=', self.income_account_02.id), |
||||
|
('journal_id', '=', self.misc_journal.id)]) |
||||
|
# I check that there is only one move line |
||||
|
self.assertEqual(len(move_line.ids), 1) |
||||
|
self.assertAlmostEqual(move_line.debit, 100, 2) |
||||
|
domain = [('move_id', '=', move_line.move_id.id), |
||||
|
('id', '!=', move_line.id)] |
||||
|
reverse_lines = self.move_line_obj.search(domain) |
||||
|
# I ensure that the move contains reverse lines |
||||
|
self.assertEqual(len(reverse_lines), 1) |
||||
|
# I ensure reverse lines are reconciled |
||||
|
not_reconcile_reverse_lines = reverse_lines.filtered( |
||||
|
lambda r: not r.reconciled) |
||||
|
self.assertEqual(len(not_reconcile_reverse_lines), 0) |
||||
|
|
||||
|
def test_globalization_2(self): |
||||
|
# add payment method |
||||
|
self.main_config.write({'journal_ids': [(6, 0, [ |
||||
|
self.payment_method_02.id, self.payment_method_03.id])]}) |
||||
|
# Create and open a new session |
||||
|
self.session = self.pos_session_obj.create( |
||||
|
{'config_id': self.main_config.id}) |
||||
|
self.session.action_pos_session_open() |
||||
|
|
||||
|
self.payment_method_02.pos_payment_globalization = True |
||||
|
self.payment_method_02.pos_payment_globalization_account = \ |
||||
|
self.income_account |
||||
|
self.payment_method_02.pos_payment_globalization_journal = \ |
||||
|
self.misc_journal |
||||
|
self.payment_method_03.pos_payment_globalization = True |
||||
|
self.payment_method_03.pos_payment_globalization_account = \ |
||||
|
self.income_account_02 |
||||
|
self.payment_method_03.pos_payment_globalization_journal = \ |
||||
|
self.misc_journal |
||||
|
|
||||
|
# create orders |
||||
|
order_01 = self.create_order(100, self.session) |
||||
|
order_02 = self.create_order(100, self.session) |
||||
|
|
||||
|
# I pay the created order |
||||
|
payment_data1 = {'amount': 100, |
||||
|
'journal': self.payment_method_02.id, |
||||
|
'partner_id': order_01.partner_id.id} |
||||
|
payment_data2 = {'amount': 100, |
||||
|
'journal': self.payment_method_03.id, |
||||
|
'partner_id': order_02.partner_id.id} |
||||
|
|
||||
|
order_01.add_payment(payment_data1) |
||||
|
if order_01.test_paid(): |
||||
|
order_01.action_pos_order_paid() |
||||
|
|
||||
|
order_02.add_payment(payment_data2) |
||||
|
if order_02.test_paid(): |
||||
|
order_02.action_pos_order_paid() |
||||
|
|
||||
|
# close session |
||||
|
self.session.action_pos_session_closing_control() |
||||
|
|
||||
|
# I check the first globalization account |
||||
|
move_line = self.move_line_obj.search( |
||||
|
[('account_id', '=', self.income_account.id), |
||||
|
('journal_id', '=', self.misc_journal.id)]) |
||||
|
# I check that there is only one move line |
||||
|
self.assertEqual(len(move_line.ids), 1) |
||||
|
self.assertAlmostEqual(move_line.debit, 100, 2) |
||||
|
domain = [('move_id', '=', move_line.move_id.id), |
||||
|
('id', '!=', move_line.id)] |
||||
|
reverse_lines = self.move_line_obj.search(domain) |
||||
|
# I ensure that the move contains reverse lines |
||||
|
self.assertEqual(len(reverse_lines), 1) |
||||
|
# I ensure reverse lines are reconciled |
||||
|
not_reconcile_reverse_lines = reverse_lines.filtered( |
||||
|
lambda r: not r.reconciled) |
||||
|
self.assertEqual(len(not_reconcile_reverse_lines), 0) |
||||
|
# I check the second globalization account |
||||
|
move_line = self.move_line_obj.search( |
||||
|
[('account_id', '=', self.income_account_02.id), |
||||
|
('journal_id', '=', self.misc_journal.id)]) |
||||
|
# I check that there is only one move line |
||||
|
self.assertEqual(len(move_line.ids), 1) |
||||
|
self.assertAlmostEqual(move_line.debit, 100, 2) |
||||
|
domain = [('move_id', '=', move_line.move_id.id), |
||||
|
('id', '!=', move_line.id)] |
||||
|
reverse_lines = self.move_line_obj.search(domain) |
||||
|
# I ensure that the move contains reverse lines |
||||
|
self.assertEqual(len(reverse_lines), 1) |
||||
|
# I ensure reverse lines are reconciled |
||||
|
not_reconcile_reverse_lines = reverse_lines.filtered( |
||||
|
lambda r: not r.reconciled) |
||||
|
self.assertEqual(len(not_reconcile_reverse_lines), 0) |
||||
|
|
||||
|
def test_globalization_3(self): |
||||
|
# add payment method |
||||
|
self.main_config.write( |
||||
|
{'journal_ids': [(6, 0, [self.payment_method_02.id, |
||||
|
self.payment_method_03.id])]}) |
||||
|
# Create and open a new session |
||||
|
self.session = self.pos_session_obj.create( |
||||
|
{'config_id': self.main_config.id}) |
||||
|
self.session.action_pos_session_open() |
||||
|
|
||||
|
self.payment_method_02.pos_payment_globalization = True |
||||
|
self.payment_method_02.pos_payment_globalization_account =\ |
||||
|
self.income_account |
||||
|
self.payment_method_02.pos_payment_globalization_journal =\ |
||||
|
self.misc_journal |
||||
|
self.payment_method_03.pos_payment_globalization = True |
||||
|
self.payment_method_03.pos_payment_globalization_account =\ |
||||
|
self.income_account |
||||
|
self.payment_method_03.pos_payment_globalization_journal =\ |
||||
|
self.misc_journal_02 |
||||
|
|
||||
|
# I create orders |
||||
|
order_01 = self.create_order(100, self.session) |
||||
|
order_02 = self.create_order(100, self.session) |
||||
|
|
||||
|
# I pay the created orders |
||||
|
payment_data1 = {'amount': 100, |
||||
|
'journal': self.payment_method_02.id, |
||||
|
'partner_id': order_02.partner_id.id} |
||||
|
payment_data2 = {'amount': 100, |
||||
|
'journal': self.payment_method_03.id, |
||||
|
'partner_id': order_02.partner_id.id} |
||||
|
|
||||
|
order_01.add_payment(payment_data1) |
||||
|
if order_01.test_paid(): |
||||
|
order_01.action_pos_order_paid() |
||||
|
|
||||
|
order_02.add_payment(payment_data2) |
||||
|
if order_02.test_paid(): |
||||
|
order_02.action_pos_order_paid() |
||||
|
|
||||
|
# close session |
||||
|
self.session.action_pos_session_closing_control() |
||||
|
|
||||
|
# I check the first globalization journal |
||||
|
move_line = self.move_line_obj.search( |
||||
|
[('account_id', '=', self.income_account.id), |
||||
|
('journal_id', '=', self.misc_journal.id)]) |
||||
|
# I check that there is only one move line |
||||
|
self.assertEqual(len(move_line.ids), 1) |
||||
|
self.assertAlmostEqual(move_line.debit, 100, 2) |
||||
|
domain = [('move_id', '=', move_line.move_id.id), |
||||
|
('id', '!=', move_line.id)] |
||||
|
reverse_lines = self.move_line_obj.search(domain) |
||||
|
# I ensure that the move contains reverse lines |
||||
|
self.assertEqual(len(reverse_lines), 1) |
||||
|
# I ensure reverse lines are reconciled |
||||
|
not_reconcile_reverse_lines = reverse_lines.filtered( |
||||
|
lambda r: not r.reconciled) |
||||
|
self.assertEqual(len(not_reconcile_reverse_lines), 0) |
||||
|
# I check the second globalization journal |
||||
|
move_line = self.move_line_obj.search( |
||||
|
[('account_id', '=', self.income_account.id), |
||||
|
('journal_id', '=', self.misc_journal_02.id)]) |
||||
|
# I check that there is only one move line |
||||
|
self.assertEqual(len(move_line.ids), 1) |
||||
|
self.assertAlmostEqual(move_line.debit, 100, 2) |
||||
|
domain = [('move_id', '=', move_line.move_id.id), |
||||
|
('id', '!=', move_line.id)] |
||||
|
reverse_lines = self.move_line_obj.search(domain) |
||||
|
# I ensure that the move contains reverse lines |
||||
|
self.assertEqual(len(reverse_lines), 1) |
||||
|
# I ensure reverse lines are reconciled |
||||
|
not_reconcile_reverse_lines = reverse_lines.filtered( |
||||
|
lambda r: not r.reconciled) |
||||
|
self.assertEqual(len(not_reconcile_reverse_lines), 0) |
@ -0,0 +1,21 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>) |
||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
||||
|
<odoo> |
||||
|
<data> |
||||
|
<record model="ir.ui.view" id="view_account_journal_pos_user_form"> |
||||
|
<field name="name">POS Journal (pos_payment_entries_globalization)</field> |
||||
|
<field name="model">account.journal</field> |
||||
|
<field name="inherit_id" ref="point_of_sale.view_account_journal_pos_user_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//group[@name='amount_authorized']" position="after"> |
||||
|
<group string="Payment Globalization" name="globalization"> |
||||
|
<field name="pos_payment_globalization" /> |
||||
|
<field name="pos_payment_globalization_account" attrs="{'required': [('pos_payment_globalization', '=', True)], 'invisible': [('pos_payment_globalization', '=', False)]}"/> |
||||
|
<field name="pos_payment_globalization_journal" attrs="{'required': [('pos_payment_globalization', '=', True)], 'invisible': [('pos_payment_globalization', '=', False)]}"/> |
||||
|
</group> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
</data> |
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue