forked from OCA/project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] project_task_code: Migration to 12.0 (fix)
- Loading branch information
1 parent
62e745f
commit dbb6a69
Showing
15 changed files
with
592 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
========================= | ||
Sequential code for tasks | ||
Sequential Code for Tasks | ||
========================= | ||
|
||
* This module adds a sequential code for tasks. | ||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fproject-lightgray.png?logo=github | ||
:target: https://github.com/OCA/project/tree/12.0/project_task_code | ||
:alt: OCA/project | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/project-12-0/project-12-0-project_task_code | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/140/12.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module adds a sequential code for tasks. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
@@ -26,43 +50,50 @@ To use this module, you need to: | |
new code saving it. | ||
#. If you duplicate a task, you will get a new code for the new task. | ||
|
||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/140/12.0 | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/project/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_task_code%0Aversion:%2012.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 | ||
~~~~~~~ | ||
|
||
* OdooMRP team | ||
* AvanzOSC | ||
* Tecnativa | ||
|
||
Contributors | ||
------------ | ||
~~~~~~~~~~~~ | ||
|
||
* Oihane Crucelaegui <[email protected]> | ||
* Pedro M. Baeza <[email protected]> | ||
* Ana Juaristi <[email protected]> | ||
* Vicent Cubells <[email protected]> | ||
* Rodrigo Ferreira <[email protected]> | ||
* Damien Bouvy <[email protected]> | ||
* Alexey Pelykh <[email protected]> | ||
|
||
Maintainer | ||
---------- | ||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. | ||
This module is part of the `OCA/project <https://github.com/OCA/project/tree/12.0/project_task_code>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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,33 +1,5 @@ | ||
# Copyright 2016 Tecnativa <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import models | ||
from odoo import api, SUPERUSER_ID | ||
|
||
|
||
def create_code_equal_to_id(cr): | ||
""" | ||
With this pre-init-hook we want to avoid error when creating the UNIQUE | ||
code constraint when the module is installed and before the post-init-hook | ||
is launched. | ||
""" | ||
cr.execute('ALTER TABLE project_task ' | ||
'ADD COLUMN code character varying;') | ||
cr.execute('UPDATE project_task ' | ||
'SET code = id;') | ||
|
||
|
||
def assign_old_sequences(cr, registry): | ||
""" | ||
This post-init-hook will update all existing task assigning them the | ||
corresponding sequence code. | ||
""" | ||
env = api.Environment(cr, SUPERUSER_ID, dict()) | ||
task_obj = env['project.task'] | ||
sequence_obj = env['ir.sequence'] | ||
tasks = task_obj.search([], order="id") | ||
for task_id in tasks.ids: | ||
cr.execute('UPDATE project_task ' | ||
'SET code = %s ' | ||
'WHERE id = %s;', | ||
(sequence_obj.next_by_code('project.task'), task_id,)) | ||
from .hooks import pre_init_hook | ||
from .hooks import post_init_hook |
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 |
---|---|---|
|
@@ -2,29 +2,23 @@ | |
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Sequential Code for Tasks", | ||
"version": "12.0.1.1.0", | ||
"category": "Project Management", | ||
"author": "OdooMRP team, " | ||
"AvanzOSC, " | ||
"Tecnativa, " | ||
"Odoo Community Association (OCA)", | ||
"website": "http://www.avanzosc.es", | ||
"license": "AGPL-3", | ||
"contributors": [ | ||
"Oihane Crucelaegui <[email protected]>", | ||
"Pedro M. Baeza <[email protected]>", | ||
"Ana Juaristi <[email protected]>", | ||
"Vicent Cubells <[email protected]>", | ||
'name': 'Sequential Code for Tasks', | ||
'version': '12.0.1.0.0', | ||
'category': 'Project Management', | ||
'author': 'OdooMRP team, ' | ||
'AvanzOSC, ' | ||
'Tecnativa, ' | ||
'Odoo Community Association (OCA)', | ||
'website': 'https://github.com/OCA/project', | ||
'license': 'AGPL-3', | ||
'depends': [ | ||
'project', | ||
], | ||
"depends": [ | ||
"project", | ||
], | ||
"data": [ | ||
"data/task_sequence.xml", | ||
"views/project_view.xml", | ||
'data': [ | ||
'data/task_sequence.xml', | ||
'views/project_view.xml', | ||
], | ||
'installable': True, | ||
"pre_init_hook": "create_code_equal_to_id", | ||
"post_init_hook": "assign_old_sequences", | ||
'pre_init_hook': 'pre_init_hook', | ||
'post_init_hook': 'post_init_hook', | ||
} |
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,11 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo noupdate="1"> | ||
<!-- | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
|
||
<record id="sequence_task" model="ir.sequence"> | ||
<field name="name">Task code</field> | ||
<field name="code">project.task</field> | ||
<field eval="4" name="padding" /> | ||
<field name="prefix">T</field> | ||
</record> | ||
<record id="sequence_task" model="ir.sequence"> | ||
<field name="name">Task code</field> | ||
<field name="code">project.task</field> | ||
<field eval="4" name="padding" /> | ||
<field name="prefix">T</field> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2016 Tecnativa <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, SUPERUSER_ID | ||
|
||
|
||
def pre_init_hook(cr): | ||
""" | ||
With this pre-init-hook we want to avoid error when creating the UNIQUE | ||
code constraint when the module is installed and before the post-init-hook | ||
is launched. | ||
""" | ||
cr.execute('ALTER TABLE project_task ' | ||
'ADD COLUMN code character varying;') | ||
cr.execute('UPDATE project_task ' | ||
'SET code = id;') | ||
|
||
|
||
def post_init_hook(cr, registry): | ||
""" | ||
This post-init-hook will update all existing task assigning them the | ||
corresponding sequence code. | ||
""" | ||
env = api.Environment(cr, SUPERUSER_ID, dict()) | ||
task_obj = env['project.task'] | ||
sequence_obj = env['ir.sequence'] | ||
tasks = task_obj.search([], order="id") | ||
for task_id in tasks.ids: | ||
cr.execute('UPDATE project_task ' | ||
'SET code = %s ' | ||
'WHERE id = %s;', | ||
(sequence_obj.next_by_code('project.task'), task_id,)) |
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,4 +1,3 @@ | ||
# Copyright 2016 Tecnativa <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import project_task |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
To change the task code sequence, you must: | ||
|
||
#. Activate the developer mode. | ||
#. Go to Settings > Technical > Sequences & Identifiers > Sequences. | ||
#. Click on "Task code" sequence to edit. |
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 @@ | ||
* Oihane Crucelaegui <[email protected]> | ||
* Pedro M. Baeza <[email protected]> | ||
* Ana Juaristi <[email protected]> | ||
* Vicent Cubells <[email protected]> | ||
* Rodrigo Ferreira <[email protected]> | ||
* Damien Bouvy <[email protected]> | ||
* Alexey Pelykh <[email protected]> |
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 @@ | ||
This module adds a sequential code for tasks. |
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,5 @@ | ||
To use this module, you need to: | ||
|
||
#. Go to menu Project > Search > Tasks and create a new task, and you get a | ||
new code saving it. | ||
#. If you duplicate a task, you will get a new code for the new task. |
Oops, something went wrong.