diff --git a/pos_ship_later_default/README.rst b/pos_ship_later_default/README.rst new file mode 100644 index 0000000000..105b0f447c --- /dev/null +++ b/pos_ship_later_default/README.rst @@ -0,0 +1,103 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +====================== +POS Ship Later Default +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c7e1fe92ea40120860decbb30852c07d5828d48f212783421f87d0a1cbf7b686 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github + :target: https://github.com/OCA/pos/tree/19.0/pos_ship_later_default + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-19-0/pos-19-0-pos_ship_later_default + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of the Point of Sale to allow +setting a default "Ship Later" date. + +It adds three configuration options: + +- **Ship Later by Default**: Automatically mark new orders as "Ship + Later". +- **Delivery Delay**: Set the default shipping date by adding this + number of days to the current date. +- **Hide Ship Later Button**: Prevents the cashier from changing the + ship later option. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +1. Go to Point of Sale > Configuration > Settings. +2. Enable "Allow Ship Later". +3. Check "Ship Later by Default". +4. Set the "Delivery Delay" if you want a specific offset in days. +5. Check "Hide Ship Later Button" if you want to force all orders to be + shipped later without allowing the cashier to change it. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Jarsa + +Contributors +------------ + +- Odoo Community Association (OCA) +- Jarsa + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/pos `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_ship_later_default/__init__.py b/pos_ship_later_default/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_ship_later_default/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_ship_later_default/__manifest__.py b/pos_ship_later_default/__manifest__.py new file mode 100644 index 0000000000..e166850f98 --- /dev/null +++ b/pos_ship_later_default/__manifest__.py @@ -0,0 +1,22 @@ +{ + "name": "POS Ship Later Default", + "version": "19.0.1.0.0", + "category": "Sales/Point of Sale", + "summary": "Set Ship Later by default in Point of Sale", + "author": "Odoo Community Association (OCA), Jarsa", + "website": "https://github.com/OCA/pos", + "license": "AGPL-3", + "depends": ["point_of_sale"], + "data": [ + "views/res_config_settings_views.xml", + ], + "assets": { + "point_of_sale._assets_pos": [ + "pos_ship_later_default/static/src/overrides/**/*", + ], + "web.assets_tests": [ + "pos_ship_later_default/static/tests/tours/pos_ship_later_default_tour.esm.js", + ], + }, + "installable": True, +} diff --git a/pos_ship_later_default/i18n/es.po b/pos_ship_later_default/i18n/es.po new file mode 100644 index 0000000000..85922a4ab1 --- /dev/null +++ b/pos_ship_later_default/i18n/es.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_ship_later_default +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 19.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-06-18 20:00+0000\n" +"PO-Revision-Date: 2026-06-18 20:00+0000\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_ship_later_default +#: model:ir.model,name:pos_ship_later_default.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuración del Punto de Venta" + +#. module: pos_ship_later_default +#: model:ir.model.fields,field_description:pos_ship_later_default.field_pos_config__ship_later_default +#: model:ir.model.fields,field_description:pos_ship_later_default.field_res_config_settings__pos_ship_later_default +msgid "Ship Later by Default" +msgstr "Enviar después por defecto" + +#. module: pos_ship_later_default +#: model:ir.model.fields,field_description:pos_ship_later_default.field_pos_config__hide_ship_later_button +#: model:ir.model.fields,field_description:pos_ship_later_default.field_res_config_settings__pos_hide_ship_later_button +msgid "Hide Ship Later Button" +msgstr "Ocultar botón de enviar después de UI" + +#. module: pos_ship_later_default +#: model:ir.model.fields,field_description:pos_ship_later_default.field_pos_config__ship_later_delivery_delay +#: model:ir.model.fields,field_description:pos_ship_later_default.field_res_config_settings__pos_ship_later_delivery_delay +msgid "Delivery Delay" +msgstr "Retraso de entrega" + +#. module: pos_ship_later_default +#: model:ir.model.fields,help:pos_ship_later_default.field_pos_config__ship_later_delivery_delay +msgid "Number of days to add to the current date for the default shipping date." +msgstr "Número de días a sumar a la fecha actual para la fecha de envío por defecto." + +#. module: pos_ship_later_default +#: model_terms:ir.ui.view,arch_db:pos_ship_later_default.res_config_settings_view_form +msgid "Set Ship Later by default on new orders." +msgstr "Establecer Enviar después por defecto en los nuevos pedidos." diff --git a/pos_ship_later_default/models/__init__.py b/pos_ship_later_default/models/__init__.py new file mode 100644 index 0000000000..2b92809a3b --- /dev/null +++ b/pos_ship_later_default/models/__init__.py @@ -0,0 +1,2 @@ +from . import pos_config +from . import res_config_settings diff --git a/pos_ship_later_default/models/pos_config.py b/pos_ship_later_default/models/pos_config.py new file mode 100644 index 0000000000..3d34a5afae --- /dev/null +++ b/pos_ship_later_default/models/pos_config.py @@ -0,0 +1,17 @@ +from odoo import fields, models + + +class PosConfig(models.Model): + _inherit = "pos.config" + + ship_later_default = fields.Boolean( + string="Ship Later by Default", + ) + ship_later_delivery_delay = fields.Integer( + string="Delivery Delay", + default=0, + help="Number of days to add to the current date for the default shipping date.", + ) + hide_ship_later_button = fields.Boolean( + help="Prevents the cashier from changing the ship later option." + ) diff --git a/pos_ship_later_default/models/res_config_settings.py b/pos_ship_later_default/models/res_config_settings.py new file mode 100644 index 0000000000..174685546f --- /dev/null +++ b/pos_ship_later_default/models/res_config_settings.py @@ -0,0 +1,18 @@ +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + pos_ship_later_default = fields.Boolean( + related="pos_config_id.ship_later_default", + readonly=False, + ) + pos_ship_later_delivery_delay = fields.Integer( + related="pos_config_id.ship_later_delivery_delay", + readonly=False, + ) + pos_hide_ship_later_button = fields.Boolean( + related="pos_config_id.hide_ship_later_button", + readonly=False, + ) diff --git a/pos_ship_later_default/pyproject.toml b/pos_ship_later_default/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/pos_ship_later_default/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pos_ship_later_default/readme/CONTRIBUTORS.md b/pos_ship_later_default/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..2fc641b033 --- /dev/null +++ b/pos_ship_later_default/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Odoo Community Association (OCA) +- Jarsa diff --git a/pos_ship_later_default/readme/DESCRIPTION.md b/pos_ship_later_default/readme/DESCRIPTION.md new file mode 100644 index 0000000000..a52d221209 --- /dev/null +++ b/pos_ship_later_default/readme/DESCRIPTION.md @@ -0,0 +1,11 @@ +This module extends the functionality of the Point of Sale to allow +setting a default "Ship Later" date. + +It adds three configuration options: + +- **Ship Later by Default**: Automatically mark new orders as "Ship + Later". +- **Delivery Delay**: Set the default shipping date by adding this + number of days to the current date. +- **Hide Ship Later Button**: Prevents the cashier from changing the + ship later option. diff --git a/pos_ship_later_default/readme/USAGE.md b/pos_ship_later_default/readme/USAGE.md new file mode 100644 index 0000000000..38eac228c9 --- /dev/null +++ b/pos_ship_later_default/readme/USAGE.md @@ -0,0 +1,8 @@ +To use this module, you need to: + +1. Go to Point of Sale \> Configuration \> Settings. +2. Enable "Allow Ship Later". +3. Check "Ship Later by Default". +4. Set the "Delivery Delay" if you want a specific offset in days. +5. Check "Hide Ship Later Button" if you want to force all orders to be + shipped later without allowing the cashier to change it. diff --git a/pos_ship_later_default/static/description/index.html b/pos_ship_later_default/static/description/index.html new file mode 100644 index 0000000000..be27a3f456 --- /dev/null +++ b/pos_ship_later_default/static/description/index.html @@ -0,0 +1,453 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

POS Ship Later Default

+ +

Beta License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

+

This module extends the functionality of the Point of Sale to allow +setting a default “Ship Later” date.

+

It adds three configuration options:

+
    +
  • Ship Later by Default: Automatically mark new orders as “Ship +Later”.
  • +
  • Delivery Delay: Set the default shipping date by adding this +number of days to the current date.
  • +
  • Hide Ship Later Button: Prevents the cashier from changing the +ship later option.
  • +
+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Point of Sale > Configuration > Settings.
  2. +
  3. Enable “Allow Ship Later”.
  4. +
  5. Check “Ship Later by Default”.
  6. +
  7. Set the “Delivery Delay” if you want a specific offset in days.
  8. +
  9. Check “Hide Ship Later Button” if you want to force all orders to be +shipped later without allowing the cashier to change it.
  10. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Jarsa
  • +
+
+
+

Contributors

+
    +
  • Odoo Community Association (OCA)
  • +
  • Jarsa
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/pos project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/pos_ship_later_default/static/src/overrides/models/pos_order.esm.js b/pos_ship_later_default/static/src/overrides/models/pos_order.esm.js new file mode 100644 index 0000000000..ea0e076598 --- /dev/null +++ b/pos_ship_later_default/static/src/overrides/models/pos_order.esm.js @@ -0,0 +1,15 @@ +import {PosOrder} from "@point_of_sale/app/models/pos_order"; +import {patch} from "@web/core/utils/patch"; + +const {DateTime} = luxon; + +patch(PosOrder.prototype, { + setup() { + super.setup(...arguments); + if (this.config.ship_later_default && !this.shipping_date) { + const delay = this.config.ship_later_delivery_delay || 0; + const shippingDate = DateTime.now().plus({days: delay}); + this.setShippingDate(shippingDate); + } + }, +}); diff --git a/pos_ship_later_default/static/src/overrides/screens/payment_screen/payment_screen.xml b/pos_ship_later_default/static/src/overrides/screens/payment_screen/payment_screen.xml new file mode 100644 index 0000000000..65221e5ed8 --- /dev/null +++ b/pos_ship_later_default/static/src/overrides/screens/payment_screen/payment_screen.xml @@ -0,0 +1,17 @@ + + + + + pos.config.ship_later and !pos.config.hide_ship_later_button + + + diff --git a/pos_ship_later_default/static/tests/tours/pos_ship_later_default_tour.esm.js b/pos_ship_later_default/static/tests/tours/pos_ship_later_default_tour.esm.js new file mode 100644 index 0000000000..ae0abb85c9 --- /dev/null +++ b/pos_ship_later_default/static/tests/tours/pos_ship_later_default_tour.esm.js @@ -0,0 +1,30 @@ +/* eslint-disable */ +import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util"; +import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util"; +import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util"; +import * as ProductScreen from "@point_of_sale/../tests/pos/tours/utils/product_screen_util"; +import {registry} from "@web/core/registry"; + +registry.category("web_tour.tours").add("pos_ship_later_default_tour", { + steps: () => + [ + Chrome.startPoS(), + Dialog.confirm("Open Register"), + ProductScreen.addOrderline("Whiteboard Pen", "1"), + ProductScreen.clickPartnerButton(), + ProductScreen.clickCustomer("Partner Test with Address"), + ProductScreen.clickPayButton(), + { + content: "verify ship later button is hidden", + trigger: ".payment-buttons:not(:has(.button:contains('Ship Later')))", + run: () => {}, + }, + PaymentScreen.clickPaymentMethod("Cash"), + PaymentScreen.clickValidate(), + { + content: "close point of sale", + trigger: ".pos-receipt", + run: () => {}, + }, + ].flat(), +}); diff --git a/pos_ship_later_default/tests/__init__.py b/pos_ship_later_default/tests/__init__.py new file mode 100644 index 0000000000..57cedd4d2a --- /dev/null +++ b/pos_ship_later_default/tests/__init__.py @@ -0,0 +1,2 @@ +from . import test_pos_ship_later_default +from . import test_pos_ship_later_tour diff --git a/pos_ship_later_default/tests/test_pos_ship_later_default.py b/pos_ship_later_default/tests/test_pos_ship_later_default.py new file mode 100644 index 0000000000..08f8ed3214 --- /dev/null +++ b/pos_ship_later_default/tests/test_pos_ship_later_default.py @@ -0,0 +1,38 @@ +from odoo.tests import TransactionCase + + +class TestPosShipLaterDefault(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.pos_config = cls.env["pos.config"].create( + { + "name": "Test POS", + "ship_later_default": True, + "ship_later_delivery_delay": 5, + "hide_ship_later_button": True, + } + ) + + def test_pos_config_fields(self): + """Test that the new fields are available and configurable on pos.config""" + self.assertTrue(self.pos_config.ship_later_default) + self.assertEqual(self.pos_config.ship_later_delivery_delay, 5) + self.assertTrue(self.pos_config.hide_ship_later_button) + + def test_res_config_settings(self): + """Test that the res.config.settings correctly reflect pos.config fields""" + res_config = self.env["res.config.settings"].create( + { + "pos_config_id": self.pos_config.id, + } + ) + self.assertTrue(res_config.pos_ship_later_default) + self.assertEqual(res_config.pos_ship_later_delivery_delay, 5) + self.assertTrue(res_config.pos_hide_ship_later_button) + + # Change via res.config.settings + res_config.write({"pos_ship_later_delivery_delay": 2}) + # Res config settings execute writes changes + res_config.execute() + self.assertEqual(self.pos_config.ship_later_delivery_delay, 2) diff --git a/pos_ship_later_default/tests/test_pos_ship_later_tour.py b/pos_ship_later_default/tests/test_pos_ship_later_tour.py new file mode 100644 index 0000000000..4b87308471 --- /dev/null +++ b/pos_ship_later_default/tests/test_pos_ship_later_tour.py @@ -0,0 +1,35 @@ +import odoo.tests + +from odoo.addons.point_of_sale.tests.common import TestPointOfSaleHttpCommon + + +@odoo.tests.tagged("post_install", "-at_install") +class TestPosShipLaterTour(TestPointOfSaleHttpCommon): + def test_pos_ship_later_tour(self): + # Create a partner with address + self.env["res.partner"].create( + { + "name": "Partner Test with Address", + "street": "test street", + "zip": "1234", + "city": "test city", + "country_id": self.env.ref("base.us").id, + } + ) + # Configure POS with ship later default settings + self.main_pos_config.write( + { + "ship_later": True, + "ship_later_default": True, + "ship_later_delivery_delay": 5, + "hide_ship_later_button": True, + } + ) + # Open UI + self.main_pos_config.with_user(self.pos_user).open_ui() + # Run tour + self.start_tour( + f"/pos/ui?config_id={self.main_pos_config.id}", + "pos_ship_later_default_tour", + login="pos_user", + ) diff --git a/pos_ship_later_default/views/res_config_settings_views.xml b/pos_ship_later_default/views/res_config_settings_views.xml new file mode 100644 index 0000000000..14261fca52 --- /dev/null +++ b/pos_ship_later_default/views/res_config_settings_views.xml @@ -0,0 +1,38 @@ + + + + res.config.settings.view.form.inherit.pos_ship_later_default + res.config.settings + + + +
+
+
+
+
+
+
+
+
+