diff --git a/purchase_sign/README.rst b/purchase_sign/README.rst new file mode 100644 index 00000000000..fb6c6fc9347 --- /dev/null +++ b/purchase_sign/README.rst @@ -0,0 +1,82 @@ +============= +Purchase Sign +============= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:56a9aecd4b0b47eda77efd60cc19b8963193fee67e2fe6ad675449af14a3c6c6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/18.0/purchase_sign + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_sign + :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/purchase-workflow&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to take online signatures from vendors to confirm +purchase orders.It adds a global configuration (Online signature) which +can be accessed through Purchase->Configuration->Settings and it can +further be handled also on each of the purchase orders.When it is +enabled, it shows a button 'Accept & Sign' on the portal to the vendors +for RFQ which are sent by email to them.Once the vendor accepts and adds +their signature, the RFQ gets confirmed into a purchase order + +**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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Onestein + +Contributors +------------ + +- `Onestein `__ + +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/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_sign/__init__.py b/purchase_sign/__init__.py new file mode 100644 index 00000000000..07eb8f9a078 --- /dev/null +++ b/purchase_sign/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2024 Onestein +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import models +from . import controllers diff --git a/purchase_sign/__manifest__.py b/purchase_sign/__manifest__.py new file mode 100644 index 00000000000..b5e911696ce --- /dev/null +++ b/purchase_sign/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2024 Onestein +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Purchase Sign", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "category": "Purchase", + "author": "Onestein, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/purchase-workflow", + "depends": ["purchase"], + "data": [ + "views/purchase_view.xml", + "views/res_config_settings_view.xml", + "templates/purchase_portal_templates.xml", + "report/purchase_order_template.xml", + ], + "assets": { + "web.assets_tests": [ + "purchase_sign/static/tests/tours/purchase_signature.esm.js" + ], + }, +} diff --git a/purchase_sign/controllers/__init__.py b/purchase_sign/controllers/__init__.py new file mode 100644 index 00000000000..c1401fbe0ee --- /dev/null +++ b/purchase_sign/controllers/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from . import main diff --git a/purchase_sign/controllers/main.py b/purchase_sign/controllers/main.py new file mode 100644 index 00000000000..7cb540bc5a1 --- /dev/null +++ b/purchase_sign/controllers/main.py @@ -0,0 +1,78 @@ +# Copyright 2024 Onestein +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import binascii + +from odoo import _, fields, http +from odoo.exceptions import AccessError, MissingError +from odoo.http import request + +from odoo.addons.portal.controllers.portal import CustomerPortal + + +class PortalPurchase(CustomerPortal): + def _purchase_order_get_page_view_values(self, order, access_token, **kwargs): + response = super()._purchase_order_get_page_view_values( + order=order, access_token=access_token, **kwargs + ) + if kwargs.get("message"): + response.update({"message": kwargs.get("message")}) + return response + + @http.route( + ["/my/purchase//accept"], type="json", auth="public", website=True + ) + def portal_purchase_accept( + self, order_id, access_token=None, name=None, signature=None + ): + access_token = access_token or request.httprequest.args.get("access_token") + try: + order_sudo = self._document_check_access( + "purchase.order", order_id, access_token=access_token + ) + except (AccessError, MissingError): + return {"error": _("Invalid order.")} + + if not order_sudo._has_to_be_signed(): + return { + "error": _("The order is not in a state requiring vendor signature.") + } + if not signature: + return {"error": _("Signature is missing.")} + + try: + order_sudo.write( + { + "signed_by": name, + "signed_on": fields.Datetime.now(), + "signature": signature, + } + ) + request.env.cr.commit() + except (TypeError, binascii.Error): + return {"error": _("Invalid signature data.")} + order_sudo.button_confirm() + pdf = ( + request.env["ir.actions.report"] + .sudo() + ._render_qweb_pdf("purchase.action_report_purchase_order", [order_sudo.id])[ + 0 + ] + ) + order_sudo.message_post( + attachments=[(f"{order_sudo.name}.pdf", pdf)], + author_id=( + order_sudo.partner_id.id + if request.env.user._is_public() + else request.env.user.partner_id.id + ), + body=_("Order signed by %s", name), + message_type="comment", + subtype_xmlid="mail.mt_comment", + ) + + query_string = "&message=sign_ok" + return { + "force_refresh": True, + "redirect_url": order_sudo.get_portal_url(query_string=query_string), + } diff --git a/purchase_sign/i18n/it.po b/purchase_sign/i18n/it.po new file mode 100644 index 00000000000..66712769877 --- /dev/null +++ b/purchase_sign/i18n/it.po @@ -0,0 +1,201 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_sign +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-08-17 18:58+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 5.6.2\n" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "" +"\n" +" Accept & Sign" +msgstr "" +"\n" +" Accetta e firma" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "" +"\n" +" Accept & Sign" +msgstr "" +"\n" +" Accetta e firma" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "" +"\n" +" Feedback" +msgstr "" +"\n" +" Commento" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "Accepted on the behalf of:" +msgstr "Accettato per conto di:" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "By signing this proposal, I agree to the following terms:" +msgstr "Firmando questa proposta accetto i seguenti termini:" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "For an amount of:" +msgstr "Per un valore di:" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "With payment terms:" +msgstr "Con termini di pagamento:" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.report_purchaseorder_document +msgid "Signature" +msgstr "Firma" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "" +"Thank You!
\n" +" Order has been confirmed." +msgstr "" +"Grazie!
\n" +" L'ordine è stato confermato." + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "Close" +msgstr "Chiudi" + +#. module: purchase_sign +#: model:ir.model,name:purchase_sign.model_res_company +msgid "Companies" +msgstr "Aziende" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/controllers/main.py:0 +#: code:addons/purchase_sign/tests/test_purchase_sign.py:0 +#, python-format +msgid "Invalid order." +msgstr "Ordine non valido." + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/tests/test_purchase_sign.py:0 +#, python-format +msgid "Invalid signature data" +msgstr "Data firma non valida" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/controllers/main.py:0 +#, python-format +msgid "Invalid signature data." +msgstr "Data firma non valida." + +#. module: purchase_sign +#: model:ir.model.fields,field_description:purchase_sign.field_purchase_order__require_signature +#: model_terms:ir.ui.view,arch_db:purchase_sign.res_config_settings_view_form_purchase +msgid "Online Signature" +msgstr "Firma online" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/controllers/main.py:0 +#, python-format +msgid "Order signed by %s" +msgstr "Ordine firmato da %s" + +#. module: purchase_sign +#: model:ir.model,name:purchase_sign.model_res_config_settings +msgid "Procurement purchase grouping settings" +msgstr "Impostazioni raggruppamento approvvigionamento acquisti" + +#. module: purchase_sign +#: model:ir.model.fields,field_description:purchase_sign.field_res_company__purchase_portal_confirmation_sign +#: model:ir.model.fields,field_description:purchase_sign.field_res_config_settings__purchase_portal_confirmation_sign +msgid "Purchase Online Signature" +msgstr "Firma online acquisto" + +#. module: purchase_sign +#: model:ir.model,name:purchase_sign.model_purchase_order +msgid "Purchase Order" +msgstr "Ordine di acquisto" + +#. module: purchase_sign +#: model:ir.model.fields,help:purchase_sign.field_purchase_order__require_signature +msgid "" +"Request a online signature and/or payment to the customer in order to " +"confirm orders automatically." +msgstr "" +"Richiede una firma online e/o pagamento al cliente per confermare gli ordini " +"automaticamente." + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.res_config_settings_view_form_purchase +msgid "Request an online signature to confirm orders" +msgstr "Richiede una firma online per confermare gli ordini" + +#. module: purchase_sign +#: model:ir.model.fields,field_description:purchase_sign.field_purchase_order__signature +#: model_terms:ir.ui.view,arch_db:purchase_sign.purchase_order_portal_content +msgid "Signature" +msgstr "Firma" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/tests/test_purchase_sign.py:0 +#, python-format +msgid "Signature is missing" +msgstr "Manca la firma" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/controllers/main.py:0 +#, python-format +msgid "Signature is missing." +msgstr "Manca la firma." + +#. module: purchase_sign +#: model:ir.model.fields,field_description:purchase_sign.field_purchase_order__signed_by +msgid "Signed By" +msgstr "Firmato da" + +#. module: purchase_sign +#: model:ir.model.fields,field_description:purchase_sign.field_purchase_order__signed_on +msgid "Signed On" +msgstr "Firmato il" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/controllers/main.py:0 +#: code:addons/purchase_sign/tests/test_purchase_sign.py:0 +#, python-format +msgid "The order is not in a state requiring vendor signature." +msgstr "L'ordine è in uno stato che non richiede la firma del fornitore." + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "Validate Order" +msgstr "Validazione ordine" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.purchase_order_view_form_inherit +msgid "Vendor Signature" +msgstr "Firma fornitore" diff --git a/purchase_sign/i18n/purchase_sign.pot b/purchase_sign/i18n/purchase_sign.pot new file mode 100644 index 00000000000..6645990b857 --- /dev/null +++ b/purchase_sign/i18n/purchase_sign.pot @@ -0,0 +1,188 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_sign +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "" +"\n" +" Accept & Sign" +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "" +"\n" +" Accept & Sign" +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "" +"\n" +" Feedback" +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "Accepted on the behalf of:" +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "By signing this proposal, I agree to the following terms:" +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "For an amount of:" +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "With payment terms:" +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.report_purchaseorder_document +msgid "Signature" +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "" +"Thank You!
\n" +" Order has been confirmed." +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "Close" +msgstr "" + +#. module: purchase_sign +#: model:ir.model,name:purchase_sign.model_res_company +msgid "Companies" +msgstr "" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/controllers/main.py:0 +#: code:addons/purchase_sign/tests/test_purchase_sign.py:0 +#, python-format +msgid "Invalid order." +msgstr "" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/tests/test_purchase_sign.py:0 +#, python-format +msgid "Invalid signature data" +msgstr "" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/controllers/main.py:0 +#, python-format +msgid "Invalid signature data." +msgstr "" + +#. module: purchase_sign +#: model:ir.model.fields,field_description:purchase_sign.field_purchase_order__require_signature +#: model_terms:ir.ui.view,arch_db:purchase_sign.res_config_settings_view_form_purchase +msgid "Online Signature" +msgstr "" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/controllers/main.py:0 +#, python-format +msgid "Order signed by %s" +msgstr "" + +#. module: purchase_sign +#: model:ir.model,name:purchase_sign.model_res_config_settings +msgid "Procurement purchase grouping settings" +msgstr "" + +#. module: purchase_sign +#: model:ir.model.fields,field_description:purchase_sign.field_res_company__purchase_portal_confirmation_sign +#: model:ir.model.fields,field_description:purchase_sign.field_res_config_settings__purchase_portal_confirmation_sign +msgid "Purchase Online Signature" +msgstr "" + +#. module: purchase_sign +#: model:ir.model,name:purchase_sign.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: purchase_sign +#: model:ir.model.fields,help:purchase_sign.field_purchase_order__require_signature +msgid "" +"Request a online signature and/or payment to the customer in order to " +"confirm orders automatically." +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.res_config_settings_view_form_purchase +msgid "Request an online signature to confirm orders" +msgstr "" + +#. module: purchase_sign +#: model:ir.model.fields,field_description:purchase_sign.field_purchase_order__signature +#: model_terms:ir.ui.view,arch_db:purchase_sign.purchase_order_portal_content +msgid "Signature" +msgstr "" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/tests/test_purchase_sign.py:0 +#, python-format +msgid "Signature is missing" +msgstr "" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/controllers/main.py:0 +#, python-format +msgid "Signature is missing." +msgstr "" + +#. module: purchase_sign +#: model:ir.model.fields,field_description:purchase_sign.field_purchase_order__signed_by +msgid "Signed By" +msgstr "" + +#. module: purchase_sign +#: model:ir.model.fields,field_description:purchase_sign.field_purchase_order__signed_on +msgid "Signed On" +msgstr "" + +#. module: purchase_sign +#. odoo-python +#: code:addons/purchase_sign/controllers/main.py:0 +#: code:addons/purchase_sign/tests/test_purchase_sign.py:0 +#, python-format +msgid "The order is not in a state requiring vendor signature." +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.portal_my_purchase_order +msgid "Validate Order" +msgstr "" + +#. module: purchase_sign +#: model_terms:ir.ui.view,arch_db:purchase_sign.purchase_order_view_form_inherit +msgid "Vendor Signature" +msgstr "" diff --git a/purchase_sign/models/__init__.py b/purchase_sign/models/__init__.py new file mode 100644 index 00000000000..575530f0397 --- /dev/null +++ b/purchase_sign/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from . import purchase_order +from . import res_company +from . import res_config_settings diff --git a/purchase_sign/models/purchase_order.py b/purchase_sign/models/purchase_order.py new file mode 100644 index 00000000000..384653dd5cf --- /dev/null +++ b/purchase_sign/models/purchase_order.py @@ -0,0 +1,36 @@ +# Copyright 2024 Onestein +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class PurchaseOrder(models.Model): + _inherit = "purchase.order" + + require_signature = fields.Boolean( + string="Online Signature", + compute="_compute_require_signature", + store=True, + readonly=False, + precompute=True, + help="Request an online signature from the supplier " + "to confirm orders automatically.", + ) + + signature = fields.Image( + copy=False, attachment=True, max_width=1024, max_height=1024 + ) + + signed_by = fields.Char(copy=False) + signed_on = fields.Datetime(copy=False) + + @api.depends("company_id") + def _compute_require_signature(self): + for order in self: + order.require_signature = bool( + order.company_id.purchase_portal_confirmation_sign + ) + + def _has_to_be_signed(self): + """Checks whether this purchase order requires signature.""" + self.ensure_one() + return self.state == "sent" and self.require_signature and not self.signature diff --git a/purchase_sign/models/res_company.py b/purchase_sign/models/res_company.py new file mode 100644 index 00000000000..14d1d085d6b --- /dev/null +++ b/purchase_sign/models/res_company.py @@ -0,0 +1,14 @@ +# Copyright 2024 Onestein +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + purchase_portal_confirmation_sign = fields.Boolean( + string="Online Signature", + default=False, + help="Enable this to request a digital signature when confirming " + "Purchase Orders via the portal.", + ) diff --git a/purchase_sign/models/res_config_settings.py b/purchase_sign/models/res_config_settings.py new file mode 100644 index 00000000000..7559d5bc969 --- /dev/null +++ b/purchase_sign/models/res_config_settings.py @@ -0,0 +1,12 @@ +# Copyright 2024 Onestein +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + purchase_portal_confirmation_sign = fields.Boolean( + related="company_id.purchase_portal_confirmation_sign", + readonly=False, + ) diff --git a/purchase_sign/pyproject.toml b/purchase_sign/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/purchase_sign/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/purchase_sign/readme/CONTRIBUTORS.md b/purchase_sign/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..9446ebc23d0 --- /dev/null +++ b/purchase_sign/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- [Onestein](https://www.onestein.nl) diff --git a/purchase_sign/readme/DESCRIPTION.md b/purchase_sign/readme/DESCRIPTION.md new file mode 100644 index 00000000000..2342dac0354 --- /dev/null +++ b/purchase_sign/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +This module allows to take online signatures from vendors to confirm +purchase orders.It adds a global configuration (Online signature) which +can be accessed through Purchase-\>Configuration-\>Settings and it can +further be handled also on each of the purchase orders.When it is +enabled, it shows a button 'Accept & Sign' on the portal to the vendors +for RFQ which are sent by email to them.Once the vendor accepts and adds +their signature, the RFQ gets confirmed into a purchase order diff --git a/purchase_sign/report/purchase_order_template.xml b/purchase_sign/report/purchase_order_template.xml new file mode 100644 index 00000000000..e6ff8498f20 --- /dev/null +++ b/purchase_sign/report/purchase_order_template.xml @@ -0,0 +1,24 @@ + + + + diff --git a/purchase_sign/static/description/icon.png b/purchase_sign/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_sign/static/description/icon.png differ diff --git a/purchase_sign/static/description/index.html b/purchase_sign/static/description/index.html new file mode 100644 index 00000000000..fc23f6d43e4 --- /dev/null +++ b/purchase_sign/static/description/index.html @@ -0,0 +1,429 @@ + + + + + +Purchase Sign + + + +
+

Purchase Sign

+ + +

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

+

This module allows to take online signatures from vendors to confirm +purchase orders.It adds a global configuration (Online signature) which +can be accessed through Purchase->Configuration->Settings and it can +further be handled also on each of the purchase orders.When it is +enabled, it shows a button ‘Accept & Sign’ on the portal to the vendors +for RFQ which are sent by email to them.Once the vendor accepts and adds +their signature, the RFQ gets confirmed into a purchase order

+

Table of contents

+ +
+

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

+
    +
  • Onestein
  • +
+
+ +
+

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/purchase-workflow project on GitHub.

+

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

+
+
+
+ + diff --git a/purchase_sign/static/tests/tours/purchase_signature.esm.js b/purchase_sign/static/tests/tours/purchase_signature.esm.js new file mode 100644 index 00000000000..a6bb562f8f3 --- /dev/null +++ b/purchase_sign/static/tests/tours/purchase_signature.esm.js @@ -0,0 +1,56 @@ +/** @odoo-module **/ + +import {registry} from "@web/core/registry"; +import {redirect} from "@web/core/utils/urls"; + +registry.category("web_tour.tours").add("purchase_signature", { + url: "/my/rfq", + steps: () => [ + { + content: "open the test PO", + trigger: "a:contains(/^test PO$/)", + run: "click", + }, + { + content: "click sign", + trigger: 'a:contains("Sign")', + run: "click", + }, + { + content: "check submit is enabled", + trigger: ".o_portal_sign_submit:enabled", + }, + { + trigger: ".modal .o_web_sign_name_and_signature input:value(Joel Willis)", + }, + { + content: "click select style", + trigger: ".modal .o_web_sign_auto_select_style button", + run: "click", + }, + { + content: "click style 4", + trigger: ".o-dropdown-item:eq(3)", + run: "click", + }, + { + content: "click submit", + trigger: ".modal .o_portal_sign_submit:enabled", + run: "click", + }, + { + content: "check it's confirmed", + trigger: '#quote_content:contains("Thank You")', + run: "click", + }, + { + trigger: "#quote_content", + run: function () { + redirect("/odoo"); + }, + }, + { + trigger: "nav", + }, + ], +}); diff --git a/purchase_sign/templates/purchase_portal_templates.xml b/purchase_sign/templates/purchase_portal_templates.xml new file mode 100644 index 00000000000..503cd24f5b8 --- /dev/null +++ b/purchase_sign/templates/purchase_portal_templates.xml @@ -0,0 +1,159 @@ + + + + + + diff --git a/purchase_sign/tests/__init__.py b/purchase_sign/tests/__init__.py new file mode 100644 index 00000000000..814899e4fac --- /dev/null +++ b/purchase_sign/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from . import test_purchase_sign diff --git a/purchase_sign/tests/test_purchase_sign.py b/purchase_sign/tests/test_purchase_sign.py new file mode 100644 index 00000000000..aba48e1a6cf --- /dev/null +++ b/purchase_sign/tests/test_purchase_sign.py @@ -0,0 +1,113 @@ +# Copyright 2024 Onestein +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import binascii +import json +from unittest.mock import patch + +from odoo import _ +from odoo.tests import tagged + +from odoo.addons.base.tests.common import HttpCaseWithUserPortal +from odoo.addons.purchase.models.purchase_order import PurchaseOrder + + +@tagged("post_install", "-at_install") +class TestPurchaseSign(HttpCaseWithUserPortal): + def test_01_portal_purchase_signature_tour(self): + """The goal of this test is to make sure the portal user can sign PO.""" + self.user_portal.company_id.purchase_portal_confirmation_sign = True + portal_user_partner = self.partner_portal + # create a PO to be signed + purchase_order = self.env["purchase.order"].create( + { + "name": "test PO", + "partner_id": portal_user_partner.id, + "state": "sent", + } + ) + self.env["purchase.order.line"].create( + { + "order_id": purchase_order.id, + "product_id": self.env["product.product"] + .create({"name": "A product"}) + .id, + "price_unit": 10.0, + } + ) + + email_act = purchase_order.action_rfq_send() + email_ctx = email_act.get("context", {}) + purchase_order.with_context(**email_ctx).message_post_with_source( + self.env["mail.template"].browse(email_ctx.get("default_template_id")), + subtype_xmlid="mail.mt_comment", + ) + self.start_tour("/", "purchase_signature", login="portal") + + def test_02_portal_purchase_check_errors(self): + """The goal of this test is to check error handling.""" + self.user_portal.company_id.purchase_portal_confirmation_sign = True + portal_user_partner = self.partner_portal + purchase_order = self.env["purchase.order"].create( + { + "name": "test PO2", + "partner_id": portal_user_partner.id, + "access_token": "test_po", + } + ) + purchase_order.message_subscribe(partner_ids=[portal_user_partner.id]) + self.env["purchase.order.line"].create( + { + "order_id": purchase_order.id, + "product_id": self.env["product.product"] + .create({"name": "A product"}) + .id, + "price_unit": 10.0, + } + ) + data = json.dumps({}).encode() + resp = self.url_open( + f"/my/purchase/{purchase_order.id}/accept", + data=data, + allow_redirects=False, + headers={"Content-Type": "application/json"}, + ) + self.assertIn(_("Invalid order."), resp.text) + resp = self.url_open( + "/my/purchase/{}/accept?access_token={}".format( + purchase_order.id, "test_po" + ), + data=data, + allow_redirects=False, + headers={"Content-Type": "application/json"}, + ) + self.assertIn( + _("The order is not in a state requiring vendor signature."), resp.text + ) + purchase_order.state = "sent" + resp = self.url_open( + "/my/purchase/{}/accept?access_token={}".format( + purchase_order.id, "test_po" + ), + data=data, + allow_redirects=False, + headers={"Content-Type": "application/json"}, + ) + self.assertIn(_("Signature is missing"), resp.text) + + def write(self, vals): + raise binascii.Error + + with patch.object( + PurchaseOrder, + "write", + write, + ): + resp = self.url_open( + "/my/purchase/{}/accept?access_token={}".format( + purchase_order.id, "test_po" + ), + data=json.dumps({"params": {"signature": "Joel Willis"}}).encode(), + allow_redirects=False, + headers={"Content-Type": "application/json"}, + ) + self.assertIn(_("Invalid signature data"), resp.text) diff --git a/purchase_sign/views/purchase_view.xml b/purchase_sign/views/purchase_view.xml new file mode 100644 index 00000000000..633b1289a35 --- /dev/null +++ b/purchase_sign/views/purchase_view.xml @@ -0,0 +1,30 @@ + + + + purchase.order.form.inherit.signature + purchase.order + + + + + + + + + + + + + + + + + diff --git a/purchase_sign/views/res_config_settings_view.xml b/purchase_sign/views/res_config_settings_view.xml new file mode 100644 index 00000000000..ce87b9b5b04 --- /dev/null +++ b/purchase_sign/views/res_config_settings_view.xml @@ -0,0 +1,21 @@ + + + + res.config.settings.view.form.inherit.purchase + res.config.settings + + + + + + + + + +