Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][MIG] project_task_sign_oca: Migration to 15.0 #60

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions project_task_sign_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
=====================
Project Task Sign Oca
=====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ef9506e1ac22f6f38d91f32bddc1ab62a1f17703d1a3d3b449c1ca148240d7d4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fsign-lightgray.png?logo=github
:target: https://github.com/OCA/sign/tree/15.0/project_task_sign_oca
:alt: OCA/sign
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sign-15-0/sign-15-0-project_task_sign_oca
: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/sign&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows you to generate manual and automatic signature requests from project tasks to task customers.

**Table of contents**

.. contents::
:local:

Configuration
=============

#. Go to Sign > Settings > Roles and create a role with the following data:

- Partner type: Expression
- Expression: {{object.partner_id.id}}

#. Go to Sign > Templates and create a template with the following data:

- Model: Project Task
- In one of the fields, you must set the previously created role.

#. (Optional) Go to Project > Configuration > Settings.

- In the Task Sign section, define a template to enable automatic task sing requests.
- Use the template previously created.

Usage
=====

Creating a Signature Request from a Project Task:
- Go to Projects > Tasks.
- Open an existing task or create a new one (make sure to fill in the `partner_id` field).
- In the task tree or form view, click on the action "Sign from template".
- Sign Requests will have been generated (and sent) linked to the selected project and task.

Automatic Signature Request creation:
- Define a template in Project > Configuration > Settings.
- When an customer is assigned to a task, a Sign Request will be created (and sent) automatically.

Viewing Signature Requests:
- Go to Projects > Tasks.
- Open a task with an associated signature request.
- Click on the smart-button Sign Requests.
- Click on any signature request to view its details, status, and progress.
- Alternatively, go to Sign > Requests.
- Use the Group By feature to group requests by Project and/or Task.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sign/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 <https://github.com/OCA/sign/issues/new?body=module:%20project_task_sign_oca%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Escodoo

Contributors
~~~~~~~~~~~~

* `Escodoo <https://www.escodoo.com.br>`_:

* Marcel Savegnago <marcel.savegnago@escodoo.com.br>
* Wesley Oliveira <wesley.oliveira@escodoo.com.br>

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/sign <https://github.com/OCA/sign/tree/15.0/project_task_sign_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions project_task_sign_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions project_task_sign_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 - TODAY, Escodoo
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Project Task Sign Oca",
"summary": """
Project Task Sign Oca""",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"author": "Escodoo, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sign",
"depends": ["sign_oca", "project"],
"data": [
"views/project_task.xml",
"views/res_config_settings.xml",
"views/sign_oca_request.xml",
],
"demo": [
"demo/sign_oca_role.xml",
"demo/sign_oca_template.xml",
],
}
12 changes: 12 additions & 0 deletions project_task_sign_oca/demo/sign_oca_role.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2024 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record id="sign_role_project_task_customer" model="sign.oca.role">
<field name="name">Task Customer</field>
<field name="partner_type">expression</field>
<field name="expression_partner">{{object.partner_id.id}}</field>
</record>

</odoo>
32 changes: 32 additions & 0 deletions project_task_sign_oca/demo/sign_oca_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2024 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record id="sign_oca_template_project_task_demo" model="sign.oca.template">
<field name="name">Task Approval</field>
<field name="model_id" ref="project.model_project_task" />
<field name="data" type="base64" file="sign_oca/tests/empty.pdf" />
</record>
<record
id="sign_oca_template_project_task_demo_item"
model="sign.oca.template.item"
>
<field
name="template_id"
ref="project_task_sign_oca.sign_oca_template_project_task_demo"
/>
<field name="field_id" ref="sign_oca.sign_field_signature" />
<field
name="role_id"
ref="project_task_sign_oca.sign_role_project_task_customer"
/>
<field name="page">1</field>
<field name="position_x">10</field>
<field name="position_y">10</field>
<field name="width">30</field>
<field name="height">4</field>
<field name="required" eval="True" />
</record>

</odoo>
99 changes: 99 additions & 0 deletions project_task_sign_oca/i18n/project_task_sign_oca.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_task_sign_oca
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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: project_task_sign_oca
#: model_terms:ir.ui.view,arch_db:project_task_sign_oca.res_config_settings_view_form
msgid "<span class=\"o_form_label\">Task Sign</span>"
msgstr ""

#. module: project_task_sign_oca
#: model:ir.model,name:project_task_sign_oca.model_res_company
msgid "Companies"
msgstr ""

#. module: project_task_sign_oca
#: model:ir.model,name:project_task_sign_oca.model_res_config_settings
msgid "Config Settings"
msgstr ""

#. module: project_task_sign_oca
#: model_terms:ir.ui.view,arch_db:project_task_sign_oca.res_config_settings_view_form
msgid ""
"Define a template to enable automatic sign requests for the task customer"
msgstr ""

#. module: project_task_sign_oca
#: model:ir.model.fields,field_description:project_task_sign_oca.field_project_task__display_name
#: model:ir.model.fields,field_description:project_task_sign_oca.field_res_company__display_name
#: model:ir.model.fields,field_description:project_task_sign_oca.field_res_config_settings__display_name
#: model:ir.model.fields,field_description:project_task_sign_oca.field_sign_oca_request__display_name
msgid "Display Name"
msgstr ""

#. module: project_task_sign_oca
#: model:ir.model.fields,field_description:project_task_sign_oca.field_project_task__id
#: model:ir.model.fields,field_description:project_task_sign_oca.field_res_company__id
#: model:ir.model.fields,field_description:project_task_sign_oca.field_res_config_settings__id
#: model:ir.model.fields,field_description:project_task_sign_oca.field_sign_oca_request__id
msgid "ID"
msgstr ""

#. module: project_task_sign_oca
#: model:ir.model.fields,field_description:project_task_sign_oca.field_project_task____last_update
#: model:ir.model.fields,field_description:project_task_sign_oca.field_res_company____last_update
#: model:ir.model.fields,field_description:project_task_sign_oca.field_res_config_settings____last_update
#: model:ir.model.fields,field_description:project_task_sign_oca.field_sign_oca_request____last_update
msgid "Last Modified on"
msgstr ""

#. module: project_task_sign_oca
#: model:ir.model.fields,field_description:project_task_sign_oca.field_sign_oca_request__project_id
#: model_terms:ir.ui.view,arch_db:project_task_sign_oca.sign_oca_request_search_view
msgid "Project"
msgstr ""

#. module: project_task_sign_oca
#: model:ir.model.fields,field_description:project_task_sign_oca.field_res_company__project_task_sign_oca_template_id
#: model:ir.model.fields,field_description:project_task_sign_oca.field_res_config_settings__project_task_sign_oca_template_id
msgid "Project Task Sign Oca Template"
msgstr ""

#. module: project_task_sign_oca
#: model:ir.model,name:project_task_sign_oca.model_sign_oca_request
msgid "Sign Request"
msgstr ""

#. module: project_task_sign_oca
#: model:ir.model.fields,field_description:project_task_sign_oca.field_project_task__sign_request_ids
#: model_terms:ir.ui.view,arch_db:project_task_sign_oca.view_task_form2
msgid "Sign Requests"
msgstr ""

#. module: project_task_sign_oca
#: model_terms:ir.ui.view,arch_db:project_task_sign_oca.res_config_settings_view_form
msgid "Sign Template"
msgstr ""

#. module: project_task_sign_oca
#: model:ir.model.fields,field_description:project_task_sign_oca.field_project_task__sign_request_count
msgid "Sign request count"
msgstr ""

#. module: project_task_sign_oca
#: model:ir.model,name:project_task_sign_oca.model_project_task
#: model:ir.model.fields,field_description:project_task_sign_oca.field_sign_oca_request__task_id
#: model_terms:ir.ui.view,arch_db:project_task_sign_oca.sign_oca_request_search_view
msgid "Task"
msgstr ""
4 changes: 4 additions & 0 deletions project_task_sign_oca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import project_task
from . import res_company
from . import res_config_settings
from . import sign_oca_request
60 changes: 60 additions & 0 deletions project_task_sign_oca/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2024 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class ProjectTask(models.Model):

_inherit = "project.task"

sign_request_ids = fields.One2many(
comodel_name="sign.oca.request",
inverse_name="task_id",
string="Sign Requests",
)
sign_request_count = fields.Integer(
string="Sign request count",
compute="_compute_sign_request_count",
compute_sudo=True,
)

@api.depends("sign_request_ids")
def _compute_sign_request_count(self):
for task in self:
task.sign_request_count = len(task.sign_request_ids)

def action_view_sign_requests(self):
self.ensure_one()
result = self.env["ir.actions.act_window"]._for_xml_id(

Check warning on line 29 in project_task_sign_oca/models/project_task.py

View check run for this annotation

Codecov / codecov/patch

project_task_sign_oca/models/project_task.py#L28-L29

Added lines #L28 - L29 were not covered by tests
"sign_oca.sign_oca_request_act_window"
)
result["domain"] = [("id", "in", self.sign_request_ids.ids)]
return result

Check warning on line 33 in project_task_sign_oca/models/project_task.py

View check run for this annotation

Codecov / codecov/patch

project_task_sign_oca/models/project_task.py#L32-L33

Added lines #L32 - L33 were not covered by tests

def _generate_sign_oca_request(self):
sign_request_obj = self.env["sign.oca.request"].sudo()
for task in self:
sign_template = task.company_id.project_task_sign_oca_template_id
if sign_template:
sign_template = sign_template.sudo()
request = sign_request_obj.create(
sign_template._prepare_sign_oca_request_vals_from_record(task)
)
request.action_send()

@api.model_create_multi
def create(self, vals_list):
res = super().create(vals_list)
for task in res:
if task.partner_id:
task._generate_sign_oca_request()
return res

def write(self, vals):
old_partner_id = self.partner_id
new_partner_id = vals.get("partner_id")
res = super().write(vals)
if new_partner_id and new_partner_id != old_partner_id:
self._generate_sign_oca_request()
return res
14 changes: 14 additions & 0 deletions project_task_sign_oca/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

project_task_sign_oca_template_id = fields.Many2one(
comodel_name="sign.oca.template",
domain="[('model_id.model', '=', 'project.task')]",
string="Project Task Sign Oca Template",
)
15 changes: 15 additions & 0 deletions project_task_sign_oca/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br>
# 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"

project_task_sign_oca_template_id = fields.Many2one(
comodel_name="sign.oca.template",
related="company_id.project_task_sign_oca_template_id",
string="Project Task Sign Oca Template",
readonly=False,
)
Loading
Loading