Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
580 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
2
Jul 25
1882
0
Jun 25
415
2
Jul 25
1745
0
Mar 25
1011
1
Jan 25
1861