Skip to content

Commit

Permalink
[MIG] edi_oca: Migration to V18
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiMForgeFlow committed Oct 23, 2024
1 parent 19b96ae commit 8fa351e
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 121 deletions.
10 changes: 5 additions & 5 deletions edi_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ EDI
: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_oca
: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-17-0/edi-framework-17-0-edi_oca
: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=17.0
: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|
Expand Down Expand Up @@ -152,7 +152,7 @@ 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:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`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.

Expand Down Expand Up @@ -197,6 +197,6 @@ 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/17.0/edi_oca>`_ project on GitHub.
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.
2 changes: 1 addition & 1 deletion edi_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": "17.0.1.1.2",
"version": "18.0.1.0.0",
"website": "https://github.com/OCA/edi-framework",
"development_status": "Beta",
"license": "LGPL-3",
Expand Down
4 changes: 0 additions & 4 deletions edi_oca/data/cron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="model_id" ref="edi_oca.model_edi_backend" />
<field name="state">code</field>
<field name="code">model.search([])._cron_check_output_exchange_sync()</field>
Expand All @@ -27,8 +25,6 @@
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="model_id" ref="edi_oca.model_edi_backend" />
<field name="state">code</field>
<field name="code">model.search([])._cron_check_input_exchange_sync()</field>
Expand Down
45 changes: 0 additions & 45 deletions edi_oca/migrations/16.0.1.0.0/pre-migrate.py

This file was deleted.

2 changes: 1 addition & 1 deletion edi_oca/models/edi_backend_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ def _onchange_code(self):
def _inverse_code(self):
for rec in self:
# Make sure it's always normalized
rec.code = normalize_string(rec.code)
rec.code = normalize_string(self, rec.code)
22 changes: 9 additions & 13 deletions edi_oca/models/edi_exchange_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,12 @@ def _notify_ack_received_error(self):
self._trigger_edi_event("done", suffix="ack_received_error")

@api.model
def _search(self, domain, offset=0, limit=None, order=None, access_rights_uid=None):
def _search(self, domain, offset=0, limit=None, order=None):
query = super()._search(
domain=domain,
offset=offset,
limit=limit,
order=order,
access_rights_uid=access_rights_uid,
)
if self.env.is_superuser():
# restrictions do not apply for the superuser
Expand All @@ -466,12 +465,11 @@ def _search(self, domain, offset=0, limit=None, order=None, access_rights_uid=No
model_data = defaultdict(lambda: defaultdict(set))
for sub_ids in self._cr.split_for_in_conditions(ids):
self._cr.execute(
"""
f"""
SELECT id, res_id, model
FROM "%s"
FROM "{self._table}"
WHERE id = ANY (%%(ids)s)
"""
% self._table,
""",
dict(ids=list(sub_ids)),
)
for eid, res_id, model in self._cr.fetchall():
Expand Down Expand Up @@ -510,7 +508,6 @@ def _search(self, domain, offset=0, limit=None, order=None, access_rights_uid=No
offset=offset + len(orig_ids),
limit=limit,
order=order,
access_rights_uid=access_rights_uid,
)
extend_ids = list(extend_query)
result.extend(extend_ids[: limit - len(result)])
Expand All @@ -525,13 +522,13 @@ def _search(self, domain, offset=0, limit=None, order=None, access_rights_uid=No
def read(self, fields=None, load="_classic_read"):
"""Override to explicitely call check_access_rule, that is not called
by the ORM. It instead directly fetches ir.rules and apply them."""
self.check_access_rule("read")
self.check_access("read")
return super().read(fields=fields, load=load)

def check_access_rule(self, operation):
def check_access(self, operation):
"""In order to check if we can access a record, we are checking if we can access
the related document"""
super().check_access_rule(operation)
super().check_access(operation)
if self.env.is_superuser():
return
default_checker = self.env["edi.exchange.consumer.mixin"].get_edi_access
Expand All @@ -553,11 +550,10 @@ def check_access_rule(self, operation):
check_operation = checker(
[record.id], operation, model_name=record._name
)
record.check_access_rights(check_operation)
record.check_access_rule(check_operation)
record.check_access(check_operation)

def write(self, vals):
self.check_access_rule("write")
self.check_access("write")
return super().write(vals)

def _job_delay_params(self):
Expand Down
7 changes: 3 additions & 4 deletions edi_oca/models/edi_exchange_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from odoo.tools import groupby

from odoo.addons.base_sparse_field.models.fields import Serialized
from odoo.addons.http_routing.models.ir_http import slugify

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -187,7 +186,7 @@ def _make_exchange_filename_datetime(self):
date_pattern = pattern_settings.get("date_pattern", DATETIME_FORMAT)
tz = timezone(force_tz) if force_tz else None
now = datetime.now(utc).astimezone(tz)
return slugify(now.strftime(date_pattern))
return self.env["ir.http"]._slugify(now.strftime(date_pattern))

def _make_exchange_filename(self, exchange_record):
"""Generate filename."""
Expand All @@ -211,10 +210,10 @@ def _make_exchange_filename(self, exchange_record):

def _get_record_name(self, exchange_record):
if not exchange_record.res_id or not exchange_record.model:
return slugify(exchange_record.display_name)
return self.env["ir.http"]._slugify(exchange_record.display_name)
if hasattr(exchange_record.record, "_get_edi_exchange_record_name"):
return exchange_record.record._get_edi_exchange_record_name(exchange_record)
return slugify(exchange_record.record.display_name)
return self.env["ir.http"]._slugify(exchange_record.record.display_name)

def is_partner_enabled(self, partner):
"""Check if given partner record is allowed for the current type.
Expand Down
17 changes: 7 additions & 10 deletions edi_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -369,7 +368,7 @@ <h1 class="title">EDI</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c7344329c34f917fed853ce360400a3a6512a865e75db046046a87b86b25eeac
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/edi-framework/tree/17.0/edi_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-17-0/edi-framework-17-0-edi_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=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/edi-framework/tree/18.0/edi_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_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>
<p>Provides following models:</p>
<ol class="arabic simple">
Expand Down Expand Up @@ -504,7 +503,7 @@ <h1><a class="toc-backref" href="#toc-entry-10">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/edi-framework/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/edi-framework/issues/new?body=module:%20edi_oca%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="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**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -528,15 +527,13 @@ <h2><a class="toc-backref" href="#toc-entry-13">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-14">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/simahawk"><img alt="simahawk" src="https://github.com/simahawk.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/etobella"><img alt="etobella" src="https://github.com/etobella.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi-framework/tree/17.0/edi_oca">OCA/edi-framework</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi-framework/tree/18.0/edi_oca">OCA/edi-framework</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
6 changes: 2 additions & 4 deletions edi_oca/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
# @author Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo.addons.http_routing.models.ir_http import slugify


def normalize_string(a_string, sep="_"):
def normalize_string(cls, a_string, sep="_"):
"""Normalize given string, replace dashes with given separator."""
return slugify(a_string).replace("-", sep)
return cls.env["ir.http"]._slugify(a_string).replace("-", sep)
8 changes: 4 additions & 4 deletions edi_oca/views/edi_backend_type_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<record id="edi_backend_type_view_tree" model="ir.ui.view">
<field name="model">edi.backend.type</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="code" />
</tree>
</list>
</field>
</record>
<record id="edi_backend_type_view_form" model="ir.ui.view">
Expand Down Expand Up @@ -35,7 +35,7 @@
<field name="name">EDI Backend Type</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">edi.backend.type</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="search_view_id" ref="edi_backend_type_view_search" />
<field name="domain">[]</field>
<field name="context">{}</field>
Expand All @@ -49,7 +49,7 @@
<record model="ir.actions.act_window.view" id="act_open_edi_backend_type_view_tree">
<field name="act_window_id" ref="act_open_edi_backend_type_view" />
<field name="sequence" eval="10" />
<field name="view_mode">tree</field>
<field name="view_mode">list</field>
<field name="view_id" ref="edi_backend_type_view_tree" />
</record>
</odoo>
8 changes: 4 additions & 4 deletions edi_oca/views/edi_backend_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<record id="edi_backend_view_tree" model="ir.ui.view">
<field name="model">edi.backend</field>
<field name="arch" type="xml">
<tree decoration-muted="(not active)">
<list decoration-muted="(not active)">
<field name="name" />
<field name="active" />
</tree>
</list>
</field>
</record>
<record id="edi_backend_view_form" model="ir.ui.view">
Expand Down Expand Up @@ -87,7 +87,7 @@
<field name="name">EDI Backend</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">edi.backend</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="search_view_id" ref="edi_backend_view_search" />
<field name="domain">[]</field>
<field name="context">{'search_default_filter_all': 1}</field>
Expand All @@ -101,7 +101,7 @@
<record model="ir.actions.act_window.view" id="act_open_edi_backend_view_tree">
<field name="act_window_id" ref="act_open_edi_backend_view" />
<field name="sequence" eval="10" />
<field name="view_mode">tree</field>
<field name="view_mode">list</field>
<field name="view_id" ref="edi_backend_view_tree" />
</record>
</odoo>
Loading

0 comments on commit 8fa351e

Please sign in to comment.