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_oca #5

Merged
merged 11 commits into from
Oct 2, 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
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
^edi_oca/|
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
Expand Down
5 changes: 3 additions & 2 deletions edi_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ EDI
:target: https://runbot.odoo-community.org/runbot/226/15.0
:alt: Try me on Runbot

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

Base EDI backend.

Expand Down Expand Up @@ -142,6 +142,7 @@ Contributors

* Simone Orsi <[email protected]>
* Enric Tobella <[email protected]>
* John Herholz <[email protected]>

Maintainers
~~~~~~~~~~~
Expand All @@ -165,7 +166,7 @@ promote its widespread use.

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

|maintainer-simahawk| |maintainer-etobella|
|maintainer-simahawk| |maintainer-etobella|

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

Expand Down
6 changes: 3 additions & 3 deletions edi_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
Define backends, exchange types, exchange records,
basic automation and views for handling EDI exchanges.
""",
"version": "15.0.1.5.0",
"website": "https://github.com/OCA/edi",
"version": "16.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)",
Expand Down Expand Up @@ -45,5 +45,5 @@
"web.assets_qweb": ["edi_oca/static/src/xml/widget_edi.xml"],
},
"demo": ["demo/edi_backend_demo.xml"],
"installable": False,
"installable": True,
}
35 changes: 0 additions & 35 deletions edi_oca/migrations/14.0.1.19.0/post-migrate.py

This file was deleted.

42 changes: 0 additions & 42 deletions edi_oca/migrations/14.0.1.19.0/pre-migrate.py

This file was deleted.

19 changes: 0 additions & 19 deletions edi_oca/migrations/15.0.1.4.0/post-migrate.py

This file was deleted.

45 changes: 45 additions & 0 deletions edi_oca/migrations/16.0.1.0.0/pre-migrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2023 Camptocamp SA (http://www.camptocamp.com)
# @author: Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import logging

from psycopg2 import sql

from odoo import SUPERUSER_ID, api, tools

_logger = logging.getLogger(__name__)


def migrate(cr, version):
if not version:
return
env = api.Environment(cr, SUPERUSER_ID, {})
rename_disable_auto_columns(env)


def rename_disable_auto_columns(env):
tables = _get_consumer_model_tables(env)
for table in tables:
if tools.sql.column_exists(env.cr, table, "disable_edi_auto"):
env.cr.execute(_make_query(table))
_logger.info(
"table %s: renamed column `disable_edi_auto` to `edi_disable_auto`"
)


def _make_query(table):
return sql.SQL(
"ALTER TABLE {} RENAME COLUMN 'disable_edi_auto' TO 'edi_disable_auto'"
).format(
sql.Identifier(table),
)


def _get_consumer_model_tables(env):
tables = []
mixin = "edi.exchange.consumer.mixin"
for model in env.values():
if model._name != mixin and not model._abstract and mixin in model._inherit:
tables.append(model._table)
return tables
18 changes: 2 additions & 16 deletions edi_oca/models/edi_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import base64
import logging

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

from odoo.addons.component.exception import NoComponentError

Expand Down Expand Up @@ -127,7 +127,7 @@ def _find_component(self, model, usage_candidates, safe=True, work_ctx=None, **k
components, key=lambda x: self._component_sort_key(x), reverse=True
)
component = components[0](c_work_ctx)
_logger.debug("using component", component._name)
_logger.debug("using component %s", component._name)
break
if not component and not safe:
raise NoComponentError(
Expand Down Expand Up @@ -189,14 +189,6 @@ def _get_exchange_type_domain(self, code):
("backend_id", "=", False),
]

def _delay_action(self, rec):
# TODO: Remove this on 16.0
_logger.warning(
"This function has been replaced by rec.with_delay(). "
"It will be removed on 16.0."
)
return self.with_delay(**rec._job_delay_params())

def exchange_generate(self, exchange_record, store=True, force=False, **kw):
"""Generate output content for given exchange record.

Expand All @@ -218,12 +210,6 @@ def exchange_generate(self, exchange_record, store=True, force=False, **kw):
"edi_exchange_state": "output_pending",
}
)
try:
# TODO: Remove this on 15.0, we will keep it in order to not break current
# installations
output = tools.pycompat.to_text(output)
except UnicodeDecodeError:
_logger.info("File is not a text, so it cannot be converted")
if output:
try:
self._validate_data(exchange_record, output)
Expand Down
17 changes: 6 additions & 11 deletions edi_oca/models/edi_exchange_consumer_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class EDIExchangeConsumerMixin(models.AbstractModel):
default={},
)
edi_has_form_config = fields.Boolean(compute="_compute_edi_config")
# TODO: rename to `edi_disable_auto`
disable_edi_auto = fields.Boolean(
edi_disable_auto = fields.Boolean(
string="Disable auto",
help="When marked, EDI automatic processing will be avoided",
# Each extending module should override `states` as/if needed.
Expand Down Expand Up @@ -113,12 +112,8 @@ def _get_eval_context(self):
}

@api.model
def fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
):
res = super().fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
)
def get_view(self, view_id=None, view_type="form", **options):
res = super().get_view(view_id, view_type, **options)
if view_type == "form":
doc = etree.XML(res["arch"])
for node in doc.xpath("//sheet"):
Expand All @@ -136,12 +131,12 @@ def fields_view_get(
# Override context for postprocessing
if view_id and res.get("base_model", self._name) != self._name:
View = View.with_context(base_model_name=res["base_model"])
new_arch, new_fields = View.postprocess_and_fields(doc, self._name)
new_arch, new_models = View.postprocess_and_fields(doc, self._name)
res["arch"] = new_arch
# We don't want to lose previous configuration, so, we only want to add
# the new fields
new_fields.update(res["fields"])
res["fields"] = new_fields
new_models.update(res["models"])
res["models"] = new_models
return res

def _edi_create_exchange_record_vals(self, exchange_type):
Expand Down
1 change: 1 addition & 0 deletions edi_oca/models/edi_exchange_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def create(self, vals_list):
rec._execute_next_action()
return records

@api.model
def _get_identifier(self):
return self.env["ir.sequence"].next_by_code("edi.exchange")

Expand Down
Loading
Loading