Skip to content

Commit

Permalink
Merge PR #115 into 18.0
Browse files Browse the repository at this point in the history
Signed-off-by etobella
  • Loading branch information
OCA-git-bot committed Jan 14, 2025
2 parents 5d1f080 + b598954 commit 4a73f4f
Show file tree
Hide file tree
Showing 74 changed files with 11,008 additions and 0 deletions.
215 changes: 215 additions & 0 deletions edi_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
===
EDI
===

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3118073124de7f4dbeaf05a5afbf9cc5889f5ee7111ff311a10893490c2481c6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/18.0/edi_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-18-0/edi-framework-18-0-edi_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=18.0
:alt: Try me on Runboat

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

Base EDI backend.

Provides following models:

1. EDI Backend, to centralize configuration
2. EDI Backend Type, to classify EDI backends (eg: UBL, GS1, e-invoice,
pick-yours)
3. EDI Exchange Type, to define file types of exchange
4. EDI Exchange Record, to define a record exchanged between systems

Also define a mixin to be inherited by records that will generate EDIs

**Table of contents**

.. contents::
:local:

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

This module aims to provide an infrastructure to simplify
interchangability of documents between systems providing a configuration
platform. It will be inherited by other modules in order to define the
proper implementations of components.

In order to define a new Exchange Record, we need to configure:

- Backend Type
- Exchange Type
- Backend
- Components

Jobs
----

- (1) **Internal User**: might be an EDI user without even knowing
about it, triggering EDI flows by some of his actions on business
records; does not need access to related queue jobs.

- (2) **EDI User**: more conscious EDI user that might sometimes need
to debug things a bit further and thus needs access to related queue
jobs.

- (3) **EDI Manager**: full configuration access.

Component definition
--------------------

The component usage must be defined like edi.{direction}.{kind}.{code}
where:

- direction is output or input
- kind can be: generate, send, check, process, receive
- code is the {backend type code} or {backend type code}.{exchange type
code}

User EDI generation
-------------------

On the exchange type, it might be possible to define a set of models, a
domain and a snippet of code. After defining this fields, we will
automatically see buttons on the view to generate the exchange records.
This configuration is useful to define a way of generation managed by
user.

Exchange type rules configuration
---------------------------------

Exchange types can be further configured with rules. You can use rules
to:

1. make buttons automatically appear in forms
2. define your own custom logic

Go to an exchange type and go to the tab "Model rules". There you can
add one or more rule, one per model. On each rule you can define a
domain or a snippet to activate it. In case of a "Form button" kind, if
the domain and/ the snippet is/are satisfied, a form btn will appear on
the top of the form. This button can be used by the end user to manually
generate an exchange. If there's more than a backend and the exchange
type has not a backend set, a wizard will appear asking to select a
backend to be used for the exchange.

In case of "Custom" kind, you'll have to define your own logic to do
something.

Usage
=====

After certain operations or manual execution, Exchange records will be
generated. This Exchange records might be input records or outputs
records.

The change of state can be manually executed by the system or be managed
through by ir.cron.

Output Exchange records
-----------------------

An output record is intended to be used for exchange information from
Odoo to another system.

The flow of an output record should be:

- Creation
- Generation of data
- Validation of data
- Sending data
- Validation of data processed properly by the other party

Input Exchange records
----------------------

An input record is intended to be used for exchange information another
system to odoo.

The flow of an input record should be:

- Creation
- Reception of data
- Checking data
- Processing data

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

14.0.1.0.0
----------

The module name has been changed from edi to edi_oca.

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_oca%0Aversion:%2018.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
-------

* ACSONE
* Creu Blanca
* Camptocamp

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

- Simone Orsi <[email protected]>
- Enric Tobella <[email protected]>
- Manuel Regidor <[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.

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

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

|maintainer-simahawk| |maintainer-etobella|

This module is part of the `OCA/edi-framework <https://github.com/OCA/edi-framework/tree/18.0/edi_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions edi_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import components
from . import models
from . import wizards
53 changes: 53 additions & 0 deletions edi_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2020 ACSONE
# Copyright 2021 Camptocamp
# @author: Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "EDI",
"summary": """
Define backends, exchange types, exchange records,
basic automation and views for handling EDI exchanges.
""",
"version": "18.0.1.0.0",
"website": "https://github.com/OCA/edi-framework",
"development_status": "Beta",
"license": "LGPL-3",
"author": "ACSONE,Creu Blanca,Camptocamp,Odoo Community Association (OCA)",
"maintainers": ["simahawk", "etobella"],
"depends": [
"base_edi",
"component_event",
"mail",
"base_sparse_field",
"queue_job",
],
"external_dependencies": {"python": ["PyYAML"]},
"data": [
"wizards/edi_exchange_record_create_wiz.xml",
"data/cron.xml",
"data/ir_actions_server.xml",
"data/sequence.xml",
"data/job_channel.xml",
"data/job_function.xml",
"security/res_groups.xml",
"security/ir_model_access.xml",
"views/edi_backend_views.xml",
"views/edi_backend_type_views.xml",
"views/edi_exchange_record_views.xml",
"views/edi_exchange_type_views.xml",
"views/edi_exchange_type_rule_views.xml",
"views/res_partner.xml",
"views/menuitems.xml",
"templates/exchange_chatter_msg.xml",
"templates/exchange_mixin_buttons.xml",
],
"assets": {
"web.assets_backend": [
"edi_oca/static/src/js/widget_edi.esm.js",
"edi_oca/static/src/xml/widget_edi.xml",
],
},
"demo": ["demo/edi_backend_demo.xml"],
"installable": True,
}
4 changes: 4 additions & 0 deletions edi_oca/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import base
from . import base_output
from . import base_input
from . import base_validate
72 changes: 72 additions & 0 deletions edi_oca/components/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright 2020 ACSONE
# @author: Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo.addons.component.core import AbstractComponent


class EDIBackendComponentMixin(AbstractComponent):
"""Generic mixin for all EDI components."""

_name = "edi.component.base.mixin"
_collection = "edi.backend"
_usage = None
_backend_type = None
_exchange_type = None

def __init__(self, work_context):
super().__init__(work_context)
self.backend = work_context.backend

@staticmethod
def _match_attrs():
"""Attributes to be used for matching this component.
By default, match by backend and exchange type.
NOTE: the class attribute must have an underscore, the name here not.
"""
return ("backend_type", "exchange_type")

@classmethod
def _component_match(cls, work, usage=None, model_name=None, **kw):
"""Override to customize match.
Registry lookup filtered by usage and model_name when landing here.
Now, narrow match to `_match_attrs` attributes.
"""
match_attrs = cls._match_attrs()
if not any([kw.get(k) for k in match_attrs]):
# No attr to check
return True

backend_type = kw.get("backend_type")
exchange_type = kw.get("exchange_type")

if cls._backend_type and cls._exchange_type:
# They must match both
return (
cls._backend_type == backend_type
and cls._exchange_type == exchange_type
)

if cls._backend_type not in (None, kw.get("backend_type")):
return False

if cls._exchange_type not in (None, kw.get("exchange_type")):
return False

return True


class EDIBackendRecordComponentMixin(AbstractComponent):
"""Generic mixin for record-bound components."""

_name = "edi.component.mixin"
_inherit = "edi.component.base.mixin"

def __init__(self, work_context):
super().__init__(work_context)
self.exchange_record = work_context.exchange_record
self.record = self.exchange_record.record
self.type_settings = self.exchange_record.type_id.get_settings()
23 changes: 23 additions & 0 deletions edi_oca/components/base_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2020 ACSONE
# @author: Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo.addons.component.core import AbstractComponent


class EDIBackendInputComponentMixin(AbstractComponent):
"""Generate input content."""

_name = "edi.component.input.mixin"
_inherit = "edi.component.mixin"

def process(self):
raise NotImplementedError()


class EDIBackendReceiveComponentMixin(AbstractComponent):
_name = "edi.component.receive.mixin"
_inherit = "edi.component.mixin"

def receive(self):
raise NotImplementedError()
Loading

0 comments on commit 4a73f4f

Please sign in to comment.