-
-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] refactorize the module to better fit standard Odoo (ie stock_pi…
…cking)
- Loading branch information
Showing
11 changed files
with
161 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import res_config_settings | ||
from . import project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,40 @@ | ||
# Copyright 2017 Tecnativa - Vicent Cubells | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
from odoo import _, api, fields, models | ||
|
||
|
||
class ProjectTask(models.Model): | ||
_inherit = "project.task" | ||
|
||
customer_signature = fields.Binary( | ||
string="Customer acceptance", | ||
) | ||
signature = fields.Image(help="Signature", copy=False, attachment=True) | ||
is_signed = fields.Boolean(compute="_compute_is_signed") | ||
|
||
@api.depends("signature") | ||
def _compute_is_signed(self): | ||
for task in self: | ||
task.is_signed = task.signature | ||
|
||
def write(self, vals): | ||
res = super(ProjectTask, self).write(vals) | ||
if vals.get("signature"): | ||
for task in self: | ||
task._attach_sign() | ||
return res | ||
|
||
def _attach_sign(self): | ||
"""Render the delivery report in pdf and attach it to the task in `self`.""" | ||
self.ensure_one() | ||
report = self.env["ir.actions.report"]._render_qweb_pdf( | ||
"project_task_report.report_project_task_action", self.id | ||
) | ||
filename = "%s_signed_task_report" % self.name | ||
if self.partner_id: | ||
message = _("Task signed by %s") % (self.partner_id.name) | ||
else: | ||
message = _("Task signed") | ||
self.message_post( | ||
attachments=[("%s.pdf" % filename, report[0])], | ||
body=message, | ||
) | ||
return True |
10 changes: 10 additions & 0 deletions
10
project_task_digitized_signature/models/res_config_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
group_project_sign_task = fields.Boolean( | ||
"Task Signature", | ||
implied_group="project_task_digitized_signature.group_project_sign_task", | ||
) |
29 changes: 13 additions & 16 deletions
29
project_task_digitized_signature/report/project_task_report.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
project_task_digitized_signature/security/project_task_digitized_signature_security.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="group_project_sign_task" model="res.groups"> | ||
<field name="name">Require a signature on your project tasks</field> | ||
<field name="category_id" ref="base.module_category_hidden" /> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 64 additions & 6 deletions
70
project_task_digitized_signature/views/project_task_views.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
project_task_digitized_signature/views/res_config_settings_views.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="res_config_settings_view_form" model="ir.ui.view"> | ||
<field name="name">res.config.settings.view.form.inherit.stock</field> | ||
<field name="model">res.config.settings</field> | ||
<field name="priority" eval="30" /> | ||
<field name="inherit_id" ref="project.res_config_settings_view_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//div[@id='tasks_management']" position="inside"> | ||
<div class="col-12 col-lg-6 o_setting_box" id="signature_project_tasks"> | ||
<div class="o_setting_left_pane"> | ||
<field name="group_project_sign_task" /> | ||
</div> | ||
<div class="o_setting_right_pane"> | ||
<label for="group_project_sign_task" /> | ||
<div class="text-muted"> | ||
Require a signature on your project tasks | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |