diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 49804913ee..e623a05b78 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,6 +25,7 @@ exclude: > shopinvader_product_stock_assortment| shopinvader_promotion_rule| shopinvader_quotation| + shopinvader_sale_communication| shopinvader_sale_report )/ ) diff --git a/shopinvader_sale_communication/README.rst b/shopinvader_sale_communication/README.rst new file mode 100644 index 0000000000..1dcda0a875 --- /dev/null +++ b/shopinvader_sale_communication/README.rst @@ -0,0 +1,59 @@ +============================= +Shopinvader Sale Communcation +============================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-shopinvader%2Fodoo--shopinvader-lightgray.png?logo=github + :target: https://github.com/shopinvader/odoo-shopinvader + :alt: shopinvader/odoo-shopinvader + +|badge1| |badge2| |badge3| + +This module adds information fields for customers and vendors. +Vendor communicates with customer with online_information_for_customer. +Customer can request information to vendor with online_information_request. + +**Table of contents** + +.. contents:: + :local: + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Benoit Aimont + +Maintainers +~~~~~~~~~~~ + +This module is part of the `shopinvader/odoo-shopinvader `_ project on GitHub. + +You are welcome to contribute. diff --git a/shopinvader_sale_communication/__init__.py b/shopinvader_sale_communication/__init__.py new file mode 100644 index 0000000000..71a02422d5 --- /dev/null +++ b/shopinvader_sale_communication/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import services diff --git a/shopinvader_sale_communication/__manifest__.py b/shopinvader_sale_communication/__manifest__.py new file mode 100644 index 0000000000..8de4b208f1 --- /dev/null +++ b/shopinvader_sale_communication/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Shopinvader Sale Communication", + "summary": """ + This module adds information fields for customers and vendors.""", + "version": "10.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV", + "website": "https://shopinvader.com/", + "depends": ["sale", "shopinvader"], + "data": ["views/sale_order.xml"], + "demo": [], + "installable": False, +} diff --git a/shopinvader_sale_communication/models/__init__.py b/shopinvader_sale_communication/models/__init__.py new file mode 100644 index 0000000000..6aacb75313 --- /dev/null +++ b/shopinvader_sale_communication/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order diff --git a/shopinvader_sale_communication/models/sale_order.py b/shopinvader_sale_communication/models/sale_order.py new file mode 100644 index 0000000000..70511ed6b1 --- /dev/null +++ b/shopinvader_sale_communication/models/sale_order.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class SaleOrder(models.Model): + + _inherit = "sale.order" + + online_information_for_customer = fields.Html( + help="Fill in this field to provide your customer more information " + "on his online account" + ) + online_information_request = fields.Text( + help="This field is filled by the customer to request information", + readonly=True, + ) diff --git a/shopinvader_sale_communication/readme/CONTRIBUTORS.rst b/shopinvader_sale_communication/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..0de613821c --- /dev/null +++ b/shopinvader_sale_communication/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Benoit Aimont diff --git a/shopinvader_sale_communication/readme/DESCRIPTION.rst b/shopinvader_sale_communication/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..f4b6c215d6 --- /dev/null +++ b/shopinvader_sale_communication/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module adds information fields for customers and vendors. +Vendor communicates with customer with online_information_for_customer. +Customer can request information to vendor with online_information_request. diff --git a/shopinvader_sale_communication/services/__init__.py b/shopinvader_sale_communication/services/__init__.py new file mode 100644 index 0000000000..0ebb328998 --- /dev/null +++ b/shopinvader_sale_communication/services/__init__.py @@ -0,0 +1,2 @@ +from . import abstract_sale +from . import cart diff --git a/shopinvader_sale_communication/services/abstract_sale.py b/shopinvader_sale_communication/services/abstract_sale.py new file mode 100644 index 0000000000..f4f0d313a6 --- /dev/null +++ b/shopinvader_sale_communication/services/abstract_sale.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.component.core import AbstractComponent + + +class AbstractSaleService(AbstractComponent): + _inherit = "shopinvader.abstract.sale.service" + + def _convert_one_sale(self, sale): + values = super(AbstractSaleService, self)._convert_one_sale(sale) + values.update( + { + "online_information_for_customer": sale.online_information_for_customer, + "online_information_request": sale.online_information_request, + } + ) + return values diff --git a/shopinvader_sale_communication/services/cart.py b/shopinvader_sale_communication/services/cart.py new file mode 100644 index 0000000000..2d57d28b93 --- /dev/null +++ b/shopinvader_sale_communication/services/cart.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.addons.component.core import Component + + +class CartService(Component): + _inherit = "shopinvader.cart.service" + + def _validator_update(self): + validator = super(CartService, self)._validator_update() + validator.update({"online_information_request": {"type": "string"}}) + return validator diff --git a/shopinvader_sale_communication/tests/__init__.py b/shopinvader_sale_communication/tests/__init__.py new file mode 100644 index 0000000000..180ead1382 --- /dev/null +++ b/shopinvader_sale_communication/tests/__init__.py @@ -0,0 +1,2 @@ +from . import test_cart +from . import test_sale diff --git a/shopinvader_sale_communication/tests/test_cart.py b/shopinvader_sale_communication/tests/test_cart.py new file mode 100644 index 0000000000..d68c862ff4 --- /dev/null +++ b/shopinvader_sale_communication/tests/test_cart.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.shopinvader.tests.common import CommonCase + + +class TestCart(CommonCase): + def setUp(self): + super(TestCart, self).setUp() + self.cart = self.env.ref("shopinvader.sale_order_2") + self.shopinvader_session = {"cart_id": self.cart.id} + self.partner = self.env.ref("shopinvader.partner_1") + with self.work_on_services( + partner=self.partner, shopinvader_session=self.shopinvader_session + ) as work: + self.service = work.component(usage="cart") + + def test_cart(self): + online_information_for_customer = "CUSTOMER INFO" + online_information_request = "VENDOR INFO REQUEST" + params = { + "online_information_for_customer": online_information_for_customer, + "online_information_request": online_information_request, + } + self.service.dispatch("update", params=params) + # online_information_for_customer should not be updated from the front + self.assertFalse(self.cart.online_information_for_customer) + self.assertEqual( + self.cart.online_information_request, online_information_request + ) diff --git a/shopinvader_sale_communication/tests/test_sale.py b/shopinvader_sale_communication/tests/test_sale.py new file mode 100644 index 0000000000..3fc1d5f41c --- /dev/null +++ b/shopinvader_sale_communication/tests/test_sale.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.shopinvader.tests.common import CommonCase + + +class TestSale(CommonCase): + def setUp(self): + super(TestSale, self).setUp() + self.partner = self.env.ref("base.res_partner_2") + with self.work_on_services(partner=self.partner) as work: + self.service = work.component(usage="sales") + + def test_sale_order_info(self): + online_information_for_customer = "TEST" + so = self.env["sale.order"].create( + { + "partner_id": self.env.ref("base.res_partner_2").id, + "online_information_for_customer": online_information_for_customer, + "shopinvader_backend_id": self.env.ref( + "shopinvader.backend_1" + ).id, + "typology": "sale", + } + ) + so.action_confirm() + res = self.service.get(so.id) + self.assertEqual( + res.get("online_information_for_customer"), + so.online_information_for_customer, + ) diff --git a/shopinvader_sale_communication/views/sale_order.xml b/shopinvader_sale_communication/views/sale_order.xml new file mode 100644 index 0000000000..bf367a0611 --- /dev/null +++ b/shopinvader_sale_communication/views/sale_order.xml @@ -0,0 +1,23 @@ + + + + + + + sale.order.form (in shopinvader_sale_communication) + sale.order + + + + + + + + + + + + + +