Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] project_type_sequence: New field "Sequence" in project type. #298

Closed
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
30 changes: 30 additions & 0 deletions project_type_sequence/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. 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

=====================
Project type sequence
=====================

* When a project is created and is associated with a project type with a
defined sequence, the new project will be registered with said sequence,
otherwise the general sequence for projects will be used.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/avanzosc/project-addons/issues>`_. In case of trouble,
please check there if your issue has already been reported. If you spotted
it first, help us smash it by providing detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

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

* Ana Juaristi <[email protected]>
* Alfredo de la Fuente <[email protected]>
1 change: 1 addition & 0 deletions project_type_sequence/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions project_type_sequence/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Project Type Sequence",
"version": "16.0.1.0.0",
"category": "Services/Project",
"license": "AGPL-3",
"author": "AvanzOSC",
"website": "https://github.com/avanzosc/project-addons",
"depends": ["sale_project", "project_type", "project_sequence"],
"data": [
"views/project_type_views.xml",
"views/project_project_views.xml",
],
"installable": True,
}
36 changes: 36 additions & 0 deletions project_type_sequence/i18n/ca_ES.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_type_sequence
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-14 09:26+0000\n"
"PO-Revision-Date: 2024-10-14 09:26+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: project_type_sequence
#: model:ir.model,name:project_type_sequence.model_project_project
msgid "Project"
msgstr "Projecte"

#. module: project_type_sequence
#: model:ir.model,name:project_type_sequence.model_project_type
msgid "Project Type"
msgstr "Tipus de Projectes"

#. module: project_type_sequence
#: model:ir.model.fields,field_description:project_type_sequence.field_project_type__sequence_id
msgid "Sequence"
msgstr ""

#. module: project_type_sequence
#: model_terms:ir.ui.view,arch_db:project_type_sequence.project_project_view_form_simplified
msgid "Type of project"
msgstr ""
36 changes: 36 additions & 0 deletions project_type_sequence/i18n/en_GB.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_type_sequence
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-14 09:27+0000\n"
"PO-Revision-Date: 2024-10-14 09:27+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: project_type_sequence
#: model:ir.model,name:project_type_sequence.model_project_project
msgid "Project"
msgstr ""

#. module: project_type_sequence
#: model:ir.model,name:project_type_sequence.model_project_type
msgid "Project Type"
msgstr ""

#. module: project_type_sequence
#: model:ir.model.fields,field_description:project_type_sequence.field_project_type__sequence_id
msgid "Sequence"
msgstr ""

#. module: project_type_sequence
#: model_terms:ir.ui.view,arch_db:project_type_sequence.project_project_view_form_simplified
msgid "Type of project"
msgstr ""
36 changes: 36 additions & 0 deletions project_type_sequence/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_type_sequence
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-14 09:27+0000\n"
"PO-Revision-Date: 2024-10-14 09:27+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: project_type_sequence
#: model:ir.model,name:project_type_sequence.model_project_project
msgid "Project"
msgstr "Proyecto"

#. module: project_type_sequence
#: model:ir.model,name:project_type_sequence.model_project_type
msgid "Project Type"
msgstr "Tipos de Proyectos"

#. module: project_type_sequence
#: model:ir.model.fields,field_description:project_type_sequence.field_project_type__sequence_id
msgid "Sequence"
msgstr "Secuencia"

#. module: project_type_sequence
#: model_terms:ir.ui.view,arch_db:project_type_sequence.project_project_view_form_simplified
msgid "Type of project"
msgstr "Tipo de proyecto"
36 changes: 36 additions & 0 deletions project_type_sequence/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_type_sequence
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-14 09:27+0000\n"
"PO-Revision-Date: 2024-10-14 09:27+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: project_type_sequence
#: model:ir.model,name:project_type_sequence.model_project_project
msgid "Project"
msgstr "Projet"

#. module: project_type_sequence
#: model:ir.model,name:project_type_sequence.model_project_type
msgid "Project Type"
msgstr "Type de projet"

#. module: project_type_sequence
#: model:ir.model.fields,field_description:project_type_sequence.field_project_type__sequence_id
msgid "Sequence"
msgstr ""

#. module: project_type_sequence
#: model_terms:ir.ui.view,arch_db:project_type_sequence.project_project_view_form_simplified
msgid "Type of project"
msgstr ""
36 changes: 36 additions & 0 deletions project_type_sequence/i18n/project_type_sequence.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_type_sequence
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-14 09:26+0000\n"
"PO-Revision-Date: 2024-10-14 09:26+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: project_type_sequence
#: model:ir.model,name:project_type_sequence.model_project_project
msgid "Project"
msgstr ""

#. module: project_type_sequence
#: model:ir.model,name:project_type_sequence.model_project_type
msgid "Project Type"
msgstr ""

#. module: project_type_sequence
#: model:ir.model.fields,field_description:project_type_sequence.field_project_type__sequence_id
msgid "Sequence"
msgstr ""

#. module: project_type_sequence
#: model_terms:ir.ui.view,arch_db:project_type_sequence.project_project_view_form_simplified
msgid "Type of project"
msgstr ""
3 changes: 3 additions & 0 deletions project_type_sequence/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import project_type
from . import project_project
from . import sale_order_line
29 changes: 29 additions & 0 deletions project_type_sequence/models/project_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, models


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

@api.model_create_multi
def create(self, vals_list):
context = self.env.context
ProjectType = self.env["project.type"]
for vals in vals_list:
if "name" in vals and "from_sale_line" not in context:
vals.pop("name")
type_id = vals.get("type_id")
if "sequence_code" not in vals and type_id:
project_type = ProjectType.browse(type_id)
if project_type.sequence_id:
sequence_code = project_type.sequence_id.next_by_id()
vals["sequence_code"] = sequence_code
if "name" in vals and "from_sale_line" in context:
vals["name"] = f"{sequence_code} - {vals['name']}"
projects = super().create(vals_list)
if "from_sale_line" in context:
for project in projects:
if project.sequence_code and project.sequence_code not in project.name:
project.name = f"{project.sequence_code} - {project.name}"
return projects
9 changes: 9 additions & 0 deletions project_type_sequence/models/project_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models


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

sequence_id = fields.Many2one(string="Sequence", comodel_name="ir.sequence")
12 changes: 12 additions & 0 deletions project_type_sequence/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

def _timesheet_create_project(self):
return super(
SaleOrderLine, self.with_context(from_sale_line=True)
)._timesheet_create_project()
43 changes: 43 additions & 0 deletions project_type_sequence/views/project_project_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record model="ir.ui.view" id="project_project_view_form_simplified">
<field name="model">project.project</field>
<field name="inherit_id" ref="project.project_project_view_form_simplified" />
<field name="arch" type="xml">
<field name="user_id" position="before">
<div name="project-type">
<label
for="type_id"
class="oe_inline mt-4"
string="Type of project"
/>
<field name="type_id" />
</div>
</field>
</field>
</record>

<record model="ir.ui.view" id="project_sequence_form_view">
<field name="model">project.project</field>
<field name="inherit_id" ref="project_sequence.project_sequence_form_view" />
<field name="arch" type="xml">
<div name="sequence_code" position="attributes">
<attribute name="invisible">1</attribute>
</div>
</field>
</record>

<record model="ir.ui.view" id="project_sequence_tree_view">
<field name="model">project.project</field>
<field name="inherit_id" ref="project_sequence.project_sequence_tree_view" />
<field name="arch" type="xml">
<field name="sequence_code" position="attributes">
<attribute name="invisible">1</attribute>
</field>
</field>
</record>

<record model="ir.ui.view" id="project_sequence.project_sequence_search_view">
<field name="active">False</field>
</record>
</odoo>
34 changes: 34 additions & 0 deletions project_type_sequence/views/project_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record model="ir.ui.view" id="project_type_form">
<field name="model">project.type</field>
<field name="inherit_id" ref="project_type.project_type_form" />
<field name="arch" type="xml">
<field name="code" position="before">
<field name="sequence_id" />
</field>
</field>
</record>

<record model="ir.ui.view" id="project_type_search">
<field name="model">project.type</field>
<field name="inherit_id" ref="project_type.project_type_search" />
<field name="arch" type="xml">
<field name="parent_id" position="after">
<field name="sequence_id" />
</field>
</field>
</record>

<record id="project_type_tree" model="ir.ui.view">
<field name="model">project.type</field>
<field name="arch" type="xml">
<tree>
<field name="complete_name" />
<field name="sequence_id" optional="show" />
<field name="project_ok" optional="show" />
<field name="task_ok" optional="show" />
</tree>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/project_type_sequence/setup.py
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,
)
Loading