Skip to content
Open
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
107 changes: 107 additions & 0 deletions project_sequence_type/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

========================
Project Sequence by Type
========================

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

.. |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/license-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/19.0/project_sequence_type
:alt: OCA/project
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/project-19-0/project-19-0-project_sequence_type
: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/project&target_branch=19.0
:alt: Try me on Runboat

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

This module lets each project type define its own sequence, so projects
get a different numbering depending on their type.

It is a glue module between ``project_sequence`` and ``project_type``
and is installed automatically when both are present.

Projects whose type has no sequence (or projects without a type) keep
using the default project sequence provided by ``project_sequence``.

**Table of contents**

.. contents::
:local:

Usage
=====

1. Go to *Settings > Technical > Sequences & Identifiers > Sequences*
and create one sequence per project type you want to number
separately (set its prefix, padding, etc. as usual).
2. Go to *Project > Configuration > Project Types*, open a type and set
its *Project Sequence* to the sequence created above.
3. Create a project of that type: its sequence code is taken from the
type's sequence. Types without a sequence keep using the default
project sequence.

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_sequence_type%0Aversion:%2019.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
-------

* Ledo

Contributors
------------

- Ledo

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.

.. |maintainer-dnplkndll| image:: https://github.com/dnplkndll.png?size=40px
:target: https://github.com/dnplkndll
:alt: dnplkndll

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-dnplkndll|

This module is part of the `OCA/project <https://github.com/OCA/project/tree/19.0/project_sequence_type>`_ 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_sequence_type/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions project_sequence_type/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2026 Ledo
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Project Sequence by Type",
"summary": "Give projects a different sequence depending on their type",
"version": "19.0.1.0.0",
"category": "Services/Project",
"website": "https://github.com/OCA/project",
"author": "Ledo, Odoo Community Association (OCA)",
"maintainers": ["dnplkndll"],
"license": "AGPL-3",
"application": False,
"installable": True,
"auto_install": True,
"depends": ["project_sequence", "project_type"],
"data": [
"views/project_type_views.xml",
],
}
2 changes: 2 additions & 0 deletions project_sequence_type/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import project_type
from . import project_project
25 changes: 25 additions & 0 deletions project_sequence_type/models/project_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2026 Ledo
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class ProjectProject(models.Model):
_inherit = "project.project"

@api.model_create_multi
def create(self, vals_list):
"""Use the project type's own sequence when it defines one.

``project_sequence`` fills ``sequence_code`` from the global
``project.sequence`` when the key is absent. We pre-fill it from the
type's sequence so that branch is skipped; types without a sequence
(or projects without a type) keep falling back to the default.
"""
for vals in vals_list:
if "sequence_code" in vals or not vals.get("type_id"):
continue
sequence = self.env["project.type"].browse(vals["type_id"]).sequence_id
if sequence:
vals["sequence_code"] = sequence.next_by_id()
return super().create(vals_list)
18 changes: 18 additions & 0 deletions project_sequence_type/models/project_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2026 Ledo
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProjectType(models.Model):
_inherit = "project.type"

sequence_id = fields.Many2one(
comodel_name="ir.sequence",
string="Project Sequence",
copy=False,
help=(
"Projects of this type take their sequence code from this sequence. "
"When left empty, the default project sequence is used."
),
)
3 changes: 3 additions & 0 deletions project_sequence_type/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions project_sequence_type/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Ledo
8 changes: 8 additions & 0 deletions project_sequence_type/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This module lets each project type define its own sequence, so projects
get a different numbering depending on their type.

It is a glue module between `project_sequence` and `project_type` and is
installed automatically when both are present.

Projects whose type has no sequence (or projects without a type) keep
using the default project sequence provided by `project_sequence`.
8 changes: 8 additions & 0 deletions project_sequence_type/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
1. Go to *Settings \> Technical \> Sequences & Identifiers \>
Sequences* and create one sequence per project type you want to
number separately (set its prefix, padding, etc. as usual).
2. Go to *Project \> Configuration \> Project Types*, open a type and
set its *Project Sequence* to the sequence created above.
3. Create a project of that type: its sequence code is taken from the
type's sequence. Types without a sequence keep using the default
project sequence.
Loading
Loading