diff --git a/website_sale_order_type/README.rst b/website_sale_order_type/README.rst new file mode 100644 index 0000000000..e51d4d126a --- /dev/null +++ b/website_sale_order_type/README.rst @@ -0,0 +1,111 @@ +======================= +Website sale order type +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:ce9cac8f43f42aba162bdadb71200e5caad7feab4910aaa9208009dc9f91127a + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/licence-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%2Fe--commerce-lightgray.png?logo=github + :target: https://github.com/OCA/e-commerce/tree/18.0/website_sale_order_type + :alt: OCA/e-commerce +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_order_type + :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/e-commerce&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows +`sale_order_type `__ +to work with websitesale. + +This module is useful for users having a sale order type defined in +their Partner form: when these users buy a product in the e-commerce, +the sale order generated will have the same sale order type that is +defined in their Partner form. + +Note that the sale order type is defined contact by contact and not at +Company level. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +1. In the backend (Sales -> Customers) set a sale order type in any + contact; +2. Log in with the associated user in the e-commerce website and buy a + product; +3. Check that the created sale oder has the same sale order type that + has been set in the contact. + +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 +------- + +* Agile Business Group + +Contributors +------------ + +- Simone Rubino + +- `Tecnativa `__: + + - João Marques + - Pilar Vargas + - Stefan Ungureanu + - Carlos Lopez + +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. + +.. |maintainer-pilarvargas-tecnativa| image:: https://github.com/pilarvargas-tecnativa.png?size=40px + :target: https://github.com/pilarvargas-tecnativa + :alt: pilarvargas-tecnativa + +Current `maintainer `__: + +|maintainer-pilarvargas-tecnativa| + +This module is part of the `OCA/e-commerce `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_sale_order_type/__init__.py b/website_sale_order_type/__init__.py new file mode 100644 index 0000000000..31660d6a96 --- /dev/null +++ b/website_sale_order_type/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/website_sale_order_type/__manifest__.py b/website_sale_order_type/__manifest__.py new file mode 100644 index 0000000000..70213b415f --- /dev/null +++ b/website_sale_order_type/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2018 Simone Rubino - Agile Business Group +# Copyright 2020 Tecnativa - João Marques +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Website sale order type", + "summary": "This module allows sale_order_type to work with website_sale.", + "version": "18.0.1.0.0", + "development_status": "Beta", + "category": "Website", + "website": "https://github.com/OCA/e-commerce", + "maintainers": ["pilarvargas-tecnativa"], + "author": "Agile Business Group, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["website_sale", "sale_order_type"], + "assets": { + "web.assets_tests": [ + "/website_sale_order_type/static/tests/tours/website_sale_order_type_tour.esm.js" + ] + }, + "auto_install": True, +} diff --git a/website_sale_order_type/i18n/ca.po b/website_sale_order_type/i18n/ca.po new file mode 100644 index 0000000000..a9afa0a58d --- /dev/null +++ b/website_sale_order_type/i18n/ca.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_order_type +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-01-20 20:44+0000\n" +"Last-Translator: claudiagn \n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: website_sale_order_type +#: model:ir.model,name:website_sale_order_type.model_website +msgid "Website" +msgstr "" + +#~ msgid "Sale Order" +#~ msgstr "Comanda de venda" diff --git a/website_sale_order_type/i18n/es.po b/website_sale_order_type/i18n/es.po new file mode 100644 index 0000000000..4ca6c4ce83 --- /dev/null +++ b/website_sale_order_type/i18n/es.po @@ -0,0 +1,28 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_order_type +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-09-05 21:36+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: website_sale_order_type +#: model:ir.model,name:website_sale_order_type.model_website +msgid "Website" +msgstr "Página Web" + +#~ msgid "Allowing sale_order_type to work with website_sale." +#~ msgstr "Permitir que sale_order_type funcione con website_sale." + +#~ msgid "Sale Order" +#~ msgstr "Pedido de venta" diff --git a/website_sale_order_type/i18n/it.po b/website_sale_order_type/i18n/it.po new file mode 100644 index 0000000000..a783fcffdf --- /dev/null +++ b/website_sale_order_type/i18n/it.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_order_type +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-05-08 07:46+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: website_sale_order_type +#: model:ir.model,name:website_sale_order_type.model_website +msgid "Website" +msgstr "Sito web" diff --git a/website_sale_order_type/i18n/website_sale_order_type.pot b/website_sale_order_type/i18n/website_sale_order_type.pot new file mode 100644 index 0000000000..542c7d4ebe --- /dev/null +++ b/website_sale_order_type/i18n/website_sale_order_type.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_order_type +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \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: website_sale_order_type +#: model:ir.model,name:website_sale_order_type.model_website +msgid "Website" +msgstr "" diff --git a/website_sale_order_type/models/__init__.py b/website_sale_order_type/models/__init__.py new file mode 100644 index 0000000000..971da6cda6 --- /dev/null +++ b/website_sale_order_type/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import website diff --git a/website_sale_order_type/models/website.py b/website_sale_order_type/models/website.py new file mode 100644 index 0000000000..b15310d37b --- /dev/null +++ b/website_sale_order_type/models/website.py @@ -0,0 +1,20 @@ +# Copyright 2023 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, models + + +class Website(models.Model): + _inherit = "website" + + @api.model + def sale_get_payment_term(self, partner): + if partner.sale_type.payment_term_id: + return partner.sale_type.payment_term_id.id + return super().sale_get_payment_term(partner) + + def _get_current_pricelist(self): + partner_sudo = self.env.user.partner_id + if partner_sudo.sale_type.pricelist_id: + return partner_sudo.sale_type.pricelist_id.id + return super()._get_current_pricelist() diff --git a/website_sale_order_type/pyproject.toml b/website_sale_order_type/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/website_sale_order_type/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/website_sale_order_type/readme/CONTRIBUTORS.md b/website_sale_order_type/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..ab5ef56047 --- /dev/null +++ b/website_sale_order_type/readme/CONTRIBUTORS.md @@ -0,0 +1,8 @@ +- Simone Rubino \<\> + +- [Tecnativa](https://www.tecnativa.com): + + > - João Marques + > - Pilar Vargas + > - Stefan Ungureanu + > - Carlos Lopez diff --git a/website_sale_order_type/readme/DESCRIPTION.md b/website_sale_order_type/readme/DESCRIPTION.md new file mode 100644 index 0000000000..9e08b21cf0 --- /dev/null +++ b/website_sale_order_type/readme/DESCRIPTION.md @@ -0,0 +1,11 @@ +This module allows +[sale_order_type](https://github.com/OCA/sale-workflow/tree/17.0/sale_order_type) +to work with websitesale. + +This module is useful for users having a sale order type defined in +their Partner form: when these users buy a product in the e-commerce, +the sale order generated will have the same sale order type that is +defined in their Partner form. + +Note that the sale order type is defined contact by contact and not at +Company level. diff --git a/website_sale_order_type/readme/USAGE.md b/website_sale_order_type/readme/USAGE.md new file mode 100644 index 0000000000..d121d257d4 --- /dev/null +++ b/website_sale_order_type/readme/USAGE.md @@ -0,0 +1,6 @@ +1. In the backend (Sales -\> Customers) set a sale order type in any + contact; +2. Log in with the associated user in the e-commerce website and buy a + product; +3. Check that the created sale oder has the same sale order type that + has been set in the contact. diff --git a/website_sale_order_type/static/description/icon.png b/website_sale_order_type/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/website_sale_order_type/static/description/icon.png differ diff --git a/website_sale_order_type/static/description/index.html b/website_sale_order_type/static/description/index.html new file mode 100644 index 0000000000..587b07f18a --- /dev/null +++ b/website_sale_order_type/static/description/index.html @@ -0,0 +1,456 @@ + + + + + +Website sale order type + + + +
+

Website sale order type

+ + +

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

+

This module allows +sale_order_type +to work with websitesale.

+

This module is useful for users having a sale order type defined in +their Partner form: when these users buy a product in the e-commerce, +the sale order generated will have the same sale order type that is +defined in their Partner form.

+

Note that the sale order type is defined contact by contact and not at +Company level.

+

Table of contents

+ +
+

Usage

+
    +
  1. In the backend (Sales -> Customers) set a sale order type in any +contact;
  2. +
  3. Log in with the associated user in the e-commerce website and buy a +product;
  4. +
  5. Check that the created sale oder has the same sale order type that +has been set in the contact.
  6. +
+
+
+

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

+
    +
  • Agile Business Group
  • +
+
+
+

Contributors

+ +
+
+

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.

+

Current maintainer:

+

pilarvargas-tecnativa

+

This module is part of the OCA/e-commerce project on GitHub.

+

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

+
+
+
+ + diff --git a/website_sale_order_type/static/tests/tours/website_sale_order_type_tour.esm.js b/website_sale_order_type/static/tests/tours/website_sale_order_type_tour.esm.js new file mode 100644 index 0000000000..01ccd896e7 --- /dev/null +++ b/website_sale_order_type/static/tests/tours/website_sale_order_type_tour.esm.js @@ -0,0 +1,30 @@ +/** @odoo-module */ +/* Copyright 2020 Tecnativa - João Marques + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ + +import {registry} from "@web/core/registry"; + +registry.category("web_tour.tours").add("website_sale_order_type_tour", { + test: true, + url: "/shop", + steps: () => [ + { + trigger: ".oe_product_cart a:contains('Test Product SO Type')", + run: "click", + }, + { + trigger: "#add_to_cart", + run: "click", + }, + { + trigger: "a[href='/shop/cart']", + }, + { + trigger: "sup.my_cart_quantity:contains('1')", + run: "click", + }, + { + trigger: ".btn:contains('Checkout')", + }, + ], +}); diff --git a/website_sale_order_type/tests/__init__.py b/website_sale_order_type/tests/__init__.py new file mode 100644 index 0000000000..e27813a1a7 --- /dev/null +++ b/website_sale_order_type/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_website_sale_order_type diff --git a/website_sale_order_type/tests/test_website_sale_order_type.py b/website_sale_order_type/tests/test_website_sale_order_type.py new file mode 100644 index 0000000000..8fd99f1b47 --- /dev/null +++ b/website_sale_order_type/tests/test_website_sale_order_type.py @@ -0,0 +1,64 @@ +# Copyright 2018 Simone Rubino - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests import HttpCase, RecordCapturer, tagged + + +@tagged("post_install", "-at_install") +class TestFrontend(HttpCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.sale_type_model = cls.env["sale.order.type"] + cls.product_template = cls.env["product.template"].create( + { + "name": "Test Product SO Type", + "is_published": True, + "website_sequence": 1, + "type": "consu", + } + ) + cls.partner = cls.env.ref("base.partner_admin") + cls.sale_pricelist = cls.env["product.pricelist"].create( + {"name": "Test Pricelist"} + ) + cls.sale_type = cls.create_sale_type() + + @classmethod + def create_sale_type(cls): + cls.sequence = cls.env["ir.sequence"].create( + { + "name": "Test Sales Order", + "code": "sale.order", + "prefix": "TSO", + "padding": 3, + } + ) + cls.journal = cls.env["account.journal"].search( + [("type", "=", "sale")], limit=1 + ) + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.immediate_payment = cls.env.ref("account.account_payment_term_immediate") + cls.free_carrier = cls.env.ref("account.incoterm_FCA") + return cls.sale_type_model.create( + { + "name": "Test Sale Order Type", + "sequence_id": cls.sequence.id, + "journal_id": cls.journal.id, + "warehouse_id": cls.warehouse.id, + "picking_policy": "one", + "payment_term_id": cls.immediate_payment.id, + "pricelist_id": cls.sale_pricelist.id, + "incoterm_id": cls.free_carrier.id, + } + ) + + def test_website_sale_order_type(self): + self.partner.sale_type = self.sale_type + # In frontend, create an order + with RecordCapturer(self.env["sale.order"], []) as capture: + self.start_tour("/shop", "website_sale_order_type_tour", login="admin") + # Verify the followers of mail.message + created_order = capture.records + self.assertEqual(created_order.type_id, self.sale_type) + self.assertEqual(created_order.payment_term_id, self.sale_type.payment_term_id) + self.assertEqual(created_order.pricelist_id, self.sale_type.pricelist_id)