Move all OCA POS modules from oca-technical to dedicated oca-pos submodule

Reorganized 74 POS-related modules for better structure:
- Moved all odoo-bringout-oca-pos-* packages from packages/oca-technical/
- Now organized in dedicated packages/oca-pos/ submodule
- Includes payment, receipt, loyalty, order, product, and partner modules
- Maintains all module functionality while improving project organization

This creates a cleaner separation between general technical modules
and Point of Sale specific functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ernad Husremovic 2025-08-30 17:15:35 +02:00
parent 3791451dc1
commit 377f346a99
2675 changed files with 93308 additions and 0 deletions

View file

@ -0,0 +1,2 @@
from . import pos_config
from . import pos_order

View file

@ -0,0 +1,51 @@
# 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, fields, models
from odoo.exceptions import ValidationError
class PosConfig(models.Model):
_inherit = "pos.config"
_PAYMENT_CHANGE_POLICY_SELECTION = [
("refund", "Refund and Resale"),
("update", "Update Payments"),
]
payment_change_policy = fields.Selection(
selection=_PAYMENT_CHANGE_POLICY_SELECTION,
default="refund",
required=True,
help="Payment Change Policy when users want"
" to change the payment lines of a given PoS Order.\n"
"* 'Refund and Resale': Odoo will refund the current"
" Pos Order to cancel it, and create a new PoS Order"
" with the correct payment lines.\n"
"* 'Update Payments': Odoo will change payment lines.\n\n"
"Note : In some countries the 'Update Payments' Option"
" is not allowed by law, because orders history shouldn't"
" not be altered.",
)
@api.constrains("payment_change_policy")
def _check_payment_change_policy(self):
# Check if certification module is installed
# and if yes, if 'update payments' option is allowed
module_states = (
self.env["ir.module.module"]
.sudo()
.search([("name", "=", "l10n_fr_pos_cert")])
.mapped("state")
)
if "installed" not in module_states:
return
for config in self.filtered(lambda x: x.payment_change_policy == "update"):
if config.company_id._is_accounting_unalterable():
raise ValidationError(
_(
"Unable to use the 'Update Payments' options"
" for companies that have unalterable accounting."
)
)

View file

@ -0,0 +1,101 @@
# Copyright (C) 2015 - Today: GRAP (http://www.grap.coop)
# @author: Julien WESTE
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import datetime
from odoo import _, fields, models
from odoo.exceptions import UserError
from odoo.tools import float_is_zero
class PosOrder(models.Model):
_inherit = "pos.order"
def change_payment(self, payment_lines):
"""
Change payment of a given order.
payment_lines should be a list of data that are
the argument of the Odoo Core function add_payment()
Return a list of order ids, depending on the
payment_change_policy of the related pos_config.
"""
self.ensure_one()
orders = self
# Removing zero lines
precision = self.pricelist_id.currency_id.decimal_places
payment_lines = [
x
for x in payment_lines
if not float_is_zero(x["amount"], precision_digits=precision)
]
self._check_payment_change_allowed()
comment = _(
"The payments of the Order %(order)s (Ref: %(ref)s have"
" been changed by %(user_name)s on %(today)s",
order=self.name,
ref=self.pos_reference,
user_name=self.env.user.name,
today=datetime.today(),
)
if self.config_id.payment_change_policy == "update":
self.payment_ids.with_context().unlink()
# Create new payment
for line in payment_lines:
self.add_payment(line)
elif self.config_id.payment_change_policy == "refund":
# Refund order and mark it as paid
# with same payment method as the original one
refund_result = self.refund()
refund_order = self.browse(refund_result["res_id"])
for payment in self.payment_ids:
refund_order.add_payment(
{
"pos_order_id": refund_order.id,
"payment_method_id": payment.payment_method_id.id,
"amount": -payment.amount,
"payment_date": fields.Date.context_today(self),
}
)
refund_order.action_pos_order_paid()
# Resale order and mark it as paid
# with the new payment
resale_order = self.copy(default={"pos_reference": self.pos_reference})
for line in payment_lines:
line.update({"pos_order_id": resale_order.id})
resale_order.add_payment(line)
resale_order.action_pos_order_paid()
orders += refund_order + resale_order
comment += _(
" (Refund Order: %(refund_order)s ; Resale Order: %(resale_order)s)",
refund_order=refund_order.name,
resale_order=resale_order.name,
)
for order in orders:
order.note = "%s\n%s" % (order.note or "", comment)
return orders
def _check_payment_change_allowed(self):
"""Return True if the user can change the payment of a POS, depending
of the state of the current session."""
closed_orders = self.filtered(lambda x: x.session_id.state == "closed")
if len(closed_orders):
raise UserError(
_(
"You can not change payments of the POS '%(name)s' because"
" the associated session '%(session)s' has been closed!",
name=", ".join(closed_orders.mapped("name")),
session=", ".join(closed_orders.mapped("session_id.name")),
)
)