-
-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f14c71
commit 4072367
Showing
19 changed files
with
320 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
**This file is going to be generated by oca-gen-addon-readme.** | ||
|
||
*Manual changes will be overwritten.* | ||
|
||
Please provide content in the ``readme`` directory: | ||
|
||
* **DESCRIPTION.rst** (required) | ||
* INSTALL.rst (optional) | ||
* CONFIGURE.rst (optional) | ||
* **USAGE.rst** (optional, highly recommended) | ||
* DEVELOP.rst (optional) | ||
* ROADMAP.rst (optional) | ||
* HISTORY.rst (optional, recommended) | ||
* **CONTRIBUTORS.rst** (optional, highly recommended) | ||
* CREDITS.rst (optional) | ||
|
||
Content of this README will also be drawn from the addon manifest, | ||
from keys such as name, authors, maintainers, development_status, | ||
and license. | ||
|
||
A good, one sentence summary in the manifest is also highly recommended. | ||
|
||
|
||
Automatic changelog generation | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
`HISTORY.rst` can be auto generated using `towncrier <https://pypi.org/project/towncrier>`_. | ||
|
||
Just put towncrier compatible changelog fragments into `readme/newsfragments` | ||
and the changelog file will be automatically generated and updated when a new fragment is added. | ||
|
||
Please refer to `towncrier` documentation to know more. | ||
|
||
NOTE: the changelog will be automatically generated when using `/ocabot merge $option`. | ||
If you need to run it manually, refer to `OCA/maintainer-tools README <https://github.com/OCA/maintainer-tools>`_. |
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 @@ | ||
from . import models |
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,28 @@ | ||
# Copyright 2023 Moduon Team S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) | ||
|
||
{ | ||
"name": "Project Sequence", | ||
"summary": "Add a sequence field to projects, filled automatically", | ||
"version": "14.0.0.1.0", | ||
"development_status": "Alpha", | ||
"category": "Services/Project", | ||
"website": "https://github.com/OCA/project", | ||
"author": "Moduon, Odoo Community Association (OCA)", | ||
"maintainers": ["yajo", "anddago78"], | ||
"license": "LGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"preloadable": True, | ||
"external_dependencies": { | ||
"python": [], | ||
"bin": [], | ||
}, | ||
"depends": [ | ||
"project", | ||
], | ||
"data": [ | ||
"data/ir_sequence.xml", | ||
"views/project_project.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,12 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2023 Moduon Team S.L. | ||
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) --> | ||
<data noupdate="1"> | ||
<record id="seq_project_sequence" model="ir.sequence"> | ||
<field name="name">Project sequence</field> | ||
<field name="code">project.sequence</field> | ||
<field name="prefix">%(y)s-</field> | ||
<field name="padding">5</field> | ||
<field name="company_id" eval="False" /> | ||
</record> | ||
</data> |
Empty file.
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 @@ | ||
from . import project_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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2023 Moduon Team S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) | ||
|
||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ProjectProject(models.Model): | ||
_inherit = "project.project" | ||
|
||
code = fields.Char( | ||
readonly=True, | ||
copy=False, | ||
default=lambda self: self.env["ir.sequence"].next_by_code("project.sequence"), | ||
) | ||
name = fields.Char(required=False) | ||
display_name = fields.Char( | ||
compute="_compute_display_name_project", store=True, index=True | ||
) | ||
|
||
@api.depends("name", "code") | ||
def _compute_display_name_project(self): | ||
for rec in self: | ||
rec.display_name = rec.name | ||
if rec.name != rec.code: | ||
rec.display_name = "{} - {}".format(rec.code, rec.name) | ||
|
||
@api.model | ||
def create(self, vals): | ||
res = super().create(vals) | ||
if not res.name: | ||
res.name = res.code | ||
return res | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
for rec in self: | ||
if not rec.name: | ||
rec.name = rec.code | ||
return res |
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,2 @@ | ||
* Andrea Cattalani (`Moduon <https://www.moduon.team/>`__) | ||
* Jairo Llopis (`Moduon <https://www.moduon.team/>`__) |
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,6 @@ | ||
.. This file is optional and contains additional credits, other than | ||
authors, contributors, and maintainers. | ||
The development of this module has been financially supported by: | ||
|
||
* Moduon |
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,4 @@ | ||
.. This file must be max 2-3 paragraphs, and is required. | ||
It should explain *why* this module exists. | ||
Add a sequence field to projects, filled automatically and add a code sequence filter in tree view 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.. This file must be present. It contains the usage instructions | ||
for end-users. As all other rst files included in the README, | ||
it MUST NOT contain reStructuredText sections | ||
only body text (paragraphs, lists, tables, etc). Should you need | ||
a more elaborate structure to explain the addon, please create a | ||
Sphinx documentation (which may include this file as a "quick start" | ||
section). | ||
To use this module, you need to: | ||
|
||
#. Go in the project icon. | ||
#. Click the button "create" for create a new project | ||
#. Fill the field Project name and click create button | ||
#. Now in the kanban view see the project name when you are created | ||
#. Repeat this operation creating other project without name. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
from . import test_project_sequence |
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,37 @@ | ||
# Copyright 2023 Moduon Team S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) | ||
|
||
from freezegun import freeze_time | ||
|
||
from odoo.tests.common import Form, SavepointCase, new_test_user, users | ||
|
||
|
||
@freeze_time("2023-01-01 12:00:00", tick=True) | ||
class TestProjectSequence(SavepointCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
new_test_user(cls.env, "manager", "project.group_project_manager") | ||
cls.pjr_seq = cls.env["ir.sequence"].search([("code", "=", "project.sequence")]) | ||
cls.pjr_seq.number_next = 11 | ||
|
||
@users("manager") | ||
def test_sequence_after_creation(self): | ||
"""Sequence is applied only after project creation.""" | ||
prj_f = Form(self.env["project.project"]) | ||
self.assertFalse(prj_f.name) | ||
# self.assertFalse(prj_f.code) | ||
proj = prj_f.save() | ||
self.assertTrue(proj.code) | ||
self.assertEqual(proj.name, proj.code) | ||
self.assertEqual(proj.code, "23-00012") | ||
|
||
@users("manager") | ||
def test_sequence_copied_to_name_if_emptied(self): | ||
"""Sequence is copied to project name if user removes it.""" | ||
proj = self.env["project.project"].create({"name": "whatever"}) | ||
self.assertEqual(proj.name, "whatever") | ||
self.assertEqual(proj.code, "23-00013") | ||
with Form(proj) as prj_f: | ||
prj_f.name = False | ||
self.assertEqual(proj.name, "23-00013") |
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,50 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2023 Moduon Team S.L. | ||
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) --> | ||
<data> | ||
|
||
<record id="project_sequence_form_edit_project" model="ir.ui.view"> | ||
<field name="name">Project.sequence.project.edit</field> | ||
<field name="model">project.project</field> | ||
<field name="inherit_id" ref="project.edit_project" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='partner_id']" position="after"> | ||
<field name="code" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
<record id="project_sequence_form_view_project" model="ir.ui.view"> | ||
<field name="name">Project_sequence_project_view</field> | ||
<field name="model">project.project</field> | ||
<field name="inherit_id" ref="project.view_project" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='name']" position="replace"> | ||
<field name="display_name" /> | ||
<field name="code" optional="hide" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
<record id="project_sequence_form_kanban_project" model="ir.ui.view"> | ||
<field name="name">Project.sequence.project.kanban</field> | ||
<field name="model">project.project</field> | ||
<field name="inherit_id" ref="project.view_project_kanban" /> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="after"> | ||
<field name="display_name" /> | ||
</field> | ||
<xpath expr="//t[@t-esc='record.name.value']" position="replace"> | ||
<t t-esc="record.display_name.value" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
<record id="project_sequence_form_view_project_search" model="ir.ui.view"> | ||
<field name="name">Project_sequence_project_view_search</field> | ||
<field name="model">project.project</field> | ||
<field name="inherit_id" ref="project.view_project_project_filter" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='partner_id']" position="after"> | ||
<field name="code" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
</data> |
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 @@ | ||
../../../../project_sequence |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |