Skip to Content
Menu
This question has been flagged
1 Reply
214 Views

Although the time appears in the categories, in Odoo Community Edition no filtering by time is applied at the point of sale unless you program it yourself or use an external module.

Avatar
Discard
Best Answer

1. Manually Implement the Filtering (Custom Code)

You can customize the POS frontend JavaScript logic to filter categories or products by current date/time. Here's a summary of how you'd approach it:

a. Add custom fields to the category model (if not already there)

In a custom module:

from odoo import models, fields

class PosCategory(models.Model):
    _inherit = 'pos.category'

    available_from = fields.Datetime("Available From")
    available_until = fields.Datetime("Available Until")


b. Extend POS data loading to include those fields

In your POS module XML:

<field name="pos_category_ids" eval="[('available_from','<=',fields.Datetime.now()), ('available_until','>=',fields.Datetime.now())]"/>

Then ensure you load those fields in your custom JS:

odoo.define('your_module_name.pos_category_time_filter', function (require) {

    const models = require('point_of_sale.models');

    const time = new Date();


    models.load_fields('pos.category', ['available_from', 'available_until']);


    const _super = models.PosModel.prototype;

    models.PosModel = models.PosModel.extend({

        load_new_categories: function () {

            this.pos.categories = this.pos.categories.filter(cat => {

                if (!cat.available_from || !cat.available_until) return true;

                const from = new Date(cat.available_from);

                const until = new Date(cat.available_until);

                return time >= from && time <= until;

            });

        },

        initialize: function () {

            const res = _super.initialize.apply(this, arguments);

            this.ready.then(() => {

                this.load_new_categories();

            });

            return res;

        },

    });

});



2. Use a Free or Paid Community Add-on (OCA or 3rd Party)

Some OCA or third-party community modules offer this functionality. Examples:

  • pos_time_restrict_category (available on GitHub or Odoo Apps)
  • Custom modules developed for restaurants/cafes with time-based menus

You'd still want to vet and test these modules since not all are actively maintained.


Thanks & Regards,

Email :- contact@datainteger.com

Avatar
Discard
Related Posts Replies Views Activity
0
Mar 25
413
0
Mar 25
331
1
Mar 25
1110
2
Apr 24
1297
3
Mar 22
17267