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_party_data_oca: Migration to 16.0 #812

Closed
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
133 changes: 133 additions & 0 deletions edi_party_data_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
==============
EDI Party data
==============

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

.. |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-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%2Fedi-lightgray.png?logo=github
:target: https://github.com/OCA/edi/tree/16.0/edi_party_data_oca
:alt: OCA/edi
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-edi_party_data_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&target_branch=16.0
:alt: Try me on Runboat

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

Technical module for the EDI suite module to retrieve data for parties of an exchange.

This module provides default component
and a mixin to be used for registering new components for specific backends.

It's based on `partner_identification`
so that the party information will include allowed ID numbers for a given exchange.

You can configure which ID number categories are allowed on the exchange type.

.. 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
=============

ID numbers selection
~~~~~~~~~~~~~~~~~~~~

On the exchange type form, find the field "ID categories"
and set the categories allowed for that exchange type.

If not set, *all the IDs* of the partner will be exposed.

Name field
~~~~~~~~~~

On the exchange type form, modify the advanced settings
so that the work context of the component that is used (eg: generate)
contains `party_data_name_field`. For instance::

components:
generate:
usage: my.generate
work_ctx:
party_data_name_field: name

Usage
=====

An handy util method is to retrive the component::

from odoo.addons.edi_party_data_oca.utils import get_party_data_component

component = get_party_data_component(exchange_record, partner)

data = component.get_party()

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi/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/issues/new?body=module:%20edi_party_data_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]>

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 <https://github.com/OCA/edi/tree/16.0/edi_party_data_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions edi_party_data_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import components
from . import models
19 changes: 19 additions & 0 deletions edi_party_data_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2022 Camptocamp SA
# @author: Simone Orsi <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "EDI Party data",
"summary": """
Allow to configure and retrieve party information for EDI exchanges.
""",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"license": "AGPL-3",
"website": "https://github.com/OCA/edi",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["simahawk"],
"depends": ["edi_oca", "partner_identification"],
"data": [
"views/edi_exchange_type_views.xml",
],
}
2 changes: 2 additions & 0 deletions edi_party_data_oca/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import common
from . import party_data
73 changes: 73 additions & 0 deletions edi_party_data_oca/components/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2022 Camptocamp SA
# @author: Simone Orsi <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tools import DotDict

from odoo.addons.component.core import AbstractComponent


class EDIExchangePartyDataMixin(AbstractComponent):
"""Abstract component mixin provide partner data for exchanges."""

_name = "edi.party.data.mixin"
_inherit = "edi.component.mixin"
_collection = "edi.backend"
_usage = "edi.party.data"

def __init__(self, work_context):
super().__init__(work_context)
self.partner = self._get_partner()
self.allowed_id_categories = self.exchange_record.type_id.id_category_ids

def _get_partner(self):
# Hook here to define different logic to lookup for the partner
# based on current partner (eg: pick the parent).
return self.work.partner

def get_party(self):
"""Return party information.

Requires a res.partner to be passed via work context.

:return: odoo.tools.DotDict
"""
return self._party_from_partner()

def _party_from_partner(self, **kw):
# NB: for UBL this should probably replace `base.ubl._ubl_get_party_identification`
# which does nothing today.
party = DotDict(
name=self._get_name(),
identifiers=self._get_identifiers(),
# TODO: is this only for UBL?
endpoint=self._get_endpoint(),
)
party.update(kw)
return party

def _get_name(self):
name_field = getattr(self.work, "party_data_name_field", "display_name")
return self.partner[name_field]

def _get_endpoint(self):
return {}

def _get_identifiers(self):
identifiers = self.partner.id_numbers.filtered(
lambda x: self._filter_id_number(x)
)
return [self._get_indentity(x) for x in identifiers]

def _filter_id_number(self, id_number):
if self.allowed_id_categories:
return id_number.category_id in self.allowed_id_categories
return True

def _get_indentity(self, id_number):
return DotDict(
attrs={
"schemeID": id_number.category_id.code,
},
value=id_number.name,
)
12 changes: 12 additions & 0 deletions edi_party_data_oca/components/party_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2022 Camptocamp SA
# @author: Simone Orsi <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.component.core import Component


class EDIPartyData(Component):
"""Default component to lookup for party information."""

_name = "edi.party.data"
_inherit = "edi.party.data.mixin"
44 changes: 44 additions & 0 deletions edi_party_data_oca/i18n/edi_party_data_oca.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * edi_party_data_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_party_data_oca
#: model:ir.model.fields,help:edi_party_data_oca.field_edi_exchange_type__id_category_ids
msgid "Allowed ID categories to be used to generate parties information."
msgstr ""

#. module: edi_party_data_oca
#: model:ir.model.fields,field_description:edi_party_data_oca.field_edi_exchange_type__display_name
msgid "Display Name"
msgstr ""

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

#. module: edi_party_data_oca
#: model:ir.model.fields,field_description:edi_party_data_oca.field_edi_exchange_type__id
msgid "ID"
msgstr ""

#. module: edi_party_data_oca
#: model:ir.model.fields,field_description:edi_party_data_oca.field_edi_exchange_type__id_category_ids
msgid "ID categories"
msgstr ""

#. module: edi_party_data_oca
#: model:ir.model.fields,field_description:edi_party_data_oca.field_edi_exchange_type____last_update
msgid "Last Modified on"
msgstr ""
1 change: 1 addition & 0 deletions edi_party_data_oca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import edi_exchange_type
16 changes: 16 additions & 0 deletions edi_party_data_oca/models/edi_exchange_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2022 Camptocamp SA
# @author Simone Orsi <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class EDIExchangeType(models.Model):

_inherit = "edi.exchange.type"

id_category_ids = fields.Many2many(
string="ID categories",
comodel_name="res.partner.id_category",
help="Allowed ID categories to be used to generate parties information.",
)
20 changes: 20 additions & 0 deletions edi_party_data_oca/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ID numbers selection
~~~~~~~~~~~~~~~~~~~~

On the exchange type form, find the field "ID categories"
and set the categories allowed for that exchange type.

If not set, *all the IDs* of the partner will be exposed.

Name field
~~~~~~~~~~

On the exchange type form, modify the advanced settings
so that the work context of the component that is used (eg: generate)
contains `party_data_name_field`. For instance::

components:
generate:
usage: my.generate
work_ctx:
party_data_name_field: name
2 changes: 2 additions & 0 deletions edi_party_data_oca/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Simone Orsi <[email protected]>
* Duong (Tran Quoc) <[email protected]>
9 changes: 9 additions & 0 deletions edi_party_data_oca/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Technical module for the EDI suite module to retrieve data for parties of an exchange.

This module provides default component
and a mixin to be used for registering new components for specific backends.

It's based on `partner_identification`
so that the party information will include allowed ID numbers for a given exchange.

You can configure which ID number categories are allowed on the exchange type.
7 changes: 7 additions & 0 deletions edi_party_data_oca/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
An handy util method is to retrive the component::

from odoo.addons.edi_party_data_oca.utils import get_party_data_component

component = get_party_data_component(exchange_record, partner)

data = component.get_party()
Binary file added edi_party_data_oca/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading