Skip to content

Commit 781c00a

Browse files
committed
Merge PR #2270 into 16.0
Signed-off-by yajo
2 parents 0e33c71 + ad61699 commit 781c00a

21 files changed

+1085
-0
lines changed

purchase_sign/README.rst

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
=============
2+
Purchase Sign
3+
=============
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:88ac5c691562f3453857db7210257da345b2b903c05d80b3ed305fab437b14b5
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
20+
:target: https://github.com/OCA/purchase-workflow/tree/16.0/purchase_sign
21+
:alt: OCA/purchase-workflow
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/purchase-workflow-16-0/purchase-workflow-16-0-purchase_sign
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
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
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Bug Tracker
39+
===========
40+
41+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
42+
In case of trouble, please check there if your issue has already been reported.
43+
If you spotted it first, help us to smash it by providing a detailed and welcomed
44+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_sign%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
45+
46+
Do not contact contributors directly about support or help with technical issues.
47+
48+
Credits
49+
=======
50+
51+
Authors
52+
~~~~~~~
53+
54+
* Onestein
55+
56+
Contributors
57+
~~~~~~~~~~~~
58+
59+
* `Onestein <https://www.onestein.nl>`__
60+
61+
Maintainers
62+
~~~~~~~~~~~
63+
64+
This module is maintained by the OCA.
65+
66+
.. image:: https://odoo-community.org/logo.png
67+
:alt: Odoo Community Association
68+
:target: https://odoo-community.org
69+
70+
OCA, or the Odoo Community Association, is a nonprofit organization whose
71+
mission is to support the collaborative development of Odoo features and
72+
promote its widespread use.
73+
74+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/16.0/purchase_sign>`_ project on GitHub.
75+
76+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

purchase_sign/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright 2024 Onestein
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from . import controllers
4+
from . import models

purchase_sign/__manifest__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2024 Onestein (<http://www.onestein.eu>)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
{
5+
"name": "Purchase Sign",
6+
"version": "16.0.1.0.0",
7+
"license": "AGPL-3",
8+
"category": "Purchase",
9+
"author": "Onestein, Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/purchase-workflow",
11+
"depends": ["purchase"],
12+
"data": [
13+
"report/purchase_order_template.xml",
14+
"templates/purchase_portal_templates.xml",
15+
"views/purchase_view.xml",
16+
"views/res_config_settings_view.xml",
17+
],
18+
"assets": {
19+
"web.assets_tests": [
20+
"purchase_sign/static/tests/tours/purchase_signature.esm.js"
21+
],
22+
},
23+
}

purchase_sign/controllers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
2+
from . import main

purchase_sign/controllers/main.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copyright 2024 Onestein
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
import binascii
4+
5+
from odoo import _, fields, http
6+
from odoo.exceptions import AccessError, MissingError
7+
from odoo.http import request
8+
9+
from odoo.addons.portal.controllers.mail import _message_post_helper
10+
from odoo.addons.portal.controllers.portal import CustomerPortal
11+
12+
13+
class PortalPurchase(CustomerPortal):
14+
def _purchase_order_get_page_view_values(self, order, access_token, **kwargs):
15+
response = super(PortalPurchase, self)._purchase_order_get_page_view_values(
16+
order=order, access_token=access_token, **kwargs
17+
)
18+
if kwargs.get("message"):
19+
response.update({"message": kwargs.get("message")})
20+
return response
21+
22+
@http.route(
23+
["/my/purchase/<int:order_id>/accept"], type="json", auth="public", website=True
24+
)
25+
def portal_purchase_accept(
26+
self, order_id, access_token=None, name=None, signature=None
27+
):
28+
# get from query string if not on json param
29+
access_token = access_token or request.httprequest.args.get("access_token")
30+
try:
31+
order_sudo = self._document_check_access(
32+
"purchase.order", order_id, access_token=access_token
33+
)
34+
except (AccessError, MissingError):
35+
return {"error": _("Invalid order.")}
36+
37+
if not order_sudo._has_to_be_signed():
38+
return {
39+
"error": _("The order is not in a state requiring vendor signature.")
40+
}
41+
if not signature:
42+
return {"error": _("Signature is missing.")}
43+
44+
try:
45+
order_sudo.write(
46+
{
47+
"signed_by": name,
48+
"signed_on": fields.Datetime.now(),
49+
"signature": signature,
50+
}
51+
)
52+
except (TypeError, binascii.Error):
53+
return {"error": _("Invalid signature data.")}
54+
order_sudo.button_confirm()
55+
pdf = (
56+
request.env["ir.actions.report"]
57+
.sudo()
58+
._render_qweb_pdf("purchase.action_report_purchase_order", [order_sudo.id])[
59+
0
60+
]
61+
)
62+
63+
_message_post_helper(
64+
"purchase.order",
65+
order_sudo.id,
66+
_("Order signed by %s", name),
67+
attachments=[("%s.pdf" % order_sudo.name, pdf)],
68+
token=access_token,
69+
)
70+
71+
query_string = "&message=sign_ok"
72+
return {
73+
"force_refresh": True,
74+
"redirect_url": order_sudo.get_portal_url(query_string=query_string),
75+
}

purchase_sign/models/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
2+
from . import purchase_order
3+
from . import res_company
4+
from . import res_config_settings
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2024 Onestein
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from odoo import api, fields, models
4+
5+
from odoo.addons.purchase.models.purchase import PurchaseOrder as Purchase
6+
7+
8+
class PurchaseOrder(models.Model):
9+
_inherit = "purchase.order"
10+
11+
require_signature = fields.Boolean(
12+
string="Online Signature",
13+
compute="_compute_require_signature",
14+
store=True,
15+
readonly=False,
16+
precompute=True,
17+
states=Purchase.READONLY_STATES,
18+
help="Request a online signature and/or payment to the customer in "
19+
"order to confirm orders automatically.",
20+
)
21+
signature = fields.Image(
22+
copy=False, attachment=True, max_width=1024, max_height=1024
23+
)
24+
signed_by = fields.Char(copy=False)
25+
signed_on = fields.Datetime(copy=False)
26+
27+
@api.depends("company_id")
28+
def _compute_require_signature(self):
29+
for order in self:
30+
order.require_signature = order.company_id.purchase_portal_confirmation_sign
31+
32+
def _has_to_be_signed(self):
33+
return self.state == "sent" and self.require_signature and not self.signature

purchase_sign/models/res_company.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2024 Onestein
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from odoo import fields, models
4+
5+
6+
class ResCompany(models.Model):
7+
_inherit = "res.company"
8+
9+
purchase_portal_confirmation_sign = fields.Boolean(
10+
string="Purchase Online Signature", default=False
11+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2024 Onestein
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from odoo import fields, models
4+
5+
6+
class ResConfigSettings(models.TransientModel):
7+
_inherit = "res.config.settings"
8+
9+
purchase_portal_confirmation_sign = fields.Boolean(
10+
related="company_id.purchase_portal_confirmation_sign",
11+
readonly=False,
12+
)

purchase_sign/readme/CONTRIBUTORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* `Onestein <https://www.onestein.nl>`__

purchase_sign/readme/DESCRIPTION.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
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
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<template
4+
id="report_purchaseorder_document"
5+
inherit_id="purchase.report_purchaseorder_document"
6+
>
7+
<xpath expr="//p[@t-field='o.notes']" position="before">
8+
<div t-if="o.signature" class="mt-4 ml64 mr4" name="signature">
9+
<div class="offset-8">
10+
<strong>Signature</strong>
11+
</div>
12+
<div class="offset-8">
13+
<img
14+
t-att-src="image_data_uri(o.signature)"
15+
style="max-height: 4cm; max-width: 8cm;"
16+
/>
17+
</div>
18+
<div class="offset-8 text-center">
19+
<p t-field="o.signed_by" />
20+
</div>
21+
</div>
22+
</xpath>
23+
</template>
24+
25+
</odoo>

0 commit comments

Comments
 (0)