Skip to Content
Menu
This question has been flagged
2 Replies
313 Zobrazenia

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

Avatar
Zrušiť
Best Answer

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

Avatar
Zrušiť
Best Answer

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.

Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
2
júl 25
1686
0
jún 25
346
2
júl 25
1629
0
mar 25
959
1
jan 25
1710