[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

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

View File

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

View File

@@ -65,10 +65,13 @@ class ExternalSystemAdapter(models.AbstractModel):
"""
raise UserError(_("The connection was a success."))
@api.model
def create(self, vals):
@api.model_create_multi
def create(self, vals_list):
context_self = self.with_context(no_create_interface=True)
vals.update({"system_type": self._name})
record = super(ExternalSystemAdapter, context_self).create(vals)
record.system_id.interface = record
return record
records = self.browse([])
for vals in vals_list:
vals.update({"system_type": self._name})
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).
from contextlib import contextmanager
from mock import MagicMock
from unittest.mock import MagicMock
from odoo.tests.common import TransactionCase