mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[MIG] base_external_system Migration to 13.0
This commit is contained in:
committed by
Pedro M. Baeza
parent
df7608d90b
commit
9087b53bfd
@@ -4,14 +4,14 @@
|
|||||||
{
|
{
|
||||||
"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": "12.0.1.0.0",
|
"version": "13.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)",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"application": False,
|
"application": False,
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"depends": ["base",],
|
"depends": ["base"],
|
||||||
"data": [
|
"data": [
|
||||||
"demo/external_system_os_demo.xml",
|
"demo/external_system_os_demo.xml",
|
||||||
"security/ir.model.access.csv",
|
"security/ir.model.access.csv",
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ class ExternalSystem(models.Model):
|
|||||||
adapter = self.env["external.system.adapter"]
|
adapter = self.env["external.system.adapter"]
|
||||||
return [(m, self.env[m]._description) for m in adapter._inherit_children]
|
return [(m, self.env[m]._description) for m in adapter._inherit_children]
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.constrains("fingerprint", "ignore_fingerprint")
|
@api.constrains("fingerprint", "ignore_fingerprint")
|
||||||
def check_fingerprint_ignore_fingerprint(self):
|
def check_fingerprint_ignore_fingerprint(self):
|
||||||
"""Do not allow a blank fingerprint if not set to ignore."""
|
"""Do not allow a blank fingerprint if not set to ignore."""
|
||||||
@@ -87,7 +86,6 @@ class ExternalSystem(models.Model):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def client(self):
|
def client(self):
|
||||||
"""Client object usable as a context manager to include destruction.
|
"""Client object usable as a context manager to include destruction.
|
||||||
@@ -107,11 +105,10 @@ class ExternalSystem(models.Model):
|
|||||||
"""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)
|
record = super(ExternalSystem, self).create(vals)
|
||||||
if not self.env.context.get("no_create_interface"):
|
if not self.env.context.get("no_create_interface"):
|
||||||
interface = self.env[vals["system_type"]].create({"system_id": record.id,})
|
interface = self.env[vals["system_type"]].create({"system_id": record.id})
|
||||||
record.interface = interface
|
record.interface = interface
|
||||||
return record
|
return record
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_test_connection(self):
|
def action_test_connection(self):
|
||||||
"""Test the connection to the external system."""
|
"""Test the connection to the external system."""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ class ExternalSystemAdapter(models.AbstractModel):
|
|||||||
ondelete="cascade",
|
ondelete="cascade",
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def client(self):
|
def client(self):
|
||||||
"""Client object usable as a context manager to include destruction.
|
"""Client object usable as a context manager to include destruction.
|
||||||
@@ -42,12 +41,10 @@ class ExternalSystemAdapter(models.AbstractModel):
|
|||||||
finally:
|
finally:
|
||||||
self.external_destroy_client(client)
|
self.external_destroy_client(client)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def external_get_client(self):
|
def external_get_client(self):
|
||||||
"""Return a usable client representing the remote system."""
|
"""Return a usable client representing the remote system."""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def external_destroy_client(self, client):
|
def external_destroy_client(self, client):
|
||||||
"""Perform any logic necessary to destroy the client connection.
|
"""Perform any logic necessary to destroy the client connection.
|
||||||
|
|
||||||
@@ -57,7 +54,6 @@ class ExternalSystemAdapter(models.AbstractModel):
|
|||||||
"""
|
"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def external_test_connection(self):
|
def external_test_connection(self):
|
||||||
"""Adapters should override this method, then call super if valid.
|
"""Adapters should override this method, then call super if valid.
|
||||||
|
|
||||||
@@ -72,9 +68,7 @@ class ExternalSystemAdapter(models.AbstractModel):
|
|||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
context_self = self.with_context(no_create_interface=True)
|
context_self = self.with_context(no_create_interface=True)
|
||||||
vals.update(
|
vals.update({"system_type": self._name})
|
||||||
{"system_type": self._name,}
|
|
||||||
)
|
|
||||||
record = super(ExternalSystemAdapter, context_self).create(vals)
|
record = super(ExternalSystemAdapter, context_self).create(vals)
|
||||||
record.system_id.interface = record
|
record.system_id.interface = record
|
||||||
return record
|
return record
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from odoo import api, models
|
from odoo import models
|
||||||
|
|
||||||
|
|
||||||
class ExternalSystemOs(models.Model):
|
class ExternalSystemOs(models.Model):
|
||||||
@@ -19,7 +19,6 @@ class ExternalSystemOs(models.Model):
|
|||||||
|
|
||||||
previous_dir = None
|
previous_dir = None
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def external_get_client(self):
|
def external_get_client(self):
|
||||||
"""Return a usable client representing the remote system."""
|
"""Return a usable client representing the remote system."""
|
||||||
super(ExternalSystemOs, self).external_get_client()
|
super(ExternalSystemOs, self).external_get_client()
|
||||||
@@ -28,7 +27,6 @@ class ExternalSystemOs(models.Model):
|
|||||||
os.chdir(self.system_id.remote_path)
|
os.chdir(self.system_id.remote_path)
|
||||||
return os
|
return os
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def external_destroy_client(self, client):
|
def external_destroy_client(self, client):
|
||||||
"""Perform any logic necessary to destroy the client connection.
|
"""Perform any logic necessary to destroy the client connection.
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
* Dave Lasley <dave@laslabs.com>
|
* Dave Lasley <dave@laslabs.com>
|
||||||
* Alexandre Díaz <alexandre.diaz@tecnativa.com>
|
* Alexandre Díaz <alexandre.diaz@tecnativa.com>
|
||||||
|
* Ronald Portier <ronald@therp.nl>
|
||||||
|
|||||||
@@ -97,7 +97,6 @@
|
|||||||
<field name="name">External Systems</field>
|
<field name="name">External Systems</field>
|
||||||
<field name="res_model">external.system</field>
|
<field name="res_model">external.system</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
<menuitem
|
<menuitem
|
||||||
|
|||||||
Reference in New Issue
Block a user