-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Showing
17 changed files
with
1,083 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,137 @@ | ||
=========== | ||
Edi Project | ||
=========== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:c50da2c108f9f404566d0cf21a1cbf15c1d508f761b9841d1f1a99abad4e80b1 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi--framework-lightgray.png?logo=github | ||
:target: https://github.com/OCA/edi-framework/tree/17.0/edi_project_oca | ||
:alt: OCA/edi-framework | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/edi-framework-17-0/edi-framework-17-0-edi_project_oca | ||
: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/edi-framework&target_branch=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module intends to create a base to be extended by local EDI rules | ||
for project management. | ||
|
||
In order to add customizations for projects, create a listener: | ||
|
||
.. code:: python | ||
from odoo.addons.component.core import Component | ||
class ProjectEventListenerExample(Component): | ||
_name = "project.project.event.listener.example" | ||
_inherit = "base.event.listener" | ||
_apply_on = ["project.project"] | ||
def on_project_create(self, project, vals: dict): | ||
"""Do stuff after the project has been created""" | ||
def on_project_write(self, project, vals: dict): | ||
"""Do stuff after the project has been updated""" | ||
def on_project_unlink(self, project): | ||
"""Do stuff before the project gets deleted""" | ||
In order to add customizations for tasks, create a listener: | ||
|
||
.. code:: python | ||
from odoo.addons.component.core import Component | ||
class ProjectTaskEventListenerExample(Component): | ||
_name = "project.task.event.listener.example" | ||
_inherit = "base.event.listener" | ||
_apply_on = ["project.task"] | ||
def on_task_create(self, task, vals: dict): | ||
"""Do stuff after the task has been created""" | ||
def on_task_write(self, task, vals: dict): | ||
"""Do stuff after the task has been updated""" | ||
def on_task_unlink(self, task): | ||
"""Do stuff before the task gets deleted""" | ||
Use ``@skip_if()`` decorator to avoid triggering a listener's method if | ||
necessary: | ||
|
||
.. code:: python | ||
from odoo.addons.component.core import Component | ||
from odoo.addons.component_event import skip_if | ||
class ProjectTaskEventListenerExample(Component): | ||
_name = "project.task.event.listener.example" | ||
_inherit = "base.event.listener" | ||
_apply_on = ["project.task"] | ||
@skip_if(lambda self, task: not task.stage_id) # Do nothing if the task has no stage | ||
def on_task_create(self, task): | ||
"""Do stuff after the task has been created""" | ||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi-framework/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/edi-framework/issues/new?body=module:%20edi_project_oca%0Aversion:%2017.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 | ||
------- | ||
|
||
* Camptocamp | ||
|
||
Contributors | ||
------------ | ||
|
||
- Silvio Gregorini <[email protected]> | ||
|
||
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. | ||
|
||
This module is part of the `OCA/edi-framework <https://github.com/OCA/edi-framework/tree/17.0/edi_project_oca>`_ 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 |
---|---|---|
@@ -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 2024 Camptocamp SA | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Edi Project", | ||
"summary": """ | ||
Define EDI Configuration for Projects and Tasks | ||
""", | ||
"version": "17.0.1.0.0", | ||
"license": "LGPL-3", | ||
"author": "Camptocamp,Odoo Community Association (OCA)", | ||
"development_status": "Beta", | ||
"website": "https://github.com/OCA/edi-framework", | ||
"depends": [ | ||
# Odoo addons | ||
"project", | ||
# OCA/connector | ||
"component_event", | ||
# OCA/edi-framework | ||
"edi_oca", | ||
], | ||
"data": [ | ||
"views/edi_exchange_record.xml", | ||
"views/project_project.xml", | ||
"views/project_task.xml", | ||
], | ||
"demo": [], | ||
} |
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 @@ | ||
from . import project_project | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ProjectProject(models.Model): | ||
_name = "project.project" | ||
_inherit = ["project.project", "edi.exchange.consumer.mixin"] | ||
|
||
edi_disable_auto = fields.Boolean() | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
projects = super().create(vals_list) | ||
for project, vals in zip(projects, vals_list, strict=True): | ||
project._event("on_project_create").notify(project, vals) | ||
return projects | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
for project in self: | ||
project._event("on_project_write").notify(project, vals) | ||
return res | ||
|
||
def unlink(self): | ||
for project in self: | ||
project._event("on_project_unlink").notify(project) | ||
return super().unlink() |
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,29 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ProjectTask(models.Model): | ||
_name = "project.task" | ||
_inherit = ["project.task", "edi.exchange.consumer.mixin"] | ||
|
||
edi_disable_auto = fields.Boolean() | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
tasks = super().create(vals_list) | ||
for task, vals in zip(tasks, vals_list, strict=True): | ||
task._event("on_task_create").notify(task, vals) | ||
return tasks | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
for task in self: | ||
task._event("on_task_write").notify(task, vals) | ||
return res | ||
|
||
def unlink(self): | ||
for task in self: | ||
task._event("on_task_unlink").notify(task) | ||
return super().unlink() |
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,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
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 @@ | ||
- Silvio Gregorini \<<[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,61 @@ | ||
This module intends to create a base to be extended by local EDI rules | ||
for project management. | ||
|
||
In order to add customizations for projects, create a listener: | ||
|
||
```python | ||
from odoo.addons.component.core import Component | ||
|
||
|
||
class ProjectEventListenerExample(Component): | ||
_name = "project.project.event.listener.example" | ||
_inherit = "base.event.listener" | ||
_apply_on = ["project.project"] | ||
|
||
def on_project_create(self, project, vals: dict): | ||
"""Do stuff after the project has been created""" | ||
|
||
def on_project_write(self, project, vals: dict): | ||
"""Do stuff after the project has been updated""" | ||
|
||
def on_project_unlink(self, project): | ||
"""Do stuff before the project gets deleted""" | ||
``` | ||
|
||
In order to add customizations for tasks, create a listener: | ||
|
||
```python | ||
from odoo.addons.component.core import Component | ||
|
||
|
||
class ProjectTaskEventListenerExample(Component): | ||
_name = "project.task.event.listener.example" | ||
_inherit = "base.event.listener" | ||
_apply_on = ["project.task"] | ||
|
||
def on_task_create(self, task, vals: dict): | ||
"""Do stuff after the task has been created""" | ||
|
||
def on_task_write(self, task, vals: dict): | ||
"""Do stuff after the task has been updated""" | ||
|
||
def on_task_unlink(self, task): | ||
"""Do stuff before the task gets deleted""" | ||
``` | ||
|
||
Use ``@skip_if()`` decorator to avoid triggering a listener's method if necessary: | ||
|
||
```python | ||
from odoo.addons.component.core import Component | ||
from odoo.addons.component_event import skip_if | ||
|
||
|
||
class ProjectTaskEventListenerExample(Component): | ||
_name = "project.task.event.listener.example" | ||
_inherit = "base.event.listener" | ||
_apply_on = ["project.task"] | ||
|
||
@skip_if(lambda self, task: not task.stage_id) # Do nothing if the task has no stage | ||
def on_task_create(self, task): | ||
"""Do stuff after the task has been created""" | ||
``` |
Oops, something went wrong.