Skip to content

Commit 6a1c148

Browse files
committed
[ADD] new module pos_cash_control_multiple_config to handle correctly cash control in a multi point of sale context
1 parent 989462d commit 6a1c148

File tree

8 files changed

+89
-0
lines changed

8 files changed

+89
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=======================================
2+
Point Of Sale - Correct Opening Balance
3+
=======================================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
{
6+
"name": "Point Of Sale - Correct Opening Balance",
7+
"summary": "Handle correctly opening balance in a multi point of sale"
8+
" context with Cash control enabled.",
9+
"version": "12.0.1.0.1",
10+
"category": "Point of Sale",
11+
"author": "GRAP, Odoo Community Association (OCA)",
12+
"website": "http://www.grap.coop",
13+
"license": "AGPL-3",
14+
"depends": [
15+
"point_of_sale",
16+
],
17+
"installable": True,
18+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import account_bank_statement
2+
from . import pos_session
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
from odoo import api, models
6+
7+
8+
class AccountBankStatement(models.Model):
9+
_inherit = "account.bank.statement"
10+
11+
@api.multi
12+
def _get_opening_balance(self, journal_id):
13+
PosSession = self.env["pos.session"]
14+
pos_config_id = self.env.context.get("pos_config_id")
15+
if self.env.context.get("pos_config_id"):
16+
sessions = PosSession.search(
17+
[('config_id', '=', pos_config_id)],
18+
order="start_at desc", limit=1)
19+
if not sessions:
20+
# it is the first time the pos config is opened.
21+
# returning 0
22+
return 0
23+
else:
24+
last_valid_statement = False
25+
for old_statement in sessions.mapped('statement_ids'):
26+
if old_statement.journal_id.id == journal_id:
27+
last_valid_statement = old_statement
28+
if last_valid_statement:
29+
return last_valid_statement.balance_end
30+
31+
return super()._get_opening_balance(journal_id)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
from odoo import api, models
6+
7+
8+
class PosSession(models.Model):
9+
_inherit = "pos.session"
10+
11+
@api.model
12+
def create(self, values):
13+
pos_config_id = values.get('config_id')\
14+
or self.env.context.get('default_config_id')
15+
return super(PosSession, self.with_context(
16+
pos_config_id=pos_config_id)).create(values)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Sylvain LE GAL <https://twitter.com/legalsylvain>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
This module extends the functionality of the point of sale fixing
2+
cash control in a multi pos config context.
3+
4+
By default, in Odoo, if we have two Point of Sale (``pos.config``) with cash control
5+
enabled on each Point of sale, the opening balance will be bad, when opening many
6+
session.
7+
8+
This module fixes that bug.
9+
10+
Ref :
11+
12+
https://github.com/odoo/odoo/issues/62147

0 commit comments

Comments
 (0)