diff --git a/delivery_slot/README.rst b/delivery_slot/README.rst new file mode 100644 index 000000000..fd2d26d26 --- /dev/null +++ b/delivery_slot/README.rst @@ -0,0 +1,46 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Delivery Slot +============= +This module helps you to choose different delivery slot for each product. + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +Gnu Affero General Public License, Version 3 (AGPL v3). +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Credits +------- +* Developer : (V16) Muhsina V, Contact : odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/delivery_slot/__init__.py b/delivery_slot/__init__.py new file mode 100644 index 000000000..e23e75e91 --- /dev/null +++ b/delivery_slot/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Muhsina V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import controllers +from . import models diff --git a/delivery_slot/__manifest__.py b/delivery_slot/__manifest__.py new file mode 100644 index 000000000..7ed7ff383 --- /dev/null +++ b/delivery_slot/__manifest__.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Muhsina V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +{ + 'name': 'Delivery Slot', + 'version': '16.0.1.0.0', + 'category': 'Sales', + 'summary': "Time slot selection for deliveries", + 'description': """This module helps to choose a different delivery date + and time for each product in the order line. Multiple deliveries and + corresponding delivery slots are created for each line in the sale order, + based on the chosen date and slot.""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['sale_management', 'stock', 'account', 'website_sale'], + 'data': [ + 'security/ir.model.access.csv', + 'data/slot_time_data.xml', + 'views/delivery_slot_views.xml', + 'views/res_config_settings_views.xml', + 'views/sale_order_views.xml', + 'views/slot_time_views.xml', + 'views/website_delivery_slot_templates.xml', + 'views/website_slot_time_templates.xml', + ], + 'assets': { + 'web.assets_frontend': [ + 'delivery_slot/static/src/js/delivery_slot.js', + 'delivery_slot/static/src/js/slot_time.js', + 'delivery_slot/static/src/js/website_sale_utils.js', + ], + }, + 'images': ['static/description/banner.jpg'], + 'licence': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/delivery_slot/controllers/__init__.py b/delivery_slot/controllers/__init__.py new file mode 100644 index 000000000..37e3ee792 --- /dev/null +++ b/delivery_slot/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Muhsina V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import delivery_slot diff --git a/delivery_slot/controllers/delivery_slot.py b/delivery_slot/controllers/delivery_slot.py new file mode 100644 index 000000000..e55cfad99 --- /dev/null +++ b/delivery_slot/controllers/delivery_slot.py @@ -0,0 +1,104 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Muhsina V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import http +from odoo.http import request +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class WebsiteSale(WebsiteSale): + """Extends the WebsiteSale controller to add delivery slot functionality. + """ + + @http.route(['/shop/cart'], type='http', auth="public", website=True) + def cart(self, **post): + """ Adding extra field to choose delivery date and slot for each + cart lines""" + val = super().cart(**post) + is_delivery_slot = request.env['ir.config_parameter'].sudo().get_param( + 'delivery_slot.enable_delivery_date') + slots = request.env['slot.time'].search([]) + slot_home = request.env['slot.time'].search([]).filtered( + lambda l: l.slot_type == 'home') + slot_office = request.env['slot.time'].search([]).filtered( + lambda l: l.slot_type == 'office') + val.qcontext.update({ + 'is_delivery_slot': is_delivery_slot, + 'slots': slots, + 'slot_home': slot_home, + 'slot_office': slot_office, + }) + return val + + @http.route(['/shop/cart/update_json'], type='json', auth="public", + methods=['POST'], website=True, csrf=False) + def cart_update_json(self, **kw): + """Passing delivery date and slot values""" + val = super().cart_update_json(**kw) + is_delivery_slot = request.env['ir.config_parameter'].sudo().get_param( + 'delivery_slot.enable_delivery_date') + slots = request.env['slot.time'].search([]) + slot_home = request.env['slot.time'].search([]).filtered( + lambda l: l.slot_type == 'home') + slot_office = request.env['slot.time'].search([]).filtered( + lambda l: l.slot_type == 'office') + val.update({ + 'is_delivery_slot': is_delivery_slot, + 'slots': slots, + 'slot_home': slot_home, + 'slot_office': slot_office, + }) + return val + + @http.route(['/shop/cart/get_option'], type='json', auth="public", + website=True) + def get_option(self, **kw): + """ Called when changing the slot timing ie office hours or home hours + returns the option chosen""" + option = kw.get('selected_option') + slot_filtered = request.env['slot.time'].search([]).filtered( + lambda l: l.slot_type == option) + options = [[slot.id, slot.name] for slot in slot_filtered] + return options + + @http.route(['/shop/cart/set_delivery_date'], type='json', auth="public", + website=True) + def set_delivery_date(self, **kwargs): + """Sets the delivery date for each order line of sale order created""" + order = request.website.sale_get_order() + date = kwargs.get('delivery_date') + line_id = int(kwargs.get('line_id')) + for line in order.order_line: + if line.id == line_id: + if date: + line.delivery_date = date + + @http.route(['/shop/cart/set_delivery_slot'], type='json', auth="public", + website=True) + def set_delivery_slot(self, **kwargs): + """Sets the delivery slots for each order line of sale order created""" + order = request.website.sale_get_order() + slot_id = int(kwargs.get('delivery_slot')) + line_id = int(kwargs.get('line_id')) + for line in order.order_line: + if line.id == line_id: + if slot_id: + line.slot_id = request.env['slot.time'].browse(slot_id) diff --git a/delivery_slot/data/slot_time_data.xml b/delivery_slot/data/slot_time_data.xml new file mode 100644 index 000000000..ccd3a8fe9 --- /dev/null +++ b/delivery_slot/data/slot_time_data.xml @@ -0,0 +1,40 @@ + + + + + + 6AM TO 6PM + home + 6 + 18 + + + + 9AM TO 5PM + office + 9 + 17 + + + + 10AM TO 6PM + office + 10 + 18 + + + + 2PM TO 5PM + office + 2 + 17 + + + + 7AM TO 10PM + home + 7 + 22 + + + diff --git a/delivery_slot/doc/RELEASE_NOTES.md b/delivery_slot/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..8edb154a8 --- /dev/null +++ b/delivery_slot/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 13.11.2023 +#### Version 16.0.1.0.0 +##### ADD +- Initial Commit for Delivery Slot diff --git a/delivery_slot/models/__init__.py b/delivery_slot/models/__init__.py new file mode 100644 index 000000000..de5150896 --- /dev/null +++ b/delivery_slot/models/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Muhsina V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import delivery_slot +from . import res_config_settings +from . import sale_order +from . import slot_time +from . import stock_move diff --git a/delivery_slot/models/delivery_slot.py b/delivery_slot/models/delivery_slot.py new file mode 100644 index 000000000..51bc512b3 --- /dev/null +++ b/delivery_slot/models/delivery_slot.py @@ -0,0 +1,99 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Muhsina V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import api, fields, models + + +class DeliverySlot(models.Model): + """ Delivery slot model""" + _name = 'delivery.slot' + _description = 'Delivery slot' + _rec_name = 'delivery_date' + + delivery_date = fields.Date( + string='Delivery Date', default=fields.Date.today(), + help="Choose a delivery date") + slot_id = fields.Many2one('slot.time', string="slot", + help="Choose Delivery slot") + delivery_ids = fields.One2many( + 'sale.order', 'delivery_slot_id', string="Delivery", + compute="_compute_sale_ids", help="Related Deliveries") + delivery_limit = fields.Integer(string="Delivery Limit", default=100, + help="Limit of this delivery slot") + total_delivery = fields.Integer( + string="Total No of Deliveries", compute='_compute_total_delivery', + help="Current deliveries in this slot") + remaining_slots = fields.Integer( + string="Available No of Deliveries", compute='_compute_remaining_slots' + , help="Remaining no of deliveries in this slot") + active = fields.Boolean( + string='Active', default=True, help="Active or not") + + @api.depends('delivery_ids') + def _compute_total_delivery(self): + """ Update the total deliveries of the delivery slot""" + for rec in self: + rec.total_delivery = len(rec.delivery_ids or []) + + @api.depends('total_delivery', 'delivery_limit') + def _compute_remaining_slots(self): + """Calculate the remaining slots for each delivery slot and deactivate + the slot if it is full""" + self.remaining_slots = self.delivery_limit - self.total_delivery + if self.remaining_slots <= 0: + self.active = False + + @api.model + def create(self, vals): + """Override create method to update delivery_ids""" + delivery_slot = super(DeliverySlot, self).create(vals) + delivery_slot.update_delivery_ids() + return delivery_slot + + def write(self, vals): + """Override write method to update delivery_ids""" + if 'delivery_ids' not in vals: + res = super(DeliverySlot, self).write(vals) + self.update_delivery_ids() + return res + else: + return super(DeliverySlot, self).write(vals) + + def update_delivery_ids(self): + """Update the delivery_ids field based on related sale orders""" + sale_orders = self.env['sale.order'].search( + [('slot_per_product', '=', True)]) + delivery_orders = sale_orders.filtered(lambda order: any( + line.slot_id == self.slot_id and line.delivery_date == + self.delivery_date + for line in order.order_line)) + self.delivery_ids = delivery_orders + + def _compute_sale_ids(self): + """Computing the related sale orders of each delivery slot""" + for rec in self: + sale_orders = self.env['sale.order'].search( + [('slot_per_product', '=', True)]) + delivery_orders = sale_orders.filtered(lambda order: any( + line.slot_id == rec.slot_id and line.delivery_date == + rec.delivery_date + for line in order.order_line)) + rec.delivery_ids = delivery_orders diff --git a/delivery_slot/models/res_config_settings.py b/delivery_slot/models/res_config_settings.py new file mode 100644 index 000000000..f38a147ff --- /dev/null +++ b/delivery_slot/models/res_config_settings.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Muhsina V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + """ Inhering to add a field to enable delivery slot""" + _inherit = 'res.config.settings' + + enable_delivery_date = fields.Boolean( + string='Enable Delivery Date Feature', config_parameter= + 'delivery_slot.enable_delivery_date', help="Enable delivery slot") diff --git a/delivery_slot/models/sale_order.py b/delivery_slot/models/sale_order.py new file mode 100644 index 000000000..e0fb750e9 --- /dev/null +++ b/delivery_slot/models/sale_order.py @@ -0,0 +1,147 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Muhsina V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from datetime import timedelta +from odoo import fields, models +from odoo.addons.sale_stock.models.sale_order_line import SaleOrderLine + + +class SaleOrder(models.Model): + """Inheriting sale order to add boolean field to enable delivery slot""" + _inherit = 'sale.order' + + slot_per_product = fields.Boolean( + string="Delivery Slot per Product", + default=lambda self: self.env['ir.config_parameter'].sudo().get_param( + 'delivery_slot.enable_delivery_date'), + help="Enable delivery slot feature") + delivery_slot_id = fields.Many2one('delivery.slot', string='Delivery Slot', + help="Delivery slot") + slot_count = fields.Integer( + string='Slot Count', compute='_compute_delivery_slot_count', + help="Total no of delivery slot related to this sale order") + + def action_confirm(self): + """Confirm the order and update delivery slot information. + If `slot_per_product` is enabled, for each order line, the + corresponding delivery slot is searched in the system. + If found, the total delivery count is incremented. If not found, + a new delivery slot is created with a delivery count of 1. + :return: The result of the super method `action_confirm()`.""" + if self.slot_per_product: + for line in self.order_line: + delivery_slot = self.env['delivery.slot'].search( + [('delivery_date', '=', line.delivery_date), + ('slot_id', '=', line.slot_id.id), + ('active', '=', True)]) + if delivery_slot: + delivery_slot.total_delivery += 1 + else: + if line.slot_id: + if line.delivery_date: + self.env['delivery.slot'].create({ + 'delivery_date': line.delivery_date, + 'slot_id': line.slot_id.id, + 'total_delivery': 1, + }) + + return super().action_confirm() + + def _compute_delivery_slot_count(self): + """Returns total number of delivery slots per record""" + for record in self: + if record.slot_per_product: + recs = { + slot_record.id + for line in record.order_line + if line.delivery_date + for slot_record in self.env['delivery.slot'].search([ + ('delivery_date', '=', line.delivery_date), + ('slot_id', '=', line.slot_id.id), + ('active', '=', True)], limit=1) + } + record.slot_count = len(recs) + else: + record.slot_count = 0 + + def action_view_delivery_slot(self): + """Returns all delivery slot related to the sale order""" + rec = [ + slot_record.id + for record in self + if record.slot_per_product + for line in record.order_line + for slot_record in self.env['delivery.slot'].search([ + ('delivery_date', '=', line.delivery_date or self.date_order), + ('slot_id', '=', line.slot_id.id), + ('active', '=', True)], limit=1) + ] + return { + 'type': 'ir.actions.act_window', + 'name': 'Delivery Slots', + 'view_mode': 'tree,form', + 'res_model': 'delivery.slot', + 'domain': [('id', 'in', rec)], + 'context': "{'create': False}" + } + + +class SaleOrderLine(models.Model): + """Inheriting sale order line to add slot fields""" + _inherit = 'sale.order.line' + + delivery_date = fields.Date(string="Delivery Date", help="Delivery date") + slot_id = fields.Many2one('slot.time', string="Time Slot", + help="Delivery time") + delivery_slot_id = fields.Many2one( + 'delivery.slot', string='Delivery Slot', help="Related Delivery Slot") + + def _prepare_procurement_values(self, group_id=False): + """ Prepare specific key for moves or other components that will be + created from a stock rule coming from a sale order line. This method + could be overridden in order to add other custom key that could + be used in move/po creation. + """ + date_deadline = self.delivery_date or ( + self.order_id.date_order + timedelta( + days=self.customer_lead or 0.0)) + date_planned = date_deadline - timedelta( + days=self.order_id.company_id.security_lead) + values = { + 'group_id': group_id, + 'sale_line_id': self.id, + 'date_planned': date_planned, + 'date_deadline': date_deadline, + 'route_ids': self.route_id, + 'warehouse_id': self.order_id.warehouse_id or False, + 'product_description_variants': self.with_context( + lang=self.order_id.partner_id.lang). + _get_sale_order_line_multiline_description_variants(), + 'company_id': self.order_id.company_id, + 'product_packaging_id': self.product_packaging_id, + 'sequence': self.sequence, + } + if self.order_id.slot_per_product: + values.update({"slot_per_product": 'True'}) + if self.slot_id: + values.update({'slot_time_id': self.slot_id.id}) + return values + SaleOrderLine._prepare_procurement_values = _prepare_procurement_values diff --git a/delivery_slot/models/slot_time.py b/delivery_slot/models/slot_time.py new file mode 100644 index 000000000..e7a71a4bd --- /dev/null +++ b/delivery_slot/models/slot_time.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Muhsina V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class SlotTime(models.Model): + """Slot time model""" + _name = 'slot.time' + _description = 'Delivery time' + + name = fields.Char(string='Slot', help="Slot name") + slot_type = fields.Selection([ + ('home', 'Home Hours'), ('office', 'Office Hours')], + string="Slot type", help="Slot will be shown based on this slot type") + time_from = fields.Selection([ + ('0', '12:00 AM'), ('1', '1:00 AM'), + ('2', '2:00 AM'), ('3', '3:00 AM'), + ('4', '4:00 AM'), ('5', '5:00 AM'), + ('6', '6:00 AM'), ('7', '7:00 AM'), + ('8', '8:00 AM'), ('9', '9:00 AM'), + ('10', '10:00 AM'), ('11', '11:00 AM'), + ('12', '12:00 PM'), ('13', '1:00 PM'), + ('14', '2:00 PM'), ('15', '3:00 PM'), + ('16', '4:00 PM'), ('17', '5:00 PM'), + ('18', '6:00 PM'), ('19', '7:00 PM'), + ('20', '8:00 PM'), ('21', '9:00 PM'), + ('22', '10:00 PM'), ('23', '11:00 PM') + ], string='Time From', help="From time") + time_to = fields.Selection([ + ('0', '12:00 AM'), ('1', '1:00 AM'), + ('2', '2:00 AM'), ('3', '3:00 AM'), + ('4', '4:00 AM'), ('5', '5:00 AM'), + ('6', '6:00 AM'), ('7', '7:00 AM'), + ('8', '8:00 AM'), ('9', '9:00 AM'), + ('10', '10:00 AM'), ('11', '11:00 AM'), + ('12', '12:00 PM'), ('13', '1:00 PM'), + ('14', '2:00 PM'), ('15', '3:00 PM'), + ('16', '4:00 PM'), ('17', '5:00 PM'), + ('18', '6:00 PM'), ('19', '7:00 PM'), + ('20', '8:00 PM'), ('21', '9:00 PM'), + ('22', '10:00 PM'), ('23', '11:00 PM')], + string='Time To', help="To time") diff --git a/delivery_slot/models/stock_move.py b/delivery_slot/models/stock_move.py new file mode 100644 index 000000000..b4290bdbc --- /dev/null +++ b/delivery_slot/models/stock_move.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Muhsina V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import models +from odoo.tools import float_compare +from odoo.tools.misc import groupby +from odoo.addons.stock.models.stock_move import StockMove + + +class StockMoves(models.Model): + """Inheriting the stock move model""" + _inherit = 'stock.move' + + def _assign_picking(self): + """ Try to assign the moves to an existing picking that has not been + reserved yet and has the same procurement group, locations, and picking + type (moves should already have them identical). Otherwise, create a + new picking to assign them to. """ + picking_obj = self.env['stock.picking'] + grouped_moves = groupby(self, + key=lambda m: m._key_assign_picking()) + for group, moves in grouped_moves: + moves = self.env['stock.move'].concat(*moves) + # Could pass the arguments contained in group, but they are the + # same for each move that's why moves[0] is acceptable + picking = moves[0]._search_picking_for_assignation() + if picking: + # If a picking is found, we'll append `move` to its move list + # and thus its `partner_id` and `ref` field will refer to + # multiple records. + # In this case, we chose to wipe them. + vals = {} + if any(picking.partner_id.id != m.partner_id.id for m in + moves): + vals['partner_id'] = False + if any(picking.origin != m.origin for m in moves): + vals['origin'] = False + if vals: + picking.write(vals) + else: + # Don't create picking for negative moves since they will be + # reversed and assigned to another picking + moves = moves.filtered(lambda m: float_compare( + m.product_uom_qty, 0.0, precision_rounding= + m.product_uom.rounding) >= 0) + if not moves: + continue + pick_values = moves._get_new_picking_values() + sale_order = self.env['sale.order'].search([ + ('name', '=', pick_values['origin'])]) + if sale_order.slot_per_product: + for move in moves: + new_picking = picking_obj.create( + move._get_new_picking_values()) + move.write({'picking_id': new_picking.id}) + move._assign_picking_post_process(new=new_picking) + else: + new_picking = picking_obj.create( + moves._get_new_picking_values()) + moves.write({'picking_id': new_picking.id}) + moves._assign_picking_post_process(new=new_picking) + return True + StockMove._assign_picking = _assign_picking diff --git a/delivery_slot/security/ir.model.access.csv b/delivery_slot/security/ir.model.access.csv new file mode 100644 index 000000000..38fe20922 --- /dev/null +++ b/delivery_slot/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +access_slot_time_user,access.slot.time.user,model_slot_time,base.group_user,1,1,1,1 +access_delivery_slot_user,access.delivery.slot.user,model_delivery_slot,base.group_user,1,1,1,1 diff --git a/delivery_slot/static/description/assets/icons/check.png b/delivery_slot/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/delivery_slot/static/description/assets/icons/check.png differ diff --git a/delivery_slot/static/description/assets/icons/chevron.png b/delivery_slot/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/delivery_slot/static/description/assets/icons/chevron.png differ diff --git a/delivery_slot/static/description/assets/icons/cogs.png b/delivery_slot/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/delivery_slot/static/description/assets/icons/cogs.png differ diff --git a/delivery_slot/static/description/assets/icons/consultation.png b/delivery_slot/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/delivery_slot/static/description/assets/icons/consultation.png differ diff --git a/delivery_slot/static/description/assets/icons/ecom-black.png b/delivery_slot/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/delivery_slot/static/description/assets/icons/ecom-black.png differ diff --git a/delivery_slot/static/description/assets/icons/education-black.png b/delivery_slot/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/delivery_slot/static/description/assets/icons/education-black.png differ diff --git a/delivery_slot/static/description/assets/icons/hotel-black.png b/delivery_slot/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/delivery_slot/static/description/assets/icons/hotel-black.png differ diff --git a/delivery_slot/static/description/assets/icons/license.png b/delivery_slot/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/delivery_slot/static/description/assets/icons/license.png differ diff --git a/delivery_slot/static/description/assets/icons/lifebuoy.png b/delivery_slot/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/delivery_slot/static/description/assets/icons/lifebuoy.png differ diff --git a/delivery_slot/static/description/assets/icons/logo.png b/delivery_slot/static/description/assets/icons/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/delivery_slot/static/description/assets/icons/logo.png differ diff --git a/delivery_slot/static/description/assets/icons/manufacturing-black.png b/delivery_slot/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/delivery_slot/static/description/assets/icons/manufacturing-black.png differ diff --git a/delivery_slot/static/description/assets/icons/pos-black.png b/delivery_slot/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/delivery_slot/static/description/assets/icons/pos-black.png differ diff --git a/delivery_slot/static/description/assets/icons/puzzle.png b/delivery_slot/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/delivery_slot/static/description/assets/icons/puzzle.png differ diff --git a/delivery_slot/static/description/assets/icons/restaurant-black.png b/delivery_slot/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/delivery_slot/static/description/assets/icons/restaurant-black.png differ diff --git a/delivery_slot/static/description/assets/icons/service-black.png b/delivery_slot/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/delivery_slot/static/description/assets/icons/service-black.png differ diff --git a/delivery_slot/static/description/assets/icons/trading-black.png b/delivery_slot/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/delivery_slot/static/description/assets/icons/trading-black.png differ diff --git a/delivery_slot/static/description/assets/icons/training.png b/delivery_slot/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/delivery_slot/static/description/assets/icons/training.png differ diff --git a/delivery_slot/static/description/assets/icons/update.png b/delivery_slot/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/delivery_slot/static/description/assets/icons/update.png differ diff --git a/delivery_slot/static/description/assets/icons/user.png b/delivery_slot/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/delivery_slot/static/description/assets/icons/user.png differ diff --git a/delivery_slot/static/description/assets/icons/wrench.png b/delivery_slot/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/delivery_slot/static/description/assets/icons/wrench.png differ diff --git a/delivery_slot/static/description/assets/misc/categories.png b/delivery_slot/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/delivery_slot/static/description/assets/misc/categories.png differ diff --git a/delivery_slot/static/description/assets/misc/check-box.png b/delivery_slot/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/delivery_slot/static/description/assets/misc/check-box.png differ diff --git a/delivery_slot/static/description/assets/misc/compass.png b/delivery_slot/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/delivery_slot/static/description/assets/misc/compass.png differ diff --git a/delivery_slot/static/description/assets/misc/corporate.png b/delivery_slot/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/delivery_slot/static/description/assets/misc/corporate.png differ diff --git a/delivery_slot/static/description/assets/misc/customer-support.png b/delivery_slot/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/delivery_slot/static/description/assets/misc/customer-support.png differ diff --git a/delivery_slot/static/description/assets/misc/cybrosys-logo.png b/delivery_slot/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/delivery_slot/static/description/assets/misc/cybrosys-logo.png differ diff --git a/delivery_slot/static/description/assets/misc/features.png b/delivery_slot/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/delivery_slot/static/description/assets/misc/features.png differ diff --git a/delivery_slot/static/description/assets/misc/logo.png b/delivery_slot/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/delivery_slot/static/description/assets/misc/logo.png differ diff --git a/delivery_slot/static/description/assets/misc/pictures.png b/delivery_slot/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/delivery_slot/static/description/assets/misc/pictures.png differ diff --git a/delivery_slot/static/description/assets/misc/pie-chart.png b/delivery_slot/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/delivery_slot/static/description/assets/misc/pie-chart.png differ diff --git a/delivery_slot/static/description/assets/misc/right-arrow.png b/delivery_slot/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/delivery_slot/static/description/assets/misc/right-arrow.png differ diff --git a/delivery_slot/static/description/assets/misc/star.png b/delivery_slot/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/delivery_slot/static/description/assets/misc/star.png differ diff --git a/delivery_slot/static/description/assets/misc/support.png b/delivery_slot/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/delivery_slot/static/description/assets/misc/support.png differ diff --git a/delivery_slot/static/description/assets/misc/whatsapp.png b/delivery_slot/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/delivery_slot/static/description/assets/misc/whatsapp.png differ diff --git a/delivery_slot/static/description/assets/modules/dynamic_product_fields.png b/delivery_slot/static/description/assets/modules/dynamic_product_fields.png new file mode 100644 index 000000000..55fb7ba18 Binary files /dev/null and b/delivery_slot/static/description/assets/modules/dynamic_product_fields.png differ diff --git a/delivery_slot/static/description/assets/modules/dynamic_sale_order_fields.png b/delivery_slot/static/description/assets/modules/dynamic_sale_order_fields.png new file mode 100644 index 000000000..febd12d15 Binary files /dev/null and b/delivery_slot/static/description/assets/modules/dynamic_sale_order_fields.png differ diff --git a/delivery_slot/static/description/assets/modules/picking_order_line_view.png b/delivery_slot/static/description/assets/modules/picking_order_line_view.png new file mode 100644 index 000000000..b8ea6b411 Binary files /dev/null and b/delivery_slot/static/description/assets/modules/picking_order_line_view.png differ diff --git a/delivery_slot/static/description/assets/modules/sale_discount_total.png b/delivery_slot/static/description/assets/modules/sale_discount_total.png new file mode 100644 index 000000000..3add135c3 Binary files /dev/null and b/delivery_slot/static/description/assets/modules/sale_discount_total.png differ diff --git a/delivery_slot/static/description/assets/modules/sale_order_line_views.png b/delivery_slot/static/description/assets/modules/sale_order_line_views.png new file mode 100644 index 000000000..624ef69b7 Binary files /dev/null and b/delivery_slot/static/description/assets/modules/sale_order_line_views.png differ diff --git a/delivery_slot/static/description/assets/modules/sale_purchase_previous_product_cost.png b/delivery_slot/static/description/assets/modules/sale_purchase_previous_product_cost.png new file mode 100644 index 000000000..61bb0ced0 Binary files /dev/null and b/delivery_slot/static/description/assets/modules/sale_purchase_previous_product_cost.png differ diff --git a/delivery_slot/static/description/assets/screenshots/0.png b/delivery_slot/static/description/assets/screenshots/0.png new file mode 100644 index 000000000..d899f1b7f Binary files /dev/null and b/delivery_slot/static/description/assets/screenshots/0.png differ diff --git a/delivery_slot/static/description/assets/screenshots/1.png b/delivery_slot/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..77d3387ec Binary files /dev/null and b/delivery_slot/static/description/assets/screenshots/1.png differ diff --git a/delivery_slot/static/description/assets/screenshots/2.png b/delivery_slot/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..ed9cb94c3 Binary files /dev/null and b/delivery_slot/static/description/assets/screenshots/2.png differ diff --git a/delivery_slot/static/description/assets/screenshots/3.png b/delivery_slot/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..6780205d1 Binary files /dev/null and b/delivery_slot/static/description/assets/screenshots/3.png differ diff --git a/delivery_slot/static/description/assets/screenshots/4.png b/delivery_slot/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..7ea0dd0ca Binary files /dev/null and b/delivery_slot/static/description/assets/screenshots/4.png differ diff --git a/delivery_slot/static/description/assets/screenshots/5.png b/delivery_slot/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..06fca4690 Binary files /dev/null and b/delivery_slot/static/description/assets/screenshots/5.png differ diff --git a/delivery_slot/static/description/assets/screenshots/6.png b/delivery_slot/static/description/assets/screenshots/6.png new file mode 100644 index 000000000..072fb7666 Binary files /dev/null and b/delivery_slot/static/description/assets/screenshots/6.png differ diff --git a/delivery_slot/static/description/assets/screenshots/hero.gif b/delivery_slot/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..c0c6a99f2 Binary files /dev/null and b/delivery_slot/static/description/assets/screenshots/hero.gif differ diff --git a/delivery_slot/static/description/banner.jpg b/delivery_slot/static/description/banner.jpg new file mode 100644 index 000000000..0bf7753b8 Binary files /dev/null and b/delivery_slot/static/description/banner.jpg differ diff --git a/delivery_slot/static/description/icon.png b/delivery_slot/static/description/icon.png new file mode 100644 index 000000000..9a26a3dd3 Binary files /dev/null and b/delivery_slot/static/description/icon.png differ diff --git a/delivery_slot/static/description/index.html b/delivery_slot/static/description/index.html new file mode 100644 index 000000000..dadfb3f73 --- /dev/null +++ b/delivery_slot/static/description/index.html @@ -0,0 +1,675 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+
+ +
+
+
+ +

+ Delivery Slot +

+

+ A Module For Adding Delivery Slot For Each Product +

+ + +
+
+
+
+ + +
+
+ +
+

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+ In Odoo, currently delivery will be created to the whole + products at once in sales order. Using Delivery Slot, + we can create multiple deliveries based on delivery date and delivery + slot + added in each sale order line. +
+
+ + + +
+
+ +
+

+ Features +

+
+
+
+
+ + Community & Enterprise Support. + +
+
+ + Option to Enable/Disable Delivery Slot. +
+
+ + Set Delivery Date and Delivery Slot For Each Product. +
+
+ + Multiple deliveries are Created. +
+
+ + Limited number of Deliveries In Each Slots. +
+
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+
+

+ Configure Slot Time and Delivery Slot +

+

+ Go to Sale => Configuration => Slot Timing to create time + slots. + We can also configure delivery slot , though they will be + automatically created when confirming the sale order.

+ +
+
+

+ Enable Delivery Slot +

+

+ Enable 'Delivery Slot Feature' in website configuration then we + can add delivery slot for each product from the cart.

+ +
+
+

+ Choose Delivery Date And Delivery Slot +

+

+ When the Delivery Slot feature is enabled, we can add a + delivery date and delivery slot for each cart line.It is + mandatory + to provide both delivery date and slot to create separate + delivery slot for each product. + We have the option to choose both office hours and home + hours.

+ +
+
+

+ Multiple Deliveries +

+

+ After the payment, a sale order is created with multiple + deliveries, + and we can see the corresponding delivery slots.

+ +
+
+

+

+

+ When creating a sale order from the backend, we have the option + to enable the delivery slot per product. + Then, we can choose the delivery date and slot for each product + from the order line. + Both delivery date and slot should be added to the orderline + for which we want to create separate delivery slot. +

+ +
+
+

+

+

+ Upon confirming the sale order, multiple deliveries are created + based on + the selected delivery date and slot.

+ +
+
+
+ + + +
+
+ +
+

+ Related + Products +

+
+
+
+ +
+
+ + + +
+
+ +
+

+ Our Services +

+
+
+
+
+
+ +
+
+ Odoo + Customization
+
+
+
+ +
+
+ Odoo + Implementation
+
+
+
+ +
+
+ Odoo + Support
+
+
+
+ +
+
+ Hire + Odoo + Developer
+
+
+
+ +
+
+ Odoo + Integration
+
+
+
+ +
+
+ Odoo + Migration
+
+
+
+ +
+
+ Odoo + Consultancy
+
+
+
+ +
+
+ Odoo + Implementation
+
+
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+
+ + + +
+
+ +
+

+ Our + Industries +

+
+
+
+
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+
+
+ + + +
+
+ +
+

+ Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? + Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+ +91 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/delivery_slot/static/src/js/delivery_slot.js b/delivery_slot/static/src/js/delivery_slot.js new file mode 100644 index 000000000..59a131e68 --- /dev/null +++ b/delivery_slot/static/src/js/delivery_slot.js @@ -0,0 +1,37 @@ +odoo.define('delivery_slot.cart_line', function(require) { + 'use strict'; + /** + * Module for handling delivery slot selection in the shopping cart. + */ + var publicWidget = require('web.public.widget'); + const ajax = require('web.ajax'); + publicWidget.registry.websiteDeliverySlot = publicWidget.Widget.extend({ + selector: '.delivery_slot_div', + events: { + 'change #slot_id': '_onDateChange', + 'change #date': '_onDateChange', + }, + /** + * Handles the change event of the date or slot selection. + * @param {Event} ev - The change event. + */ + _onDateChange: function(ev) { + if (ev.currentTarget.id == 'date') { + var delivery_date = ev.currentTarget.value + var line_id = $(ev.currentTarget).attr('data-line-id') + ajax.jsonRpc('/shop/cart/set_delivery_date', "call", { + 'delivery_date': delivery_date, + 'line_id': line_id + }); + } + else if (ev.currentTarget.id == 'slot_id') { + var delivery_slot = ev.currentTarget.value + var line_id = $(ev.currentTarget).attr('data-line-id') + ajax.jsonRpc('/shop/cart/set_delivery_slot', "call", { + 'delivery_slot': delivery_slot, + 'line_id': line_id + }); + } + }, + }); +}); diff --git a/delivery_slot/static/src/js/slot_time.js b/delivery_slot/static/src/js/slot_time.js new file mode 100644 index 000000000..c6be606ad --- /dev/null +++ b/delivery_slot/static/src/js/slot_time.js @@ -0,0 +1,34 @@ +odoo.define('delivery_slot.cart', function(require) { + 'use strict'; + var publicWidget = require('web.public.widget'); + const ajax = require('web.ajax'); + /** + * Widget that handles the slot time selection on the cart line. + */ + publicWidget.registry.websiteSlotTimeHours = publicWidget.Widget.extend({ + selector: '.slot-time-div', + events: { + 'change input[type="radio"][name="slot_hour"]': '_onSlotTime', + }, + _onSlotTime: function(ev) { + var selected_option = $("input[type='radio'][name='slot_hour']:checked").val() + ajax.jsonRpc('/shop/cart/get_option', "call", { + 'selected_option': selected_option, + }) + .then(function(result) { + const selects = document.querySelectorAll('select'); + const input = document.querySelector('input'); + selects.forEach((select) => { + const options = Array.from(select.options); + options.forEach((option) => { + option.remove(); + }); + result.forEach((item) => { + let newOption = new Option(item[1], item[0]); + select.add(newOption, undefined); + }); + }); + }); + }, + }); +}); diff --git a/delivery_slot/static/src/js/website_sale_utils.js b/delivery_slot/static/src/js/website_sale_utils.js new file mode 100644 index 000000000..7d08ed32f --- /dev/null +++ b/delivery_slot/static/src/js/website_sale_utils.js @@ -0,0 +1,24 @@ +odoo.define('delivery_slot.website_sale_utils', function (require) { + "use strict"; + const utils = require('website_sale.utils'); + /** + * Custom implementation of the updateCartNavBar function. + * + * @param {Object} data - The data to update the cart navbar. + */ + utils.updateCartNavBar = function (data) { + $(".my_cart_quantity") + .parents('li.o_wsale_my_cart').removeClass('d-none').end() + .addClass('o_mycart_zoom_animation').delay(300) + .queue(function () { + $(this) + .toggleClass('fa fa-warning', !data.cart_quantity) + .attr('title', data.warning) + .text(data.cart_quantity || '') + .removeClass('o_mycart_zoom_animation') + .dequeue(); + }); + $(".js_cart_summary").replaceWith(data['website_sale.short_cart_summary']); + }; + return utils; +}); diff --git a/delivery_slot/views/delivery_slot_views.xml b/delivery_slot/views/delivery_slot_views.xml new file mode 100644 index 000000000..8e316fc90 --- /dev/null +++ b/delivery_slot/views/delivery_slot_views.xml @@ -0,0 +1,52 @@ + + + + + delivery.slot.view.tree + delivery.slot + + + + + + + + + + delivery.slot.view.form + delivery.slot + +
+ + + + + + + + + + + + + + + + + +
+
+
+ + + Delivery Slot + delivery.slot + tree,form + + + +
diff --git a/delivery_slot/views/res_config_settings_views.xml b/delivery_slot/views/res_config_settings_views.xml new file mode 100644 index 000000000..220c2abed --- /dev/null +++ b/delivery_slot/views/res_config_settings_views.xml @@ -0,0 +1,28 @@ + + + + + + res.config.settings.view.form.inherit.delivery.slot + + res.config.settings + + + + + +
+
+
+ Enable Delivery Slot + Feature + +
+ +
+
+
+ + + + diff --git a/delivery_slot/views/sale_order_views.xml b/delivery_slot/views/sale_order_views.xml new file mode 100644 index 000000000..fbcf2c182 --- /dev/null +++ b/delivery_slot/views/sale_order_views.xml @@ -0,0 +1,34 @@ + + + + + sale.order.view.form.inherit.delivery.slot + + sale.order + + + + + +
+ + +
+ + + + + +
+
+
diff --git a/delivery_slot/views/slot_time_views.xml b/delivery_slot/views/slot_time_views.xml new file mode 100644 index 000000000..cee283ad2 --- /dev/null +++ b/delivery_slot/views/slot_time_views.xml @@ -0,0 +1,43 @@ + + + + + slot.time.view.tree + slot.time + + + + + + + + + + + + slot.time.view.form + slot.time + +
+ + + + + + + + +
+
+
+ + + Slots + slot.time + tree,form + + + +
diff --git a/delivery_slot/views/website_delivery_slot_templates.xml b/delivery_slot/views/website_delivery_slot_templates.xml new file mode 100644 index 000000000..bfabd5e3e --- /dev/null +++ b/delivery_slot/views/website_delivery_slot_templates.xml @@ -0,0 +1,61 @@ + + + + diff --git a/delivery_slot/views/website_slot_time_templates.xml b/delivery_slot/views/website_slot_time_templates.xml new file mode 100644 index 000000000..9adeda46c --- /dev/null +++ b/delivery_slot/views/website_slot_time_templates.xml @@ -0,0 +1,32 @@ + + + +