New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD] new module pos_cash_control_multiple_config to handle correctly cash control in a multi point of sale context #569
Merged
OCA-git-bot
merged 2 commits into
OCA:12.0
from
legalsylvain:12.0-ADD-pos_cash_control_multiple_config
May 14, 2021
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
======================================= | ||
Point Of Sale - Correct Opening Balance | ||
======================================= | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (C) 2020 - 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 - Correct Opening Balance", | ||
"summary": "Handle correctly opening balance in a multi point of sale" | ||
" context with Cash control enabled.", | ||
"version": "12.0.1.0.1", | ||
"category": "Point of Sale", | ||
"author": "GRAP, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/pos", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"point_of_sale", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import account_bank_statement | ||
from . import pos_session |
31 changes: 31 additions & 0 deletions
31
pos_cash_control_multiple_config/models/account_bank_statement.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (C) 2020 - 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 api, models | ||
|
||
|
||
class AccountBankStatement(models.Model): | ||
_inherit = "account.bank.statement" | ||
|
||
@api.multi | ||
def _get_opening_balance(self, journal_id): | ||
PosSession = self.env["pos.session"] | ||
pos_config_id = self.env.context.get("pos_config_id") | ||
if pos_config_id: | ||
sessions = PosSession.search( | ||
[('config_id', '=', pos_config_id)], | ||
order="start_at desc", limit=1) | ||
if not sessions: | ||
# it is the first time the pos config is opened. | ||
# returning 0 | ||
return 0 | ||
else: | ||
last_valid_statement = False | ||
for old_statement in sessions.mapped('statement_ids'): | ||
if old_statement.journal_id.id == journal_id: | ||
last_valid_statement = old_statement | ||
if last_valid_statement: | ||
return last_valid_statement.balance_end_real | ||
|
||
return super()._get_opening_balance(journal_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (C) 2020 - 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 api, models | ||
|
||
|
||
class PosSession(models.Model): | ||
_inherit = "pos.session" | ||
|
||
@api.model | ||
def create(self, values): | ||
pos_config_id = values.get('config_id')\ | ||
or self.env.context.get('default_config_id') | ||
return super(PosSession, self.with_context( | ||
pos_config_id=pos_config_id)).create(values) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Sylvain LE GAL <https://twitter.com/legalsylvain> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
This module extends the functionality of the point of sale fixing | ||
cash control in a multi pos config context. | ||
|
||
By default, in Odoo, if we have two Point of Sale (``pos.config``) with cash control | ||
enabled on each Point of sale, the opening balance will be bad, when opening many | ||
session. | ||
|
||
This module fixes that bug. | ||
|
||
Ref : | ||
|
||
https://github.com/odoo/odoo/issues/62147 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also remove this extra line.