Skip to content
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ addon | version | maintainers | summary
[edi_account_core_oca](edi_account_core_oca/) | 18.0.1.1.1 | <a href='https://github.com/etobella'><img src='https://github.com/etobella.png' width='32' height='32' style='border-radius:50%;' alt='etobella'/></a> | Define EDI Configuration for Account Moves
[edi_account_oca](edi_account_oca/) | 18.0.1.1.1 | <a href='https://github.com/etobella'><img src='https://github.com/etobella.png' width='32' height='32' style='border-radius:50%;' alt='etobella'/></a> | Define some component listeners for Account Moves
[edi_component_oca](edi_component_oca/) | 18.0.1.1.0 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> <a href='https://github.com/etobella'><img src='https://github.com/etobella.png' width='32' height='32' style='border-radius:50%;' alt='etobella'/></a> | Allow to use Connector as a source in EDI
[edi_core_oca](edi_core_oca/) | 18.0.1.7.2 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> <a href='https://github.com/etobella'><img src='https://github.com/etobella.png' width='32' height='32' style='border-radius:50%;' alt='etobella'/></a> | Define backends, exchange types, exchange records, basic automation and views for handling EDI exchanges.
[edi_core_oca](edi_core_oca/) | 18.0.1.7.3 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> <a href='https://github.com/etobella'><img src='https://github.com/etobella.png' width='32' height='32' style='border-radius:50%;' alt='etobella'/></a> | Define backends, exchange types, exchange records, basic automation and views for handling EDI exchanges.
[edi_endpoint_oca](edi_endpoint_oca/) | 18.0.1.0.3 | | Base module allowing configuration of custom endpoints for EDI framework.
[edi_exchange_deduplicate_oca](edi_exchange_deduplicate_oca/) | 18.0.1.0.0 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> <a href='https://github.com/etobella'><img src='https://github.com/etobella.png' width='32' height='32' style='border-radius:50%;' alt='etobella'/></a> | Introduce a deduplication mechanism at the sending step
[edi_exchange_template_oca](edi_exchange_template_oca/) | 18.0.1.3.3 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> | Allows definition of exchanges via templates.
[edi_exchange_template_party_data](edi_exchange_template_party_data/) | 18.0.1.0.1 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> | Glue module between edi_exchange_template and edi_party_data
[edi_notification_oca](edi_notification_oca/) | 18.0.1.0.0 | | Define notification activities on exchange records.
Expand Down
2 changes: 1 addition & 1 deletion edi_core_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ EDI
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5e54bc58f7c88ff2eaac2207226e25488a4aa47b800e1cdc606f485cf0523830
!! source digest: sha256:a2ec0c8c9a701363efa1965a3296fbc0972859cf5c22504865d391c74d13ab86
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion edi_core_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Define backends, exchange types, exchange records,
basic automation and views for handling EDI exchanges.
""",
"version": "18.0.1.7.2",
"version": "18.0.1.7.3",
"website": "https://github.com/OCA/edi-framework",
"development_status": "Beta",
"license": "LGPL-3",
Expand Down
1 change: 1 addition & 0 deletions edi_core_oca/models/edi_exchange_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class EDIExchangeType(models.Model):
rule_ids = fields.One2many(
comodel_name="edi.exchange.type.rule",
inverse_name="type_id",
context={"active_test": False},
help="Rules to handle exchanges and UI automatically",
)
quick_exec = fields.Boolean(
Expand Down
2 changes: 1 addition & 1 deletion edi_core_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>EDI</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5e54bc58f7c88ff2eaac2207226e25488a4aa47b800e1cdc606f485cf0523830
!! source digest: sha256:a2ec0c8c9a701363efa1965a3296fbc0972859cf5c22504865d391c74d13ab86
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/edi-framework/tree/18.0/edi_core_oca"><img alt="OCA/edi-framework" src="https://img.shields.io/badge/github-OCA%2Fedi--framework-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/edi-framework-18-0/edi-framework-18-0-edi_core_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/edi-framework&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Base EDI backend.</p>
Expand Down
80 changes: 63 additions & 17 deletions edi_core_oca/tests/test_exchange_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from freezegun import freeze_time

from odoo.fields import Command
from odoo.tools import mute_logger

from .common import EDIBackendCommonTestCase
Expand Down Expand Up @@ -147,26 +148,71 @@ def test_filename_pattern_settings(self):
self._test_exchange_filename("Test-File-0000001.csv")

def test_archive_rules(self):
exc_type = self.exchange_type_out
rule1 = exc_type.rule_ids.create(
{
"type_id": exc_type.id,
"name": "Fake partner rule",
"model_id": self.env["ir.model"]._get("res.partner").id,
}
)
rule2 = exc_type.rule_ids.create(
# Make sure to drop the ``active_test`` flag to be able to properly test
# whether archived rules can be found in the exchange type O2M field
ctx = dict(self.env.context)
ctx.pop("active_test", None)
exc_type = self.exchange_type_out.with_context(ctx) # pylint: disable=W8121
exc_type.write(
{
"type_id": exc_type.id,
"name": "Fake user rule",
"model_id": self.env["ir.model"]._get("res.users").id,
"rule_ids": [
Command.clear(), # Drop preexisting rules to avoid pollution
Command.create(
{
"name": "Fake partner rule",
"model_id": self.env["ir.model"]._get("res.partner").id,
}
),
Command.create(
{
"name": "Fake user rule",
"model_id": self.env["ir.model"]._get("res.users").id,
}
),
]
}
)
exc_type.active = False
rule1.invalidate_recordset()
rule2.invalidate_recordset()
self.assertFalse(rule1.active)
self.assertFalse(rule2.active)
rules = rule_1, rule_2 = exc_type.rule_ids

def _check_exc_type_rule_ids():
exc_type.invalidate_recordset(["rule_ids"])
self.assertEqual(exc_type.rule_ids, rules)

# Make sure both Exc Type and all its rules are active
self.assertTrue(exc_type.active)
self.assertTrue(rule_1.active)
self.assertTrue(rule_2.active)
_check_exc_type_rule_ids()

# Archive one of the rules, make sure the Exc Type and the other rule stay
# active, and the archived rule is still found in the Exc Type O2M field
rule_1.action_archive()
self.assertTrue(exc_type.active)
self.assertFalse(rule_1.active)
self.assertTrue(rule_2.active)
_check_exc_type_rule_ids()

# Archive the Exc Type, make sure both rules are archived, and they both are
# still found in the Exc Type O2M field
exc_type.action_archive()
self.assertFalse(exc_type.active)
self.assertFalse(rule_1.active)
self.assertFalse(rule_2.active)
_check_exc_type_rule_ids()

# Reactivate the Exc Type, make sure both rules are still archived, and they
# both are still found in the Exc Type O2M field
exc_type.action_unarchive()
self.assertTrue(exc_type.active)
self.assertFalse(rule_1.active)
self.assertFalse(rule_2.active)
_check_exc_type_rule_ids()

# Force ``active_test`` in record ctx => archived rules are found anyway
# (record context does not override field context)
for value in (True, False):
exc_type = exc_type.with_context(active_test=value)
_check_exc_type_rule_ids()

def _create_exchange_record(self, exc_type):
return self.backend.create_record(
Expand Down
9 changes: 1 addition & 8 deletions edi_core_oca/views/edi_exchange_type_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,7 @@
<field name="view_mode">list,form</field>
<field name="search_view_id" ref="edi_exchange_type_view_search" />
<field name="domain">[]</field>
<!--
`active_test` here is fundamental to see archived `rule_ids`.
Reason: when related fields are loaded with a `read`
the ctx that you could set at field level on the view is lost.
-->
<field
name="context"
>{'search_default_filter_all': 1, 'active_test': False}</field>
<field name="context">{'search_default_filter_all': 1}</field>
</record>
<record
model="ir.actions.act_window.view"
Expand Down
122 changes: 122 additions & 0 deletions edi_exchange_deduplicate_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

============================
Edi Exchange Deduplicate OCA
============================

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

.. |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/license-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_exchange_deduplicate_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_exchange_deduplicate_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|

This module adds options for deduplication records before sending step
on type:

- deduplicate_on_send: check if a fresher one does not exist for the
same record. If so, mark the oldest one as obsolete.
- delete_obsolete_records: Delete records marked as obsolete.

**Table of contents**

.. contents::
:local:

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

Go to "EDI -> Config -> Exchange Type".

Enable "Deduplicate on Send" option -> Enable "Delete obsolete records"
option.

Usage
=====

With all the types that have been enabled "Deduplicate on Send" option,
this module will check their records if a fresher one does not exist for
the same record. If so, mark the oldest one as obsolete (except
"block_obsolescence" records)

- "block_obsolescence" is an technical option on records to avoid
marking them as obsolete.

With all the types that have been enabled "Delete obsolete records"
option, the cron will remove their obsolete records.

- If the records are obsolete, delete them even if their type's flag has
been disabled.

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_exchange_deduplicate_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
-------

* Camptocamp

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

- Simone Orsi <simone.orsi@camptocamp.com>
- Duong (Tran Quoc) <duongtq@trobz.com>

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_exchange_deduplicate_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_exchange_deduplicate_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions edi_exchange_deduplicate_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Camptocamp
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Edi Exchange Deduplicate OCA",
"summary": """
Introduce a deduplication mechanism at the sending step""",
"version": "18.0.1.0.0",
"license": "LGPL-3",
"author": "Camptocamp,Odoo Community Association (OCA)",
"maintainers": ["simahawk", "etobella"],
"website": "https://github.com/OCA/edi-framework",
"depends": ["edi_core_oca"],
"data": [
"data/cron.xml",
"views/edi_exchange_type_views.xml",
],
"demo": [],
}
17 changes: 17 additions & 0 deletions edi_exchange_deduplicate_oca/data/cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record
id="cron_edi_backend_delete_obsolete_records"
model="ir.cron"
forcecreate="True"
>
<field name="name">EDI exchange delete obsolete records</field>
<field name="active" eval="True" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="model_id" ref="edi_core_oca.model_edi_backend" />
<field name="state">code</field>
<field name="code">model.search([])._cron_delete_obsolete_records()</field>
</record>
</odoo>
76 changes: 76 additions & 0 deletions edi_exchange_deduplicate_oca/i18n/edi_exchange_deduplicate_oca.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * edi_exchange_deduplicate_oca
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.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_exchange_deduplicate_oca
#: model:ir.model.fields,help:edi_exchange_deduplicate_oca.field_edi_exchange_type__deduplicate_on_send
msgid ""
"Before sending an exchange record, check if a fresher one does not exist for"
" same record; if so, mark oldest one as obsolete."
msgstr ""

#. module: edi_exchange_deduplicate_oca
#: model:ir.model.fields,field_description:edi_exchange_deduplicate_oca.field_edi_exchange_record__block_obsolescence
msgid "Block Obsolescence"
msgstr ""

#. module: edi_exchange_deduplicate_oca
#: model:ir.model.fields,field_description:edi_exchange_deduplicate_oca.field_edi_exchange_type__deduplicate_on_send
msgid "Deduplicate on Send"
msgstr ""

#. module: edi_exchange_deduplicate_oca
#: model:ir.model.fields,field_description:edi_exchange_deduplicate_oca.field_edi_exchange_type__delete_obsolete_records
msgid "Delete obsolete records"
msgstr ""

#. module: edi_exchange_deduplicate_oca
#: model:ir.model.fields,help:edi_exchange_deduplicate_oca.field_edi_exchange_type__delete_obsolete_records
msgid "Delete records marked as obsolete."
msgstr ""

#. module: edi_exchange_deduplicate_oca
#: model:ir.model,name:edi_exchange_deduplicate_oca.model_edi_backend
msgid "EDI Backend"
msgstr ""

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

#. module: edi_exchange_deduplicate_oca
#: model:ir.model,name:edi_exchange_deduplicate_oca.model_edi_exchange_record
msgid "EDI exchange Record"
msgstr ""

#. module: edi_exchange_deduplicate_oca
#: model:ir.actions.server,name:edi_exchange_deduplicate_oca.cron_edi_backend_delete_obsolete_records_ir_actions_server
msgid "EDI exchange delete obsolete records"
msgstr ""

#. module: edi_exchange_deduplicate_oca
#: model:ir.model.fields,field_description:edi_exchange_deduplicate_oca.field_edi_exchange_record__edi_exchange_state
msgid "Exchange state"
msgstr ""

#. module: edi_exchange_deduplicate_oca
#: model:ir.model.fields,help:edi_exchange_deduplicate_oca.field_edi_exchange_record__block_obsolescence
msgid "Flag record that can never be marked as obsolete"
msgstr ""

#. module: edi_exchange_deduplicate_oca
#: model:ir.model.fields.selection,name:edi_exchange_deduplicate_oca.selection__edi_exchange_record__edi_exchange_state__obsolete
msgid "Obsolete"
msgstr ""
Loading
Loading