mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[IMP] base_external_system: Add create bypass
* In cases of deep inheritance, it may be required to create an adapter directly. Add an override in the create via the env context to support this. * Add default system type if creating from an interface * Fix interface assignment during creation in adapter
This commit is contained in:
committed by
Pedro M. Baeza
parent
21df00169e
commit
c11c3cd251
@@ -112,10 +112,11 @@ class ExternalSystem(models.Model):
|
||||
def create(self, vals):
|
||||
"""Create the interface for the record and assign to ``interface``."""
|
||||
record = super(ExternalSystem, self).create(vals)
|
||||
interface = self.env[vals['system_type']].create({
|
||||
'system_id': record.id,
|
||||
})
|
||||
record.interface = interface
|
||||
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
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -69,3 +69,13 @@ class ExternalSystemAdapter(models.AbstractModel):
|
||||
odoo.exceptions.UserError: In the event of a good connection.
|
||||
"""
|
||||
raise UserError(_('The connection was a success.'))
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user