Search 1.9 billion lines of Odoo code on GitHub

project_task_reference

Author: Numigi
License: LGPL-3
Branch: 14.0
Repository: Numigi/odoo-project-addons
Dependencies: project
Languages: Python (139, 81.8%), and reStructuredText (31, 18.2%)
Other branches: 12.0, 452, TA#42546, TA#43556, TA#44075---manage_project_budget_using_milestone, TA#44076---Update-dockerfile, TA#44215---project_task_kanban_view_partner, TA#445738---project_outsourcing_timesheet_manage_contacts, TA#45451---add_project_milestone_week_duration, TA#45451---fix_after_test, TA#45452, TA#45459---project_milestone_timeline_dynamic, TA#45464---project_manager_access_right, TA#45526, TA#45528, TA#45902---analytic_line_revenue_v14, TA#45902---project_cost_smart_button_migration, TA#45902-analytic_line_employee_migration, TA#46088---project_timesheet_time_control_employee_pin, TA#46412---project_default_task_stage, TA#46412---project_stage_no_quick_create, TA#46412---project_task_date_planned, TA#46412---project_type, TA#46412--project_task_full_text_search, TA#47760---correctif#6, TA#47906, TA#48575, TA#51167, TumbaoJu-patch-1, abenzbiria-patch-1, jbreard-patch-1, jbreard-patch-2, and update_analytic_account_on_timesheets

<h1 class="title">Project Task Reference Extract</h1> <p>This is a technical module. It has no functional use on its own.</p> <p>It allows to extract a reference to a task from a string.</p> <div class="contents topic" id="table-of-contents"> <p class="topic-title">Table of Contents</p> <ul class="simple"> <li><a class="reference internal" href="#basic-usage" id="id1">Basic Usage</a></li> <li><a class="reference internal" href="#advanced-setup" id="id2">Advanced Setup</a></li> <li><a class="reference internal" href="#contributors" id="id3">Contributors</a></li> </ul> </div> <a name="basic-usage"></a> <h2><a class="toc-backref" href="#id1">Basic Usage</a></h2> <p>The module adds a method <code>_search_references_from_text</code> on <code>project.task</code>.</p> <p>This method takes a string and returns a list of TaskReference (a python class defined in the module).</p> <pre> <code lang="python">from odoo.addons.project_task_reference.reference import TaskReference some_text = &quot;ta#123 Some commit message&quot; reference = env['project.task']._search_references_from_text(some_text)[0] assert isinstance(reference, TaskReference) assert reference.task == env['project.task'].browse(123) assert reference.string == &quot;ta#123&quot; assert reference.normalized_string == &quot;TA#123&quot;</code> </pre> <p>The reference(s) can be located anywhere in the given text.</p> <p>The method is at some point tolerant to variations in the format of the reference inside the given text.</p> <ul class="simple"> <li>It is insensitive to lower case.</li> <li>The <code>#</code> is optional.</li> </ul> <p>Thefore <code>ta123</code> would be recognized.</p> <a name="advanced-setup"></a> <h2><a class="toc-backref" href="#id2">Advanced Setup</a></h2> <p>By default, the system uses the following regex to parse the references:</p> <blockquote> [tT][aA]#?(?P&lt;id&gt;d+)</blockquote> <p>This means that the strings <code>TA#123</code>, <code>ta#123</code>, <code>TA123</code> or <code>ta123</code> will generate a reference that point to the task with ID=123.</p> <p>Then, the following python format is used to render the reference in a normalized form:</p> <blockquote> TA#{id}</blockquote> <p>The reference will always be formatted <code>TA#123</code>.</p> <p>This can be tweeked by defining 2 system parameters:</p> <ul class="simple"> <li><code>project_task_reference.regex</code>: the REGEX used to parse the reference.</li> <li><code>project_task_reference.format</code>: the python format to use for formatting the reference.</li> </ul> <p>For example, let's suppose the format for our links must be: <code>[ST#123]</code>. The system parameters could be as follow:</p> <ul class="simple"> <li><code>project_task_reference.regex</code>: <code>\[?[sS][tT]#?(?P&lt;id&gt;\d+)\]?</code></li> <li><code>project_task_reference.format</code>: <code>[ST#{id}]</code></li> </ul> <p>The regex must contain a parameter <code>(?P&lt;id&gt;\d+)</code> (the database ID of the task).</p> <a name="contributors"></a> <h2><a class="toc-backref" href="#id3">Contributors</a></h2> <ul class="simple"> <li>Numigi (tm) and all its contributors (<a class="reference external" href="https://bit.ly/numigiens">https://bit.ly/numigiens</a>)</li> </ul>