diff --git a/pos_session_pay_invoice/README.rst b/pos_session_pay_invoice/README.rst
index 5e525e446f..2c33d31619 100644
--- a/pos_session_pay_invoice/README.rst
+++ b/pos_session_pay_invoice/README.rst
@@ -17,13 +17,13 @@ POS Session Pay invoice
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
- :target: https://github.com/OCA/pos/tree/14.0/pos_session_pay_invoice
+ :target: https://github.com/OCA/pos/tree/16.0/pos_session_pay_invoice
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/pos-14-0/pos-14-0-pos_session_pay_invoice
+ :target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_session_pay_invoice
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
- :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=14.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -68,7 +68,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -85,6 +85,9 @@ Contributors
* Enric Tobella
* Jordi Ballester
+* Tecnativa (https://www.tecnativa.com):
+
+ * Carlos Lopez
Maintainers
~~~~~~~~~~~
@@ -99,6 +102,6 @@ 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.
-This module is part of the `OCA/pos `_ project on GitHub.
+This module is part of the `OCA/pos `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/pos_session_pay_invoice/__manifest__.py b/pos_session_pay_invoice/__manifest__.py
index 617413e1cb..2dae1d61aa 100644
--- a/pos_session_pay_invoice/__manifest__.py
+++ b/pos_session_pay_invoice/__manifest__.py
@@ -3,7 +3,7 @@
{
"name": "POS Session Pay invoice",
- "version": "14.0.1.1.0",
+ "version": "16.0.1.0.0",
"category": "Point Of Sale",
"author": "Creu Blanca, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
@@ -14,7 +14,7 @@
"security/ir.model.access.csv",
"wizard/pos_box_cash_invoice_out.xml",
"wizard/pos_box_cash_invoice_in.xml",
- "wizard/cash_invoice_in.xml",
+ "wizard/cash_pay_invoice.xml",
"views/pos_session.xml",
],
}
diff --git a/pos_session_pay_invoice/models/__init__.py b/pos_session_pay_invoice/models/__init__.py
index e9ab911ddc..b2f4b5e054 100644
--- a/pos_session_pay_invoice/models/__init__.py
+++ b/pos_session_pay_invoice/models/__init__.py
@@ -1 +1,2 @@
from . import pos_order
+from . import pos_session
diff --git a/pos_session_pay_invoice/models/pos_session.py b/pos_session_pay_invoice/models/pos_session.py
new file mode 100644
index 0000000000..829e3fdaf0
--- /dev/null
+++ b/pos_session_pay_invoice/models/pos_session.py
@@ -0,0 +1,17 @@
+from odoo import models
+
+
+class PosSession(models.Model):
+ _inherit = "pos.session"
+
+ def button_show_wizard_pay_invoice(self):
+ cash_journal = self.cash_journal_id
+ action = self.env["ir.actions.actions"]._for_xml_id(
+ "pos_session_pay_invoice.action_pos_invoice_in_control"
+ )
+ action["context"] = {
+ "active_ids": cash_journal.ids,
+ "active_name": cash_journal._name,
+ "pos_session_id": self.id,
+ }
+ return action
diff --git a/pos_session_pay_invoice/readme/CONTRIBUTORS.rst b/pos_session_pay_invoice/readme/CONTRIBUTORS.rst
index e250875ecd..120a999245 100644
--- a/pos_session_pay_invoice/readme/CONTRIBUTORS.rst
+++ b/pos_session_pay_invoice/readme/CONTRIBUTORS.rst
@@ -1,2 +1,5 @@
* Enric Tobella
* Jordi Ballester
+* Tecnativa (https://www.tecnativa.com):
+
+ * Carlos Lopez
\ No newline at end of file
diff --git a/pos_session_pay_invoice/static/description/index.html b/pos_session_pay_invoice/static/description/index.html
index 15ecdc78b7..bd08aa2a32 100644
--- a/pos_session_pay_invoice/static/description/index.html
+++ b/pos_session_pay_invoice/static/description/index.html
@@ -1,4 +1,3 @@
-
@@ -369,7 +368,7 @@ POS Session Pay invoice
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6eac7dbff1f6e08ae835df882a549b193c4d037be692dfd6913960c06245184b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This modules allows to pay an existing Supplier Invoice / Customer Refund, or
to collect payment for an existing Customer Invoice, from within a POS Session.
Table of contents
@@ -420,7 +419,7 @@
Bugs are tracked on GitHub Issues .
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
-feedback .
+feedback .
Do not contact contributors directly about support or help with technical issues.
@@ -445,7 +448,7 @@
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.
-
This module is part of the OCA/pos project on GitHub.
+
This module is part of the OCA/pos project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute .
diff --git a/pos_session_pay_invoice/tests/test_pay_invoice.py b/pos_session_pay_invoice/tests/test_pay_invoice.py
index 6046603a1f..fbd6140a05 100644
--- a/pos_session_pay_invoice/tests/test_pay_invoice.py
+++ b/pos_session_pay_invoice/tests/test_pay_invoice.py
@@ -4,6 +4,7 @@
import odoo
from odoo.tests import Form
+from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
from odoo.addons.point_of_sale.tests.common import TestPointOfSaleCommon
@@ -12,18 +13,8 @@ class TestSessionPayInvoice(TestPointOfSaleCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
+ cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
cls.pos_config.cash_control = True
-
- account = cls.env["account.account"].create(
- {
- "code": "test_cash_pay_invoice",
- "company_id": cls.company.id,
- "name": "Test",
- "user_type_id": cls.env.ref("account.data_account_type_revenue").id,
- "reconcile": True,
- }
- )
-
cls.invoice_out = cls.env["account.move"].create(
{
"company_id": cls.company.id,
@@ -32,19 +23,20 @@ def setUpClass(cls, chart_template_ref=None):
"invoice_date": "2016-03-12",
"move_type": "out_invoice",
"invoice_line_ids": [
- 0,
- 0,
- {
- "product_id": cls.product3.id,
- "name": "Producto de prueba",
- "account_id": account.id,
- "quantity": 1.0,
- "price_unit": 100.0,
- },
+ (
+ 0,
+ 0,
+ {
+ "product_id": cls.product3.id,
+ "name": "Producto de prueba",
+ "quantity": 1.0,
+ "price_unit": 100.0,
+ "tax_ids": [],
+ },
+ )
],
}
)
- cls.invoice_out._onchange_invoice_line_ids()
cls.invoice_out.action_post()
cls.invoice_in = cls.env["account.move"].create(
{
@@ -54,19 +46,20 @@ def setUpClass(cls, chart_template_ref=None):
"date": "2016-03-12",
"invoice_date": "2016-03-12",
"invoice_line_ids": [
- 0,
- 0,
- {
- "product_id": cls.product3.id,
- "name": "Producto de prueba",
- "account_id": account.id,
- "quantity": 1.0,
- "price_unit": 100.0,
- },
+ (
+ 0,
+ 0,
+ {
+ "product_id": cls.product3.id,
+ "name": "Producto de prueba",
+ "quantity": 1.0,
+ "price_unit": 100.0,
+ "tax_ids": [],
+ },
+ )
],
}
)
- cls.invoice_in._onchange_invoice_line_ids()
cls.invoice_in.action_post()
refund_wizard = (
cls.env["account.move.reversal"]
@@ -75,7 +68,7 @@ def setUpClass(cls, chart_template_ref=None):
active_id=cls.invoice_out.id,
active_model=cls.invoice_out._name,
)
- .create({})
+ .create({"journal_id": cls.invoice_out.journal_id.id})
.reverse_moves()
)
cls.refund = cls.env[refund_wizard["res_model"]].browse(refund_wizard["res_id"])
@@ -83,33 +76,26 @@ def setUpClass(cls, chart_template_ref=None):
def test_pos_in_invoice(self):
self.assertEqual(self.invoice_in.amount_residual, 100.0)
- self.pos_config.open_session_cb()
+ self.pos_config._action_to_open_ui()
session = self.pos_config.current_session_id
- self.assertIsNotNone(session.statement_ids)
- cash_statements = session.statement_ids.filtered(
- lambda x: x.journal_id.type == "cash"
- )
- self.assertEqual(len(cash_statements), 1)
+ self.assertTrue(session.cash_control)
+ self.assertTrue(session.cash_journal_id)
session.action_pos_session_open()
- cash_in = self.env["cash.invoice.in"].with_context(
- active_ids=session.ids, active_model="pos.session"
- )
+ wizard_context = session.button_show_wizard_pay_invoice()["context"]
+ cash_in = self.env["cash.pay.invoice"].with_context(**wizard_context)
with Form(cash_in) as form:
form.invoice_id = self.invoice_in
self.assertEqual(form.amount, -100)
- cash_in.browse(form.id).run()
+ cash_in.browse(form.id).action_pay_invoice()
session.action_pos_session_closing_control()
- session._validate_session()
- session.flush()
- session.refresh()
- self.invoice_in.flush()
- self.invoice_in.refresh()
+ session.invalidate_recordset()
+ self.invoice_in.invalidate_recordset()
self.invoice_in._compute_amount()
self.assertEqual(self.invoice_in.amount_residual, 0.0)
def test_pos_out_invoice(self):
self.assertEqual(self.invoice_out.amount_residual, 100.0)
- self.pos_config.open_session_cb()
+ self.pos_config._action_to_open_ui()
session = self.pos_config.current_session_id
out_invoice = self.env["pos.box.cash.invoice.out"].with_context(
active_ids=session.ids,
@@ -122,15 +108,14 @@ def test_pos_out_invoice(self):
form.amount = 75
out_invoice.browse(form.id).run()
session.action_pos_session_closing_control()
- session._validate_session()
- session.flush()
- self.invoice_out.flush()
+ session.invalidate_recordset()
+ self.invoice_out.invalidate_recordset()
self.invoice_out._compute_amount()
self.assertEqual(self.invoice_out.amount_residual, 25.0)
def test_pos_invoice_refund(self):
self.assertEqual(self.refund.amount_residual, 100.0)
- self.pos_config.open_session_cb()
+ self.pos_config._action_to_open_ui()
session = self.pos_config.current_session_id
in_invoice = self.env["pos.box.cash.invoice.in"].with_context(
active_ids=session.ids,
@@ -142,8 +127,7 @@ def test_pos_invoice_refund(self):
self.assertEqual(form.amount, -100)
in_invoice.browse(form.id).run()
session.action_pos_session_closing_control()
- session._validate_session()
- session.flush()
- self.invoice_out.flush()
- self.refund.refresh()
+ session.invalidate_recordset()
+ self.invoice_out.invalidate_recordset()
+ self.refund.invalidate_recordset()
self.assertEqual(self.refund.amount_residual, 0.0)
diff --git a/pos_session_pay_invoice/views/pos_session.xml b/pos_session_pay_invoice/views/pos_session.xml
index 87e3cca07d..d5c956b735 100644
--- a/pos_session_pay_invoice/views/pos_session.xml
+++ b/pos_session_pay_invoice/views/pos_session.xml
@@ -36,8 +36,8 @@
diff --git a/pos_session_pay_invoice/wizard/__init__.py b/pos_session_pay_invoice/wizard/__init__.py
index 2ceb0264dd..d1ada846cd 100644
--- a/pos_session_pay_invoice/wizard/__init__.py
+++ b/pos_session_pay_invoice/wizard/__init__.py
@@ -1,4 +1,4 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-from . import cash_invoice_in
+from . import cash_pay_invoice
from . import pos_box_cash_invoice_in
from . import pos_box_cash_invoice_out
diff --git a/pos_session_pay_invoice/wizard/cash_invoice_in.py b/pos_session_pay_invoice/wizard/cash_invoice_in.py
deleted file mode 100644
index 295dd89bc8..0000000000
--- a/pos_session_pay_invoice/wizard/cash_invoice_in.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright (C) 2017 Creu Blanca
-# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-
-from odoo import _, models
-from odoo.exceptions import UserError
-from odoo.fields import first
-
-
-class CashInvoiceIn(models.TransientModel):
- _inherit = "cash.invoice.in"
-
- def default_company(self, active_model, active_ids):
- if active_model == "pos.session":
- active = first(self.env[active_model].browse(active_ids))
- return active.config_id.company_id
- return super().default_company(active_model, active_ids)
-
- def default_journals(self, active_model, active_ids):
- if active_model == "pos.session":
- active = first(self.env[active_model].browse(active_ids))
- if not active.cash_register_id:
- raise UserError(_("There is no cash register for this Pos session"))
- return active.cash_register_id.journal_id
- return super().default_journals(active_model, active_ids)
-
- def default_currency(self, active_model, active_ids):
- if active_model == "pos.session":
- journal = self._default_journal()
- if journal.currency_id:
- return journal.currency_id
- return super().default_currency(active_model, active_ids)
-
- def run(self):
- active_model = self.env.context.get("active_model", False)
- active_ids = self.env.context.get("active_ids", False)
- if active_model == "pos.session":
- bank_statements = [
- session.statement_ids.filtered(
- lambda r: r.journal_id == self.journal_id
- )
- for session in self.env[active_model].browse(active_ids)
- ]
- if not bank_statements:
- raise UserError(_("Bank Statement was not found"))
- return self._run(bank_statements)
- else:
- return super().run()
diff --git a/pos_session_pay_invoice/wizard/cash_pay_invoice.py b/pos_session_pay_invoice/wizard/cash_pay_invoice.py
new file mode 100644
index 0000000000..c9cffe78c1
--- /dev/null
+++ b/pos_session_pay_invoice/wizard/cash_pay_invoice.py
@@ -0,0 +1,21 @@
+# Copyright (C) 2017 Creu Blanca
+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
+
+from odoo import api, models
+
+
+class CashPayInvoice(models.TransientModel):
+ _inherit = "cash.pay.invoice"
+
+ @api.model
+ def default_get(self, fields_list):
+ values = super().default_get(fields_list)
+ if "invoice_type" in fields_list and self.env.context.get("pos_session_id"):
+ values["invoice_type"] = "vendor"
+ return values
+
+ def _prepare_statement_line_vals(self):
+ vals = super()._prepare_statement_line_vals()
+ if self.env.context.get("pos_session_id"):
+ vals["pos_session_id"] = self.env.context.get("pos_session_id")
+ return vals
diff --git a/pos_session_pay_invoice/wizard/cash_invoice_in.xml b/pos_session_pay_invoice/wizard/cash_pay_invoice.xml
similarity index 83%
rename from pos_session_pay_invoice/wizard/cash_invoice_in.xml
rename to pos_session_pay_invoice/wizard/cash_pay_invoice.xml
index 20ba5ab1c4..dac41a74e6 100644
--- a/pos_session_pay_invoice/wizard/cash_invoice_in.xml
+++ b/pos_session_pay_invoice/wizard/cash_pay_invoice.xml
@@ -2,7 +2,7 @@
Pay invoice
- cash.invoice.in
+ cash.pay.invoice
form
new
diff --git a/pos_session_pay_invoice/wizard/pos_box_cash_invoice_in.py b/pos_session_pay_invoice/wizard/pos_box_cash_invoice_in.py
index ceb80a0730..6e90256a1f 100644
--- a/pos_session_pay_invoice/wizard/pos_box_cash_invoice_in.py
+++ b/pos_session_pay_invoice/wizard/pos_box_cash_invoice_in.py
@@ -11,7 +11,7 @@ class CashInvoiceIn(models.TransientModel):
_description = "pos box cash invoice in"
session_id = fields.Many2one("pos.session", required=True)
- amount = fields.Float(string="Amount", digits=0, required=True)
+ amount = fields.Float(digits=0, required=True)
move_id = fields.Many2one(
comodel_name="account.move",
string="Invoice",
@@ -85,4 +85,5 @@ def run(self):
)
order.action_pos_order_paid()
order.state = "invoiced"
+ order._apply_invoice_payments()
return
diff --git a/pos_session_pay_invoice/wizard/pos_box_cash_invoice_in.xml b/pos_session_pay_invoice/wizard/pos_box_cash_invoice_in.xml
index bb06baaee5..a5a9b081f9 100644
--- a/pos_session_pay_invoice/wizard/pos_box_cash_invoice_in.xml
+++ b/pos_session_pay_invoice/wizard/pos_box_cash_invoice_in.xml
@@ -42,6 +42,7 @@
class="oe_inline"
groups="base.group_multi_currency"
/>
+
diff --git a/pos_session_pay_invoice/wizard/pos_box_cash_invoice_out.py b/pos_session_pay_invoice/wizard/pos_box_cash_invoice_out.py
index dfb25fae37..533db80e04 100644
--- a/pos_session_pay_invoice/wizard/pos_box_cash_invoice_out.py
+++ b/pos_session_pay_invoice/wizard/pos_box_cash_invoice_out.py
@@ -11,7 +11,7 @@ class CashInvoiceOut(models.TransientModel):
_description = "pos box cash invoice out"
session_id = fields.Many2one("pos.session", required=True)
- amount = fields.Float(string="Amount", digits=0, required=True)
+ amount = fields.Float(digits=0, required=True)
move_id = fields.Many2one(
comodel_name="account.move",
string="Invoice",
@@ -86,4 +86,5 @@ def run(self):
)
order.action_pos_order_paid()
order.state = "invoiced"
+ order._apply_invoice_payments()
return
diff --git a/pos_session_pay_invoice/wizard/pos_box_cash_invoice_out.xml b/pos_session_pay_invoice/wizard/pos_box_cash_invoice_out.xml
index ddea4303f8..9200e4cc5f 100644
--- a/pos_session_pay_invoice/wizard/pos_box_cash_invoice_out.xml
+++ b/pos_session_pay_invoice/wizard/pos_box_cash_invoice_out.xml
@@ -42,6 +42,7 @@
class="oe_inline"
groups="base.group_multi_currency"
/>
+