Navigation Menu

Skip to content

Commit

Permalink
[MIG] pos_payment_entries_globalization
Browse files Browse the repository at this point in the history
  • Loading branch information
GillesTephaneMeyomesse committed May 23, 2017
1 parent eae7ed6 commit 3bbe6c2
Show file tree
Hide file tree
Showing 13 changed files with 241 additions and 144 deletions.
7 changes: 4 additions & 3 deletions pos_payment_entries_globalization/README.rst
Expand Up @@ -17,7 +17,7 @@ Configuration

To configure this module, you need to:

* Configure globalize account and journal on POS payment method (Account journal).
* 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.

Expand All @@ -26,7 +26,7 @@ Usage

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/184/8.0
:target: https://runbot.odoo-community.org/runbot/184/10.0

For further information, please visit:

Expand All @@ -47,6 +47,7 @@ Contributors
------------

* Adrien Peiffer <adrien.peiffer@acsone.eu>
* Meyomesse Gilles <meyomesse.gilles@gmail.com>

Maintainer
----------
Expand All @@ -59,4 +60,4 @@ This module is maintained by the OCA.

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.

To contribute to this module, please visit http://odoo-community.org.
To contribute to this module, please visit http://odoo-community.org.
3 changes: 0 additions & 3 deletions pos_payment_entries_globalization/__init__.py
@@ -1,4 +1 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
@@ -1,21 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# 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""",
'summary': """Globalize POS Payment""",
'author': 'ACSONE SA/NV,'
'Odoo Community Association (OCA)',
'website': "http://acsone.eu",
'category': 'Point Of Sale',
'version': '8.0.1.0.0',
'version': '10.0.1.0.0',
'license': 'AGPL-3',
'depends': [
'point_of_sale',
],
'data': [
'views/account_journal_view.xml',
],
'installable': True,
}
3 changes: 0 additions & 3 deletions pos_payment_entries_globalization/models/__init__.py
@@ -1,5 +1,2 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_journal
from . import pos_session
4 changes: 2 additions & 2 deletions pos_payment_entries_globalization/models/account_journal.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields
from odoo import models, fields


class AccountJournal(models.Model):
Expand Down
22 changes: 11 additions & 11 deletions pos_payment_entries_globalization/models/pos_session.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields, api, _
from odoo import models, fields, api, _
from collections import defaultdict


Expand All @@ -27,11 +27,10 @@ def _get_move_lines_for_globalization(self):
return grouped_move_lines

@api.model
def _create_globalization_move(self, journal_id, period_id):
def _create_globalization_move(self, journal_id):
"""Create the globalization move"""
entries_vals = {
'journal_id': journal_id,
'period_id': period_id,
'date': fields.Date.today(),
'name': "%s - %s" % (
self.name, _("Payment globalization")),
Expand Down Expand Up @@ -63,19 +62,21 @@ def _create_reverse_line(self, line_to_reverse, move):
'account_id': line_to_reverse.account_id.id,
'move_id': move.id
}
return self.env['account.move.line'].create(item_vals)
# 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 = []
period = self.env['account.period'].find()
for key, lines in grouped_move_lines.iteritems():
global_account_id, global_journal_id = key
move = self._create_globalization_move(global_journal_id,
period.id)
move = self._create_globalization_move(global_journal_id)
counterpart_debit = 0.0
counterpart_credit = 0.0
for line in lines:
Expand All @@ -94,9 +95,8 @@ def _generate_globalization_entries(self):
lines.reconcile()

@api.multi
def wkf_action_close(self):
res = super(PosSession, self).wkf_action_close()
def action_pos_session_closing_control(self):
super(PosSession, self).action_pos_session_closing_control()
for record in self:
# Call the method to generate globalization entries
record._generate_globalization_entries()
return res
4 changes: 0 additions & 4 deletions pos_payment_entries_globalization/tests/__init__.py
@@ -1,5 +1 @@
# -*- coding: utf-8 -*-
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import test_pos_payment_entries_globalization

0 comments on commit 3bbe6c2

Please sign in to comment.