Skip to content

Commit

Permalink
[ADD] pos_multi_order_payment
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Jan 3, 2024
1 parent b9e1429 commit 01dae43
Show file tree
Hide file tree
Showing 15 changed files with 867 additions and 0 deletions.
80 changes: 80 additions & 0 deletions pos_multi_order_payment/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
=======================
Pos Multi Order Payment
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0e30fc91c5776d9617abac03340249fc7e94642fd2781e3a0611ffd0e0c8b3d6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
:target: https://github.com/OCA/pos/tree/17.0/pos_multi_order_payment
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_multi_order_payment
: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=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module will allow you to pay several open point of sale orders at
the same time.

The principal order will return the other orders amount and the other
orders will be payed with this amount.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/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 <https://github.com/OCA/pos/issues/new?body=module:%20pos_multi_order_payment%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Dixmit

Contributors
------------

- Enric Tobella

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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 <https://github.com/OCA/pos/tree/17.0/pos_multi_order_payment>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions pos_multi_order_payment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
24 changes: 24 additions & 0 deletions pos_multi_order_payment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Pos Multi Order Payment",
"summary": """
Allow to pay multiple orders with the same payment""",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "Dixmit,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"depends": ["point_of_sale"],
"assets": {
"point_of_sale._assets_pos": [
"pos_multi_order_payment/static/src/app/screens/payment_screen/payment_screen.esm.js",
"pos_multi_order_payment/static/src/app/screens/payment_screen/payment_screen.xml",
"pos_multi_order_payment/static/src/app/screens/receipt_screen/receipt_screen.esm.js",
"pos_multi_order_payment/static/src/app/screens/receipt_screen/receipt_screen.xml",
"pos_multi_order_payment/static/src/app/models.esm.js",
],
},
"data": [],
"demo": [],
}
1 change: 1 addition & 0 deletions pos_multi_order_payment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import pos_order
44 changes: 44 additions & 0 deletions pos_multi_order_payment/models/pos_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, fields, models
from odoo.exceptions import UserError
from odoo.tools import float_is_zero


class PosOrder(models.Model):
_inherit = "pos.order"

payment_order_id = fields.Many2one("pos.order", readonly=True)

def _export_for_ui(self, order):
result = super()._export_for_ui(order)
result["payment_order_id"] = order.payment_order_id.id
return result

Check warning on line 17 in pos_multi_order_payment/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

pos_multi_order_payment/models/pos_order.py#L15-L17

Added lines #L15 - L17 were not covered by tests

def _process_payment_lines(self, pos_order, order, pos_session, draft):
super()._process_payment_lines(pos_order, order, pos_session, draft)
prec_acc = order.currency_id.decimal_places

Check warning on line 21 in pos_multi_order_payment/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

pos_multi_order_payment/models/pos_order.py#L20-L21

Added lines #L20 - L21 were not covered by tests
if (
not draft
and float_is_zero(order.amount_paid, prec_acc)
and pos_order["payment_order_id"]
):
order.write({"payment_order_id": pos_order["payment_order_id"]})
cash_payment_method = pos_session.payment_method_ids.filtered(

Check warning on line 28 in pos_multi_order_payment/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

pos_multi_order_payment/models/pos_order.py#L27-L28

Added lines #L27 - L28 were not covered by tests
"is_cash_count"
)[:1]
if not cash_payment_method:
raise UserError(

Check warning on line 32 in pos_multi_order_payment/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

pos_multi_order_payment/models/pos_order.py#L32

Added line #L32 was not covered by tests
_(
"No cash statement found for this session. Unable to record a multiple order payment."
)
)
return_payment_vals = {

Check warning on line 37 in pos_multi_order_payment/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

pos_multi_order_payment/models/pos_order.py#L37

Added line #L37 was not covered by tests
"name": _("Multi order payment"),
"pos_order_id": order.id,
"amount": order.amount_total,
"payment_date": fields.Datetime.now(),
"payment_method_id": cash_payment_method.id,
}
order.add_payment(return_payment_vals)

Check warning on line 44 in pos_multi_order_payment/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

pos_multi_order_payment/models/pos_order.py#L44

Added line #L44 was not covered by tests
3 changes: 3 additions & 0 deletions pos_multi_order_payment/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions pos_multi_order_payment/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Enric Tobella
3 changes: 3 additions & 0 deletions pos_multi_order_payment/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module will allow you to pay several open point of sale orders at the same time.

The principal order will return the other orders amount and the other orders will be payed with this amount.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 01dae43

Please sign in to comment.