forked from OCA/pos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] new module pos_cash_control_multiple_config to handle correctl…
…y cash control in a multi point of sale context
- Loading branch information
1 parent
989462d
commit 6a1c148
Showing
8 changed files
with
89 additions
and
0 deletions.
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": "http://www.grap.coop", | ||
"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 self.env.context.get("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 | ||
|
||
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 |