[MIG] base_external_system: Migration to 16.0

This commit is contained in:
ntsirintanis
2023-02-06 16:34:30 +01:00
parent b330ddba76
commit 14666c8c5b
7 changed files with 31 additions and 17 deletions

View File

@@ -101,7 +101,7 @@ repos:
- id: pyupgrade - id: pyupgrade
args: ["--keep-percent-format"] args: ["--keep-percent-format"]
- repo: https://github.com/PyCQA/isort - repo: https://github.com/PyCQA/isort
rev: 5.10.1 rev: 5.12.0
hooks: hooks:
- id: isort - id: isort
name: isort except __init__.py name: isort except __init__.py

View File

@@ -4,7 +4,7 @@
{ {
"name": "Base External System", "name": "Base External System",
"summary": "Data models allowing for connection to external systems.", "summary": "Data models allowing for connection to external systems.",
"version": "15.0.1.0.0", "version": "16.0.1.0.0",
"category": "Base", "category": "Base",
"website": "https://github.com/OCA/server-backend", "website": "https://github.com/OCA/server-backend",
"author": "LasLabs, " "Odoo Community Association (OCA)", "author": "LasLabs, " "Odoo Community Association (OCA)",

View File

@@ -104,14 +104,19 @@ class ExternalSystem(models.Model):
with self.interface.client() as client: with self.interface.client() as client:
yield client yield client
@api.model @api.model_create_multi
def create(self, vals): def create(self, vals_list):
"""Create the interface for the record and assign to ``interface``.""" """Create the interface for the record and assign to ``interface``."""
record = super(ExternalSystem, self).create(vals) records = self.browse([])
if not self.env.context.get("no_create_interface"): for vals in vals_list:
interface = self.env[vals["system_type"]].create({"system_id": record.id}) record = super(ExternalSystem, self).create(vals)
record.interface = interface if not self.env.context.get("no_create_interface"):
return record interface = self.env[vals["system_type"]].create(
{"system_id": record.id}
)
record.interface = interface
records += record
return records
def action_test_connection(self): def action_test_connection(self):
"""Test the connection to the external system.""" """Test the connection to the external system."""

View File

@@ -65,10 +65,13 @@ class ExternalSystemAdapter(models.AbstractModel):
""" """
raise UserError(_("The connection was a success.")) raise UserError(_("The connection was a success."))
@api.model @api.model_create_multi
def create(self, vals): def create(self, vals_list):
context_self = self.with_context(no_create_interface=True) context_self = self.with_context(no_create_interface=True)
vals.update({"system_type": self._name}) records = self.browse([])
record = super(ExternalSystemAdapter, context_self).create(vals) for vals in vals_list:
record.system_id.interface = record vals.update({"system_type": self._name})
return record record = super(ExternalSystemAdapter, context_self).create(vals)
record.system_id.interface = record
records += record
return records

View File

@@ -2,8 +2,7 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from contextlib import contextmanager from contextlib import contextmanager
from unittest.mock import MagicMock
from mock import MagicMock
from odoo.tests.common import TransactionCase from odoo.tests.common import TransactionCase

View File

@@ -0,0 +1 @@
../../../../base_external_system

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)