Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
702 Widoki

Hello,

I am experiencing an issue in the POS module where certain orders appear twice with identical details (same articles, table, order number, etc.). The only difference is the timestamp, and as a result, the cashier ends up processing the payment twice, causing accounting discrepancies.

I would like to understand how to prevent this issue from occurring.


I'm using odoo v17 Community edition

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

This is a known issue that can happen in community setups due to network instability, client-side retries, or failure handling bugs.

Root Causes (Common in POS Community):

    Offline or unstable network

        If the POS goes temporarily offline, the order stays in the browser’s local storage and can be resent when back online, causing duplicates.

    Manual browser refresh or crash recovery

        The order may re-submit automatically from cache/local storage.

    No unique_order_id check on backend

        Odoo Community lacks built-in validation to reject duplicate orders based on unique POS order reference (unlike Enterprise with proper sync protections).

Recommended Fixes

1. Enable and enforce unique order identifiers

Modify your POS order model to reject duplicate orders based on a unique ID.

Step-by-step:

    Each order has a pos_reference (e.g., SHOP/0012).

    Add a constraint on pos.order to prevent duplicates.from odoo import models, api, exceptions

    class PosOrder(models.Model):

        _inherit = 'pos.order'

        @api.model

        def create(self, vals):

            if vals.get('pos_reference'):

                existing = self.search([('pos_reference', '=', vals['pos_reference'])], limit=1)

                if existing:

                    raise exceptions.ValidationError("Duplicate POS order detected: %s" % vals['pos_reference'])

            return super().create(vals)


Hope it helps

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

If both orders have the same uuid, you can prevent this issue by setting up a unique constraint for the uuid.

from odoo import models 

class PosOrder(models.Model):
     _inherit = "pos.order"
    _sql_constraints = [('uuid_unique', "unique(uuid)", "An order with the same UUID already exists.")]

Note: The database must not contain duplicate UUID numbers in order for the SQL constraint to be created. This means you need to delete duplicate orders (or change the uuid) first before creating the constraint.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
lip 25
1996
0
cze 25
506
2
lip 25
1841
0
mar 25
1100
1
sty 25
1982