Skip to content

Commit

Permalink
[IMP] sign_oca: Allow to store geolocalization
Browse files Browse the repository at this point in the history
[UPD] Update sign_oca.pot

[BOT] post-merge updates

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: sign-16.0/sign-16.0-sign_oca
Translate-URL: https://translation.odoo-community.org/projects/sign-16-0/sign-16-0-sign_oca/
  • Loading branch information
etobella authored and victoralmau committed Oct 31, 2024
1 parent e66df84 commit 9a537c4
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 17 deletions.
2 changes: 1 addition & 1 deletion sign_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Sign Oca
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:16ebb34be37a271d0a57d986e0a213d937308d997531a3523fef9e24866f6138
!! source digest: sha256:4cd44f4785da01198064822b367bcbe928fe915080976d5b1f5f2d8671812e51
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion sign_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Sign Oca",
"summary": """
Allow to sign documents inside Odoo CE""",
"version": "16.0.3.1.0",
"version": "16.0.4.0.0",
"license": "AGPL-3",
"author": "Dixmit,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sign",
Expand Down
8 changes: 6 additions & 2 deletions sign_oca/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@ def get_sign_oca_info_access(self, signer_id, access_token):
auth="public",
website=True,
)
def get_sign_oca_sign_access(self, signer_id, access_token, items):
def get_sign_oca_sign_access(
self, signer_id, access_token, items, latitude=False, longitude=False
):
try:
signer_sudo = self._document_check_access(
"sign.oca.request.signer", signer_id, access_token
)
except (AccessError, MissingError):
return request.redirect("/my")
return signer_sudo.action_sign(items, access_token=access_token)
return signer_sudo.action_sign(
items, access_token=access_token, latitude=latitude, longitude=longitude
)
16 changes: 16 additions & 0 deletions sign_oca/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ msgstr ""
"Tan pronto como todos los firmantes hayan firmado el documento, recibirá un "
"correo electrónico con el documento completo"

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__ask_location
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__ask_location
msgid "Ask Location"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__message_attachment_count
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__message_attachment_count
Expand Down Expand Up @@ -666,6 +672,11 @@ msgstr "Última actualización el"
msgid "Late Activities"
msgstr "Actividades tardías"

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request_signer__latitude
msgid "Latitude"
msgstr ""

#. module: sign_oca
#: model:ir.model,name:sign_oca.model_sign_oca_request_log
msgid "Log access and edition on requests"
Expand All @@ -679,6 +690,11 @@ msgstr "Acceso y edición de registros según solicitudes"
msgid "Logo"
msgstr "Logo"

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request_signer__longitude
msgid "Longitude"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__message_main_attachment_id
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__message_main_attachment_id
Expand Down
16 changes: 16 additions & 0 deletions sign_oca/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ msgstr ""
"Appena tutti i firmatari avranno firmato il documento, riceverà una e-mail "
"con il documento completo"

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__ask_location
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__ask_location
msgid "Ask Location"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__message_attachment_count
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__message_attachment_count
Expand Down Expand Up @@ -667,6 +673,11 @@ msgstr "Ultimo aggiornamento il"
msgid "Late Activities"
msgstr "Attività in ritardo"

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request_signer__latitude
msgid "Latitude"
msgstr ""

#. module: sign_oca
#: model:ir.model,name:sign_oca.model_sign_oca_request_log
msgid "Log access and edition on requests"
Expand All @@ -680,6 +691,11 @@ msgstr "Registra accesso e modifica alle richieste"
msgid "Logo"
msgstr "Logo"

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request_signer__longitude
msgid "Longitude"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__message_main_attachment_id
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__message_main_attachment_id
Expand Down
16 changes: 16 additions & 0 deletions sign_oca/i18n/pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ msgid ""
"with the full document"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__ask_location
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__ask_location
msgid "Ask Location"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__message_attachment_count
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__message_attachment_count
Expand Down Expand Up @@ -642,6 +648,11 @@ msgstr ""
msgid "Late Activities"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request_signer__latitude
msgid "Latitude"
msgstr ""

#. module: sign_oca
#: model:ir.model,name:sign_oca.model_sign_oca_request_log
msgid "Log access and edition on requests"
Expand All @@ -655,6 +666,11 @@ msgstr ""
msgid "Logo"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request_signer__longitude
msgid "Longitude"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__message_main_attachment_id
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__message_main_attachment_id
Expand Down
16 changes: 16 additions & 0 deletions sign_oca/i18n/sign_oca.pot
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ msgid ""
"with the full document"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__ask_location
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__ask_location
msgid "Ask Location"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__message_attachment_count
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__message_attachment_count
Expand Down Expand Up @@ -637,6 +643,11 @@ msgstr ""
msgid "Late Activities"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request_signer__latitude
msgid "Latitude"
msgstr ""

#. module: sign_oca
#: model:ir.model,name:sign_oca.model_sign_oca_request_log
msgid "Log access and edition on requests"
Expand All @@ -650,6 +661,11 @@ msgstr ""
msgid "Logo"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request_signer__longitude
msgid "Longitude"
msgstr ""

#. module: sign_oca
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_request__message_main_attachment_id
#: model:ir.model.fields,field_description:sign_oca.field_sign_oca_template__message_main_attachment_id
Expand Down
8 changes: 7 additions & 1 deletion sign_oca/models/sign_oca_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class SignOcaRequest(models.Model):
states={"draft": [("readonly", False)]},
)
next_item_id = fields.Integer(compute="_compute_next_item_id")
ask_location = fields.Boolean()

@api.depends("signer_ids")
@api.depends_context("uid")
Expand Down Expand Up @@ -370,6 +371,8 @@ class SignOcaRequestSigner(models.Model):
"ir.sequence", copy=False, default=lambda r: r._get_sequence()
)
altered_hash = fields.Boolean(compute="_compute_altered_hash")
latitude = fields.Float()
longitude = fields.Float()

@api.depends("request_id.record_ref")
def _compute_model(self):
Expand Down Expand Up @@ -414,6 +417,7 @@ def get_info(self, access_token=False):
"name": self.request_id.template_id.name,
"items": self.request_id.signatory_data,
"to_sign": self.request_id.to_sign,
"ask_location": self.request_id.ask_location,
"partner": {
"id": self.partner_id.id,
"name": self.partner_id.name,
Expand All @@ -432,7 +436,7 @@ def sign(self):
"url": self.access_url,
}

def action_sign(self, items, access_token=False):
def action_sign(self, items, access_token=False, latitude=False, longitude=False):
self.ensure_one()
if self.signed_on:
raise ValidationError(
Expand Down Expand Up @@ -477,6 +481,8 @@ def action_sign(self, items, access_token=False):
}
)
self.signature_hash = final_hash
self.latitude = latitude
self.longitude = longitude
self.request_id._check_signed()
self._set_action_log("sign", access_token=access_token)
if self.sequence_id:
Expand Down
1 change: 1 addition & 0 deletions sign_oca/models/sign_oca_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class SignOcaTemplate(models.Model):

name = fields.Char(required=True)
data = fields.Binary(attachment=True, required=True)
ask_location = fields.Boolean()
filename = fields.Char()
item_ids = fields.One2many("sign.oca.template.item", inverse_name="template_id")
request_count = fields.Integer(compute="_compute_request_count")
Expand Down
2 changes: 1 addition & 1 deletion sign_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Sign Oca</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:16ebb34be37a271d0a57d986e0a213d937308d997531a3523fef9e24866f6138
!! source digest: sha256:4cd44f4785da01198064822b367bcbe928fe915080976d5b1f5f2d8671812e51
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sign/tree/16.0/sign_oca"><img alt="OCA/sign" src="https://img.shields.io/badge/github-OCA%2Fsign-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sign-16-0/sign-16-0-sign_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sign&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to create documents for signature inside Odoo using
Expand Down
51 changes: 42 additions & 9 deletions sign_oca/static/src/components/sign_oca_pdf/sign_oca_pdf.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,51 @@ export default class SignOcaPdf extends SignOcaPdfCommon {
})
);
$buttons.on("click.o_sign_oca_button_sign", () => {
this.env.services
.rpc({
model: this.props.model,
method: "action_sign",
args: [[this.props.res_id], this.info.items],
})
.then(() => {
this.props.trigger("history_back");
});
this.signOca();
});
return $buttons;
}
async getLocation() {
if (!this.info.ask_location || !navigator.geolocation) {
return {};
}
try {
return await new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(resolve, reject);
});

// Do something with the latitude and longitude
} catch (error) {
switch (error.code) {
case error.PERMISSION_DENIED:
console.debug("User denied the request for geolocation.");
break;
case error.POSITION_UNAVAILABLE:
console.debug("Location information is unavailable.");
break;
case error.TIMEOUT:
console.debug("The request to get user location timed out.");
break;
default:
console.debug("An unknown error occurred.");
break;
}
}
return {};
}
async signOca() {
const position = await this.getLocation();
await this.env.services.rpc({
model: this.props.model,
method: "action_sign",
args: [[this.props.res_id], this.info.items],
kwargs: {
latitude: position && position.coords && position.coords.latitude,
longitude: position && position.coords && position.coords.longitude,
},
});
this.props.trigger("history_back");
}
_trigger_up(ev) {
const evType = ev.name;
const payload = ev.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,20 @@ export class SignOcaPdfPortal extends SignOcaPdf {
super.postIframeFields(...arguments);
this.checkFilledAll();
}
_onClickSign() {
async _onClickSign() {
const position = await this.getLocation();
this.env.services
.rpc({
route:
"/sign_oca/sign/" +
this.props.signer_id +
"/" +
this.props.access_token,
params: {items: this.info.items},
params: {
items: this.info.items,
latitude: position && position.coords && position.coords.latitude,
longitude: position && position.coords && position.coords.longitude,
},
})
.then((action) => {
// As we are on frontend env, it is not possible to use do_action(), so we
Expand Down
2 changes: 2 additions & 0 deletions sign_oca/views/sign_oca_request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@
<field name="request_id" readonly="1" />
<field name="signed_on" />
<field name="inalterable_hash" />
<field name="latitude" />
<field name="longitude" />
</group>
</sheet>
</form>
Expand Down
1 change: 1 addition & 0 deletions sign_oca/views/sign_oca_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<field name="data" filename="filename" />
<field name="filename" invisible="1" />
<field name="model_id" groups="sign_oca.sign_oca_group_admin" />
<field name="ask_location" />
</group>
<notebook>
<page name="items" string="Fields">
Expand Down
1 change: 1 addition & 0 deletions sign_oca/wizards/sign_oca_template_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def _generate_vals(self):
"template_id": self.template_id.id,
"signatory_data": self.template_id._get_signatory_data(),
"data": self.template_id.data,
"ask_location": self.template_id.ask_location,
"signer_ids": [
(
0,
Expand Down

0 comments on commit 9a537c4

Please sign in to comment.