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][MIG] edi_state_oca: Migration to 16.0 #22

Merged
merged 9 commits into from
Oct 10, 2023
Merged
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
124 changes: 124 additions & 0 deletions edi_state_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
=========
EDI state
=========

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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/16.0/edi_state_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-16-0/edi-framework-16-0-edi_state_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=16.0
:alt: Try me on Runboat

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

Technical module for the EDI suite to provide additional states for any records.

Example: a SO is generated via UBL file and you want to provide an ORDRSP with the right state on the order and on each line.

It provides 2 new models:

* EDI state workflow

* groups states together
* limit states to a specific model

* EDI state

* describe the state of the record

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Configuration
=============

Go to "EDI -> Config -> States" and configure workflow and states.
Go to "EDI -> Config -> EDI Exchange Type" and enable 1 or more workflow on a given type.

Usage
=====

Add the mixin `edi.state.consumer.mixin` to the model that will use states.

Known issues / Roadmap
======================

* automatized state transitions (via domain and / or code snippet)

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_state_oca%0Aversion:%2016.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
~~~~~~~~~~~~

* Simone Orsi <[email protected]>
* Duong (Tran Quoc) <[email protected]>

Other credits
~~~~~~~~~~~~~

The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp

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-simahawk| image:: https://github.com/simahawk.png?size=40px
:target: https://github.com/simahawk
:alt: simahawk

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

|maintainer-simahawk|

This module is part of the `OCA/edi-framework <https://github.com/OCA/edi-framework/tree/16.0/edi_state_oca>`_ 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 edi_state_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
24 changes: 24 additions & 0 deletions edi_state_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 Camptocamp SA
# @author: Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "EDI state",
"summary": """
Allow to assign specific EDI states to related records.
""",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"license": "LGPL-3",
"website": "https://github.com/OCA/edi-framework",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["simahawk"],
"depends": ["edi_oca"],
"data": [
"security/ir_model_access.xml",
"views/edi_exchange_type.xml",
"views/edi_state_workflow.xml",
"views/edi_state.xml",
"views/menuitems.xml",
],
}
194 changes: 194 additions & 0 deletions edi_state_oca/i18n/edi_state_oca.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * edi_state_oca
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \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: edi_state_oca
#: model:ir.model.fields,help:edi_state_oca.field_edi_exchange_type__state_workflow_ids
msgid ""
"Allowed workflows that can be used by this type of exchanges. You can select"
" only 1 workflow per model."
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow__state_ids
msgid "Available states"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow__backend_type_id
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_workflow_view_search
msgid "Backend type"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state__code
msgid "Code"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.constraint,message:edi_state_oca.constraint_edi_state_state_workflow_code_uniq
msgid "Code must be unique per each workflow."
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state__create_uid
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow__create_uid
msgid "Created by"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state__create_date
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow__create_date
msgid "Created on"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state__description
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow__description
msgid "Description"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_exchange_type__display_name
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state__display_name
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_consumer_mixin__display_name
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow__display_name
msgid "Display Name"
msgstr ""

#. module: edi_state_oca
#: model:ir.model,name:edi_state_oca.model_edi_exchange_type
msgid "EDI Exchange Type"
msgstr ""

#. module: edi_state_oca
#: model:ir.model,name:edi_state_oca.model_edi_state
msgid "EDI specific state."
msgstr ""

#. module: edi_state_oca
#: model:ir.actions.act_window,name:edi_state_oca.act_open_edi_state_view
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_consumer_mixin__edi_state_id
#: model:ir.ui.menu,name:edi_state_oca.menu_edi_state
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_view_form
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_view_search
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_view_tree
msgid "EDI state"
msgstr ""

#. module: edi_state_oca
#: model:ir.actions.act_window,name:edi_state_oca.act_open_edi_state_workflow_view
#: model:ir.ui.menu,name:edi_state_oca.menu_edi_state_workflow
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_workflow_view_form
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_workflow_view_search
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_workflow_view_tree
msgid "EDI state workflow"
msgstr ""

#. module: edi_state_oca
#: model:ir.model,name:edi_state_oca.model_edi_state_workflow
msgid "EDI state workflow."
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_exchange_type__state_workflow_ids
msgid "Enabled state workflows"
msgstr ""

#. module: edi_state_oca
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_view_search
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_workflow_view_search
msgid "Group By"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_exchange_type__id
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state__id
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_consumer_mixin__id
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow__id
msgid "ID"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state__is_default
msgid "Is Default"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_exchange_type____last_update
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state____last_update
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_consumer_mixin____last_update
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow____last_update
msgid "Last Modified on"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state__write_uid
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow__write_uid
msgid "Last Updated by"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state__write_date
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow__write_date
msgid "Last Updated on"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow__model_id
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_workflow_view_search
msgid "Model"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state__name
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_workflow__name
msgid "Name"
msgstr ""

#. module: edi_state_oca
#: code:addons/edi_state_oca/models/edi_state.py:0
#, python-format
msgid "Only one state per workflow can be the default one."
msgstr ""

#. module: edi_state_oca
#: code:addons/edi_state_oca/models/edi_exchange_type.py:0
#, python-format
msgid "Only one workflow per model is allowed"
msgstr ""

#. module: edi_state_oca
#: model:ir.model,name:edi_state_oca.model_edi_state_consumer_mixin
msgid "Provide specific EDI states for related records."
msgstr ""

#. module: edi_state_oca
#: code:addons/edi_state_oca/models/edi_state_consumer_mixin.py:0
#, python-format
msgid "State %(name)s [%(code)s] not allowed"
msgstr ""

#. module: edi_state_oca
#: model:ir.ui.menu,name:edi_state_oca.menu_edi_state_root
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_workflow_view_form
msgid "States"
msgstr ""

#. module: edi_state_oca
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state__workflow_id
#: model:ir.model.fields,field_description:edi_state_oca.field_edi_state_consumer_mixin__edi_state_workflow_id
#: model_terms:ir.ui.view,arch_db:edi_state_oca.edi_state_view_search
msgid "Workflow"
msgstr ""
4 changes: 4 additions & 0 deletions edi_state_oca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import edi_exchange_type
from . import edi_state
from . import edi_state_workflow
from . import edi_state_consumer_mixin
31 changes: 31 additions & 0 deletions edi_state_oca/models/edi_exchange_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023 Camptocamp SA
# @author Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import _, api, exceptions, fields, models


class EDIExchangeType(models.Model):

_inherit = "edi.exchange.type"

state_workflow_ids = fields.Many2many(
string="Enabled state workflows",
comodel_name="edi.state.workflow",
help=(
"Allowed workflows that can be used by this type of exchanges. "
"You can select only 1 workflow per model."
),
)

@api.constrains("state_workflow_ids")
def _check_workflow_models(self):
for rec in self:
models = [x.model_id.id for x in rec.state_workflow_ids]
if any([(models.count(x) > 1) for x in models]):
raise exceptions.UserError(_("Only one workflow per model is allowed"))

def get_state_for_model(self, model, code=None, default=False):
assert code or default
wf = self.state_workflow_ids.filtered(lambda x: x.model_id.model == model)
return wf.get_state(code) if code else wf.get_default_state()
Loading
Loading