diff --git a/pos_cash_move_reason/__manifest__.py b/pos_cash_move_reason/__manifest__.py
index 4de47e98f2..42396603cc 100644
--- a/pos_cash_move_reason/__manifest__.py
+++ b/pos_cash_move_reason/__manifest__.py
@@ -6,7 +6,7 @@
"author": "ACSONE SA/NV," "GRAP," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"category": "Point Of sale",
- "version": "15.0.1.0.0",
+ "version": "16.0.1.0.0",
"license": "AGPL-3",
"depends": ["point_of_sale"],
"data": [
diff --git a/pos_cash_move_reason/demo/account_account.xml b/pos_cash_move_reason/demo/account_account.xml
index 142e0ce52f..a10182cbfc 100644
--- a/pos_cash_move_reason/demo/account_account.xml
+++ b/pos_cash_move_reason/demo/account_account.xml
@@ -8,11 +8,11 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
101505
Cash Awaiting Bank Deposit
-
+ asset_cash
221500
Gazoline Expense
-
+ expense
diff --git a/pos_cash_move_reason/models/pos_session.py b/pos_cash_move_reason/models/pos_session.py
index 48a34179fe..6cce92d2d0 100644
--- a/pos_cash_move_reason/models/pos_session.py
+++ b/pos_cash_move_reason/models/pos_session.py
@@ -41,5 +41,7 @@ def _button_move_reason(self, move_type):
.sudo()
.read()[0]
)
- action["context"] = {"default_move_type": move_type}
+ action["context"] = {
+ "default_move_type": move_type,
+ }
return action
diff --git a/pos_cash_move_reason/tests/test_pos_cash_move_reason.py b/pos_cash_move_reason/tests/test_pos_cash_move_reason.py
index 175b6904b9..f6c139147c 100644
--- a/pos_cash_move_reason/tests/test_pos_cash_move_reason.py
+++ b/pos_cash_move_reason/tests/test_pos_cash_move_reason.py
@@ -31,16 +31,11 @@ def test_onchange_expense_reason(self):
def test_take_money(self):
# Open New Session
- self.config.open_session_cb()
+ self.config.open_existing_session_cb()
session = self.PosSession.search(
[("state", "=", "opening_control"), ("config_id", "=", self.config.id)]
)
- # Get Cash Statement
- statement = session.statement_ids.filtered(
- lambda x: x.journal_id == self.cash_journal
- )
-
# Take money to put in Bank
wizard = self.WizardReason.with_context(
active_id=session.id, default_move_type="expense"
@@ -48,7 +43,7 @@ def test_take_money(self):
{
"move_reason_id": self.deposit_reason.id,
"journal_id": self.cash_journal.id,
- "statement_id": statement.id,
+ "session_id": session.id,
"amount": 500,
"name": "Test Bank Deposit",
}
@@ -62,7 +57,7 @@ def test_take_money(self):
[
("account_id", "=", self.deposit_reason.expense_account_id.id),
("debit", "=", 500.0),
- ("id", "in", statement.move_line_ids.ids),
+ ("id", "in", session.statement_line_ids.move_line_ids.ids),
]
)
# I check the created move line from the cash in
@@ -70,17 +65,12 @@ def test_take_money(self):
def test_take_invalid_amount(self):
# Open New Session
- self.config.open_session_cb()
+ self.config.open_existing_session_cb()
#
session = self.PosSession.search(
[("state", "=", "opening_control"), ("config_id", "=", self.config.id)]
)
- # Get Cash Statement
- statement = session.statement_ids.filtered(
- lambda x: x.journal_id == self.cash_journal
- )
-
# Enter Invalid money
with self.assertRaises(UserError):
self.WizardReason.with_context(
@@ -89,14 +79,14 @@ def test_take_invalid_amount(self):
{
"move_reason_id": self.deposit_reason.id,
"journal_id": self.cash_journal.id,
- "statement_id": statement.id,
"amount": -100,
+ "session_id": session.id,
"name": "Test Deposit",
}
)
def test_button_put_money(self):
- self.config.open_session_cb()
+ self.config.open_existing_session_cb()
session = self.PosSession.search(
[("state", "=", "opened"), ("config_id", "=", self.config.id)]
)
diff --git a/pos_cash_move_reason/wizard/wizard_pos_move_reason.py b/pos_cash_move_reason/wizard/wizard_pos_move_reason.py
index 0da12e18d6..71021c4db2 100644
--- a/pos_cash_move_reason/wizard/wizard_pos_move_reason.py
+++ b/pos_cash_move_reason/wizard/wizard_pos_move_reason.py
@@ -43,12 +43,6 @@ def _default_session_id(self):
readonly=True,
)
- statement_id = fields.Many2one(
- comodel_name="account.bank.statement",
- string="Bank Statement",
- compute="_compute_statement_id",
- )
-
journal_ids = fields.Many2many(
comodel_name="account.journal", related="move_reason_id.journal_ids"
)
@@ -75,17 +69,6 @@ def _check_amount(self):
if any(w.amount <= 0 for w in self):
raise UserError(_("Invalid Amount"))
- @api.depends("journal_id", "session_id")
- def _compute_statement_id(self):
- for wizard in self:
- statement = self.env["account.bank.statement"].browse()
- if wizard.session_id and wizard.journal_id:
- statements = wizard.session_id.statement_ids.filtered(
- lambda x, w=wizard: x.journal_id == w.journal_id
- )
- statement = fields.first(statements)
- wizard.statement_id = statement
-
def apply(self):
self.ensure_one()
AccountBankStatementLine = self.env["account.bank.statement.line"]
@@ -101,7 +84,7 @@ def _prepare_statement_line(self):
account_id = self.move_reason_id.expense_account_id.id
return {
"date": fields.Date.context_today(self),
- "statement_id": self.statement_id.id,
+ "pos_session_id": self.session_id.id,
"journal_id": self.journal_id.id,
"amount": amount,
"payment_ref": f"{self.session_id.name} - {self.name}",
diff --git a/pos_cash_move_reason/wizard/wizard_pos_move_reason.xml b/pos_cash_move_reason/wizard/wizard_pos_move_reason.xml
index e22e54ff4d..5a8a6b2bcd 100644
--- a/pos_cash_move_reason/wizard/wizard_pos_move_reason.xml
+++ b/pos_cash_move_reason/wizard/wizard_pos_move_reason.xml
@@ -20,7 +20,6 @@
name="journal_id"
attrs="{'invisible': [('move_reason_id', '=', False)]}"
/>
-
diff --git a/setup/pos_cash_move_reason/odoo/addons/pos_cash_move_reason b/setup/pos_cash_move_reason/odoo/addons/pos_cash_move_reason
new file mode 120000
index 0000000000..507af4e8aa
--- /dev/null
+++ b/setup/pos_cash_move_reason/odoo/addons/pos_cash_move_reason
@@ -0,0 +1 @@
+../../../../pos_cash_move_reason
\ No newline at end of file
diff --git a/setup/pos_cash_move_reason/setup.py b/setup/pos_cash_move_reason/setup.py
new file mode 100644
index 0000000000..28c57bb640
--- /dev/null
+++ b/setup/pos_cash_move_reason/setup.py
@@ -0,0 +1,6 @@
+import setuptools
+
+setuptools.setup(
+ setup_requires=['setuptools-odoo'],
+ odoo_addon=True,
+)